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 /* 230dc2366fSVenugopal Iyer * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24da14cebeSEric Cheng * Use is subject to license terms. 25*1a41ca23SJerry Jelinek * Copyright 2013 Joyent, Inc. All rights reserved. 26da14cebeSEric Cheng */ 27da14cebeSEric Cheng 28da14cebeSEric Cheng /* 29da14cebeSEric Cheng * This file captures the MAC client API definitions. It can be 30da14cebeSEric Cheng * included from any MAC clients. 31da14cebeSEric Cheng */ 32da14cebeSEric Cheng 33da14cebeSEric Cheng #ifndef _SYS_MAC_CLIENT_H 34da14cebeSEric Cheng #define _SYS_MAC_CLIENT_H 35da14cebeSEric Cheng 36da14cebeSEric Cheng #include <sys/mac.h> 37da14cebeSEric Cheng #include <sys/mac_flow.h> 38da14cebeSEric Cheng 39da14cebeSEric Cheng #ifdef __cplusplus 40da14cebeSEric Cheng extern "C" { 41da14cebeSEric Cheng #endif 42da14cebeSEric Cheng 43da14cebeSEric Cheng #ifdef _KERNEL 44da14cebeSEric Cheng 45da14cebeSEric Cheng /* 46da14cebeSEric Cheng * MAC client interface. 47da14cebeSEric Cheng */ 48da14cebeSEric Cheng 49da14cebeSEric Cheng typedef struct __mac_client_handle *mac_client_handle_t; 50da14cebeSEric Cheng typedef struct __mac_unicast_handle *mac_unicast_handle_t; 51da14cebeSEric Cheng typedef struct __mac_promisc_handle *mac_promisc_handle_t; 52da14cebeSEric Cheng typedef struct __mac_perim_handle *mac_perim_handle_t; 53da14cebeSEric Cheng typedef uintptr_t mac_tx_cookie_t; 54da14cebeSEric Cheng 55da14cebeSEric Cheng typedef void (*mac_tx_notify_t)(void *, mac_tx_cookie_t); 56da14cebeSEric Cheng 57da14cebeSEric Cheng typedef enum { 58da14cebeSEric Cheng MAC_DIAG_NONE, 59da14cebeSEric Cheng MAC_DIAG_MACADDR_NIC, 60da14cebeSEric Cheng MAC_DIAG_MACADDR_INUSE, 61da14cebeSEric Cheng MAC_DIAG_MACADDR_INVALID, 62da14cebeSEric Cheng MAC_DIAG_MACADDRLEN_INVALID, 63da14cebeSEric Cheng MAC_DIAG_MACFACTORYSLOTINVALID, 64da14cebeSEric Cheng MAC_DIAG_MACFACTORYSLOTUSED, 65da14cebeSEric Cheng MAC_DIAG_MACFACTORYSLOTALLUSED, 66da14cebeSEric Cheng MAC_DIAG_MACFACTORYNOTSUP, 67da14cebeSEric Cheng MAC_DIAG_MACPREFIX_INVALID, 68da14cebeSEric Cheng MAC_DIAG_MACPREFIXLEN_INVALID, 69da14cebeSEric Cheng MAC_DIAG_MACNO_HWRINGS 70da14cebeSEric Cheng } mac_diag_t; 71da14cebeSEric Cheng 720dc2366fSVenugopal Iyer /* 730dc2366fSVenugopal Iyer * These are used when MAC clients what to specify tx and rx rings 740dc2366fSVenugopal Iyer * properties. MAC_RXRINGS_NONE/MAC_TXRINGS_NONE mean that we should 750dc2366fSVenugopal Iyer * not reserve any rings while MAC_RXRINGS_DONTCARE/MAC_TXRINGS_DONTCARE 760dc2366fSVenugopal Iyer * mean that the system can decide if it wants to reserve rings or 770dc2366fSVenugopal Iyer * not. 780dc2366fSVenugopal Iyer */ 790dc2366fSVenugopal Iyer #define MAC_RXRINGS_NONE 0 800dc2366fSVenugopal Iyer #define MAC_TXRINGS_NONE MAC_RXRINGS_NONE 810dc2366fSVenugopal Iyer #define MAC_RXRINGS_DONTCARE -1 820dc2366fSVenugopal Iyer #define MAC_TXRINGS_DONTCARE MAC_RXRINGS_DONTCARE 830dc2366fSVenugopal Iyer 84da14cebeSEric Cheng typedef enum { 85da14cebeSEric Cheng MAC_CLIENT_PROMISC_ALL, 86da14cebeSEric Cheng MAC_CLIENT_PROMISC_FILTERED, 87da14cebeSEric Cheng MAC_CLIENT_PROMISC_MULTI 88da14cebeSEric Cheng } mac_client_promisc_type_t; 89da14cebeSEric Cheng 90da14cebeSEric Cheng /* flags passed to mac_unicast_add() */ 91da14cebeSEric Cheng #define MAC_UNICAST_NODUPCHECK 0x0001 92da14cebeSEric Cheng #define MAC_UNICAST_PRIMARY 0x0002 93da14cebeSEric Cheng #define MAC_UNICAST_HW 0x0004 94da14cebeSEric Cheng #define MAC_UNICAST_VNIC_PRIMARY 0x0008 954c91d6c6SVenugopal Iyer #define MAC_UNICAST_TAG_DISABLE 0x0010 964c91d6c6SVenugopal Iyer #define MAC_UNICAST_STRIP_DISABLE 0x0020 974c91d6c6SVenugopal Iyer #define MAC_UNICAST_DISABLE_TX_VID_CHECK 0x0040 98da14cebeSEric Cheng 99da14cebeSEric Cheng /* flags passed to mac_client_open */ 100da14cebeSEric Cheng #define MAC_OPEN_FLAGS_IS_VNIC 0x0001 101da14cebeSEric Cheng #define MAC_OPEN_FLAGS_EXCLUSIVE 0x0002 1024c91d6c6SVenugopal Iyer #define MAC_OPEN_FLAGS_IS_AGGR_PORT 0x0004 1030dc2366fSVenugopal Iyer #define MAC_OPEN_FLAGS_SHARES_DESIRED 0x0008 1040dc2366fSVenugopal Iyer #define MAC_OPEN_FLAGS_USE_DATALINK_NAME 0x0010 1050dc2366fSVenugopal Iyer #define MAC_OPEN_FLAGS_MULTI_PRIMARY 0x0020 1060dc2366fSVenugopal Iyer #define MAC_OPEN_FLAGS_NO_UNICAST_ADDR 0x0040 107da14cebeSEric Cheng 108da14cebeSEric Cheng /* flags passed to mac_client_close */ 109da14cebeSEric Cheng #define MAC_CLOSE_FLAGS_IS_VNIC 0x0001 110da14cebeSEric Cheng #define MAC_CLOSE_FLAGS_EXCLUSIVE 0x0002 111da14cebeSEric Cheng #define MAC_CLOSE_FLAGS_IS_AGGR_PORT 0x0004 112da14cebeSEric Cheng 113da14cebeSEric Cheng /* flags passed to mac_promisc_add() */ 114da14cebeSEric Cheng #define MAC_PROMISC_FLAGS_NO_TX_LOOP 0x0001 115da14cebeSEric Cheng #define MAC_PROMISC_FLAGS_NO_PHYS 0x0002 116ae6aa22aSVenugopal Iyer #define MAC_PROMISC_FLAGS_VLAN_TAG_STRIP 0x0004 1170a0e9771SDarren Reed #define MAC_PROMISC_FLAGS_NO_COPY 0x0008 118da14cebeSEric Cheng 119da14cebeSEric Cheng /* flags passed to mac_tx() */ 120da14cebeSEric Cheng #define MAC_DROP_ON_NO_DESC 0x01 /* freemsg() if no tx descs */ 121da14cebeSEric Cheng #define MAC_TX_NO_ENQUEUE 0x02 /* don't enqueue mblks if not xmit'ed */ 122da14cebeSEric Cheng #define MAC_TX_NO_HOLD 0x04 /* don't bump the active Tx count */ 123da14cebeSEric Cheng 124da14cebeSEric Cheng extern int mac_client_open(mac_handle_t, mac_client_handle_t *, char *, 125da14cebeSEric Cheng uint16_t); 126da14cebeSEric Cheng extern void mac_client_close(mac_client_handle_t, uint16_t); 127da14cebeSEric Cheng 128da14cebeSEric Cheng extern int mac_unicast_add(mac_client_handle_t, uint8_t *, uint16_t, 129da14cebeSEric Cheng mac_unicast_handle_t *, uint16_t, mac_diag_t *); 130fc4e975dSVenugopal Iyer extern int mac_unicast_add_set_rx(mac_client_handle_t, uint8_t *, uint16_t, 131fc4e975dSVenugopal Iyer mac_unicast_handle_t *, uint16_t, mac_diag_t *, mac_rx_t, void *); 132da14cebeSEric Cheng extern int mac_unicast_remove(mac_client_handle_t, mac_unicast_handle_t); 133da14cebeSEric Cheng 134da14cebeSEric Cheng extern int mac_multicast_add(mac_client_handle_t, const uint8_t *); 135da14cebeSEric Cheng extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *); 136da14cebeSEric Cheng 137da14cebeSEric Cheng extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *); 138da14cebeSEric Cheng extern void mac_rx_clear(mac_client_handle_t); 139*1a41ca23SJerry Jelinek extern void mac_secondary_dup(mac_client_handle_t, mac_client_handle_t); 140*1a41ca23SJerry Jelinek extern void mac_secondary_cleanup(mac_client_handle_t); 141da14cebeSEric Cheng extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *, 142da14cebeSEric Cheng uintptr_t, uint16_t, mblk_t **); 143da14cebeSEric Cheng extern boolean_t mac_tx_is_flow_blocked(mac_client_handle_t, mac_tx_cookie_t); 144da14cebeSEric Cheng extern uint64_t mac_client_stat_get(mac_client_handle_t, uint_t); 145da14cebeSEric Cheng 146da14cebeSEric Cheng extern int mac_promisc_add(mac_client_handle_t, mac_client_promisc_type_t, 147da14cebeSEric Cheng mac_rx_t, void *, mac_promisc_handle_t *, uint16_t); 1485ecc58b1SGirish Moodalbail extern void mac_promisc_remove(mac_promisc_handle_t); 149da14cebeSEric Cheng 150da14cebeSEric Cheng extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, void *); 151da14cebeSEric Cheng extern int mac_notify_remove(mac_notify_handle_t, boolean_t); 152da14cebeSEric Cheng extern void mac_notify_remove_wait(mac_handle_t); 153da14cebeSEric Cheng extern int mac_rename_primary(mac_handle_t, const char *); 154da14cebeSEric Cheng extern char *mac_client_name(mac_client_handle_t); 155da14cebeSEric Cheng 156da14cebeSEric Cheng extern int mac_open(const char *, mac_handle_t *); 157da14cebeSEric Cheng extern void mac_close(mac_handle_t); 158da14cebeSEric Cheng extern uint64_t mac_stat_get(mac_handle_t, uint_t); 159da14cebeSEric Cheng 160da14cebeSEric Cheng extern int mac_unicast_primary_set(mac_handle_t, const uint8_t *); 161da14cebeSEric Cheng extern void mac_unicast_primary_get(mac_handle_t, uint8_t *); 162da14cebeSEric Cheng extern void mac_unicast_primary_info(mac_handle_t, char *, boolean_t *); 163da14cebeSEric Cheng 164*1a41ca23SJerry Jelinek extern void mac_unicast_secondary_get(mac_client_handle_t, uint8_t *); 165*1a41ca23SJerry Jelinek 1662b24ab6bSSebastien Roy extern boolean_t mac_dst_get(mac_handle_t, uint8_t *); 1672b24ab6bSSebastien Roy 168da14cebeSEric Cheng extern int mac_addr_random(mac_client_handle_t, uint_t, uint8_t *, 169da14cebeSEric Cheng mac_diag_t *); 170da14cebeSEric Cheng 171da14cebeSEric Cheng extern int mac_addr_factory_reserve(mac_client_handle_t, int *); 172da14cebeSEric Cheng extern void mac_addr_factory_release(mac_client_handle_t, uint_t); 173da14cebeSEric Cheng extern void mac_addr_factory_value(mac_handle_t, int, uchar_t *, uint_t *, 174da14cebeSEric Cheng char *, boolean_t *); 175da14cebeSEric Cheng extern uint_t mac_addr_factory_num(mac_handle_t); 176da14cebeSEric Cheng 177da14cebeSEric Cheng extern mac_tx_notify_handle_t mac_client_tx_notify(mac_client_handle_t, 178da14cebeSEric Cheng mac_tx_notify_t, void *); 179da14cebeSEric Cheng 180da14cebeSEric Cheng extern int mac_client_set_resources(mac_client_handle_t, 181da14cebeSEric Cheng mac_resource_props_t *); 182da14cebeSEric Cheng extern void mac_client_get_resources(mac_client_handle_t, 183da14cebeSEric Cheng mac_resource_props_t *); 1840dc2366fSVenugopal Iyer extern void mac_client_get_eff_resources(mac_client_handle_t, 1850dc2366fSVenugopal Iyer mac_resource_props_t *); 186da14cebeSEric Cheng 1874eaa4710SRishi Srivatsavai /* bridging-related interfaces */ 1884eaa4710SRishi Srivatsavai extern int mac_set_pvid(mac_handle_t, uint16_t); 1894eaa4710SRishi Srivatsavai extern uint16_t mac_get_pvid(mac_handle_t); 1904eaa4710SRishi Srivatsavai extern uint32_t mac_get_llimit(mac_handle_t); 1914eaa4710SRishi Srivatsavai extern uint32_t mac_get_ldecay(mac_handle_t); 1924eaa4710SRishi Srivatsavai 193da14cebeSEric Cheng extern int mac_share_capable(mac_handle_t); 194da14cebeSEric Cheng extern int mac_share_bind(mac_client_handle_t, uint64_t, uint64_t *); 195da14cebeSEric Cheng extern void mac_share_unbind(mac_client_handle_t); 196da14cebeSEric Cheng 197da14cebeSEric Cheng extern int mac_set_mtu(mac_handle_t, uint_t, uint_t *); 198da14cebeSEric Cheng 1990dc2366fSVenugopal Iyer extern void mac_client_set_rings(mac_client_handle_t, int, int); 200ae6aa22aSVenugopal Iyer 201da14cebeSEric Cheng #endif /* _KERNEL */ 202da14cebeSEric Cheng 203da14cebeSEric Cheng #ifdef __cplusplus 204da14cebeSEric Cheng } 205da14cebeSEric Cheng #endif 206da14cebeSEric Cheng 207da14cebeSEric Cheng #endif /* _SYS_MAC_CLIENT_H */ 208