1da14cebeSEric Cheng /* 2da14cebeSEric Cheng * CDDL HEADER START 3da14cebeSEric Cheng * 4da14cebeSEric Cheng * The contents of this file are subject to the terms of the 5da14cebeSEric Cheng * Common Development and Distribution License (the "License"). 6da14cebeSEric Cheng * You may not use this file except in compliance with the License. 7da14cebeSEric Cheng * 8da14cebeSEric Cheng * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9da14cebeSEric Cheng * or http://www.opensolaris.org/os/licensing. 10da14cebeSEric Cheng * See the License for the specific language governing permissions 11da14cebeSEric Cheng * and limitations under the License. 12da14cebeSEric Cheng * 13da14cebeSEric Cheng * When distributing Covered Code, include this CDDL HEADER in each 14da14cebeSEric Cheng * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15da14cebeSEric Cheng * If applicable, add the following below this CDDL HEADER, with the 16da14cebeSEric Cheng * fields enclosed by brackets "[]" replaced with your own identifying 17da14cebeSEric Cheng * information: Portions Copyright [yyyy] [name of copyright owner] 18da14cebeSEric Cheng * 19da14cebeSEric Cheng * CDDL HEADER END 20da14cebeSEric Cheng */ 21da14cebeSEric Cheng 22da14cebeSEric Cheng /* 23550b6e40SSowmini Varadhan * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 2448a4016cSRobert Mustacchi * Copyright (c) 2017, Joyent, Inc. 25da14cebeSEric Cheng */ 26da14cebeSEric Cheng 27da14cebeSEric Cheng #ifndef _SYS_MAC_PROVIDER_H 28da14cebeSEric Cheng #define _SYS_MAC_PROVIDER_H 29da14cebeSEric Cheng 30da14cebeSEric Cheng #include <sys/types.h> 31da14cebeSEric Cheng #include <sys/ddi.h> 32da14cebeSEric Cheng #include <sys/sunddi.h> 33da14cebeSEric Cheng #include <sys/stream.h> 3493a61d92SGarrett D'Amore #include <sys/mkdev.h> 35da14cebeSEric Cheng #include <sys/mac.h> 36550b6e40SSowmini Varadhan #include <sys/mac_flow.h> 37da14cebeSEric Cheng 38da14cebeSEric Cheng /* 39da14cebeSEric Cheng * MAC Provider Interface 40da14cebeSEric Cheng */ 41da14cebeSEric Cheng 42da14cebeSEric Cheng #ifdef __cplusplus 43da14cebeSEric Cheng extern "C" { 44da14cebeSEric Cheng #endif 45da14cebeSEric Cheng 46da14cebeSEric Cheng /* 470dc2366fSVenugopal Iyer * MAC version identifiers. Drivers compiled against the stable V1 version 480dc2366fSVenugopal Iyer * of the API should register with MAC_VERSION_V1. ON drivers should use 490dc2366fSVenugopal Iyer * MAC_VERSION. This is used by mac_alloc() mac_register() to 50da14cebeSEric Cheng * verify that incompatible drivers don't register. 51da14cebeSEric Cheng */ 520dc2366fSVenugopal Iyer #define MAC_VERSION_V1 0x1 530dc2366fSVenugopal Iyer #define MAC_VERSION MAC_VERSION_V1 54da14cebeSEric Cheng 55da14cebeSEric Cheng /* 560dc2366fSVenugopal Iyer * Possible values for ETHER_STAT_XCVR_INUSE statistic. 57da14cebeSEric Cheng */ 58da14cebeSEric Cheng 59da14cebeSEric Cheng #define XCVR_UNDEFINED 0 60da14cebeSEric Cheng #define XCVR_NONE 1 61da14cebeSEric Cheng #define XCVR_10 2 62da14cebeSEric Cheng #define XCVR_100T4 3 63da14cebeSEric Cheng #define XCVR_100X 4 64da14cebeSEric Cheng #define XCVR_100T2 5 65da14cebeSEric Cheng #define XCVR_1000X 6 66da14cebeSEric Cheng #define XCVR_1000T 7 67da14cebeSEric Cheng 68da14cebeSEric Cheng #ifdef _KERNEL 69da14cebeSEric Cheng 70da14cebeSEric Cheng /* 71da14cebeSEric Cheng * Definitions for MAC Drivers Capabilities 72da14cebeSEric Cheng */ 73da14cebeSEric Cheng /* 74da14cebeSEric Cheng * MAC layer capabilities. These capabilities are handled by the drivers' 75da14cebeSEric Cheng * mc_capab_get() callbacks. Some capabilities require the driver to fill 76da14cebeSEric Cheng * in a given data structure, and others are simply boolean capabilities. 77da14cebeSEric Cheng * Note that capability values must be powers of 2 so that consumers and 78da14cebeSEric Cheng * providers of this interface can keep track of which capabilities they 79da14cebeSEric Cheng * care about by keeping a bitfield of these things around somewhere. 80da14cebeSEric Cheng */ 81da14cebeSEric Cheng typedef enum { 82da14cebeSEric Cheng /* 830dc2366fSVenugopal Iyer * Public Capabilities (MAC_VERSION_V1) 84da14cebeSEric Cheng */ 850dc2366fSVenugopal Iyer MAC_CAPAB_HCKSUM = 0x00000001, /* data is a uint32_t */ 860dc2366fSVenugopal Iyer MAC_CAPAB_LSO = 0x00000008, /* data is mac_capab_lso_t */ 87da14cebeSEric Cheng 88da14cebeSEric Cheng /* 890dc2366fSVenugopal Iyer * Reserved capabilities, do not use 90da14cebeSEric Cheng */ 910dc2366fSVenugopal Iyer MAC_CAPAB_RESERVED1 = 0x00000002, 920dc2366fSVenugopal Iyer MAC_CAPAB_RESERVED2 = 0x00000004, 93da14cebeSEric Cheng 940dc2366fSVenugopal Iyer /* 950dc2366fSVenugopal Iyer * Private driver capabilities 960dc2366fSVenugopal Iyer */ 970dc2366fSVenugopal Iyer MAC_CAPAB_RINGS = 0x00000010, /* data is mac_capab_rings_t */ 980dc2366fSVenugopal Iyer MAC_CAPAB_SHARES = 0x00000020, /* data is mac_capab_share_t */ 990dc2366fSVenugopal Iyer MAC_CAPAB_MULTIFACTADDR = 0x00000040, /* mac_data_multifactaddr_t */ 1000dc2366fSVenugopal Iyer 1010dc2366fSVenugopal Iyer /* 1020dc2366fSVenugopal Iyer * Private driver capabilities for use by the GLDv3 framework only 1030dc2366fSVenugopal Iyer */ 1040dc2366fSVenugopal Iyer MAC_CAPAB_VNIC = 0x00010000, /* data is mac_capab_vnic_t */ 1050dc2366fSVenugopal Iyer MAC_CAPAB_ANCHOR_VNIC = 0x00020000, /* boolean only, no data */ 1060dc2366fSVenugopal Iyer MAC_CAPAB_AGGR = 0x00040000, /* data is mac_capab_aggr_t */ 1070dc2366fSVenugopal Iyer MAC_CAPAB_NO_NATIVEVLAN = 0x00080000, /* boolean only, no data */ 1080dc2366fSVenugopal Iyer MAC_CAPAB_NO_ZCOPY = 0x00100000, /* boolean only, no data */ 1090dc2366fSVenugopal Iyer MAC_CAPAB_LEGACY = 0x00200000, /* data is mac_capab_legacy_t */ 11048a4016cSRobert Mustacchi MAC_CAPAB_VRRP = 0x00400000, /* data is mac_capab_vrrp_t */ 111*4d210590SRobert Mustacchi MAC_CAPAB_TRANSCEIVER = 0x01000000, /* mac_capab_transciever_t */ 112*4d210590SRobert Mustacchi MAC_CAPAB_LED = 0x02000000 /* data is mac_capab_led_t */ 113da14cebeSEric Cheng } mac_capab_t; 114da14cebeSEric Cheng 115da14cebeSEric Cheng /* 116da14cebeSEric Cheng * LSO capability 117da14cebeSEric Cheng */ 118da14cebeSEric Cheng typedef struct lso_basic_tcp_ipv4_s { 119da14cebeSEric Cheng t_uscalar_t lso_max; /* maximum payload */ 120da14cebeSEric Cheng } lso_basic_tcp_ipv4_t; 121da14cebeSEric Cheng 122da14cebeSEric Cheng /* 123da14cebeSEric Cheng * Currently supported flags for LSO. 124da14cebeSEric Cheng */ 125da14cebeSEric Cheng #define LSO_TX_BASIC_TCP_IPV4 0x01 /* TCP LSO capability */ 126da14cebeSEric Cheng 127da14cebeSEric Cheng /* 128da14cebeSEric Cheng * Future LSO capabilities can be added at the end of the mac_capab_lso_t. 129da14cebeSEric Cheng * When such capability is added to the GLDv3 framework, the size of the 130da14cebeSEric Cheng * mac_capab_lso_t it allocates and passes to the drivers increases. Older 131da14cebeSEric Cheng * drivers wil access only the (upper) sections of that structure, that is the 132da14cebeSEric Cheng * sections carrying the capabilities they understand. This ensures the 133da14cebeSEric Cheng * interface can be safely extended in a binary compatible way. 134da14cebeSEric Cheng */ 135da14cebeSEric Cheng typedef struct mac_capab_lso_s { 136da14cebeSEric Cheng t_uscalar_t lso_flags; 137da14cebeSEric Cheng lso_basic_tcp_ipv4_t lso_basic_tcp_ipv4; 138da14cebeSEric Cheng /* Add future lso capabilities here */ 139da14cebeSEric Cheng } mac_capab_lso_t; 140da14cebeSEric Cheng 141da14cebeSEric Cheng /* 142da14cebeSEric Cheng * Multiple Factory MAC Addresses Capability 143da14cebeSEric Cheng */ 144da14cebeSEric Cheng typedef struct mac_capab_multifactaddr_s { 145da14cebeSEric Cheng /* 146da14cebeSEric Cheng * Number of factory addresses 147da14cebeSEric Cheng */ 148da14cebeSEric Cheng uint_t mcm_naddr; 149da14cebeSEric Cheng 150da14cebeSEric Cheng /* 151da14cebeSEric Cheng * Callbacks to query all the factory addresses. 152da14cebeSEric Cheng */ 153da14cebeSEric Cheng void (*mcm_getaddr)(void *, uint_t, uint8_t *); 154da14cebeSEric Cheng } mac_capab_multifactaddr_t; 155da14cebeSEric Cheng 156da14cebeSEric Cheng /* 1575d460eafSCathy Zhou * Info and callbacks of legacy devices. 1585d460eafSCathy Zhou */ 1595d460eafSCathy Zhou typedef struct mac_capab_legacy_s { 1605d460eafSCathy Zhou /* 1615d460eafSCathy Zhou * Notifications that the legacy device does not support. 1625d460eafSCathy Zhou */ 1635d460eafSCathy Zhou uint32_t ml_unsup_note; 1645d460eafSCathy Zhou /* 1655d460eafSCathy Zhou * dev_t of the legacy device; can be held to force attach. 1665d460eafSCathy Zhou */ 1675d460eafSCathy Zhou dev_t ml_dev; 1685d460eafSCathy Zhou boolean_t (*ml_active_set)(void *); 1695d460eafSCathy Zhou void (*ml_active_clear)(void *); 1705d460eafSCathy Zhou int (*ml_fastpath_disable)(void *); 1715d460eafSCathy Zhou void (*ml_fastpath_enable)(void *); 1725d460eafSCathy Zhou } mac_capab_legacy_t; 1735d460eafSCathy Zhou 1740dc2366fSVenugopal Iyer typedef struct __mac_prop_info_handle *mac_prop_info_handle_t; 1750dc2366fSVenugopal Iyer 1765d460eafSCathy Zhou /* 177da14cebeSEric Cheng * MAC driver entry point types. 178da14cebeSEric Cheng */ 179da14cebeSEric Cheng typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); 180da14cebeSEric Cheng typedef int (*mac_start_t)(void *); 181da14cebeSEric Cheng typedef void (*mac_stop_t)(void *); 182da14cebeSEric Cheng typedef int (*mac_setpromisc_t)(void *, boolean_t); 183da14cebeSEric Cheng typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 184da14cebeSEric Cheng typedef int (*mac_unicst_t)(void *, const uint8_t *); 185da14cebeSEric Cheng typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 186da14cebeSEric Cheng typedef void (*mac_resources_t)(void *); 187da14cebeSEric Cheng typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 188da14cebeSEric Cheng typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); 189da14cebeSEric Cheng typedef int (*mac_open_t)(void *); 190da14cebeSEric Cheng typedef void (*mac_close_t)(void *); 191da14cebeSEric Cheng typedef int (*mac_set_prop_t)(void *, const char *, mac_prop_id_t, 192da14cebeSEric Cheng uint_t, const void *); 193da14cebeSEric Cheng typedef int (*mac_get_prop_t)(void *, const char *, mac_prop_id_t, 1940dc2366fSVenugopal Iyer uint_t, void *); 1950dc2366fSVenugopal Iyer typedef void (*mac_prop_info_t)(void *, const char *, mac_prop_id_t, 1960dc2366fSVenugopal Iyer mac_prop_info_handle_t); 197da14cebeSEric Cheng 198da14cebeSEric Cheng /* 1990dc2366fSVenugopal Iyer * Driver callbacks. The following capabilities are optional, and if 2000dc2366fSVenugopal Iyer * implemented by the driver, must have a corresponding MC_ flag set 2010dc2366fSVenugopal Iyer * in the mc_callbacks field. 2020dc2366fSVenugopal Iyer * 203da14cebeSEric Cheng * Any future additions to this list must also be accompanied by an 204da14cebeSEric Cheng * associated mc_callbacks flag so that the framework can grow without 205da14cebeSEric Cheng * affecting the binary compatibility of the interface. 206da14cebeSEric Cheng */ 207da14cebeSEric Cheng typedef struct mac_callbacks_s { 208da14cebeSEric Cheng uint_t mc_callbacks; /* Denotes which callbacks are set */ 209da14cebeSEric Cheng mac_getstat_t mc_getstat; /* Get the value of a statistic */ 210da14cebeSEric Cheng mac_start_t mc_start; /* Start the device */ 211da14cebeSEric Cheng mac_stop_t mc_stop; /* Stop the device */ 212da14cebeSEric Cheng mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ 213da14cebeSEric Cheng mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ 214da14cebeSEric Cheng mac_unicst_t mc_unicst; /* Set the unicast MAC address */ 215da14cebeSEric Cheng mac_tx_t mc_tx; /* Transmit a packet */ 2160dc2366fSVenugopal Iyer void *mc_reserved; /* Reserved, do not use */ 217da14cebeSEric Cheng mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ 218da14cebeSEric Cheng mac_getcapab_t mc_getcapab; /* Get capability information */ 219da14cebeSEric Cheng mac_open_t mc_open; /* Open the device */ 220da14cebeSEric Cheng mac_close_t mc_close; /* Close the device */ 221da14cebeSEric Cheng mac_set_prop_t mc_setprop; 222da14cebeSEric Cheng mac_get_prop_t mc_getprop; 2230dc2366fSVenugopal Iyer mac_prop_info_t mc_propinfo; 224da14cebeSEric Cheng } mac_callbacks_t; 225da14cebeSEric Cheng 2260dc2366fSVenugopal Iyer /* 2270dc2366fSVenugopal Iyer * Flags for mc_callbacks. Requiring drivers to set the flags associated 2280dc2366fSVenugopal Iyer * with optional callbacks initialized in the structure allows the mac 2290dc2366fSVenugopal Iyer * module to add optional callbacks in the future without requiring drivers 2300dc2366fSVenugopal Iyer * to recompile. 2310dc2366fSVenugopal Iyer */ 2320dc2366fSVenugopal Iyer #define MC_RESERVED 0x0001 2330dc2366fSVenugopal Iyer #define MC_IOCTL 0x0002 2340dc2366fSVenugopal Iyer #define MC_GETCAPAB 0x0004 2350dc2366fSVenugopal Iyer #define MC_OPEN 0x0008 2360dc2366fSVenugopal Iyer #define MC_CLOSE 0x0010 2370dc2366fSVenugopal Iyer #define MC_SETPROP 0x0020 2380dc2366fSVenugopal Iyer #define MC_GETPROP 0x0040 2390dc2366fSVenugopal Iyer #define MC_PROPINFO 0x0080 2400dc2366fSVenugopal Iyer #define MC_PROPERTIES (MC_SETPROP | MC_GETPROP | MC_PROPINFO) 241da14cebeSEric Cheng 242da14cebeSEric Cheng /* 243da14cebeSEric Cheng * Virtualization Capabilities 244da14cebeSEric Cheng */ 245da14cebeSEric Cheng /* 246da14cebeSEric Cheng * The ordering of entries below is important. MAC_HW_CLASSIFIER 247da14cebeSEric Cheng * is the cutoff below which are entries which don't depend on 248da14cebeSEric Cheng * H/W. MAC_HW_CLASSIFIER and entries after that are cases where 249da14cebeSEric Cheng * H/W has been updated through add/modify/delete APIs. 250da14cebeSEric Cheng */ 251da14cebeSEric Cheng typedef enum { 252da14cebeSEric Cheng MAC_NO_CLASSIFIER = 0, 253da14cebeSEric Cheng MAC_SW_CLASSIFIER, 254da14cebeSEric Cheng MAC_HW_CLASSIFIER 255da14cebeSEric Cheng } mac_classify_type_t; 256da14cebeSEric Cheng 257da14cebeSEric Cheng typedef void (*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *, 258da14cebeSEric Cheng boolean_t); 259da14cebeSEric Cheng 260da14cebeSEric Cheng /* 261da14cebeSEric Cheng * The virtualization level conveys the extent of the NIC hardware assistance 262da14cebeSEric Cheng * for traffic steering employed for virtualization: 263da14cebeSEric Cheng * 264da14cebeSEric Cheng * MAC_VIRT_NONE: No assist for v12n. 265da14cebeSEric Cheng * 266da14cebeSEric Cheng * MAC_VIRT_LEVEL1: Multiple Rx rings with MAC address level 267da14cebeSEric Cheng * classification between groups of rings. 268da14cebeSEric Cheng * Requires the support of the MAC_CAPAB_RINGS 269da14cebeSEric Cheng * capability. 270da14cebeSEric Cheng * 271da14cebeSEric Cheng * MAC_VIRT_HIO: Hybrid I/O capable MAC. Require the support 272da14cebeSEric Cheng * of the MAC_CAPAB_SHARES capability. 273da14cebeSEric Cheng */ 274da14cebeSEric Cheng #define MAC_VIRT_NONE 0x0 275da14cebeSEric Cheng #define MAC_VIRT_LEVEL1 0x1 276da14cebeSEric Cheng #define MAC_VIRT_HIO 0x2 277da14cebeSEric Cheng 278da14cebeSEric Cheng typedef enum { 279da14cebeSEric Cheng MAC_RING_TYPE_RX = 1, /* Receive ring */ 280da14cebeSEric Cheng MAC_RING_TYPE_TX /* Transmit ring */ 281da14cebeSEric Cheng } mac_ring_type_t; 282da14cebeSEric Cheng 283da14cebeSEric Cheng /* 284da14cebeSEric Cheng * Grouping type of a ring group 285da14cebeSEric Cheng * 286da14cebeSEric Cheng * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped. 287da14cebeSEric Cheng * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping 288da14cebeSEric Cheng */ 289da14cebeSEric Cheng typedef enum { 290da14cebeSEric Cheng MAC_GROUP_TYPE_STATIC = 1, /* Static ring group */ 291da14cebeSEric Cheng MAC_GROUP_TYPE_DYNAMIC /* Dynamic ring group */ 292da14cebeSEric Cheng } mac_group_type_t; 293da14cebeSEric Cheng 294da14cebeSEric Cheng typedef struct __mac_ring_driver *mac_ring_driver_t; 295da14cebeSEric Cheng typedef struct __mac_group_driver *mac_group_driver_t; 296da14cebeSEric Cheng 297da14cebeSEric Cheng typedef struct mac_ring_info_s mac_ring_info_t; 298da14cebeSEric Cheng typedef struct mac_group_info_s mac_group_info_t; 299da14cebeSEric Cheng 300da14cebeSEric Cheng typedef void (*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int, 301da14cebeSEric Cheng mac_ring_info_t *, mac_ring_handle_t); 302da14cebeSEric Cheng typedef void (*mac_get_group_t)(void *, mac_ring_type_t, const int, 303da14cebeSEric Cheng mac_group_info_t *, mac_group_handle_t); 304da14cebeSEric Cheng 305da14cebeSEric Cheng typedef void (*mac_group_add_ring_t)(mac_group_driver_t, 306da14cebeSEric Cheng mac_ring_driver_t, mac_ring_type_t); 307da14cebeSEric Cheng typedef void (*mac_group_rem_ring_t)(mac_group_driver_t, 308da14cebeSEric Cheng mac_ring_driver_t, mac_ring_type_t); 309da14cebeSEric Cheng 310da14cebeSEric Cheng /* 311da14cebeSEric Cheng * Multiple Rings Capability 312da14cebeSEric Cheng */ 313da14cebeSEric Cheng typedef struct mac_capab_rings_s { 314da14cebeSEric Cheng mac_ring_type_t mr_type; /* Ring type: Rx vs Tx */ 315da14cebeSEric Cheng mac_group_type_t mr_group_type; /* Dynamic vs static grouping */ 316da14cebeSEric Cheng uint_t mr_rnum; /* Number of rings */ 317da14cebeSEric Cheng uint_t mr_gnum; /* Number of ring groups */ 318da14cebeSEric Cheng mac_get_ring_t mr_rget; /* Get ring from driver */ 319da14cebeSEric Cheng mac_get_group_t mr_gget; /* Get ring group from driver */ 320da14cebeSEric Cheng mac_group_add_ring_t mr_gaddring; /* Add ring into a group */ 321da14cebeSEric Cheng mac_group_rem_ring_t mr_gremring; /* Remove ring from a group */ 322da14cebeSEric Cheng } mac_capab_rings_t; 323da14cebeSEric Cheng 324da14cebeSEric Cheng /* 325da14cebeSEric Cheng * Common ring functions and driver interfaces 326da14cebeSEric Cheng */ 327da14cebeSEric Cheng typedef int (*mac_ring_start_t)(mac_ring_driver_t, uint64_t); 328da14cebeSEric Cheng typedef void (*mac_ring_stop_t)(mac_ring_driver_t); 329da14cebeSEric Cheng 330da14cebeSEric Cheng typedef mblk_t *(*mac_ring_send_t)(void *, mblk_t *); 331da14cebeSEric Cheng typedef mblk_t *(*mac_ring_poll_t)(void *, int); 332da14cebeSEric Cheng 3330dc2366fSVenugopal Iyer typedef int (*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *); 3340dc2366fSVenugopal Iyer 335da14cebeSEric Cheng typedef struct mac_ring_info_s { 336da14cebeSEric Cheng mac_ring_driver_t mri_driver; 337da14cebeSEric Cheng mac_ring_start_t mri_start; 338da14cebeSEric Cheng mac_ring_stop_t mri_stop; 339da14cebeSEric Cheng mac_intr_t mri_intr; 340da14cebeSEric Cheng union { 341da14cebeSEric Cheng mac_ring_send_t send; 342da14cebeSEric Cheng mac_ring_poll_t poll; 343da14cebeSEric Cheng } mrfunion; 3440dc2366fSVenugopal Iyer mac_ring_stat_t mri_stat; 3450dc2366fSVenugopal Iyer /* 3460dc2366fSVenugopal Iyer * mri_flags will have some bits set to indicate some special 3470dc2366fSVenugopal Iyer * property/feature of a ring like serialization needed for a 3480dc2366fSVenugopal Iyer * Tx ring or packets should always need enqueuing on Rx side, 3490dc2366fSVenugopal Iyer * etc. 3500dc2366fSVenugopal Iyer */ 3510dc2366fSVenugopal Iyer uint_t mri_flags; 352da14cebeSEric Cheng } mac_ring_info_s; 353da14cebeSEric Cheng 354da14cebeSEric Cheng #define mri_tx mrfunion.send 355da14cebeSEric Cheng #define mri_poll mrfunion.poll 356da14cebeSEric Cheng 3570dc2366fSVenugopal Iyer /* 3580dc2366fSVenugopal Iyer * #defines for mri_flags. The flags are temporary flags that are provided 3590dc2366fSVenugopal Iyer * only to workaround issues in specific drivers, and they will be 3600dc2366fSVenugopal Iyer * removed in the future. 3610dc2366fSVenugopal Iyer */ 3620dc2366fSVenugopal Iyer #define MAC_RING_TX_SERIALIZE 0x1 3630dc2366fSVenugopal Iyer #define MAC_RING_RX_ENQUEUE 0x2 3640dc2366fSVenugopal Iyer 365da14cebeSEric Cheng typedef int (*mac_group_start_t)(mac_group_driver_t); 366da14cebeSEric Cheng typedef void (*mac_group_stop_t)(mac_group_driver_t); 367da14cebeSEric Cheng typedef int (*mac_add_mac_addr_t)(void *, const uint8_t *); 368da14cebeSEric Cheng typedef int (*mac_rem_mac_addr_t)(void *, const uint8_t *); 369da14cebeSEric Cheng 370da14cebeSEric Cheng struct mac_group_info_s { 371da14cebeSEric Cheng mac_group_driver_t mgi_driver; /* Driver reference */ 372da14cebeSEric Cheng mac_group_start_t mgi_start; /* Start the group */ 373da14cebeSEric Cheng mac_group_stop_t mgi_stop; /* Stop the group */ 374da14cebeSEric Cheng uint_t mgi_count; /* Count of rings */ 375da14cebeSEric Cheng mac_intr_t mgi_intr; /* Optional per-group intr */ 376da14cebeSEric Cheng 377da14cebeSEric Cheng /* Only used for rx groups */ 378da14cebeSEric Cheng mac_add_mac_addr_t mgi_addmac; /* Add a MAC address */ 379da14cebeSEric Cheng mac_rem_mac_addr_t mgi_remmac; /* Remove a MAC address */ 380da14cebeSEric Cheng }; 381da14cebeSEric Cheng 382da14cebeSEric Cheng /* 383da14cebeSEric Cheng * Share management functions. 384da14cebeSEric Cheng */ 385da14cebeSEric Cheng typedef uint64_t mac_share_handle_t; 386da14cebeSEric Cheng 387da14cebeSEric Cheng /* 388da14cebeSEric Cheng * Allocate and free a share. Returns ENOSPC if all shares have been 389da14cebeSEric Cheng * previously allocated. 390da14cebeSEric Cheng */ 391da14cebeSEric Cheng typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *); 392da14cebeSEric Cheng typedef void (*mac_free_share_t)(mac_share_handle_t); 393da14cebeSEric Cheng 394da14cebeSEric Cheng /* 395da14cebeSEric Cheng * Bind and unbind a share. Binding a share allows a domain 396da14cebeSEric Cheng * to have direct access to the groups and rings associated with 397da14cebeSEric Cheng * that share. 398da14cebeSEric Cheng */ 399da14cebeSEric Cheng typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *); 400da14cebeSEric Cheng typedef void (*mac_unbind_share_t)(mac_share_handle_t); 401da14cebeSEric Cheng 402da14cebeSEric Cheng /* 403da14cebeSEric Cheng * Return information on about a share. 404da14cebeSEric Cheng */ 405da14cebeSEric Cheng typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t, 406da14cebeSEric Cheng mac_ring_handle_t *, uint_t *); 407da14cebeSEric Cheng 408da14cebeSEric Cheng /* 409da14cebeSEric Cheng * Basic idea, bind previously created ring groups to shares 410da14cebeSEric Cheng * for them to be exported (or shared) by another domain. 411da14cebeSEric Cheng * These interfaces bind/unbind the ring group to a share. 412da14cebeSEric Cheng * The groups and their rings will be shared with the guest 413da14cebeSEric Cheng * as soon as the share is bound. 414da14cebeSEric Cheng */ 415da14cebeSEric Cheng typedef int (*mac_share_add_group_t)(mac_share_handle_t, 416da14cebeSEric Cheng mac_group_driver_t); 417da14cebeSEric Cheng typedef int (*mac_share_rem_group_t)(mac_share_handle_t, 418da14cebeSEric Cheng mac_group_driver_t); 419da14cebeSEric Cheng 420da14cebeSEric Cheng typedef struct mac_capab_share_s { 421da14cebeSEric Cheng uint_t ms_snum; /* Number of shares (vr's) */ 422da14cebeSEric Cheng void *ms_handle; /* Handle to driver. */ 423da14cebeSEric Cheng mac_alloc_share_t ms_salloc; /* Get a share from driver. */ 424da14cebeSEric Cheng mac_free_share_t ms_sfree; /* Return a share to driver. */ 425da14cebeSEric Cheng mac_share_add_group_t ms_sadd; /* Add a group to the share. */ 426da14cebeSEric Cheng mac_share_rem_group_t ms_sremove; /* Remove group from share. */ 427da14cebeSEric Cheng mac_share_query_t ms_squery; /* Query share constraints */ 428da14cebeSEric Cheng mac_bind_share_t ms_sbind; /* Bind a share */ 429da14cebeSEric Cheng mac_unbind_share_t ms_sunbind; /* Unbind a share */ 430da14cebeSEric Cheng } mac_capab_share_t; 431da14cebeSEric Cheng 4321cb875aeSCathy Zhou typedef struct mac_capab_vrrp_s { 4331cb875aeSCathy Zhou /* IPv6 or IPv4? */ 4341cb875aeSCathy Zhou int mcv_af; 4351cb875aeSCathy Zhou } mac_capab_vrrp_t; 4361cb875aeSCathy Zhou 437da14cebeSEric Cheng /* 43848a4016cSRobert Mustacchi * Transceiver capability 43948a4016cSRobert Mustacchi */ 44048a4016cSRobert Mustacchi typedef struct mac_transceiver_info mac_transceiver_info_t; 44148a4016cSRobert Mustacchi 44248a4016cSRobert Mustacchi typedef struct mac_capab_transceiver { 44348a4016cSRobert Mustacchi uint_t mct_flags; 44448a4016cSRobert Mustacchi uint_t mct_ntransceivers; 44548a4016cSRobert Mustacchi int (*mct_info)(void *, uint_t, mac_transceiver_info_t *); 44648a4016cSRobert Mustacchi int (*mct_read)(void *, uint_t, uint_t, void *, size_t, off_t, 44748a4016cSRobert Mustacchi size_t *); 44848a4016cSRobert Mustacchi } mac_capab_transceiver_t; 44948a4016cSRobert Mustacchi 45048a4016cSRobert Mustacchi /* 451*4d210590SRobert Mustacchi * LED capability 452*4d210590SRobert Mustacchi */ 453*4d210590SRobert Mustacchi typedef struct mac_capab_led { 454*4d210590SRobert Mustacchi uint_t mcl_flags; 455*4d210590SRobert Mustacchi mac_led_mode_t mcl_modes; 456*4d210590SRobert Mustacchi int (*mcl_set)(void *, mac_led_mode_t, uint_t); 457*4d210590SRobert Mustacchi } mac_capab_led_t; 458*4d210590SRobert Mustacchi 459*4d210590SRobert Mustacchi /* 460da14cebeSEric Cheng * MAC registration interface 461da14cebeSEric Cheng */ 462da14cebeSEric Cheng typedef struct mac_register_s { 463da14cebeSEric Cheng uint_t m_version; /* set by mac_alloc() */ 464da14cebeSEric Cheng const char *m_type_ident; 465da14cebeSEric Cheng void *m_driver; /* Driver private data */ 466da14cebeSEric Cheng dev_info_t *m_dip; 467da14cebeSEric Cheng uint_t m_instance; 468da14cebeSEric Cheng uint8_t *m_src_addr; 469da14cebeSEric Cheng uint8_t *m_dst_addr; 470da14cebeSEric Cheng mac_callbacks_t *m_callbacks; 471da14cebeSEric Cheng uint_t m_min_sdu; 472da14cebeSEric Cheng uint_t m_max_sdu; 473da14cebeSEric Cheng void *m_pdata; 474da14cebeSEric Cheng size_t m_pdata_size; 4750dc2366fSVenugopal Iyer char **m_priv_props; 476da14cebeSEric Cheng uint32_t m_margin; 477da14cebeSEric Cheng uint32_t m_v12n; /* Virtualization level */ 4781eee170aSErik Nordmark uint_t m_multicast_sdu; 479da14cebeSEric Cheng } mac_register_t; 480da14cebeSEric Cheng 481da14cebeSEric Cheng /* 482da14cebeSEric Cheng * Driver interface functions. 483da14cebeSEric Cheng */ 48489c6130dSSowmini Varadhan extern mac_protect_t *mac_protect_get(mac_handle_t); 485da14cebeSEric Cheng extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); 4861eee170aSErik Nordmark extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *, 4871eee170aSErik Nordmark uint_t *); 488da14cebeSEric Cheng extern int mac_maxsdu_update(mac_handle_t, uint_t); 4891eee170aSErik Nordmark extern int mac_maxsdu_update2(mac_handle_t, uint_t, 4901eee170aSErik Nordmark uint_t); 491da14cebeSEric Cheng 492da14cebeSEric Cheng extern mac_register_t *mac_alloc(uint_t); 493da14cebeSEric Cheng extern void mac_free(mac_register_t *); 494da14cebeSEric Cheng extern int mac_register(mac_register_t *, mac_handle_t *); 495da14cebeSEric Cheng extern int mac_disable_nowait(mac_handle_t); 496da14cebeSEric Cheng extern int mac_disable(mac_handle_t); 497da14cebeSEric Cheng extern int mac_unregister(mac_handle_t); 498da14cebeSEric Cheng extern void mac_rx(mac_handle_t, mac_resource_handle_t, 499da14cebeSEric Cheng mblk_t *); 500da14cebeSEric Cheng extern void mac_rx_ring(mac_handle_t, mac_ring_handle_t, 501da14cebeSEric Cheng mblk_t *, uint64_t); 502da14cebeSEric Cheng extern void mac_link_update(mac_handle_t, link_state_t); 5034eaa4710SRishi Srivatsavai extern void mac_link_redo(mac_handle_t, link_state_t); 504da14cebeSEric Cheng extern void mac_unicst_update(mac_handle_t, 505da14cebeSEric Cheng const uint8_t *); 5062b24ab6bSSebastien Roy extern void mac_dst_update(mac_handle_t, const uint8_t *); 507da14cebeSEric Cheng extern void mac_tx_update(mac_handle_t); 508da14cebeSEric Cheng extern void mac_tx_ring_update(mac_handle_t, 509da14cebeSEric Cheng mac_ring_handle_t); 510da14cebeSEric Cheng extern void mac_capab_update(mac_handle_t); 511da14cebeSEric Cheng extern int mac_pdata_update(mac_handle_t, void *, 512da14cebeSEric Cheng size_t); 513da14cebeSEric Cheng extern void mac_multicast_refresh(mac_handle_t, 514da14cebeSEric Cheng mac_multicst_t, void *, boolean_t); 515da14cebeSEric Cheng extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, 516da14cebeSEric Cheng void *); 517da14cebeSEric Cheng extern void mac_promisc_refresh(mac_handle_t, 518da14cebeSEric Cheng mac_setpromisc_t, void *); 519da14cebeSEric Cheng extern boolean_t mac_margin_update(mac_handle_t, uint32_t); 520da14cebeSEric Cheng extern void mac_margin_get(mac_handle_t, uint32_t *); 521da14cebeSEric Cheng extern int mac_margin_remove(mac_handle_t, uint32_t); 522da14cebeSEric Cheng extern int mac_margin_add(mac_handle_t, uint32_t *, 523da14cebeSEric Cheng boolean_t); 524da14cebeSEric Cheng extern void mac_init_ops(struct dev_ops *, const char *); 525da14cebeSEric Cheng extern void mac_fini_ops(struct dev_ops *); 52661af1958SGarrett D'Amore extern int mac_devt_to_instance(dev_t); 52761af1958SGarrett D'Amore extern minor_t mac_private_minor(void); 5280dc2366fSVenugopal Iyer extern void mac_ring_intr_set(mac_ring_handle_t, 5290dc2366fSVenugopal Iyer ddi_intr_handle_t); 5300dc2366fSVenugopal Iyer 531da14cebeSEric Cheng 532da14cebeSEric Cheng extern mactype_register_t *mactype_alloc(uint_t); 533da14cebeSEric Cheng extern void mactype_free(mactype_register_t *); 534da14cebeSEric Cheng extern int mactype_register(mactype_register_t *); 535da14cebeSEric Cheng extern int mactype_unregister(const char *); 536da14cebeSEric Cheng 537da14cebeSEric Cheng extern boolean_t mac_unicst_verify(mac_handle_t, 538da14cebeSEric Cheng const uint8_t *, uint_t); 539da14cebeSEric Cheng 540da14cebeSEric Cheng extern int mac_group_add_ring(mac_group_handle_t, int); 541da14cebeSEric Cheng extern void mac_group_rem_ring(mac_group_handle_t, 542da14cebeSEric Cheng mac_ring_handle_t); 5430dc2366fSVenugopal Iyer extern mac_ring_handle_t mac_find_ring(mac_group_handle_t, int); 5440dc2366fSVenugopal Iyer 5450dc2366fSVenugopal Iyer extern void mac_prop_info_set_default_uint8( 5460dc2366fSVenugopal Iyer mac_prop_info_handle_t, uint8_t); 5470dc2366fSVenugopal Iyer extern void mac_prop_info_set_default_str( 5480dc2366fSVenugopal Iyer mac_prop_info_handle_t, const char *); 5490dc2366fSVenugopal Iyer extern void mac_prop_info_set_default_uint64( 5500dc2366fSVenugopal Iyer mac_prop_info_handle_t, uint64_t); 5510dc2366fSVenugopal Iyer extern void mac_prop_info_set_default_uint32( 5520dc2366fSVenugopal Iyer mac_prop_info_handle_t, uint32_t); 5530dc2366fSVenugopal Iyer extern void mac_prop_info_set_default_link_flowctrl( 5540dc2366fSVenugopal Iyer mac_prop_info_handle_t, link_flowctrl_t); 5550dc2366fSVenugopal Iyer extern void mac_prop_info_set_range_uint32( 5560dc2366fSVenugopal Iyer mac_prop_info_handle_t, 5570dc2366fSVenugopal Iyer uint32_t, uint32_t); 5580dc2366fSVenugopal Iyer extern void mac_prop_info_set_perm(mac_prop_info_handle_t, 5590dc2366fSVenugopal Iyer uint8_t); 5600dc2366fSVenugopal Iyer 5610dc2366fSVenugopal Iyer extern void mac_hcksum_get(mblk_t *, uint32_t *, 5620dc2366fSVenugopal Iyer uint32_t *, uint32_t *, uint32_t *, 5630dc2366fSVenugopal Iyer uint32_t *); 5640dc2366fSVenugopal Iyer extern void mac_hcksum_set(mblk_t *, uint32_t, uint32_t, 5650dc2366fSVenugopal Iyer uint32_t, uint32_t, uint32_t); 5660dc2366fSVenugopal Iyer 5670dc2366fSVenugopal Iyer extern void mac_lso_get(mblk_t *, uint32_t *, uint32_t *); 568da14cebeSEric Cheng 56948a4016cSRobert Mustacchi extern void mac_transceiver_info_set_present( 57048a4016cSRobert Mustacchi mac_transceiver_info_t *, 57148a4016cSRobert Mustacchi boolean_t); 57248a4016cSRobert Mustacchi extern void mac_transceiver_info_set_usable( 57348a4016cSRobert Mustacchi mac_transceiver_info_t *, 57448a4016cSRobert Mustacchi boolean_t); 57548a4016cSRobert Mustacchi 576da14cebeSEric Cheng #endif /* _KERNEL */ 577da14cebeSEric Cheng 578da14cebeSEric Cheng #ifdef __cplusplus 579da14cebeSEric Cheng } 580da14cebeSEric Cheng #endif 581da14cebeSEric Cheng 582da14cebeSEric Cheng #endif /* _SYS_MAC_PROVIDER_H */ 583