18275SEric Cheng /* 28275SEric Cheng * CDDL HEADER START 38275SEric Cheng * 48275SEric Cheng * The contents of this file are subject to the terms of the 58275SEric Cheng * Common Development and Distribution License (the "License"). 68275SEric Cheng * You may not use this file except in compliance with the License. 78275SEric Cheng * 88275SEric Cheng * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 98275SEric Cheng * or http://www.opensolaris.org/os/licensing. 108275SEric Cheng * See the License for the specific language governing permissions 118275SEric Cheng * and limitations under the License. 128275SEric Cheng * 138275SEric Cheng * When distributing Covered Code, include this CDDL HEADER in each 148275SEric Cheng * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 158275SEric Cheng * If applicable, add the following below this CDDL HEADER, with the 168275SEric Cheng * fields enclosed by brackets "[]" replaced with your own identifying 178275SEric Cheng * information: Portions Copyright [yyyy] [name of copyright owner] 188275SEric Cheng * 198275SEric Cheng * CDDL HEADER END 208275SEric Cheng */ 218275SEric Cheng 228275SEric Cheng /* 2312748SSowmini.Varadhan@oracle.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 248275SEric Cheng */ 258275SEric Cheng 268275SEric Cheng #ifndef _SYS_MAC_PROVIDER_H 278275SEric Cheng #define _SYS_MAC_PROVIDER_H 288275SEric Cheng 298275SEric Cheng #include <sys/types.h> 308275SEric Cheng #include <sys/ddi.h> 318275SEric Cheng #include <sys/sunddi.h> 328275SEric Cheng #include <sys/stream.h> 3310283SGarrett.Damore@Sun.COM #include <sys/mkdev.h> 348275SEric Cheng #include <sys/mac.h> 3512748SSowmini.Varadhan@oracle.COM #include <sys/mac_flow.h> 368275SEric Cheng 378275SEric Cheng /* 388275SEric Cheng * MAC Provider Interface 398275SEric Cheng */ 408275SEric Cheng 418275SEric Cheng #ifdef __cplusplus 428275SEric Cheng extern "C" { 438275SEric Cheng #endif 448275SEric Cheng 458275SEric Cheng /* 4611878SVenu.Iyer@Sun.COM * MAC version identifiers. Drivers compiled against the stable V1 version 4711878SVenu.Iyer@Sun.COM * of the API should register with MAC_VERSION_V1. ON drivers should use 4811878SVenu.Iyer@Sun.COM * MAC_VERSION. This is used by mac_alloc() mac_register() to 498275SEric Cheng * verify that incompatible drivers don't register. 508275SEric Cheng */ 5111878SVenu.Iyer@Sun.COM #define MAC_VERSION_V1 0x1 5211878SVenu.Iyer@Sun.COM #define MAC_VERSION MAC_VERSION_V1 538275SEric Cheng 548275SEric Cheng /* 5511878SVenu.Iyer@Sun.COM * Possible values for ETHER_STAT_XCVR_INUSE statistic. 568275SEric Cheng */ 578275SEric Cheng 588275SEric Cheng #define XCVR_UNDEFINED 0 598275SEric Cheng #define XCVR_NONE 1 608275SEric Cheng #define XCVR_10 2 618275SEric Cheng #define XCVR_100T4 3 628275SEric Cheng #define XCVR_100X 4 638275SEric Cheng #define XCVR_100T2 5 648275SEric Cheng #define XCVR_1000X 6 658275SEric Cheng #define XCVR_1000T 7 668275SEric Cheng 678275SEric Cheng #ifdef _KERNEL 688275SEric Cheng 698275SEric Cheng /* 708275SEric Cheng * Definitions for MAC Drivers Capabilities 718275SEric Cheng */ 728275SEric Cheng /* 738275SEric Cheng * MAC layer capabilities. These capabilities are handled by the drivers' 748275SEric Cheng * mc_capab_get() callbacks. Some capabilities require the driver to fill 758275SEric Cheng * in a given data structure, and others are simply boolean capabilities. 768275SEric Cheng * Note that capability values must be powers of 2 so that consumers and 778275SEric Cheng * providers of this interface can keep track of which capabilities they 788275SEric Cheng * care about by keeping a bitfield of these things around somewhere. 798275SEric Cheng */ 808275SEric Cheng typedef enum { 818275SEric Cheng /* 8211878SVenu.Iyer@Sun.COM * Public Capabilities (MAC_VERSION_V1) 838275SEric Cheng */ 8411878SVenu.Iyer@Sun.COM MAC_CAPAB_HCKSUM = 0x00000001, /* data is a uint32_t */ 8511878SVenu.Iyer@Sun.COM MAC_CAPAB_LSO = 0x00000008, /* data is mac_capab_lso_t */ 8611878SVenu.Iyer@Sun.COM 8711878SVenu.Iyer@Sun.COM /* 8811878SVenu.Iyer@Sun.COM * Reserved capabilities, do not use 8911878SVenu.Iyer@Sun.COM */ 9011878SVenu.Iyer@Sun.COM MAC_CAPAB_RESERVED1 = 0x00000002, 9111878SVenu.Iyer@Sun.COM MAC_CAPAB_RESERVED2 = 0x00000004, 928275SEric Cheng 938275SEric Cheng /* 9411878SVenu.Iyer@Sun.COM * Private driver capabilities 9511878SVenu.Iyer@Sun.COM */ 9611878SVenu.Iyer@Sun.COM MAC_CAPAB_RINGS = 0x00000010, /* data is mac_capab_rings_t */ 9711878SVenu.Iyer@Sun.COM MAC_CAPAB_SHARES = 0x00000020, /* data is mac_capab_share_t */ 9811878SVenu.Iyer@Sun.COM MAC_CAPAB_MULTIFACTADDR = 0x00000040, /* mac_data_multifactaddr_t */ 9911878SVenu.Iyer@Sun.COM 10011878SVenu.Iyer@Sun.COM /* 10111878SVenu.Iyer@Sun.COM * Private driver capabilities for use by the GLDv3 framework only 1028275SEric Cheng */ 10311878SVenu.Iyer@Sun.COM MAC_CAPAB_VNIC = 0x00010000, /* data is mac_capab_vnic_t */ 10411878SVenu.Iyer@Sun.COM MAC_CAPAB_ANCHOR_VNIC = 0x00020000, /* boolean only, no data */ 10511878SVenu.Iyer@Sun.COM MAC_CAPAB_AGGR = 0x00040000, /* data is mac_capab_aggr_t */ 10611878SVenu.Iyer@Sun.COM MAC_CAPAB_NO_NATIVEVLAN = 0x00080000, /* boolean only, no data */ 10711878SVenu.Iyer@Sun.COM MAC_CAPAB_NO_ZCOPY = 0x00100000, /* boolean only, no data */ 10811878SVenu.Iyer@Sun.COM MAC_CAPAB_LEGACY = 0x00200000, /* data is mac_capab_legacy_t */ 10911878SVenu.Iyer@Sun.COM MAC_CAPAB_VRRP = 0x00400000 /* data is mac_capab_vrrp_t */ 1108275SEric Cheng } mac_capab_t; 1118275SEric Cheng 1128275SEric Cheng /* 1138275SEric Cheng * LSO capability 1148275SEric Cheng */ 1158275SEric Cheng typedef struct lso_basic_tcp_ipv4_s { 1168275SEric Cheng t_uscalar_t lso_max; /* maximum payload */ 1178275SEric Cheng } lso_basic_tcp_ipv4_t; 1188275SEric Cheng 1198275SEric Cheng /* 1208275SEric Cheng * Currently supported flags for LSO. 1218275SEric Cheng */ 1228275SEric Cheng #define LSO_TX_BASIC_TCP_IPV4 0x01 /* TCP LSO capability */ 1238275SEric Cheng 1248275SEric Cheng /* 1258275SEric Cheng * Future LSO capabilities can be added at the end of the mac_capab_lso_t. 1268275SEric Cheng * When such capability is added to the GLDv3 framework, the size of the 1278275SEric Cheng * mac_capab_lso_t it allocates and passes to the drivers increases. Older 1288275SEric Cheng * drivers wil access only the (upper) sections of that structure, that is the 1298275SEric Cheng * sections carrying the capabilities they understand. This ensures the 1308275SEric Cheng * interface can be safely extended in a binary compatible way. 1318275SEric Cheng */ 1328275SEric Cheng typedef struct mac_capab_lso_s { 1338275SEric Cheng t_uscalar_t lso_flags; 1348275SEric Cheng lso_basic_tcp_ipv4_t lso_basic_tcp_ipv4; 1358275SEric Cheng /* Add future lso capabilities here */ 1368275SEric Cheng } mac_capab_lso_t; 1378275SEric Cheng 1388275SEric Cheng /* 1398275SEric Cheng * Multiple Factory MAC Addresses Capability 1408275SEric Cheng */ 1418275SEric Cheng typedef struct mac_capab_multifactaddr_s { 1428275SEric Cheng /* 1438275SEric Cheng * Number of factory addresses 1448275SEric Cheng */ 1458275SEric Cheng uint_t mcm_naddr; 1468275SEric Cheng 1478275SEric Cheng /* 1488275SEric Cheng * Callbacks to query all the factory addresses. 1498275SEric Cheng */ 1508275SEric Cheng void (*mcm_getaddr)(void *, uint_t, uint8_t *); 1518275SEric Cheng } mac_capab_multifactaddr_t; 1528275SEric Cheng 1538275SEric Cheng /* 1549073SCathy.Zhou@Sun.COM * Info and callbacks of legacy devices. 1559073SCathy.Zhou@Sun.COM */ 1569073SCathy.Zhou@Sun.COM typedef struct mac_capab_legacy_s { 1579073SCathy.Zhou@Sun.COM /* 1589073SCathy.Zhou@Sun.COM * Notifications that the legacy device does not support. 1599073SCathy.Zhou@Sun.COM */ 1609073SCathy.Zhou@Sun.COM uint32_t ml_unsup_note; 1619073SCathy.Zhou@Sun.COM /* 1629073SCathy.Zhou@Sun.COM * dev_t of the legacy device; can be held to force attach. 1639073SCathy.Zhou@Sun.COM */ 1649073SCathy.Zhou@Sun.COM dev_t ml_dev; 1659073SCathy.Zhou@Sun.COM boolean_t (*ml_active_set)(void *); 1669073SCathy.Zhou@Sun.COM void (*ml_active_clear)(void *); 1679073SCathy.Zhou@Sun.COM int (*ml_fastpath_disable)(void *); 1689073SCathy.Zhou@Sun.COM void (*ml_fastpath_enable)(void *); 1699073SCathy.Zhou@Sun.COM } mac_capab_legacy_t; 1709073SCathy.Zhou@Sun.COM 17111878SVenu.Iyer@Sun.COM typedef struct __mac_prop_info_handle *mac_prop_info_handle_t; 17211878SVenu.Iyer@Sun.COM 1739073SCathy.Zhou@Sun.COM /* 1748275SEric Cheng * MAC driver entry point types. 1758275SEric Cheng */ 1768275SEric Cheng typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); 1778275SEric Cheng typedef int (*mac_start_t)(void *); 1788275SEric Cheng typedef void (*mac_stop_t)(void *); 1798275SEric Cheng typedef int (*mac_setpromisc_t)(void *, boolean_t); 1808275SEric Cheng typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 1818275SEric Cheng typedef int (*mac_unicst_t)(void *, const uint8_t *); 1828275SEric Cheng typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 1838275SEric Cheng typedef void (*mac_resources_t)(void *); 1848275SEric Cheng typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 1858275SEric Cheng typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); 1868275SEric Cheng typedef int (*mac_open_t)(void *); 1878275SEric Cheng typedef void (*mac_close_t)(void *); 1888275SEric Cheng typedef int (*mac_set_prop_t)(void *, const char *, mac_prop_id_t, 1898275SEric Cheng uint_t, const void *); 1908275SEric Cheng typedef int (*mac_get_prop_t)(void *, const char *, mac_prop_id_t, 19111878SVenu.Iyer@Sun.COM uint_t, void *); 19211878SVenu.Iyer@Sun.COM typedef void (*mac_prop_info_t)(void *, const char *, mac_prop_id_t, 19311878SVenu.Iyer@Sun.COM mac_prop_info_handle_t); 1948275SEric Cheng 1958275SEric Cheng /* 19611878SVenu.Iyer@Sun.COM * Driver callbacks. The following capabilities are optional, and if 19711878SVenu.Iyer@Sun.COM * implemented by the driver, must have a corresponding MC_ flag set 19811878SVenu.Iyer@Sun.COM * in the mc_callbacks field. 19911878SVenu.Iyer@Sun.COM * 2008275SEric Cheng * Any future additions to this list must also be accompanied by an 2018275SEric Cheng * associated mc_callbacks flag so that the framework can grow without 2028275SEric Cheng * affecting the binary compatibility of the interface. 2038275SEric Cheng */ 2048275SEric Cheng typedef struct mac_callbacks_s { 2058275SEric Cheng uint_t mc_callbacks; /* Denotes which callbacks are set */ 2068275SEric Cheng mac_getstat_t mc_getstat; /* Get the value of a statistic */ 2078275SEric Cheng mac_start_t mc_start; /* Start the device */ 2088275SEric Cheng mac_stop_t mc_stop; /* Stop the device */ 2098275SEric Cheng mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ 2108275SEric Cheng mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ 2118275SEric Cheng mac_unicst_t mc_unicst; /* Set the unicast MAC address */ 2128275SEric Cheng mac_tx_t mc_tx; /* Transmit a packet */ 21311878SVenu.Iyer@Sun.COM void *mc_reserved; /* Reserved, do not use */ 2148275SEric Cheng mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ 2158275SEric Cheng mac_getcapab_t mc_getcapab; /* Get capability information */ 2168275SEric Cheng mac_open_t mc_open; /* Open the device */ 2178275SEric Cheng mac_close_t mc_close; /* Close the device */ 2188275SEric Cheng mac_set_prop_t mc_setprop; 2198275SEric Cheng mac_get_prop_t mc_getprop; 22011878SVenu.Iyer@Sun.COM mac_prop_info_t mc_propinfo; 2218275SEric Cheng } mac_callbacks_t; 2228275SEric Cheng 22311878SVenu.Iyer@Sun.COM /* 22411878SVenu.Iyer@Sun.COM * Flags for mc_callbacks. Requiring drivers to set the flags associated 22511878SVenu.Iyer@Sun.COM * with optional callbacks initialized in the structure allows the mac 22611878SVenu.Iyer@Sun.COM * module to add optional callbacks in the future without requiring drivers 22711878SVenu.Iyer@Sun.COM * to recompile. 22811878SVenu.Iyer@Sun.COM */ 22911878SVenu.Iyer@Sun.COM #define MC_RESERVED 0x0001 23011878SVenu.Iyer@Sun.COM #define MC_IOCTL 0x0002 23111878SVenu.Iyer@Sun.COM #define MC_GETCAPAB 0x0004 23211878SVenu.Iyer@Sun.COM #define MC_OPEN 0x0008 23311878SVenu.Iyer@Sun.COM #define MC_CLOSE 0x0010 23411878SVenu.Iyer@Sun.COM #define MC_SETPROP 0x0020 23511878SVenu.Iyer@Sun.COM #define MC_GETPROP 0x0040 23611878SVenu.Iyer@Sun.COM #define MC_PROPINFO 0x0080 23711878SVenu.Iyer@Sun.COM #define MC_PROPERTIES (MC_SETPROP | MC_GETPROP | MC_PROPINFO) 2388275SEric Cheng 2398275SEric Cheng /* 2408275SEric Cheng * Virtualization Capabilities 2418275SEric Cheng */ 2428275SEric Cheng /* 2438275SEric Cheng * The ordering of entries below is important. MAC_HW_CLASSIFIER 2448275SEric Cheng * is the cutoff below which are entries which don't depend on 2458275SEric Cheng * H/W. MAC_HW_CLASSIFIER and entries after that are cases where 2468275SEric Cheng * H/W has been updated through add/modify/delete APIs. 2478275SEric Cheng */ 2488275SEric Cheng typedef enum { 2498275SEric Cheng MAC_NO_CLASSIFIER = 0, 2508275SEric Cheng MAC_SW_CLASSIFIER, 2518275SEric Cheng MAC_HW_CLASSIFIER 2528275SEric Cheng } mac_classify_type_t; 2538275SEric Cheng 2548275SEric Cheng typedef void (*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *, 2558275SEric Cheng boolean_t); 2568275SEric Cheng 2578275SEric Cheng /* 2588275SEric Cheng * The virtualization level conveys the extent of the NIC hardware assistance 2598275SEric Cheng * for traffic steering employed for virtualization: 2608275SEric Cheng * 2618275SEric Cheng * MAC_VIRT_NONE: No assist for v12n. 2628275SEric Cheng * 2638275SEric Cheng * MAC_VIRT_LEVEL1: Multiple Rx rings with MAC address level 2648275SEric Cheng * classification between groups of rings. 2658275SEric Cheng * Requires the support of the MAC_CAPAB_RINGS 2668275SEric Cheng * capability. 2678275SEric Cheng * 2688275SEric Cheng * MAC_VIRT_HIO: Hybrid I/O capable MAC. Require the support 2698275SEric Cheng * of the MAC_CAPAB_SHARES capability. 2708275SEric Cheng */ 2718275SEric Cheng #define MAC_VIRT_NONE 0x0 2728275SEric Cheng #define MAC_VIRT_LEVEL1 0x1 2738275SEric Cheng #define MAC_VIRT_HIO 0x2 2748275SEric Cheng 2758275SEric Cheng typedef enum { 2768275SEric Cheng MAC_RING_TYPE_RX = 1, /* Receive ring */ 2778275SEric Cheng MAC_RING_TYPE_TX /* Transmit ring */ 2788275SEric Cheng } mac_ring_type_t; 2798275SEric Cheng 2808275SEric Cheng /* 2818275SEric Cheng * Grouping type of a ring group 2828275SEric Cheng * 2838275SEric Cheng * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped. 2848275SEric Cheng * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping 2858275SEric Cheng */ 2868275SEric Cheng typedef enum { 2878275SEric Cheng MAC_GROUP_TYPE_STATIC = 1, /* Static ring group */ 2888275SEric Cheng MAC_GROUP_TYPE_DYNAMIC /* Dynamic ring group */ 2898275SEric Cheng } mac_group_type_t; 2908275SEric Cheng 2918275SEric Cheng typedef struct __mac_ring_driver *mac_ring_driver_t; 2928275SEric Cheng typedef struct __mac_group_driver *mac_group_driver_t; 2938275SEric Cheng 2948275SEric Cheng typedef struct mac_ring_info_s mac_ring_info_t; 2958275SEric Cheng typedef struct mac_group_info_s mac_group_info_t; 2968275SEric Cheng 2978275SEric Cheng typedef void (*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int, 2988275SEric Cheng mac_ring_info_t *, mac_ring_handle_t); 2998275SEric Cheng typedef void (*mac_get_group_t)(void *, mac_ring_type_t, const int, 3008275SEric Cheng mac_group_info_t *, mac_group_handle_t); 3018275SEric Cheng 3028275SEric Cheng typedef void (*mac_group_add_ring_t)(mac_group_driver_t, 3038275SEric Cheng mac_ring_driver_t, mac_ring_type_t); 3048275SEric Cheng typedef void (*mac_group_rem_ring_t)(mac_group_driver_t, 3058275SEric Cheng mac_ring_driver_t, mac_ring_type_t); 3068275SEric Cheng 3078275SEric Cheng /* 3088275SEric Cheng * Multiple Rings Capability 3098275SEric Cheng */ 3108275SEric Cheng typedef struct mac_capab_rings_s { 3118275SEric Cheng mac_ring_type_t mr_type; /* Ring type: Rx vs Tx */ 3128275SEric Cheng mac_group_type_t mr_group_type; /* Dynamic vs static grouping */ 3138275SEric Cheng uint_t mr_rnum; /* Number of rings */ 3148275SEric Cheng uint_t mr_gnum; /* Number of ring groups */ 3158275SEric Cheng mac_get_ring_t mr_rget; /* Get ring from driver */ 3168275SEric Cheng mac_get_group_t mr_gget; /* Get ring group from driver */ 3178275SEric Cheng mac_group_add_ring_t mr_gaddring; /* Add ring into a group */ 3188275SEric Cheng mac_group_rem_ring_t mr_gremring; /* Remove ring from a group */ 3198275SEric Cheng } mac_capab_rings_t; 3208275SEric Cheng 3218275SEric Cheng /* 3228275SEric Cheng * Common ring functions and driver interfaces 3238275SEric Cheng */ 3248275SEric Cheng typedef int (*mac_ring_start_t)(mac_ring_driver_t, uint64_t); 3258275SEric Cheng typedef void (*mac_ring_stop_t)(mac_ring_driver_t); 3268275SEric Cheng 3278275SEric Cheng typedef mblk_t *(*mac_ring_send_t)(void *, mblk_t *); 3288275SEric Cheng typedef mblk_t *(*mac_ring_poll_t)(void *, int); 3298275SEric Cheng 33011878SVenu.Iyer@Sun.COM typedef int (*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *); 33111878SVenu.Iyer@Sun.COM 3328275SEric Cheng typedef struct mac_ring_info_s { 3338275SEric Cheng mac_ring_driver_t mri_driver; 3348275SEric Cheng mac_ring_start_t mri_start; 3358275SEric Cheng mac_ring_stop_t mri_stop; 3368275SEric Cheng mac_intr_t mri_intr; 3378275SEric Cheng union { 3388275SEric Cheng mac_ring_send_t send; 3398275SEric Cheng mac_ring_poll_t poll; 3408275SEric Cheng } mrfunion; 34111878SVenu.Iyer@Sun.COM mac_ring_stat_t mri_stat; 34211878SVenu.Iyer@Sun.COM /* 34311878SVenu.Iyer@Sun.COM * mri_flags will have some bits set to indicate some special 34411878SVenu.Iyer@Sun.COM * property/feature of a ring like serialization needed for a 34511878SVenu.Iyer@Sun.COM * Tx ring or packets should always need enqueuing on Rx side, 34611878SVenu.Iyer@Sun.COM * etc. 34711878SVenu.Iyer@Sun.COM */ 34811878SVenu.Iyer@Sun.COM uint_t mri_flags; 3498275SEric Cheng } mac_ring_info_s; 3508275SEric Cheng 3518275SEric Cheng #define mri_tx mrfunion.send 3528275SEric Cheng #define mri_poll mrfunion.poll 3538275SEric Cheng 35411878SVenu.Iyer@Sun.COM /* 35511878SVenu.Iyer@Sun.COM * #defines for mri_flags. The flags are temporary flags that are provided 35611878SVenu.Iyer@Sun.COM * only to workaround issues in specific drivers, and they will be 35711878SVenu.Iyer@Sun.COM * removed in the future. 35811878SVenu.Iyer@Sun.COM */ 35911878SVenu.Iyer@Sun.COM #define MAC_RING_TX_SERIALIZE 0x1 36011878SVenu.Iyer@Sun.COM #define MAC_RING_RX_ENQUEUE 0x2 36111878SVenu.Iyer@Sun.COM 3628275SEric Cheng typedef int (*mac_group_start_t)(mac_group_driver_t); 3638275SEric Cheng typedef void (*mac_group_stop_t)(mac_group_driver_t); 3648275SEric Cheng typedef int (*mac_add_mac_addr_t)(void *, const uint8_t *); 3658275SEric Cheng typedef int (*mac_rem_mac_addr_t)(void *, const uint8_t *); 3668275SEric Cheng 3678275SEric Cheng struct mac_group_info_s { 3688275SEric Cheng mac_group_driver_t mgi_driver; /* Driver reference */ 3698275SEric Cheng mac_group_start_t mgi_start; /* Start the group */ 3708275SEric Cheng mac_group_stop_t mgi_stop; /* Stop the group */ 3718275SEric Cheng uint_t mgi_count; /* Count of rings */ 3728275SEric Cheng mac_intr_t mgi_intr; /* Optional per-group intr */ 3738275SEric Cheng 3748275SEric Cheng /* Only used for rx groups */ 3758275SEric Cheng mac_add_mac_addr_t mgi_addmac; /* Add a MAC address */ 3768275SEric Cheng mac_rem_mac_addr_t mgi_remmac; /* Remove a MAC address */ 3778275SEric Cheng }; 3788275SEric Cheng 3798275SEric Cheng /* 3808275SEric Cheng * Share management functions. 3818275SEric Cheng */ 3828275SEric Cheng typedef uint64_t mac_share_handle_t; 3838275SEric Cheng 3848275SEric Cheng /* 3858275SEric Cheng * Allocate and free a share. Returns ENOSPC if all shares have been 3868275SEric Cheng * previously allocated. 3878275SEric Cheng */ 3888275SEric Cheng typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *); 3898275SEric Cheng typedef void (*mac_free_share_t)(mac_share_handle_t); 3908275SEric Cheng 3918275SEric Cheng /* 3928275SEric Cheng * Bind and unbind a share. Binding a share allows a domain 3938275SEric Cheng * to have direct access to the groups and rings associated with 3948275SEric Cheng * that share. 3958275SEric Cheng */ 3968275SEric Cheng typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *); 3978275SEric Cheng typedef void (*mac_unbind_share_t)(mac_share_handle_t); 3988275SEric Cheng 3998275SEric Cheng /* 4008275SEric Cheng * Return information on about a share. 4018275SEric Cheng */ 4028275SEric Cheng typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t, 4038275SEric Cheng mac_ring_handle_t *, uint_t *); 4048275SEric Cheng 4058275SEric Cheng /* 4068275SEric Cheng * Basic idea, bind previously created ring groups to shares 4078275SEric Cheng * for them to be exported (or shared) by another domain. 4088275SEric Cheng * These interfaces bind/unbind the ring group to a share. 4098275SEric Cheng * The groups and their rings will be shared with the guest 4108275SEric Cheng * as soon as the share is bound. 4118275SEric Cheng */ 4128275SEric Cheng typedef int (*mac_share_add_group_t)(mac_share_handle_t, 4138275SEric Cheng mac_group_driver_t); 4148275SEric Cheng typedef int (*mac_share_rem_group_t)(mac_share_handle_t, 4158275SEric Cheng mac_group_driver_t); 4168275SEric Cheng 4178275SEric Cheng typedef struct mac_capab_share_s { 4188275SEric Cheng uint_t ms_snum; /* Number of shares (vr's) */ 4198275SEric Cheng void *ms_handle; /* Handle to driver. */ 4208275SEric Cheng mac_alloc_share_t ms_salloc; /* Get a share from driver. */ 4218275SEric Cheng mac_free_share_t ms_sfree; /* Return a share to driver. */ 4228275SEric Cheng mac_share_add_group_t ms_sadd; /* Add a group to the share. */ 4238275SEric Cheng mac_share_rem_group_t ms_sremove; /* Remove group from share. */ 4248275SEric Cheng mac_share_query_t ms_squery; /* Query share constraints */ 4258275SEric Cheng mac_bind_share_t ms_sbind; /* Bind a share */ 4268275SEric Cheng mac_unbind_share_t ms_sunbind; /* Unbind a share */ 4278275SEric Cheng } mac_capab_share_t; 4288275SEric Cheng 42911076SCathy.Zhou@Sun.COM typedef struct mac_capab_vrrp_s { 43011076SCathy.Zhou@Sun.COM /* IPv6 or IPv4? */ 43111076SCathy.Zhou@Sun.COM int mcv_af; 43211076SCathy.Zhou@Sun.COM } mac_capab_vrrp_t; 43311076SCathy.Zhou@Sun.COM 4348275SEric Cheng /* 4358275SEric Cheng * MAC registration interface 4368275SEric Cheng */ 4378275SEric Cheng typedef struct mac_register_s { 4388275SEric Cheng uint_t m_version; /* set by mac_alloc() */ 4398275SEric Cheng const char *m_type_ident; 4408275SEric Cheng void *m_driver; /* Driver private data */ 4418275SEric Cheng dev_info_t *m_dip; 4428275SEric Cheng uint_t m_instance; 4438275SEric Cheng uint8_t *m_src_addr; 4448275SEric Cheng uint8_t *m_dst_addr; 4458275SEric Cheng mac_callbacks_t *m_callbacks; 4468275SEric Cheng uint_t m_min_sdu; 4478275SEric Cheng uint_t m_max_sdu; 4488275SEric Cheng void *m_pdata; 4498275SEric Cheng size_t m_pdata_size; 45011878SVenu.Iyer@Sun.COM char **m_priv_props; 4518275SEric Cheng uint32_t m_margin; 4528275SEric Cheng uint32_t m_v12n; /* Virtualization level */ 453*13123SErik.Nordmark@Sun.COM uint_t m_multicast_sdu; 4548275SEric Cheng } mac_register_t; 4558275SEric Cheng 4568275SEric Cheng /* 4578275SEric Cheng * Driver interface functions. 4588275SEric Cheng */ 45912816SSowmini.Varadhan@oracle.COM extern mac_protect_t *mac_protect_get(mac_handle_t); 4608275SEric Cheng extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); 461*13123SErik.Nordmark@Sun.COM extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *, 462*13123SErik.Nordmark@Sun.COM uint_t *); 4638275SEric Cheng extern int mac_maxsdu_update(mac_handle_t, uint_t); 464*13123SErik.Nordmark@Sun.COM extern int mac_maxsdu_update2(mac_handle_t, uint_t, 465*13123SErik.Nordmark@Sun.COM uint_t); 4668275SEric Cheng 4678275SEric Cheng extern mac_register_t *mac_alloc(uint_t); 4688275SEric Cheng extern void mac_free(mac_register_t *); 4698275SEric Cheng extern int mac_register(mac_register_t *, mac_handle_t *); 4708275SEric Cheng extern int mac_disable_nowait(mac_handle_t); 4718275SEric Cheng extern int mac_disable(mac_handle_t); 4728275SEric Cheng extern int mac_unregister(mac_handle_t); 4738275SEric Cheng extern void mac_rx(mac_handle_t, mac_resource_handle_t, 4748275SEric Cheng mblk_t *); 4758275SEric Cheng extern void mac_rx_ring(mac_handle_t, mac_ring_handle_t, 4768275SEric Cheng mblk_t *, uint64_t); 4778275SEric Cheng extern void mac_link_update(mac_handle_t, link_state_t); 47810491SRishi.Srivatsavai@Sun.COM extern void mac_link_redo(mac_handle_t, link_state_t); 4798275SEric Cheng extern void mac_unicst_update(mac_handle_t, 4808275SEric Cheng const uint8_t *); 48110616SSebastien.Roy@Sun.COM extern void mac_dst_update(mac_handle_t, const uint8_t *); 4828275SEric Cheng extern void mac_tx_update(mac_handle_t); 4838275SEric Cheng extern void mac_tx_ring_update(mac_handle_t, 4848275SEric Cheng mac_ring_handle_t); 4858275SEric Cheng extern void mac_capab_update(mac_handle_t); 4868275SEric Cheng extern int mac_pdata_update(mac_handle_t, void *, 4878275SEric Cheng size_t); 4888275SEric Cheng extern void mac_multicast_refresh(mac_handle_t, 4898275SEric Cheng mac_multicst_t, void *, boolean_t); 4908275SEric Cheng extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, 4918275SEric Cheng void *); 4928275SEric Cheng extern void mac_promisc_refresh(mac_handle_t, 4938275SEric Cheng mac_setpromisc_t, void *); 4948275SEric Cheng extern boolean_t mac_margin_update(mac_handle_t, uint32_t); 4958275SEric Cheng extern void mac_margin_get(mac_handle_t, uint32_t *); 4968275SEric Cheng extern int mac_margin_remove(mac_handle_t, uint32_t); 4978275SEric Cheng extern int mac_margin_add(mac_handle_t, uint32_t *, 4988275SEric Cheng boolean_t); 4998275SEric Cheng extern void mac_init_ops(struct dev_ops *, const char *); 5008275SEric Cheng extern void mac_fini_ops(struct dev_ops *); 50110654SGarrett.Damore@Sun.COM extern int mac_devt_to_instance(dev_t); 50210654SGarrett.Damore@Sun.COM extern minor_t mac_private_minor(void); 50311878SVenu.Iyer@Sun.COM extern void mac_ring_intr_set(mac_ring_handle_t, 50411878SVenu.Iyer@Sun.COM ddi_intr_handle_t); 50511878SVenu.Iyer@Sun.COM 5068275SEric Cheng 5078275SEric Cheng extern mactype_register_t *mactype_alloc(uint_t); 5088275SEric Cheng extern void mactype_free(mactype_register_t *); 5098275SEric Cheng extern int mactype_register(mactype_register_t *); 5108275SEric Cheng extern int mactype_unregister(const char *); 5118275SEric Cheng 5128275SEric Cheng extern boolean_t mac_unicst_verify(mac_handle_t, 5138275SEric Cheng const uint8_t *, uint_t); 5148275SEric Cheng 5158275SEric Cheng extern int mac_group_add_ring(mac_group_handle_t, int); 5168275SEric Cheng extern void mac_group_rem_ring(mac_group_handle_t, 5178275SEric Cheng mac_ring_handle_t); 51811878SVenu.Iyer@Sun.COM extern mac_ring_handle_t mac_find_ring(mac_group_handle_t, int); 51911878SVenu.Iyer@Sun.COM 52011878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_default_uint8( 52111878SVenu.Iyer@Sun.COM mac_prop_info_handle_t, uint8_t); 52211878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_default_str( 52311878SVenu.Iyer@Sun.COM mac_prop_info_handle_t, const char *); 52411878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_default_uint64( 52511878SVenu.Iyer@Sun.COM mac_prop_info_handle_t, uint64_t); 52611878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_default_uint32( 52711878SVenu.Iyer@Sun.COM mac_prop_info_handle_t, uint32_t); 52811878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_default_link_flowctrl( 52911878SVenu.Iyer@Sun.COM mac_prop_info_handle_t, link_flowctrl_t); 53011878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_range_uint32( 53111878SVenu.Iyer@Sun.COM mac_prop_info_handle_t, 53211878SVenu.Iyer@Sun.COM uint32_t, uint32_t); 53311878SVenu.Iyer@Sun.COM extern void mac_prop_info_set_perm(mac_prop_info_handle_t, 53411878SVenu.Iyer@Sun.COM uint8_t); 53511878SVenu.Iyer@Sun.COM 53611878SVenu.Iyer@Sun.COM extern void mac_hcksum_get(mblk_t *, uint32_t *, 53711878SVenu.Iyer@Sun.COM uint32_t *, uint32_t *, uint32_t *, 53811878SVenu.Iyer@Sun.COM uint32_t *); 53911878SVenu.Iyer@Sun.COM extern void mac_hcksum_set(mblk_t *, uint32_t, uint32_t, 54011878SVenu.Iyer@Sun.COM uint32_t, uint32_t, uint32_t); 54111878SVenu.Iyer@Sun.COM 54211878SVenu.Iyer@Sun.COM extern void mac_lso_get(mblk_t *, uint32_t *, uint32_t *); 5438275SEric Cheng 5448275SEric Cheng #endif /* _KERNEL */ 5458275SEric Cheng 5468275SEric Cheng #ifdef __cplusplus 5478275SEric Cheng } 5488275SEric Cheng #endif 5498275SEric Cheng 5508275SEric Cheng #endif /* _SYS_MAC_PROVIDER_H */ 551