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 /* 238833SVenu.Iyer@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 248275SEric Cheng * Use is subject to license terms. 258275SEric Cheng */ 268275SEric Cheng 278275SEric Cheng /* 288275SEric Cheng * This file captures the MAC client API definitions. It can be 298275SEric Cheng * included from any MAC clients. 308275SEric Cheng */ 318275SEric Cheng 328275SEric Cheng #ifndef _SYS_MAC_CLIENT_H 338275SEric Cheng #define _SYS_MAC_CLIENT_H 348275SEric Cheng 358275SEric Cheng #include <sys/mac.h> 368275SEric Cheng #include <sys/mac_flow.h> 378275SEric Cheng 388275SEric Cheng #ifdef __cplusplus 398275SEric Cheng extern "C" { 408275SEric Cheng #endif 418275SEric Cheng 428275SEric Cheng #ifdef _KERNEL 438275SEric Cheng 448275SEric Cheng /* 458275SEric Cheng * MAC client interface. 468275SEric Cheng */ 478275SEric Cheng 488275SEric Cheng typedef struct __mac_client_handle *mac_client_handle_t; 498275SEric Cheng typedef struct __mac_unicast_handle *mac_unicast_handle_t; 508275SEric Cheng typedef struct __mac_promisc_handle *mac_promisc_handle_t; 518275SEric Cheng typedef struct __mac_perim_handle *mac_perim_handle_t; 528275SEric Cheng typedef uintptr_t mac_tx_cookie_t; 538275SEric Cheng 548275SEric Cheng typedef void (*mac_tx_notify_t)(void *, mac_tx_cookie_t); 558275SEric Cheng 568275SEric Cheng typedef enum { 578275SEric Cheng MAC_DIAG_NONE, 588275SEric Cheng MAC_DIAG_MACADDR_NIC, 598275SEric Cheng MAC_DIAG_MACADDR_INUSE, 608275SEric Cheng MAC_DIAG_MACADDR_INVALID, 618275SEric Cheng MAC_DIAG_MACADDRLEN_INVALID, 628275SEric Cheng MAC_DIAG_MACFACTORYSLOTINVALID, 638275SEric Cheng MAC_DIAG_MACFACTORYSLOTUSED, 648275SEric Cheng MAC_DIAG_MACFACTORYSLOTALLUSED, 658275SEric Cheng MAC_DIAG_MACFACTORYNOTSUP, 668275SEric Cheng MAC_DIAG_MACPREFIX_INVALID, 678275SEric Cheng MAC_DIAG_MACPREFIXLEN_INVALID, 688275SEric Cheng MAC_DIAG_MACNO_HWRINGS 698275SEric Cheng } mac_diag_t; 708275SEric Cheng 718275SEric Cheng typedef enum { 728275SEric Cheng MAC_CLIENT_PROMISC_ALL, 738275SEric Cheng MAC_CLIENT_PROMISC_FILTERED, 748275SEric Cheng MAC_CLIENT_PROMISC_MULTI 758275SEric Cheng } mac_client_promisc_type_t; 768275SEric Cheng 778275SEric Cheng /* flags passed to mac_unicast_add() */ 789024SVenu.Iyer@Sun.COM #define MAC_UNICAST_NODUPCHECK 0x0001 799024SVenu.Iyer@Sun.COM #define MAC_UNICAST_PRIMARY 0x0002 809024SVenu.Iyer@Sun.COM #define MAC_UNICAST_HW 0x0004 819024SVenu.Iyer@Sun.COM #define MAC_UNICAST_VNIC_PRIMARY 0x0008 829024SVenu.Iyer@Sun.COM #define MAC_UNICAST_TAG_DISABLE 0x0010 839024SVenu.Iyer@Sun.COM #define MAC_UNICAST_STRIP_DISABLE 0x0020 849024SVenu.Iyer@Sun.COM #define MAC_UNICAST_DISABLE_TX_VID_CHECK 0x0040 858275SEric Cheng 868275SEric Cheng /* flags passed to mac_client_open */ 878275SEric Cheng #define MAC_OPEN_FLAGS_IS_VNIC 0x0001 888275SEric Cheng #define MAC_OPEN_FLAGS_EXCLUSIVE 0x0002 899024SVenu.Iyer@Sun.COM #define MAC_OPEN_FLAGS_IS_AGGR_PORT 0x0004 909024SVenu.Iyer@Sun.COM #define MAC_OPEN_FLAGS_NO_HWRINGS 0x0008 919024SVenu.Iyer@Sun.COM #define MAC_OPEN_FLAGS_SHARES_DESIRED 0x0010 929024SVenu.Iyer@Sun.COM #define MAC_OPEN_FLAGS_USE_DATALINK_NAME 0x0020 939024SVenu.Iyer@Sun.COM #define MAC_OPEN_FLAGS_REQ_HWRINGS 0x0040 949473SVenu.Iyer@Sun.COM #define MAC_OPEN_FLAGS_MULTI_PRIMARY 0x0080 958275SEric Cheng 968275SEric Cheng /* flags passed to mac_client_close */ 978275SEric Cheng #define MAC_CLOSE_FLAGS_IS_VNIC 0x0001 988275SEric Cheng #define MAC_CLOSE_FLAGS_EXCLUSIVE 0x0002 998275SEric Cheng #define MAC_CLOSE_FLAGS_IS_AGGR_PORT 0x0004 1008275SEric Cheng 1018275SEric Cheng /* flags passed to mac_promisc_add() */ 1028833SVenu.Iyer@Sun.COM #define MAC_PROMISC_FLAGS_NO_TX_LOOP 0x0001 1038833SVenu.Iyer@Sun.COM #define MAC_PROMISC_FLAGS_NO_PHYS 0x0002 1048833SVenu.Iyer@Sun.COM #define MAC_PROMISC_FLAGS_VLAN_TAG_STRIP 0x0004 105*10639SDarren.Reed@Sun.COM #define MAC_PROMISC_FLAGS_NO_COPY 0x0008 1068275SEric Cheng 1078275SEric Cheng /* flags passed to mac_tx() */ 1088275SEric Cheng #define MAC_DROP_ON_NO_DESC 0x01 /* freemsg() if no tx descs */ 1098275SEric Cheng #define MAC_TX_NO_ENQUEUE 0x02 /* don't enqueue mblks if not xmit'ed */ 1108275SEric Cheng #define MAC_TX_NO_HOLD 0x04 /* don't bump the active Tx count */ 1118275SEric Cheng 1128275SEric Cheng extern int mac_client_open(mac_handle_t, mac_client_handle_t *, char *, 1138275SEric Cheng uint16_t); 1148275SEric Cheng extern void mac_client_close(mac_client_handle_t, uint16_t); 1158275SEric Cheng 1168275SEric Cheng extern int mac_unicast_add(mac_client_handle_t, uint8_t *, uint16_t, 1178275SEric Cheng mac_unicast_handle_t *, uint16_t, mac_diag_t *); 1189473SVenu.Iyer@Sun.COM extern int mac_unicast_add_set_rx(mac_client_handle_t, uint8_t *, uint16_t, 1199473SVenu.Iyer@Sun.COM mac_unicast_handle_t *, uint16_t, mac_diag_t *, mac_rx_t, void *); 1208275SEric Cheng extern int mac_unicast_remove(mac_client_handle_t, mac_unicast_handle_t); 1218275SEric Cheng 1228275SEric Cheng extern int mac_multicast_add(mac_client_handle_t, const uint8_t *); 1238275SEric Cheng extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *); 1248275SEric Cheng 1258275SEric Cheng extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *); 1268275SEric Cheng extern void mac_rx_clear(mac_client_handle_t); 1278275SEric Cheng extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *, 1288275SEric Cheng uintptr_t, uint16_t, mblk_t **); 1298275SEric Cheng extern boolean_t mac_tx_is_flow_blocked(mac_client_handle_t, mac_tx_cookie_t); 1308275SEric Cheng extern uint64_t mac_client_stat_get(mac_client_handle_t, uint_t); 1318275SEric Cheng 1328275SEric Cheng extern int mac_promisc_add(mac_client_handle_t, mac_client_promisc_type_t, 1338275SEric Cheng mac_rx_t, void *, mac_promisc_handle_t *, uint16_t); 1349044SGirish.Moodalbail@Sun.COM extern void mac_promisc_remove(mac_promisc_handle_t); 1358275SEric Cheng 1368275SEric Cheng extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, void *); 1378275SEric Cheng extern int mac_notify_remove(mac_notify_handle_t, boolean_t); 1388275SEric Cheng extern void mac_notify_remove_wait(mac_handle_t); 1398275SEric Cheng extern int mac_rename_primary(mac_handle_t, const char *); 1408275SEric Cheng extern char *mac_client_name(mac_client_handle_t); 1418275SEric Cheng 1428275SEric Cheng extern int mac_open(const char *, mac_handle_t *); 1438275SEric Cheng extern void mac_close(mac_handle_t); 1448275SEric Cheng extern uint64_t mac_stat_get(mac_handle_t, uint_t); 1458275SEric Cheng 1468275SEric Cheng extern int mac_unicast_primary_set(mac_handle_t, const uint8_t *); 1478275SEric Cheng extern void mac_unicast_primary_get(mac_handle_t, uint8_t *); 1488275SEric Cheng extern void mac_unicast_primary_info(mac_handle_t, char *, boolean_t *); 1498275SEric Cheng 15010616SSebastien.Roy@Sun.COM extern boolean_t mac_dst_get(mac_handle_t, uint8_t *); 15110616SSebastien.Roy@Sun.COM 1528275SEric Cheng extern int mac_addr_random(mac_client_handle_t, uint_t, uint8_t *, 1538275SEric Cheng mac_diag_t *); 1548275SEric Cheng 1558275SEric Cheng extern int mac_addr_factory_reserve(mac_client_handle_t, int *); 1568275SEric Cheng extern void mac_addr_factory_release(mac_client_handle_t, uint_t); 1578275SEric Cheng extern void mac_addr_factory_value(mac_handle_t, int, uchar_t *, uint_t *, 1588275SEric Cheng char *, boolean_t *); 1598275SEric Cheng extern uint_t mac_addr_factory_num(mac_handle_t); 1608275SEric Cheng 1618275SEric Cheng extern mac_tx_notify_handle_t mac_client_tx_notify(mac_client_handle_t, 1628275SEric Cheng mac_tx_notify_t, void *); 1638275SEric Cheng 1648275SEric Cheng extern int mac_set_resources(mac_handle_t, mac_resource_props_t *); 1658275SEric Cheng extern void mac_get_resources(mac_handle_t, mac_resource_props_t *); 1668275SEric Cheng extern int mac_client_set_resources(mac_client_handle_t, 1678275SEric Cheng mac_resource_props_t *); 1688275SEric Cheng extern void mac_client_get_resources(mac_client_handle_t, 1698275SEric Cheng mac_resource_props_t *); 1708275SEric Cheng 17110491SRishi.Srivatsavai@Sun.COM /* bridging-related interfaces */ 17210491SRishi.Srivatsavai@Sun.COM extern int mac_set_pvid(mac_handle_t, uint16_t); 17310491SRishi.Srivatsavai@Sun.COM extern uint16_t mac_get_pvid(mac_handle_t); 17410491SRishi.Srivatsavai@Sun.COM extern uint32_t mac_get_llimit(mac_handle_t); 17510491SRishi.Srivatsavai@Sun.COM extern uint32_t mac_get_ldecay(mac_handle_t); 17610491SRishi.Srivatsavai@Sun.COM 1778275SEric Cheng extern int mac_share_capable(mac_handle_t); 1788275SEric Cheng extern int mac_share_bind(mac_client_handle_t, uint64_t, uint64_t *); 1798275SEric Cheng extern void mac_share_unbind(mac_client_handle_t); 1808275SEric Cheng 1818275SEric Cheng extern int mac_set_mtu(mac_handle_t, uint_t, uint_t *); 1828275SEric Cheng 1838275SEric Cheng extern uint_t mac_hwgrp_num(mac_handle_t); 1848275SEric Cheng extern void mac_get_hwgrp_info(mac_handle_t, int, uint_t *, uint_t *, 1858275SEric Cheng uint_t *, uint_t *, char *); 1868275SEric Cheng 1878833SVenu.Iyer@Sun.COM extern uint32_t mac_no_notification(mac_handle_t); 1888833SVenu.Iyer@Sun.COM extern int mac_set_prop(mac_handle_t, mac_prop_t *, void *, uint_t); 1898833SVenu.Iyer@Sun.COM extern int mac_get_prop(mac_handle_t, mac_prop_t *, void *, uint_t, uint_t *); 1908833SVenu.Iyer@Sun.COM 1918833SVenu.Iyer@Sun.COM extern boolean_t mac_is_vnic(mac_handle_t); 1928833SVenu.Iyer@Sun.COM 1938275SEric Cheng #endif /* _KERNEL */ 1948275SEric Cheng 1958275SEric Cheng #ifdef __cplusplus 1968275SEric Cheng } 1978275SEric Cheng #endif 1988275SEric Cheng 1998275SEric Cheng #endif /* _SYS_MAC_CLIENT_H */ 200