xref: /onnv-gate/usr/src/uts/common/sys/mac_client.h (revision 9473:e27b6e39a733)
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
94*9473SVenu.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
1058275SEric Cheng 
1068275SEric Cheng /* flags passed to mac_tx() */
1078275SEric Cheng #define	MAC_DROP_ON_NO_DESC	0x01 /* freemsg() if no tx descs */
1088275SEric Cheng #define	MAC_TX_NO_ENQUEUE	0x02 /* don't enqueue mblks if not xmit'ed */
1098275SEric Cheng #define	MAC_TX_NO_HOLD		0x04 /* don't bump the active Tx count */
1108275SEric Cheng 
1118275SEric Cheng extern int mac_client_open(mac_handle_t, mac_client_handle_t *, char *,
1128275SEric Cheng     uint16_t);
1138275SEric Cheng extern void mac_client_close(mac_client_handle_t, uint16_t);
1148275SEric Cheng 
1158275SEric Cheng extern int mac_unicast_add(mac_client_handle_t, uint8_t *, uint16_t,
1168275SEric Cheng     mac_unicast_handle_t *, uint16_t, mac_diag_t *);
117*9473SVenu.Iyer@Sun.COM extern int mac_unicast_add_set_rx(mac_client_handle_t, uint8_t *, uint16_t,
118*9473SVenu.Iyer@Sun.COM     mac_unicast_handle_t *, uint16_t, mac_diag_t *, mac_rx_t, void *);
1198275SEric Cheng extern int mac_unicast_remove(mac_client_handle_t, mac_unicast_handle_t);
1208275SEric Cheng 
1218275SEric Cheng extern int mac_multicast_add(mac_client_handle_t, const uint8_t *);
1228275SEric Cheng extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *);
1238275SEric Cheng 
1248275SEric Cheng extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *);
1258275SEric Cheng extern void mac_rx_clear(mac_client_handle_t);
1268275SEric Cheng extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *,
1278275SEric Cheng     uintptr_t, uint16_t, mblk_t **);
1288275SEric Cheng extern boolean_t mac_tx_is_flow_blocked(mac_client_handle_t, mac_tx_cookie_t);
1298275SEric Cheng extern uint64_t mac_client_stat_get(mac_client_handle_t, uint_t);
1308275SEric Cheng 
1318275SEric Cheng extern int mac_promisc_add(mac_client_handle_t, mac_client_promisc_type_t,
1328275SEric Cheng     mac_rx_t, void *, mac_promisc_handle_t *, uint16_t);
1339044SGirish.Moodalbail@Sun.COM extern void mac_promisc_remove(mac_promisc_handle_t);
1348275SEric Cheng 
1358275SEric Cheng extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, void *);
1368275SEric Cheng extern int mac_notify_remove(mac_notify_handle_t, boolean_t);
1378275SEric Cheng extern void mac_notify_remove_wait(mac_handle_t);
1388275SEric Cheng extern int mac_rename_primary(mac_handle_t, const char *);
1398275SEric Cheng extern	char *mac_client_name(mac_client_handle_t);
1408275SEric Cheng 
1418275SEric Cheng extern int mac_open(const char *, mac_handle_t *);
1428275SEric Cheng extern void mac_close(mac_handle_t);
1438275SEric Cheng extern uint64_t mac_stat_get(mac_handle_t, uint_t);
1448275SEric Cheng 
1458275SEric Cheng extern int mac_unicast_primary_set(mac_handle_t, const uint8_t *);
1468275SEric Cheng extern void mac_unicast_primary_get(mac_handle_t, uint8_t *);
1478275SEric Cheng extern void mac_unicast_primary_info(mac_handle_t, char *, boolean_t *);
1488275SEric Cheng 
1498275SEric Cheng extern int mac_addr_random(mac_client_handle_t, uint_t, uint8_t *,
1508275SEric Cheng     mac_diag_t *);
1518275SEric Cheng 
1528275SEric Cheng extern int mac_addr_factory_reserve(mac_client_handle_t, int *);
1538275SEric Cheng extern void mac_addr_factory_release(mac_client_handle_t, uint_t);
1548275SEric Cheng extern void mac_addr_factory_value(mac_handle_t, int, uchar_t *, uint_t *,
1558275SEric Cheng     char *, boolean_t *);
1568275SEric Cheng extern uint_t mac_addr_factory_num(mac_handle_t);
1578275SEric Cheng 
1588275SEric Cheng extern uint_t mac_addr_len(mac_handle_t);
1598275SEric Cheng 
1608275SEric Cheng extern mac_tx_notify_handle_t mac_client_tx_notify(mac_client_handle_t,
1618275SEric Cheng     mac_tx_notify_t, void *);
1628275SEric Cheng 
1638275SEric Cheng extern int mac_set_resources(mac_handle_t, mac_resource_props_t *);
1648275SEric Cheng extern void mac_get_resources(mac_handle_t, mac_resource_props_t *);
1658275SEric Cheng extern int mac_client_set_resources(mac_client_handle_t,
1668275SEric Cheng     mac_resource_props_t *);
1678275SEric Cheng extern void mac_client_get_resources(mac_client_handle_t,
1688275SEric Cheng     mac_resource_props_t *);
1698275SEric Cheng 
1708275SEric Cheng extern int mac_share_capable(mac_handle_t);
1718275SEric Cheng extern int mac_share_bind(mac_client_handle_t, uint64_t, uint64_t *);
1728275SEric Cheng extern void mac_share_unbind(mac_client_handle_t);
1738275SEric Cheng 
1748275SEric Cheng extern int mac_set_mtu(mac_handle_t, uint_t, uint_t *);
1758275SEric Cheng 
1768275SEric Cheng extern uint_t mac_hwgrp_num(mac_handle_t);
1778275SEric Cheng extern void mac_get_hwgrp_info(mac_handle_t, int, uint_t *, uint_t *,
1788275SEric Cheng     uint_t *, uint_t *, char *);
1798275SEric Cheng 
1808833SVenu.Iyer@Sun.COM extern uint32_t mac_no_notification(mac_handle_t);
1818833SVenu.Iyer@Sun.COM extern int mac_set_prop(mac_handle_t, mac_prop_t *, void *, uint_t);
1828833SVenu.Iyer@Sun.COM extern int mac_get_prop(mac_handle_t, mac_prop_t *, void *, uint_t, uint_t *);
1838833SVenu.Iyer@Sun.COM 
1848833SVenu.Iyer@Sun.COM extern boolean_t mac_is_vnic(mac_handle_t);
1858833SVenu.Iyer@Sun.COM 
1868275SEric Cheng #endif	/* _KERNEL */
1878275SEric Cheng 
1888275SEric Cheng #ifdef	__cplusplus
1898275SEric Cheng }
1908275SEric Cheng #endif
1918275SEric Cheng 
1928275SEric Cheng #endif /* _SYS_MAC_CLIENT_H */
193