xref: /onnv-gate/usr/src/uts/common/sys/mac_client.h (revision 11878:ac93462db6d7)
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 /*
23*11878SVenu.Iyer@Sun.COM  * Copyright 2010 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 
71*11878SVenu.Iyer@Sun.COM /*
72*11878SVenu.Iyer@Sun.COM  * These are used when MAC clients what to specify tx and rx rings
73*11878SVenu.Iyer@Sun.COM  * properties. MAC_RXRINGS_NONE/MAC_TXRINGS_NONE mean that we should
74*11878SVenu.Iyer@Sun.COM  * not reserve any rings while MAC_RXRINGS_DONTCARE/MAC_TXRINGS_DONTCARE
75*11878SVenu.Iyer@Sun.COM  * mean that the system can decide if it wants to reserve rings or
76*11878SVenu.Iyer@Sun.COM  * not.
77*11878SVenu.Iyer@Sun.COM  */
78*11878SVenu.Iyer@Sun.COM #define	MAC_RXRINGS_NONE	0
79*11878SVenu.Iyer@Sun.COM #define	MAC_TXRINGS_NONE	MAC_RXRINGS_NONE
80*11878SVenu.Iyer@Sun.COM #define	MAC_RXRINGS_DONTCARE	-1
81*11878SVenu.Iyer@Sun.COM #define	MAC_TXRINGS_DONTCARE	MAC_RXRINGS_DONTCARE
82*11878SVenu.Iyer@Sun.COM 
838275SEric Cheng typedef enum {
848275SEric Cheng 	MAC_CLIENT_PROMISC_ALL,
858275SEric Cheng 	MAC_CLIENT_PROMISC_FILTERED,
868275SEric Cheng 	MAC_CLIENT_PROMISC_MULTI
878275SEric Cheng } mac_client_promisc_type_t;
888275SEric Cheng 
898275SEric Cheng /* flags passed to mac_unicast_add() */
909024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_NODUPCHECK			0x0001
919024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_PRIMARY			0x0002
929024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_HW				0x0004
939024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_VNIC_PRIMARY		0x0008
949024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_TAG_DISABLE			0x0010
959024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_STRIP_DISABLE		0x0020
969024SVenu.Iyer@Sun.COM #define	MAC_UNICAST_DISABLE_TX_VID_CHECK	0x0040
978275SEric Cheng 
988275SEric Cheng /* flags passed to mac_client_open */
998275SEric Cheng #define	MAC_OPEN_FLAGS_IS_VNIC			0x0001
1008275SEric Cheng #define	MAC_OPEN_FLAGS_EXCLUSIVE		0x0002
1019024SVenu.Iyer@Sun.COM #define	MAC_OPEN_FLAGS_IS_AGGR_PORT		0x0004
102*11878SVenu.Iyer@Sun.COM #define	MAC_OPEN_FLAGS_SHARES_DESIRED		0x0008
103*11878SVenu.Iyer@Sun.COM #define	MAC_OPEN_FLAGS_USE_DATALINK_NAME	0x0010
104*11878SVenu.Iyer@Sun.COM #define	MAC_OPEN_FLAGS_MULTI_PRIMARY		0x0020
105*11878SVenu.Iyer@Sun.COM #define	MAC_OPEN_FLAGS_NO_UNICAST_ADDR		0x0040
1068275SEric Cheng 
1078275SEric Cheng /* flags passed to mac_client_close */
1088275SEric Cheng #define	MAC_CLOSE_FLAGS_IS_VNIC		0x0001
1098275SEric Cheng #define	MAC_CLOSE_FLAGS_EXCLUSIVE	0x0002
1108275SEric Cheng #define	MAC_CLOSE_FLAGS_IS_AGGR_PORT	0x0004
1118275SEric Cheng 
1128275SEric Cheng /* flags passed to mac_promisc_add() */
1138833SVenu.Iyer@Sun.COM #define	MAC_PROMISC_FLAGS_NO_TX_LOOP		0x0001
1148833SVenu.Iyer@Sun.COM #define	MAC_PROMISC_FLAGS_NO_PHYS		0x0002
1158833SVenu.Iyer@Sun.COM #define	MAC_PROMISC_FLAGS_VLAN_TAG_STRIP	0x0004
11610639SDarren.Reed@Sun.COM #define	MAC_PROMISC_FLAGS_NO_COPY		0x0008
1178275SEric Cheng 
1188275SEric Cheng /* flags passed to mac_tx() */
1198275SEric Cheng #define	MAC_DROP_ON_NO_DESC	0x01 /* freemsg() if no tx descs */
1208275SEric Cheng #define	MAC_TX_NO_ENQUEUE	0x02 /* don't enqueue mblks if not xmit'ed */
1218275SEric Cheng #define	MAC_TX_NO_HOLD		0x04 /* don't bump the active Tx count */
1228275SEric Cheng 
1238275SEric Cheng extern int mac_client_open(mac_handle_t, mac_client_handle_t *, char *,
1248275SEric Cheng     uint16_t);
1258275SEric Cheng extern void mac_client_close(mac_client_handle_t, uint16_t);
1268275SEric Cheng 
1278275SEric Cheng extern int mac_unicast_add(mac_client_handle_t, uint8_t *, uint16_t,
1288275SEric Cheng     mac_unicast_handle_t *, uint16_t, mac_diag_t *);
1299473SVenu.Iyer@Sun.COM extern int mac_unicast_add_set_rx(mac_client_handle_t, uint8_t *, uint16_t,
1309473SVenu.Iyer@Sun.COM     mac_unicast_handle_t *, uint16_t, mac_diag_t *, mac_rx_t, void *);
1318275SEric Cheng extern int mac_unicast_remove(mac_client_handle_t, mac_unicast_handle_t);
1328275SEric Cheng 
1338275SEric Cheng extern int mac_multicast_add(mac_client_handle_t, const uint8_t *);
1348275SEric Cheng extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *);
1358275SEric Cheng 
1368275SEric Cheng extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *);
1378275SEric Cheng extern void mac_rx_clear(mac_client_handle_t);
1388275SEric Cheng extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *,
1398275SEric Cheng     uintptr_t, uint16_t, mblk_t **);
1408275SEric Cheng extern boolean_t mac_tx_is_flow_blocked(mac_client_handle_t, mac_tx_cookie_t);
1418275SEric Cheng extern uint64_t mac_client_stat_get(mac_client_handle_t, uint_t);
1428275SEric Cheng 
1438275SEric Cheng extern int mac_promisc_add(mac_client_handle_t, mac_client_promisc_type_t,
1448275SEric Cheng     mac_rx_t, void *, mac_promisc_handle_t *, uint16_t);
1459044SGirish.Moodalbail@Sun.COM extern void mac_promisc_remove(mac_promisc_handle_t);
1468275SEric Cheng 
1478275SEric Cheng extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, void *);
1488275SEric Cheng extern int mac_notify_remove(mac_notify_handle_t, boolean_t);
1498275SEric Cheng extern void mac_notify_remove_wait(mac_handle_t);
1508275SEric Cheng extern int mac_rename_primary(mac_handle_t, const char *);
1518275SEric Cheng extern	char *mac_client_name(mac_client_handle_t);
1528275SEric Cheng 
1538275SEric Cheng extern int mac_open(const char *, mac_handle_t *);
1548275SEric Cheng extern void mac_close(mac_handle_t);
1558275SEric Cheng extern uint64_t mac_stat_get(mac_handle_t, uint_t);
1568275SEric Cheng 
1578275SEric Cheng extern int mac_unicast_primary_set(mac_handle_t, const uint8_t *);
1588275SEric Cheng extern void mac_unicast_primary_get(mac_handle_t, uint8_t *);
1598275SEric Cheng extern void mac_unicast_primary_info(mac_handle_t, char *, boolean_t *);
1608275SEric Cheng 
16110616SSebastien.Roy@Sun.COM extern boolean_t mac_dst_get(mac_handle_t, uint8_t *);
16210616SSebastien.Roy@Sun.COM 
1638275SEric Cheng extern int mac_addr_random(mac_client_handle_t, uint_t, uint8_t *,
1648275SEric Cheng     mac_diag_t *);
1658275SEric Cheng 
1668275SEric Cheng extern int mac_addr_factory_reserve(mac_client_handle_t, int *);
1678275SEric Cheng extern void mac_addr_factory_release(mac_client_handle_t, uint_t);
1688275SEric Cheng extern void mac_addr_factory_value(mac_handle_t, int, uchar_t *, uint_t *,
1698275SEric Cheng     char *, boolean_t *);
1708275SEric Cheng extern uint_t mac_addr_factory_num(mac_handle_t);
1718275SEric Cheng 
1728275SEric Cheng extern mac_tx_notify_handle_t mac_client_tx_notify(mac_client_handle_t,
1738275SEric Cheng     mac_tx_notify_t, void *);
1748275SEric Cheng 
1758275SEric Cheng extern int mac_client_set_resources(mac_client_handle_t,
1768275SEric Cheng     mac_resource_props_t *);
1778275SEric Cheng extern void mac_client_get_resources(mac_client_handle_t,
1788275SEric Cheng     mac_resource_props_t *);
179*11878SVenu.Iyer@Sun.COM extern void mac_client_get_eff_resources(mac_client_handle_t,
180*11878SVenu.Iyer@Sun.COM     mac_resource_props_t *);
1818275SEric Cheng 
18210491SRishi.Srivatsavai@Sun.COM /* bridging-related interfaces */
18310491SRishi.Srivatsavai@Sun.COM extern int mac_set_pvid(mac_handle_t, uint16_t);
18410491SRishi.Srivatsavai@Sun.COM extern uint16_t mac_get_pvid(mac_handle_t);
18510491SRishi.Srivatsavai@Sun.COM extern uint32_t mac_get_llimit(mac_handle_t);
18610491SRishi.Srivatsavai@Sun.COM extern uint32_t mac_get_ldecay(mac_handle_t);
18710491SRishi.Srivatsavai@Sun.COM 
1888275SEric Cheng extern int mac_share_capable(mac_handle_t);
1898275SEric Cheng extern int mac_share_bind(mac_client_handle_t, uint64_t, uint64_t *);
1908275SEric Cheng extern void mac_share_unbind(mac_client_handle_t);
1918275SEric Cheng 
1928275SEric Cheng extern int mac_set_mtu(mac_handle_t, uint_t, uint_t *);
1938275SEric Cheng 
194*11878SVenu.Iyer@Sun.COM extern void mac_client_set_rings(mac_client_handle_t, int, int);
1958833SVenu.Iyer@Sun.COM 
1968275SEric Cheng #endif	/* _KERNEL */
1978275SEric Cheng 
1988275SEric Cheng #ifdef	__cplusplus
1998275SEric Cheng }
2008275SEric Cheng #endif
2018275SEric Cheng 
2028275SEric Cheng #endif /* _SYS_MAC_CLIENT_H */
203