17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*ba2e4443Sseb * Common Development and Distribution License (the "License"). 6*ba2e4443Sseb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ba2e4443Sseb * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_MAC_H 277c478bd9Sstevel@tonic-gate #define _SYS_MAC_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 327c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 337c478bd9Sstevel@tonic-gate #include <sys/stream.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * MAC Services Module 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * MAC Information (text emitted by modinfo(1m)) 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate #define MAC_INFO "MAC Services v%I%" 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 49*ba2e4443Sseb * MAC version identifier. This is used by mac_alloc() mac_register() to 50*ba2e4443Sseb * verify that incompatible drivers don't register. 51*ba2e4443Sseb */ 52*ba2e4443Sseb #define MAC_VERSION 0x1 53*ba2e4443Sseb 54*ba2e4443Sseb /* 55*ba2e4443Sseb * MAC-Type version identifier. This is used by mactype_alloc() and 56*ba2e4443Sseb * mactype_register() to verify that incompatible MAC-Type plugins don't 57*ba2e4443Sseb * register. 58*ba2e4443Sseb */ 59*ba2e4443Sseb #define MACTYPE_VERSION 0x1 60*ba2e4443Sseb 61*ba2e4443Sseb /* 627c478bd9Sstevel@tonic-gate * Statistics 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #define XCVR_UNDEFINED 0 667c478bd9Sstevel@tonic-gate #define XCVR_NONE 1 677c478bd9Sstevel@tonic-gate #define XCVR_10 2 687c478bd9Sstevel@tonic-gate #define XCVR_100T4 3 697c478bd9Sstevel@tonic-gate #define XCVR_100X 4 707c478bd9Sstevel@tonic-gate #define XCVR_100T2 5 717c478bd9Sstevel@tonic-gate #define XCVR_1000X 6 727c478bd9Sstevel@tonic-gate #define XCVR_1000T 7 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate typedef enum { 757c478bd9Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 767c478bd9Sstevel@tonic-gate LINK_STATE_DOWN, 777c478bd9Sstevel@tonic-gate LINK_STATE_UP 787c478bd9Sstevel@tonic-gate } link_state_t; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate typedef enum { 817c478bd9Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 827c478bd9Sstevel@tonic-gate LINK_DUPLEX_HALF, 837c478bd9Sstevel@tonic-gate LINK_DUPLEX_FULL 847c478bd9Sstevel@tonic-gate } link_duplex_t; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #ifdef _KERNEL 877c478bd9Sstevel@tonic-gate 88*ba2e4443Sseb typedef struct mac_stat_info_s { 89*ba2e4443Sseb uint_t msi_stat; 90*ba2e4443Sseb char *msi_name; 91*ba2e4443Sseb uint_t msi_type; /* as defined in kstat_named_init(9F) */ 92*ba2e4443Sseb uint64_t msi_default; 93*ba2e4443Sseb } mac_stat_info_t; 94*ba2e4443Sseb 957c478bd9Sstevel@tonic-gate /* 96*ba2e4443Sseb * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are 97*ba2e4443Sseb * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - 98*ba2e4443Sseb * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and 99*ba2e4443Sseb * maintained by each driver. MACTYPE_STAT_MIN and above are statistics 100*ba2e4443Sseb * defined by MAC-Type plugins and maintained by each driver. 1017c478bd9Sstevel@tonic-gate */ 102*ba2e4443Sseb #define MAC_STAT_MIN 1000 103*ba2e4443Sseb #define MACTYPE_STAT_MIN 2000 104*ba2e4443Sseb 105*ba2e4443Sseb #define IS_MAC_STAT(stat) \ 106*ba2e4443Sseb (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) 107*ba2e4443Sseb #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) 108*ba2e4443Sseb 109*ba2e4443Sseb enum mac_driver_stat { 110*ba2e4443Sseb /* MIB-II stats (RFC 1213 and RFC 1573) */ 111*ba2e4443Sseb MAC_STAT_IFSPEED = MAC_STAT_MIN, 1127c478bd9Sstevel@tonic-gate MAC_STAT_MULTIRCV, 1137c478bd9Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 1147c478bd9Sstevel@tonic-gate MAC_STAT_MULTIXMT, 1157c478bd9Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 1167c478bd9Sstevel@tonic-gate MAC_STAT_NORCVBUF, 1177c478bd9Sstevel@tonic-gate MAC_STAT_IERRORS, 1187c478bd9Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 1197c478bd9Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 1207c478bd9Sstevel@tonic-gate MAC_STAT_OERRORS, 1217c478bd9Sstevel@tonic-gate MAC_STAT_COLLISIONS, 1227c478bd9Sstevel@tonic-gate MAC_STAT_RBYTES, 1237c478bd9Sstevel@tonic-gate MAC_STAT_IPACKETS, 1247c478bd9Sstevel@tonic-gate MAC_STAT_OBYTES, 125*ba2e4443Sseb MAC_STAT_OPACKETS 1267c478bd9Sstevel@tonic-gate }; 1277c478bd9Sstevel@tonic-gate 128*ba2e4443Sseb #define MAC_NSTAT (MAC_STAT_OPACKETS - MAC_STAT_IFSPEED + 1) 129*ba2e4443Sseb 130*ba2e4443Sseb #define MAC_STAT_ISACOUNTER(_stat) ( \ 131*ba2e4443Sseb (_stat) == MAC_STAT_MULTIRCV || \ 132*ba2e4443Sseb (_stat) == MAC_STAT_BRDCSTRCV || \ 133*ba2e4443Sseb (_stat) == MAC_STAT_MULTIXMT || \ 134*ba2e4443Sseb (_stat) == MAC_STAT_BRDCSTXMT || \ 135*ba2e4443Sseb (_stat) == MAC_STAT_NORCVBUF || \ 136*ba2e4443Sseb (_stat) == MAC_STAT_IERRORS || \ 137*ba2e4443Sseb (_stat) == MAC_STAT_UNKNOWNS || \ 138*ba2e4443Sseb (_stat) == MAC_STAT_NOXMTBUF || \ 139*ba2e4443Sseb (_stat) == MAC_STAT_OERRORS || \ 140*ba2e4443Sseb (_stat) == MAC_STAT_COLLISIONS || \ 141*ba2e4443Sseb (_stat) == MAC_STAT_RBYTES || \ 142*ba2e4443Sseb (_stat) == MAC_STAT_IPACKETS || \ 143*ba2e4443Sseb (_stat) == MAC_STAT_OBYTES || \ 144*ba2e4443Sseb (_stat) == MAC_STAT_OPACKETS) 145*ba2e4443Sseb 1467c478bd9Sstevel@tonic-gate /* 1477c478bd9Sstevel@tonic-gate * Maximum MAC address length 1487c478bd9Sstevel@tonic-gate */ 149*ba2e4443Sseb #define MAXMACADDRLEN 20 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 1537c478bd9Sstevel@tonic-gate */ 1547c478bd9Sstevel@tonic-gate typedef struct mac_info_s { 1557c478bd9Sstevel@tonic-gate uint_t mi_media; 1567c478bd9Sstevel@tonic-gate uint_t mi_sdu_min; 1577c478bd9Sstevel@tonic-gate uint_t mi_sdu_max; 1587c478bd9Sstevel@tonic-gate uint_t mi_addr_length; 159*ba2e4443Sseb uint8_t *mi_unicst_addr; 160*ba2e4443Sseb uint8_t *mi_brdcst_addr; 1617c478bd9Sstevel@tonic-gate } mac_info_t; 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* 164*ba2e4443Sseb * MAC layer capabilities. These capabilities are handled by the drivers' 165*ba2e4443Sseb * mc_capab_get() callbacks. Some capabilities require the driver to fill 166*ba2e4443Sseb * in a given data structure, and others are simply boolean capabilities. 167*ba2e4443Sseb * Note that capability values must be powers of 2 so that consumers and 168*ba2e4443Sseb * providers of this interface can keep track of which capabilities they 169*ba2e4443Sseb * care about by keeping a bitfield of these things around somewhere. 1707c478bd9Sstevel@tonic-gate */ 171*ba2e4443Sseb typedef enum { 172*ba2e4443Sseb MAC_CAPAB_HCKSUM = 0x01, /* data is a uint32_t for the txflags */ 173*ba2e4443Sseb MAC_CAPAB_POLL = 0x02 /* boolean only, no data */ 174*ba2e4443Sseb /* add new capabilities here */ 175*ba2e4443Sseb } mac_capab_t; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * MAC driver entry point types. 1797c478bd9Sstevel@tonic-gate */ 180*ba2e4443Sseb typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); 1817c478bd9Sstevel@tonic-gate typedef int (*mac_start_t)(void *); 1827c478bd9Sstevel@tonic-gate typedef void (*mac_stop_t)(void *); 183*ba2e4443Sseb typedef int (*mac_setpromisc_t)(void *, boolean_t); 1847c478bd9Sstevel@tonic-gate typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 1857c478bd9Sstevel@tonic-gate typedef int (*mac_unicst_t)(void *, const uint8_t *); 1867c478bd9Sstevel@tonic-gate typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 187*ba2e4443Sseb typedef void (*mac_resources_t)(void *); 1887c478bd9Sstevel@tonic-gate typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 189*ba2e4443Sseb typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 192*ba2e4443Sseb * Drivers must set all of these callbacks except for mc_resources, 193*ba2e4443Sseb * mc_ioctl, and mc_getcapab, which are optional. If any of these optional 194*ba2e4443Sseb * callbacks are set, their appropriate flags must be set in mc_callbacks. 195*ba2e4443Sseb * Any future additions to this list must also be accompanied by an 196*ba2e4443Sseb * associated mc_callbacks flag so that the framework can grow without 197*ba2e4443Sseb * affecting the binary compatibility of the interface. 1987c478bd9Sstevel@tonic-gate */ 199*ba2e4443Sseb typedef struct mac_callbacks_s { 200*ba2e4443Sseb uint_t mc_callbacks; /* Denotes which callbacks are set */ 201*ba2e4443Sseb mac_getstat_t mc_getstat; /* Get the value of a statistic */ 202*ba2e4443Sseb mac_start_t mc_start; /* Start the device */ 203*ba2e4443Sseb mac_stop_t mc_stop; /* Stop the device */ 204*ba2e4443Sseb mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ 205*ba2e4443Sseb mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ 206*ba2e4443Sseb mac_unicst_t mc_unicst; /* Set the unicast MAC address */ 207*ba2e4443Sseb mac_tx_t mc_tx; /* Transmit a packet */ 208*ba2e4443Sseb mac_resources_t mc_resources; /* Get the device resources */ 209*ba2e4443Sseb mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ 210*ba2e4443Sseb mac_getcapab_t mc_getcapab; /* Get capability information */ 211*ba2e4443Sseb } mac_callbacks_t; 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate /* 214*ba2e4443Sseb * Flags for mc_callbacks. Requiring drivers to set the flags associated 215*ba2e4443Sseb * with optional callbacks initialized in the structure allows the mac 216*ba2e4443Sseb * module to add optional callbacks in the future without requiring drivers 217*ba2e4443Sseb * to recompile. 2187c478bd9Sstevel@tonic-gate */ 219*ba2e4443Sseb #define MC_RESOURCES 0x001 220*ba2e4443Sseb #define MC_IOCTL 0x002 221*ba2e4443Sseb #define MC_GETCAPAB 0x004 2227c478bd9Sstevel@tonic-gate 223*ba2e4443Sseb typedef struct mac_register_s { 224*ba2e4443Sseb uint_t m_version; /* set by mac_alloc() */ 225*ba2e4443Sseb const char *m_type_ident; 2267c478bd9Sstevel@tonic-gate void *m_driver; /* Driver private data */ 2277c478bd9Sstevel@tonic-gate dev_info_t *m_dip; 228*ba2e4443Sseb uint_t m_instance; 229*ba2e4443Sseb uint8_t *m_src_addr; 230*ba2e4443Sseb uint8_t *m_dst_addr; 231*ba2e4443Sseb mac_callbacks_t *m_callbacks; 232*ba2e4443Sseb uint_t m_min_sdu; 233*ba2e4443Sseb uint_t m_max_sdu; 234*ba2e4443Sseb void *m_pdata; 235*ba2e4443Sseb size_t m_pdata_size; 236*ba2e4443Sseb } mac_register_t; 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * Opaque handle types. 2407c478bd9Sstevel@tonic-gate */ 241*ba2e4443Sseb typedef struct mac_t *mac_handle_t; 2427c478bd9Sstevel@tonic-gate typedef struct __mac_notify_handle *mac_notify_handle_t; 2437c478bd9Sstevel@tonic-gate typedef struct __mac_rx_handle *mac_rx_handle_t; 2447c478bd9Sstevel@tonic-gate typedef struct __mac_txloop_handle *mac_txloop_handle_t; 2457c478bd9Sstevel@tonic-gate typedef struct __mac_resource_handle *mac_resource_handle_t; 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * MAC interface callback types. 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate typedef enum { 2517c478bd9Sstevel@tonic-gate MAC_NOTE_LINK, 2527c478bd9Sstevel@tonic-gate MAC_NOTE_PROMISC, 2537c478bd9Sstevel@tonic-gate MAC_NOTE_UNICST, 2547c478bd9Sstevel@tonic-gate MAC_NOTE_TX, 2557c478bd9Sstevel@tonic-gate MAC_NOTE_RESOURCE, 2567c478bd9Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 257*ba2e4443Sseb MAC_NOTE_FASTPATH_FLUSH, 2587c478bd9Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 2597c478bd9Sstevel@tonic-gate } mac_notify_type_t; 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 2627c478bd9Sstevel@tonic-gate typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *); 2637c478bd9Sstevel@tonic-gate typedef void (*mac_txloop_t)(void *, mblk_t *); 2647c478bd9Sstevel@tonic-gate typedef void (*mac_blank_t)(void *, time_t, uint_t); 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate /* 2677c478bd9Sstevel@tonic-gate * MAC promiscuous types 2687c478bd9Sstevel@tonic-gate */ 2697c478bd9Sstevel@tonic-gate typedef enum { 2707c478bd9Sstevel@tonic-gate MAC_PROMISC = 0x01, /* MAC instance is promiscuous */ 2717c478bd9Sstevel@tonic-gate MAC_DEVPROMISC = 0x02 /* Device is promiscuous */ 2727c478bd9Sstevel@tonic-gate } mac_promisc_type_t; 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate /* 2757c478bd9Sstevel@tonic-gate * MAC resource types 2767c478bd9Sstevel@tonic-gate */ 2777c478bd9Sstevel@tonic-gate typedef enum { 2787c478bd9Sstevel@tonic-gate MAC_RX_FIFO = 1 2797c478bd9Sstevel@tonic-gate } mac_resource_type_t; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 2827c478bd9Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 2837c478bd9Sstevel@tonic-gate mac_blank_t mrf_blank; 2847c478bd9Sstevel@tonic-gate void *mrf_arg; 2857c478bd9Sstevel@tonic-gate time_t mrf_normal_blank_time; 2867c478bd9Sstevel@tonic-gate uint_t mrf_normal_pkt_count; 2877c478bd9Sstevel@tonic-gate } mac_rx_fifo_t; 2887c478bd9Sstevel@tonic-gate 28998b1442aSmeem typedef struct mac_txinfo_s { 29098b1442aSmeem mac_tx_t mt_fn; 29198b1442aSmeem void *mt_arg; 29298b1442aSmeem } mac_txinfo_t; 29398b1442aSmeem 2947c478bd9Sstevel@tonic-gate typedef union mac_resource_u { 2957c478bd9Sstevel@tonic-gate mac_resource_type_t mr_type; 2967c478bd9Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 2977c478bd9Sstevel@tonic-gate } mac_resource_t; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 3007c478bd9Sstevel@tonic-gate 301*ba2e4443Sseb typedef enum { 302*ba2e4443Sseb MAC_ADDRTYPE_UNICAST, 303*ba2e4443Sseb MAC_ADDRTYPE_MULTICAST, 304*ba2e4443Sseb MAC_ADDRTYPE_BROADCAST 305*ba2e4443Sseb } mac_addrtype_t; 306*ba2e4443Sseb 307*ba2e4443Sseb typedef struct mac_header_info_s { 308*ba2e4443Sseb size_t mhi_hdrsize; 309*ba2e4443Sseb size_t mhi_pktsize; 310*ba2e4443Sseb const uint8_t *mhi_daddr; 311*ba2e4443Sseb const uint8_t *mhi_saddr; 312*ba2e4443Sseb uint32_t mhi_origsap; 313*ba2e4443Sseb uint32_t mhi_bindsap; 314*ba2e4443Sseb mac_addrtype_t mhi_dsttype; 315*ba2e4443Sseb } mac_header_info_t; 316*ba2e4443Sseb 317*ba2e4443Sseb /* 318*ba2e4443Sseb * MAC-Type plugin interfaces 319*ba2e4443Sseb */ 320*ba2e4443Sseb 321*ba2e4443Sseb typedef int (*mtops_addr_verify_t)(const void *, void *); 322*ba2e4443Sseb typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); 323*ba2e4443Sseb typedef mblk_t *(*mtops_header_t)(const void *, const void *, 324*ba2e4443Sseb uint32_t, void *, mblk_t *, size_t); 325*ba2e4443Sseb typedef int (*mtops_header_info_t)(mblk_t *, void *, 326*ba2e4443Sseb mac_header_info_t *); 327*ba2e4443Sseb typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); 328*ba2e4443Sseb typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); 329*ba2e4443Sseb 330*ba2e4443Sseb typedef struct mactype_ops_s { 331*ba2e4443Sseb uint_t mtops_ops; 332*ba2e4443Sseb /* 333*ba2e4443Sseb * mtops_unicst_verify() returns 0 if the given address is a valid 334*ba2e4443Sseb * unicast address, or a non-zero errno otherwise. 335*ba2e4443Sseb */ 336*ba2e4443Sseb mtops_addr_verify_t mtops_unicst_verify; 337*ba2e4443Sseb /* 338*ba2e4443Sseb * mtops_multicst_verify() returns 0 if the given address is a 339*ba2e4443Sseb * valid multicast address, or a non-zero errno otherwise. If the 340*ba2e4443Sseb * media doesn't support multicast, ENOTSUP should be returned (for 341*ba2e4443Sseb * example). 342*ba2e4443Sseb */ 343*ba2e4443Sseb mtops_addr_verify_t mtops_multicst_verify; 344*ba2e4443Sseb /* 345*ba2e4443Sseb * mtops_sap_verify() returns B_TRUE if the given SAP is a valid 346*ba2e4443Sseb * SAP value, or B_FALSE otherwise. 347*ba2e4443Sseb */ 348*ba2e4443Sseb mtops_sap_verify_t mtops_sap_verify; 349*ba2e4443Sseb /* 350*ba2e4443Sseb * mtops_header() is used to allocate and construct a MAC header. 351*ba2e4443Sseb */ 352*ba2e4443Sseb mtops_header_t mtops_header; 353*ba2e4443Sseb /* 354*ba2e4443Sseb * mtops_header_info() is used to gather information on a given MAC 355*ba2e4443Sseb * header. 356*ba2e4443Sseb */ 357*ba2e4443Sseb mtops_header_info_t mtops_header_info; 358*ba2e4443Sseb /* 359*ba2e4443Sseb * mtops_pdata_verify() is used to verify the validity of MAC 360*ba2e4443Sseb * plugin data. It is called by mac_register() if the driver has 361*ba2e4443Sseb * supplied MAC plugin data, and also by mac_pdata_update() when 362*ba2e4443Sseb * drivers update the data. 363*ba2e4443Sseb */ 364*ba2e4443Sseb mtops_pdata_verify_t mtops_pdata_verify; 365*ba2e4443Sseb /* 366*ba2e4443Sseb * mtops_header_cook() is an optional callback that converts (or 367*ba2e4443Sseb * "cooks") the given raw header (as sent by a raw DLPI consumer) 368*ba2e4443Sseb * into one that is appropriate to send down to the MAC driver. 369*ba2e4443Sseb * Following the example above, an Ethernet header sent down by a 370*ba2e4443Sseb * DLPI consumer would be converted to whatever header the MAC 371*ba2e4443Sseb * driver expects. 372*ba2e4443Sseb */ 373*ba2e4443Sseb mtops_header_modify_t mtops_header_cook; 374*ba2e4443Sseb /* 375*ba2e4443Sseb * mtops_header_uncook() is an optional callback that does the 376*ba2e4443Sseb * opposite of mtops_header_cook(). It "uncooks" a given MAC 377*ba2e4443Sseb * header (as received from the driver) for consumption by raw DLPI 378*ba2e4443Sseb * consumers. For example, for a non-Ethernet plugin that wants 379*ba2e4443Sseb * raw DLPI consumers to be fooled into thinking that the device 380*ba2e4443Sseb * provides Ethernet access, this callback would modify the given 381*ba2e4443Sseb * mblk_t such that the MAC header is converted to an Ethernet 382*ba2e4443Sseb * header. 383*ba2e4443Sseb */ 384*ba2e4443Sseb mtops_header_modify_t mtops_header_uncook; 385*ba2e4443Sseb } mactype_ops_t; 386*ba2e4443Sseb 387*ba2e4443Sseb /* 388*ba2e4443Sseb * mtops_ops exists for the plugin to enumerate the optional callback 389*ba2e4443Sseb * entrypoints it has defined. This allows the mac module to define 390*ba2e4443Sseb * additional plugin entrypoints in mactype_ops_t without breaking backward 391*ba2e4443Sseb * compatibility with old plugins. 392*ba2e4443Sseb */ 393*ba2e4443Sseb #define MTOPS_PDATA_VERIFY 0x001 394*ba2e4443Sseb #define MTOPS_HEADER_COOK 0x002 395*ba2e4443Sseb #define MTOPS_HEADER_UNCOOK 0x004 396*ba2e4443Sseb 397*ba2e4443Sseb typedef struct mactype_register_s { 398*ba2e4443Sseb uint_t mtr_version; /* set by mactype_alloc() */ 399*ba2e4443Sseb const char *mtr_ident; 400*ba2e4443Sseb mactype_ops_t *mtr_ops; 401*ba2e4443Sseb uint_t mtr_mactype; 402*ba2e4443Sseb uint_t mtr_addrlen; 403*ba2e4443Sseb uint8_t *mtr_brdcst_addr; 404*ba2e4443Sseb mac_stat_info_t *mtr_stats; 405*ba2e4443Sseb size_t mtr_statcount; 406*ba2e4443Sseb } mactype_register_t; 407*ba2e4443Sseb 4087c478bd9Sstevel@tonic-gate /* 4097c478bd9Sstevel@tonic-gate * Client interface functions. 4107c478bd9Sstevel@tonic-gate */ 4117c478bd9Sstevel@tonic-gate extern int mac_open(const char *, uint_t, mac_handle_t *); 4127c478bd9Sstevel@tonic-gate extern void mac_close(mac_handle_t); 4137c478bd9Sstevel@tonic-gate extern const mac_info_t *mac_info(mac_handle_t); 414210db224Sericheng extern boolean_t mac_info_get(const char *, mac_info_t *); 415*ba2e4443Sseb extern uint64_t mac_stat_get(mac_handle_t, uint_t); 4167c478bd9Sstevel@tonic-gate extern int mac_start(mac_handle_t); 4177c478bd9Sstevel@tonic-gate extern void mac_stop(mac_handle_t); 4187c478bd9Sstevel@tonic-gate extern int mac_promisc_set(mac_handle_t, boolean_t, 4197c478bd9Sstevel@tonic-gate mac_promisc_type_t); 4207c478bd9Sstevel@tonic-gate extern boolean_t mac_promisc_get(mac_handle_t, 4217c478bd9Sstevel@tonic-gate mac_promisc_type_t); 4227c478bd9Sstevel@tonic-gate extern int mac_multicst_add(mac_handle_t, const uint8_t *); 4237c478bd9Sstevel@tonic-gate extern int mac_multicst_remove(mac_handle_t, 4247c478bd9Sstevel@tonic-gate const uint8_t *); 4257c478bd9Sstevel@tonic-gate extern int mac_unicst_set(mac_handle_t, const uint8_t *); 4267c478bd9Sstevel@tonic-gate extern void mac_unicst_get(mac_handle_t, uint8_t *); 427*ba2e4443Sseb extern void mac_dest_get(mac_handle_t, uint8_t *); 4287c478bd9Sstevel@tonic-gate extern void mac_resources(mac_handle_t); 4297c478bd9Sstevel@tonic-gate extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *); 43098b1442aSmeem extern const mac_txinfo_t *mac_tx_get(mac_handle_t); 4317c478bd9Sstevel@tonic-gate extern link_state_t mac_link_get(mac_handle_t); 4327c478bd9Sstevel@tonic-gate extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, 4337c478bd9Sstevel@tonic-gate void *); 4347c478bd9Sstevel@tonic-gate extern void mac_notify_remove(mac_handle_t, 4357c478bd9Sstevel@tonic-gate mac_notify_handle_t); 4367c478bd9Sstevel@tonic-gate extern void mac_notify(mac_handle_t); 4377c478bd9Sstevel@tonic-gate extern mac_rx_handle_t mac_rx_add(mac_handle_t, mac_rx_t, void *); 4387c478bd9Sstevel@tonic-gate extern void mac_rx_remove(mac_handle_t, mac_rx_handle_t); 4397c478bd9Sstevel@tonic-gate extern mblk_t *mac_txloop(void *, mblk_t *); 4407c478bd9Sstevel@tonic-gate extern mac_txloop_handle_t mac_txloop_add(mac_handle_t, mac_txloop_t, 4417c478bd9Sstevel@tonic-gate void *); 4427c478bd9Sstevel@tonic-gate extern void mac_txloop_remove(mac_handle_t, 4437c478bd9Sstevel@tonic-gate mac_txloop_handle_t); 4447c478bd9Sstevel@tonic-gate extern boolean_t mac_active_set(mac_handle_t); 4457c478bd9Sstevel@tonic-gate extern void mac_active_clear(mac_handle_t); 4467c478bd9Sstevel@tonic-gate extern void mac_resource_set(mac_handle_t, 4477c478bd9Sstevel@tonic-gate mac_resource_add_t, void *); 448210db224Sericheng extern dev_info_t *mac_devinfo_get(mac_handle_t); 449*ba2e4443Sseb extern boolean_t mac_capab_get(mac_handle_t, mac_capab_t, 450*ba2e4443Sseb void *); 451*ba2e4443Sseb extern boolean_t mac_sap_verify(mac_handle_t, uint32_t, 452*ba2e4443Sseb uint32_t *); 453*ba2e4443Sseb extern mblk_t *mac_header(mac_handle_t, const uint8_t *, 454*ba2e4443Sseb uint32_t, mblk_t *, size_t); 455*ba2e4443Sseb extern int mac_header_info(mac_handle_t, mblk_t *, 456*ba2e4443Sseb mac_header_info_t *); 457*ba2e4443Sseb extern mblk_t *mac_header_cook(mac_handle_t, mblk_t *); 458*ba2e4443Sseb extern mblk_t *mac_header_uncook(mac_handle_t, mblk_t *); 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate /* 4617c478bd9Sstevel@tonic-gate * Driver interface functions. 4627c478bd9Sstevel@tonic-gate */ 463*ba2e4443Sseb extern mac_register_t *mac_alloc(uint_t); 464*ba2e4443Sseb extern void mac_free(mac_register_t *); 465*ba2e4443Sseb extern int mac_register(mac_register_t *, mac_handle_t *); 466*ba2e4443Sseb extern int mac_unregister(mac_handle_t); 467*ba2e4443Sseb extern void mac_rx(mac_handle_t, mac_resource_handle_t, 4687c478bd9Sstevel@tonic-gate mblk_t *); 469*ba2e4443Sseb extern void mac_link_update(mac_handle_t, link_state_t); 470*ba2e4443Sseb extern void mac_unicst_update(mac_handle_t, 471*ba2e4443Sseb const uint8_t *); 472*ba2e4443Sseb extern void mac_tx_update(mac_handle_t); 473*ba2e4443Sseb extern void mac_resource_update(mac_handle_t); 474*ba2e4443Sseb extern mac_resource_handle_t mac_resource_add(mac_handle_t, 475*ba2e4443Sseb mac_resource_t *); 476*ba2e4443Sseb extern int mac_pdata_update(mac_handle_t, void *, 477*ba2e4443Sseb size_t); 478*ba2e4443Sseb extern void mac_multicst_refresh(mac_handle_t, 479*ba2e4443Sseb mac_multicst_t, void *, boolean_t); 480*ba2e4443Sseb extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, 4817c478bd9Sstevel@tonic-gate void *); 482*ba2e4443Sseb extern void mac_promisc_refresh(mac_handle_t, 483*ba2e4443Sseb mac_setpromisc_t, void *); 484210db224Sericheng extern void mac_init_ops(struct dev_ops *, const char *); 485210db224Sericheng extern void mac_fini_ops(struct dev_ops *); 486*ba2e4443Sseb extern mactype_register_t *mactype_alloc(uint_t); 487*ba2e4443Sseb extern void mactype_free(mactype_register_t *); 488*ba2e4443Sseb extern int mactype_register(mactype_register_t *); 489*ba2e4443Sseb extern int mactype_unregister(const char *); 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4947c478bd9Sstevel@tonic-gate } 4957c478bd9Sstevel@tonic-gate #endif 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 498