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) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (c) 2018, Joyent, Inc. 25 */ 26 27 #ifndef _SYS_MAC_PROVIDER_H 28 #define _SYS_MAC_PROVIDER_H 29 30 #include <sys/types.h> 31 #include <sys/ddi.h> 32 #include <sys/sunddi.h> 33 #include <sys/stream.h> 34 #include <sys/mkdev.h> 35 #include <sys/mac.h> 36 #include <sys/mac_flow.h> 37 38 /* 39 * MAC Provider Interface 40 */ 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /* 47 * MAC version identifiers. Drivers compiled against the stable V1 version 48 * of the API should register with MAC_VERSION_V1. ON drivers should use 49 * MAC_VERSION. This is used by mac_alloc() mac_register() to 50 * verify that incompatible drivers don't register. 51 */ 52 #define MAC_VERSION_V1 0x1 53 #define MAC_VERSION MAC_VERSION_V1 54 55 /* 56 * Possible values for ETHER_STAT_XCVR_INUSE statistic. 57 */ 58 59 #define XCVR_UNDEFINED 0 60 #define XCVR_NONE 1 61 #define XCVR_10 2 62 #define XCVR_100T4 3 63 #define XCVR_100X 4 64 #define XCVR_100T2 5 65 #define XCVR_1000X 6 66 #define XCVR_1000T 7 67 68 #ifdef _KERNEL 69 70 /* 71 * Definitions for MAC Drivers Capabilities 72 */ 73 /* 74 * MAC layer capabilities. These capabilities are handled by the drivers' 75 * mc_capab_get() callbacks. Some capabilities require the driver to fill 76 * in a given data structure, and others are simply boolean capabilities. 77 * Note that capability values must be powers of 2 so that consumers and 78 * providers of this interface can keep track of which capabilities they 79 * care about by keeping a bitfield of these things around somewhere. 80 */ 81 typedef enum { 82 /* 83 * Public Capabilities (MAC_VERSION_V1) 84 */ 85 MAC_CAPAB_HCKSUM = 0x00000001, /* data is a uint32_t */ 86 MAC_CAPAB_LSO = 0x00000008, /* data is mac_capab_lso_t */ 87 88 /* 89 * Reserved capabilities, do not use 90 */ 91 MAC_CAPAB_RESERVED1 = 0x00000002, 92 MAC_CAPAB_RESERVED2 = 0x00000004, 93 94 /* 95 * Private driver capabilities 96 */ 97 MAC_CAPAB_RINGS = 0x00000010, /* data is mac_capab_rings_t */ 98 MAC_CAPAB_SHARES = 0x00000020, /* data is mac_capab_share_t */ 99 MAC_CAPAB_MULTIFACTADDR = 0x00000040, /* mac_data_multifactaddr_t */ 100 101 /* 102 * Private driver capabilities for use by the GLDv3 framework only 103 */ 104 MAC_CAPAB_VNIC = 0x00010000, /* data is mac_capab_vnic_t */ 105 MAC_CAPAB_ANCHOR_VNIC = 0x00020000, /* boolean only, no data */ 106 MAC_CAPAB_AGGR = 0x00040000, /* data is mac_capab_aggr_t */ 107 MAC_CAPAB_NO_NATIVEVLAN = 0x00080000, /* boolean only, no data */ 108 MAC_CAPAB_NO_ZCOPY = 0x00100000, /* boolean only, no data */ 109 MAC_CAPAB_LEGACY = 0x00200000, /* data is mac_capab_legacy_t */ 110 MAC_CAPAB_VRRP = 0x00400000, /* data is mac_capab_vrrp_t */ 111 MAC_CAPAB_TRANSCEIVER = 0x01000000, /* mac_capab_transciever_t */ 112 MAC_CAPAB_LED = 0x02000000 /* data is mac_capab_led_t */ 113 } mac_capab_t; 114 115 /* 116 * LSO capability 117 */ 118 typedef struct lso_basic_tcp_ipv4_s { 119 t_uscalar_t lso_max; /* maximum payload */ 120 } lso_basic_tcp_ipv4_t; 121 122 typedef struct lso_basic_tcp_ipv6_s { 123 t_uscalar_t lso_max; /* maximum payload */ 124 } lso_basic_tcp_ipv6_t; 125 126 /* 127 * Currently supported flags for LSO. 128 */ 129 #define LSO_TX_BASIC_TCP_IPV4 0x01 /* TCPv4 LSO capability */ 130 #define LSO_TX_BASIC_TCP_IPV6 0x02 /* TCPv6 LSO capability */ 131 132 /* 133 * Future LSO capabilities can be added at the end of the mac_capab_lso_t. 134 * When such capability is added to the GLDv3 framework, the size of the 135 * mac_capab_lso_t it allocates and passes to the drivers increases. Older 136 * drivers wil access only the (upper) sections of that structure, that is the 137 * sections carrying the capabilities they understand. This ensures the 138 * interface can be safely extended in a binary compatible way. 139 */ 140 typedef struct mac_capab_lso_s { 141 t_uscalar_t lso_flags; 142 lso_basic_tcp_ipv4_t lso_basic_tcp_ipv4; 143 lso_basic_tcp_ipv6_t lso_basic_tcp_ipv6; 144 /* Add future lso capabilities here */ 145 } mac_capab_lso_t; 146 147 /* 148 * Multiple Factory MAC Addresses Capability 149 */ 150 typedef struct mac_capab_multifactaddr_s { 151 /* 152 * Number of factory addresses 153 */ 154 uint_t mcm_naddr; 155 156 /* 157 * Callbacks to query all the factory addresses. 158 */ 159 void (*mcm_getaddr)(void *, uint_t, uint8_t *); 160 } mac_capab_multifactaddr_t; 161 162 /* 163 * Info and callbacks of legacy devices. 164 */ 165 typedef struct mac_capab_legacy_s { 166 /* 167 * Notifications that the legacy device does not support. 168 */ 169 uint32_t ml_unsup_note; 170 /* 171 * dev_t of the legacy device; can be held to force attach. 172 */ 173 dev_t ml_dev; 174 boolean_t (*ml_active_set)(void *); 175 void (*ml_active_clear)(void *); 176 int (*ml_fastpath_disable)(void *); 177 void (*ml_fastpath_enable)(void *); 178 } mac_capab_legacy_t; 179 180 typedef struct __mac_prop_info_handle *mac_prop_info_handle_t; 181 182 /* 183 * MAC driver entry point types. 184 */ 185 typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); 186 typedef int (*mac_start_t)(void *); 187 typedef void (*mac_stop_t)(void *); 188 typedef int (*mac_setpromisc_t)(void *, boolean_t); 189 typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 190 typedef int (*mac_unicst_t)(void *, const uint8_t *); 191 typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 192 typedef void (*mac_resources_t)(void *); 193 typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 194 typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); 195 typedef int (*mac_open_t)(void *); 196 typedef void (*mac_close_t)(void *); 197 typedef int (*mac_set_prop_t)(void *, const char *, mac_prop_id_t, 198 uint_t, const void *); 199 typedef int (*mac_get_prop_t)(void *, const char *, mac_prop_id_t, 200 uint_t, void *); 201 typedef void (*mac_prop_info_t)(void *, const char *, mac_prop_id_t, 202 mac_prop_info_handle_t); 203 204 /* 205 * Driver callbacks. The following capabilities are optional, and if 206 * implemented by the driver, must have a corresponding MC_ flag set 207 * in the mc_callbacks field. 208 * 209 * Any future additions to this list must also be accompanied by an 210 * associated mc_callbacks flag so that the framework can grow without 211 * affecting the binary compatibility of the interface. 212 */ 213 typedef struct mac_callbacks_s { 214 uint_t mc_callbacks; /* Denotes which callbacks are set */ 215 mac_getstat_t mc_getstat; /* Get the value of a statistic */ 216 mac_start_t mc_start; /* Start the device */ 217 mac_stop_t mc_stop; /* Stop the device */ 218 mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ 219 mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ 220 mac_unicst_t mc_unicst; /* Set the unicast MAC address */ 221 mac_tx_t mc_tx; /* Transmit a packet */ 222 void *mc_reserved; /* Reserved, do not use */ 223 mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ 224 mac_getcapab_t mc_getcapab; /* Get capability information */ 225 mac_open_t mc_open; /* Open the device */ 226 mac_close_t mc_close; /* Close the device */ 227 mac_set_prop_t mc_setprop; 228 mac_get_prop_t mc_getprop; 229 mac_prop_info_t mc_propinfo; 230 } mac_callbacks_t; 231 232 /* 233 * Flags for mc_callbacks. Requiring drivers to set the flags associated 234 * with optional callbacks initialized in the structure allows the mac 235 * module to add optional callbacks in the future without requiring drivers 236 * to recompile. 237 */ 238 #define MC_RESERVED 0x0001 239 #define MC_IOCTL 0x0002 240 #define MC_GETCAPAB 0x0004 241 #define MC_OPEN 0x0008 242 #define MC_CLOSE 0x0010 243 #define MC_SETPROP 0x0020 244 #define MC_GETPROP 0x0040 245 #define MC_PROPINFO 0x0080 246 #define MC_PROPERTIES (MC_SETPROP | MC_GETPROP | MC_PROPINFO) 247 248 /* 249 * Virtualization Capabilities 250 */ 251 252 /* 253 * The type of ring classification. This is used by MAC to determine 254 * what, if any, processing it has to do upon receiving traffic on a 255 * particular Rx ring. 256 * 257 * MAC_NO_CLASSIFIER 258 * 259 * No classification has been set. No traffic should cross an Rx 260 * ring in this state. 261 * 262 * MAC_SW_CLASSIFIER 263 * 264 * The driver delivers traffic for multiple clients to this ring. 265 * All traffic must be software classified by MAC to guarantee 266 * delivery to the correct client. This classification type may 267 * be chosen for several reasons. 268 * 269 * o The driver provides only one group and there are multiple 270 * clients using the MAC. 271 * 272 * o The driver provides some hardware filtering but not enough 273 * to fully classify the traffic. E.g., a VLAN VNIC requires L2 274 * unicast address filtering as well as VLAN filtering, but 275 * some drivers may only support the former. 276 * 277 * o The ring belongs to the default group. The default group 278 * acts as a spillover for all clients that can't reserve an 279 * exclusive group. It also handles multicast traffic for all 280 * clients. For these reasons, the default group's rings are 281 * always software classified. 282 * 283 * MAC_HW_CLASSIFIER 284 * 285 * The driver delivers traffic for a single MAC client across 286 * this ring. With this guarantee, MAC can simply pass the 287 * traffic up the stack or even allow polling of the ring. 288 * 289 * MAC_PASSTHRU_CLASSIFIER 290 * 291 * The ring is in "passthru" mode. In this mode we bypass all of 292 * the typical MAC processing and pass the traffic directly to 293 * the mr_pt_fn callback, see mac_rx_common(). This is used in 294 * cases where there is another module acting as MAC provider on 295 * behalf of the driver. E.g., link aggregations use this mode to 296 * take full control of the port's rings; allowing it to enforce 297 * LACP protocols and aggregate rings across discrete drivers. 298 */ 299 typedef enum { 300 MAC_NO_CLASSIFIER = 0, 301 MAC_SW_CLASSIFIER, 302 MAC_HW_CLASSIFIER, 303 MAC_PASSTHRU_CLASSIFIER 304 } mac_classify_type_t; 305 306 typedef void (*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *, 307 boolean_t); 308 309 /* 310 * The virtualization level conveys the extent of the NIC hardware assistance 311 * for traffic steering employed for virtualization: 312 * 313 * MAC_VIRT_NONE: No assist for v12n. 314 * 315 * MAC_VIRT_LEVEL1: Multiple Rx rings with MAC address level 316 * classification between groups of rings. 317 * Requires the support of the MAC_CAPAB_RINGS 318 * capability. 319 * 320 * MAC_VIRT_HIO: Hybrid I/O capable MAC. Require the support 321 * of the MAC_CAPAB_SHARES capability. 322 */ 323 #define MAC_VIRT_NONE 0x0 324 #define MAC_VIRT_LEVEL1 0x1 325 #define MAC_VIRT_HIO 0x2 326 327 typedef enum { 328 MAC_RING_TYPE_RX = 1, /* Receive ring */ 329 MAC_RING_TYPE_TX /* Transmit ring */ 330 } mac_ring_type_t; 331 332 /* 333 * The value VLAN_ID_NONE (VID 0) means a client does not have 334 * membership to any VLAN. However, this statement is true for both 335 * untagged packets and priority tagged packets leading to confusion 336 * over what semantic is intended. To the provider, VID 0 is a valid 337 * VID when priority tagging is in play. To MAC and everything above 338 * VLAN_ID_NONE almost universally implies untagged traffic. Thus, we 339 * convert VLAN_ID_NONE to a sentinel value (MAC_VLAN_UNTAGGED) at the 340 * border between MAC and MAC provider. This informs the provider that 341 * the client is interested in untagged traffic and the provider 342 * should set any relevant bits to receive such traffic. 343 * 344 * Currently, the API between MAC and the provider passes the VID as a 345 * unit16_t. In the future this could actually be the entire TCI mask 346 * (PCP, DEI, and VID). This current scheme is safe in that potential 347 * future world as well; as 0xFFFF is not a valid TCI (the 0xFFF VID 348 * is reserved and never transmitted across networks). 349 */ 350 #define MAC_VLAN_UNTAGGED UINT16_MAX 351 #define MAC_VLAN_UNTAGGED_VID(vid) \ 352 (((vid) == VLAN_ID_NONE) ? MAC_VLAN_UNTAGGED : (vid)) 353 354 /* 355 * Grouping type of a ring group 356 * 357 * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped. 358 * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping 359 */ 360 typedef enum { 361 MAC_GROUP_TYPE_STATIC = 1, /* Static ring group */ 362 MAC_GROUP_TYPE_DYNAMIC /* Dynamic ring group */ 363 } mac_group_type_t; 364 365 typedef struct __mac_ring_driver *mac_ring_driver_t; 366 typedef struct __mac_group_driver *mac_group_driver_t; 367 368 typedef struct mac_ring_info_s mac_ring_info_t; 369 typedef struct mac_group_info_s mac_group_info_t; 370 371 typedef void (*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int, 372 mac_ring_info_t *, mac_ring_handle_t); 373 typedef void (*mac_get_group_t)(void *, mac_ring_type_t, const int, 374 mac_group_info_t *, mac_group_handle_t); 375 376 typedef void (*mac_group_add_ring_t)(mac_group_driver_t, 377 mac_ring_driver_t, mac_ring_type_t); 378 typedef void (*mac_group_rem_ring_t)(mac_group_driver_t, 379 mac_ring_driver_t, mac_ring_type_t); 380 381 /* 382 * Multiple Rings Capability 383 */ 384 typedef struct mac_capab_rings_s { 385 mac_ring_type_t mr_type; /* Ring type: Rx vs Tx */ 386 mac_group_type_t mr_group_type; /* Dynamic vs static grouping */ 387 uint_t mr_rnum; /* Number of rings */ 388 uint_t mr_gnum; /* Number of ring groups */ 389 mac_get_ring_t mr_rget; /* Get ring from driver */ 390 mac_get_group_t mr_gget; /* Get ring group from driver */ 391 mac_group_add_ring_t mr_gaddring; /* Add ring into a group */ 392 mac_group_rem_ring_t mr_gremring; /* Remove ring from a group */ 393 } mac_capab_rings_t; 394 395 /* 396 * Common ring functions and driver interfaces 397 */ 398 typedef int (*mac_ring_start_t)(mac_ring_driver_t, uint64_t); 399 typedef void (*mac_ring_stop_t)(mac_ring_driver_t); 400 401 typedef mblk_t *(*mac_ring_send_t)(void *, mblk_t *); 402 typedef mblk_t *(*mac_ring_poll_t)(void *, int); 403 404 typedef int (*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *); 405 406 typedef struct mac_ring_info_s { 407 mac_ring_driver_t mri_driver; 408 mac_ring_start_t mri_start; 409 mac_ring_stop_t mri_stop; 410 mac_intr_t mri_intr; 411 union { 412 mac_ring_send_t send; 413 mac_ring_poll_t poll; 414 } mrfunion; 415 mac_ring_stat_t mri_stat; 416 417 /* 418 * mri_flags will have some bits set to indicate some special 419 * property/feature of a ring like serialization needed for a 420 * Tx ring or packets should always need enqueuing on Rx side, 421 * etc. 422 */ 423 uint_t mri_flags; 424 } mac_ring_info_s; 425 426 #define mri_tx mrfunion.send 427 #define mri_poll mrfunion.poll 428 429 /* 430 * #defines for mri_flags. The flags are temporary flags that are provided 431 * only to workaround issues in specific drivers, and they will be 432 * removed in the future. 433 * 434 * These are consumed only by sun4v and neptune (nxge). 435 */ 436 #define MAC_RING_TX_SERIALIZE 0x1 437 #define MAC_RING_RX_ENQUEUE 0x2 438 439 typedef int (*mac_group_start_t)(mac_group_driver_t); 440 typedef void (*mac_group_stop_t)(mac_group_driver_t); 441 typedef int (*mac_add_mac_addr_t)(void *, const uint8_t *); 442 typedef int (*mac_rem_mac_addr_t)(void *, const uint8_t *); 443 typedef int (*mac_add_vlan_filter_t)(mac_group_driver_t, uint16_t); 444 typedef int (*mac_rem_vlan_filter_t)(mac_group_driver_t, uint16_t); 445 446 struct mac_group_info_s { 447 mac_group_driver_t mgi_driver; /* Driver reference */ 448 mac_group_start_t mgi_start; /* Start the group */ 449 mac_group_stop_t mgi_stop; /* Stop the group */ 450 uint_t mgi_count; /* Count of rings */ 451 mac_intr_t mgi_intr; /* Optional per-group intr */ 452 453 /* Only used for Rx groups */ 454 mac_add_mac_addr_t mgi_addmac; /* Add a MAC address */ 455 mac_rem_mac_addr_t mgi_remmac; /* Remove a MAC address */ 456 mac_add_vlan_filter_t mgi_addvlan; /* Add a VLAN filter */ 457 mac_rem_vlan_filter_t mgi_remvlan; /* Remove a VLAN filter */ 458 }; 459 460 /* 461 * Share management functions. 462 */ 463 typedef uint64_t mac_share_handle_t; 464 465 /* 466 * Allocate and free a share. Returns ENOSPC if all shares have been 467 * previously allocated. 468 */ 469 typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *); 470 typedef void (*mac_free_share_t)(mac_share_handle_t); 471 472 /* 473 * Bind and unbind a share. Binding a share allows a domain 474 * to have direct access to the groups and rings associated with 475 * that share. 476 */ 477 typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *); 478 typedef void (*mac_unbind_share_t)(mac_share_handle_t); 479 480 /* 481 * Return information on about a share. 482 */ 483 typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t, 484 mac_ring_handle_t *, uint_t *); 485 486 /* 487 * Basic idea, bind previously created ring groups to shares 488 * for them to be exported (or shared) by another domain. 489 * These interfaces bind/unbind the ring group to a share. 490 * The groups and their rings will be shared with the guest 491 * as soon as the share is bound. 492 */ 493 typedef int (*mac_share_add_group_t)(mac_share_handle_t, 494 mac_group_driver_t); 495 typedef int (*mac_share_rem_group_t)(mac_share_handle_t, 496 mac_group_driver_t); 497 498 typedef struct mac_capab_share_s { 499 uint_t ms_snum; /* Number of shares (vr's) */ 500 void *ms_handle; /* Handle to driver. */ 501 mac_alloc_share_t ms_salloc; /* Get a share from driver. */ 502 mac_free_share_t ms_sfree; /* Return a share to driver. */ 503 mac_share_add_group_t ms_sadd; /* Add a group to the share. */ 504 mac_share_rem_group_t ms_sremove; /* Remove group from share. */ 505 mac_share_query_t ms_squery; /* Query share constraints */ 506 mac_bind_share_t ms_sbind; /* Bind a share */ 507 mac_unbind_share_t ms_sunbind; /* Unbind a share */ 508 } mac_capab_share_t; 509 510 typedef struct mac_capab_vrrp_s { 511 /* IPv6 or IPv4? */ 512 int mcv_af; 513 } mac_capab_vrrp_t; 514 515 /* 516 * Transceiver capability 517 */ 518 typedef struct mac_transceiver_info mac_transceiver_info_t; 519 520 typedef struct mac_capab_transceiver { 521 uint_t mct_flags; 522 uint_t mct_ntransceivers; 523 int (*mct_info)(void *, uint_t, mac_transceiver_info_t *); 524 int (*mct_read)(void *, uint_t, uint_t, void *, size_t, off_t, 525 size_t *); 526 } mac_capab_transceiver_t; 527 528 /* 529 * LED capability 530 */ 531 typedef struct mac_capab_led { 532 uint_t mcl_flags; 533 mac_led_mode_t mcl_modes; 534 int (*mcl_set)(void *, mac_led_mode_t, uint_t); 535 } mac_capab_led_t; 536 537 /* 538 * MAC registration interface 539 */ 540 typedef struct mac_register_s { 541 uint_t m_version; /* set by mac_alloc() */ 542 const char *m_type_ident; 543 void *m_driver; /* Driver private data */ 544 dev_info_t *m_dip; 545 uint_t m_instance; 546 uint8_t *m_src_addr; 547 uint8_t *m_dst_addr; 548 mac_callbacks_t *m_callbacks; 549 uint_t m_min_sdu; 550 uint_t m_max_sdu; 551 void *m_pdata; 552 size_t m_pdata_size; 553 char **m_priv_props; 554 uint32_t m_margin; 555 uint32_t m_v12n; /* Virtualization level */ 556 uint_t m_multicast_sdu; 557 } mac_register_t; 558 559 /* 560 * Driver interface functions. 561 */ 562 extern mac_protect_t *mac_protect_get(mac_handle_t); 563 extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); 564 extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *, 565 uint_t *); 566 extern int mac_maxsdu_update(mac_handle_t, uint_t); 567 extern int mac_maxsdu_update2(mac_handle_t, uint_t, 568 uint_t); 569 570 extern mac_register_t *mac_alloc(uint_t); 571 extern void mac_free(mac_register_t *); 572 extern int mac_register(mac_register_t *, mac_handle_t *); 573 extern int mac_disable_nowait(mac_handle_t); 574 extern int mac_disable(mac_handle_t); 575 extern int mac_unregister(mac_handle_t); 576 extern void mac_rx(mac_handle_t, mac_resource_handle_t, 577 mblk_t *); 578 extern void mac_rx_ring(mac_handle_t, mac_ring_handle_t, 579 mblk_t *, uint64_t); 580 extern void mac_link_update(mac_handle_t, link_state_t); 581 extern void mac_link_redo(mac_handle_t, link_state_t); 582 extern void mac_unicst_update(mac_handle_t, 583 const uint8_t *); 584 extern void mac_dst_update(mac_handle_t, const uint8_t *); 585 extern void mac_tx_update(mac_handle_t); 586 extern void mac_tx_ring_update(mac_handle_t, 587 mac_ring_handle_t); 588 extern void mac_capab_update(mac_handle_t); 589 extern int mac_pdata_update(mac_handle_t, void *, 590 size_t); 591 extern void mac_multicast_refresh(mac_handle_t, 592 mac_multicst_t, void *, boolean_t); 593 extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, 594 void *); 595 extern void mac_promisc_refresh(mac_handle_t, 596 mac_setpromisc_t, void *); 597 extern boolean_t mac_margin_update(mac_handle_t, uint32_t); 598 extern void mac_margin_get(mac_handle_t, uint32_t *); 599 extern int mac_margin_remove(mac_handle_t, uint32_t); 600 extern int mac_margin_add(mac_handle_t, uint32_t *, 601 boolean_t); 602 extern void mac_init_ops(struct dev_ops *, const char *); 603 extern void mac_fini_ops(struct dev_ops *); 604 extern int mac_devt_to_instance(dev_t); 605 extern minor_t mac_private_minor(void); 606 extern void mac_ring_intr_set(mac_ring_handle_t, 607 ddi_intr_handle_t); 608 609 610 extern mactype_register_t *mactype_alloc(uint_t); 611 extern void mactype_free(mactype_register_t *); 612 extern int mactype_register(mactype_register_t *); 613 extern int mactype_unregister(const char *); 614 615 extern boolean_t mac_unicst_verify(mac_handle_t, 616 const uint8_t *, uint_t); 617 618 extern int mac_group_add_ring(mac_group_handle_t, int); 619 extern void mac_group_rem_ring(mac_group_handle_t, 620 mac_ring_handle_t); 621 extern mac_ring_handle_t mac_find_ring(mac_group_handle_t, int); 622 623 extern void mac_prop_info_set_default_uint8( 624 mac_prop_info_handle_t, uint8_t); 625 extern void mac_prop_info_set_default_str( 626 mac_prop_info_handle_t, const char *); 627 extern void mac_prop_info_set_default_uint64( 628 mac_prop_info_handle_t, uint64_t); 629 extern void mac_prop_info_set_default_uint32( 630 mac_prop_info_handle_t, uint32_t); 631 extern void mac_prop_info_set_default_link_flowctrl( 632 mac_prop_info_handle_t, link_flowctrl_t); 633 extern void mac_prop_info_set_range_uint32( 634 mac_prop_info_handle_t, 635 uint32_t, uint32_t); 636 extern void mac_prop_info_set_perm(mac_prop_info_handle_t, 637 uint8_t); 638 639 extern void mac_hcksum_get(mblk_t *, uint32_t *, 640 uint32_t *, uint32_t *, uint32_t *, 641 uint32_t *); 642 extern void mac_hcksum_set(mblk_t *, uint32_t, uint32_t, 643 uint32_t, uint32_t, uint32_t); 644 645 extern void mac_lso_get(mblk_t *, uint32_t *, uint32_t *); 646 647 extern void mac_transceiver_info_set_present( 648 mac_transceiver_info_t *, 649 boolean_t); 650 extern void mac_transceiver_info_set_usable( 651 mac_transceiver_info_t *, 652 boolean_t); 653 654 /* 655 * This represents a provisional set of currently illumos-private APIs to get 656 * information about a mblk_t chain's type. This is an evolving interface. 657 */ 658 typedef enum mac_ether_offload_flags { 659 MEOI_L2INFO_SET = 1 << 0, 660 MEOI_VLAN_TAGGED = 1 << 1, 661 MEOI_L3INFO_SET = 1 << 2, 662 MEOI_L4INFO_SET = 1 << 3 663 } mac_ether_offload_flags_t; 664 665 typedef struct mac_ether_offload_info { 666 mac_ether_offload_flags_t meoi_flags; /* What's valid? */ 667 size_t meoi_len; /* Total message length */ 668 uint8_t meoi_l2hlen; /* How long is the Ethernet header? */ 669 uint16_t meoi_l3proto; /* What's the Ethertype */ 670 uint8_t meoi_l3hlen; /* How long is the header? */ 671 uint8_t meoi_l4proto; /* What is the payload type? */ 672 uint8_t meoi_l4hlen; /* How long is the L4 header */ 673 } mac_ether_offload_info_t; 674 675 extern int mac_ether_offload_info(mblk_t *, 676 mac_ether_offload_info_t *); 677 678 679 #endif /* _KERNEL */ 680 681 #ifdef __cplusplus 682 } 683 #endif 684 685 #endif /* _SYS_MAC_PROVIDER_H */ 686