xref: /titanic_50/usr/src/uts/common/sys/mac_client.h (revision 269473047d747f7815af570197e4ef7322d3632c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * This file captures the MAC client API definitions. It can be
29  * included from any MAC clients.
30  */
31 
32 #ifndef	_SYS_MAC_CLIENT_H
33 #define	_SYS_MAC_CLIENT_H
34 
35 #include <sys/mac.h>
36 #include <sys/mac_flow.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #ifdef	_KERNEL
43 
44 /*
45  * MAC client interface.
46  */
47 
48 typedef struct __mac_client_handle *mac_client_handle_t;
49 typedef struct __mac_unicast_handle *mac_unicast_handle_t;
50 typedef struct __mac_promisc_handle *mac_promisc_handle_t;
51 typedef struct __mac_perim_handle *mac_perim_handle_t;
52 typedef uintptr_t mac_tx_cookie_t;
53 
54 typedef void (*mac_tx_notify_t)(void *, mac_tx_cookie_t);
55 
56 typedef enum {
57 	MAC_DIAG_NONE,
58 	MAC_DIAG_MACADDR_NIC,
59 	MAC_DIAG_MACADDR_INUSE,
60 	MAC_DIAG_MACADDR_INVALID,
61 	MAC_DIAG_MACADDRLEN_INVALID,
62 	MAC_DIAG_MACFACTORYSLOTINVALID,
63 	MAC_DIAG_MACFACTORYSLOTUSED,
64 	MAC_DIAG_MACFACTORYSLOTALLUSED,
65 	MAC_DIAG_MACFACTORYNOTSUP,
66 	MAC_DIAG_MACPREFIX_INVALID,
67 	MAC_DIAG_MACPREFIXLEN_INVALID,
68 	MAC_DIAG_MACNO_HWRINGS
69 } mac_diag_t;
70 
71 typedef enum {
72 	MAC_CLIENT_PROMISC_ALL,
73 	MAC_CLIENT_PROMISC_FILTERED,
74 	MAC_CLIENT_PROMISC_MULTI
75 } mac_client_promisc_type_t;
76 
77 /* flags passed to mac_unicast_add() */
78 #define	MAC_UNICAST_NODUPCHECK			0x0001
79 #define	MAC_UNICAST_PRIMARY			0x0002
80 #define	MAC_UNICAST_HW				0x0004
81 #define	MAC_UNICAST_VNIC_PRIMARY		0x0008
82 #define	MAC_UNICAST_TAG_DISABLE			0x0010
83 #define	MAC_UNICAST_STRIP_DISABLE		0x0020
84 #define	MAC_UNICAST_DISABLE_TX_VID_CHECK	0x0040
85 
86 /* flags passed to mac_client_open */
87 #define	MAC_OPEN_FLAGS_IS_VNIC			0x0001
88 #define	MAC_OPEN_FLAGS_EXCLUSIVE		0x0002
89 #define	MAC_OPEN_FLAGS_IS_AGGR_PORT		0x0004
90 #define	MAC_OPEN_FLAGS_NO_HWRINGS		0x0008
91 #define	MAC_OPEN_FLAGS_SHARES_DESIRED		0x0010
92 #define	MAC_OPEN_FLAGS_USE_DATALINK_NAME	0x0020
93 #define	MAC_OPEN_FLAGS_REQ_HWRINGS		0x0040
94 #define	MAC_OPEN_FLAGS_MULTI_PRIMARY		0x0080
95 
96 /* flags passed to mac_client_close */
97 #define	MAC_CLOSE_FLAGS_IS_VNIC		0x0001
98 #define	MAC_CLOSE_FLAGS_EXCLUSIVE	0x0002
99 #define	MAC_CLOSE_FLAGS_IS_AGGR_PORT	0x0004
100 
101 /* flags passed to mac_promisc_add() */
102 #define	MAC_PROMISC_FLAGS_NO_TX_LOOP		0x0001
103 #define	MAC_PROMISC_FLAGS_NO_PHYS		0x0002
104 #define	MAC_PROMISC_FLAGS_VLAN_TAG_STRIP	0x0004
105 #define	MAC_PROMISC_FLAGS_NO_COPY		0x0008
106 
107 /* flags passed to mac_tx() */
108 #define	MAC_DROP_ON_NO_DESC	0x01 /* freemsg() if no tx descs */
109 #define	MAC_TX_NO_ENQUEUE	0x02 /* don't enqueue mblks if not xmit'ed */
110 #define	MAC_TX_NO_HOLD		0x04 /* don't bump the active Tx count */
111 
112 extern int mac_client_open(mac_handle_t, mac_client_handle_t *, char *,
113     uint16_t);
114 extern void mac_client_close(mac_client_handle_t, uint16_t);
115 
116 extern int mac_unicast_add(mac_client_handle_t, uint8_t *, uint16_t,
117     mac_unicast_handle_t *, uint16_t, mac_diag_t *);
118 extern int mac_unicast_add_set_rx(mac_client_handle_t, uint8_t *, uint16_t,
119     mac_unicast_handle_t *, uint16_t, mac_diag_t *, mac_rx_t, void *);
120 extern int mac_unicast_remove(mac_client_handle_t, mac_unicast_handle_t);
121 
122 extern int mac_multicast_add(mac_client_handle_t, const uint8_t *);
123 extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *);
124 
125 extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *);
126 extern void mac_rx_clear(mac_client_handle_t);
127 extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *,
128     uintptr_t, uint16_t, mblk_t **);
129 extern boolean_t mac_tx_is_flow_blocked(mac_client_handle_t, mac_tx_cookie_t);
130 extern uint64_t mac_client_stat_get(mac_client_handle_t, uint_t);
131 
132 extern int mac_promisc_add(mac_client_handle_t, mac_client_promisc_type_t,
133     mac_rx_t, void *, mac_promisc_handle_t *, uint16_t);
134 extern void mac_promisc_remove(mac_promisc_handle_t);
135 
136 extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, void *);
137 extern int mac_notify_remove(mac_notify_handle_t, boolean_t);
138 extern void mac_notify_remove_wait(mac_handle_t);
139 extern int mac_rename_primary(mac_handle_t, const char *);
140 extern	char *mac_client_name(mac_client_handle_t);
141 
142 extern int mac_open(const char *, mac_handle_t *);
143 extern void mac_close(mac_handle_t);
144 extern uint64_t mac_stat_get(mac_handle_t, uint_t);
145 
146 extern int mac_unicast_primary_set(mac_handle_t, const uint8_t *);
147 extern void mac_unicast_primary_get(mac_handle_t, uint8_t *);
148 extern void mac_unicast_primary_info(mac_handle_t, char *, boolean_t *);
149 
150 extern boolean_t mac_dst_get(mac_handle_t, uint8_t *);
151 
152 extern int mac_addr_random(mac_client_handle_t, uint_t, uint8_t *,
153     mac_diag_t *);
154 
155 extern int mac_addr_factory_reserve(mac_client_handle_t, int *);
156 extern void mac_addr_factory_release(mac_client_handle_t, uint_t);
157 extern void mac_addr_factory_value(mac_handle_t, int, uchar_t *, uint_t *,
158     char *, boolean_t *);
159 extern uint_t mac_addr_factory_num(mac_handle_t);
160 
161 extern mac_tx_notify_handle_t mac_client_tx_notify(mac_client_handle_t,
162     mac_tx_notify_t, void *);
163 
164 extern int mac_set_resources(mac_handle_t, mac_resource_props_t *);
165 extern void mac_get_resources(mac_handle_t, mac_resource_props_t *);
166 extern int mac_client_set_resources(mac_client_handle_t,
167     mac_resource_props_t *);
168 extern void mac_client_get_resources(mac_client_handle_t,
169     mac_resource_props_t *);
170 
171 /* bridging-related interfaces */
172 extern int mac_set_pvid(mac_handle_t, uint16_t);
173 extern uint16_t mac_get_pvid(mac_handle_t);
174 extern uint32_t mac_get_llimit(mac_handle_t);
175 extern uint32_t mac_get_ldecay(mac_handle_t);
176 
177 extern int mac_share_capable(mac_handle_t);
178 extern int mac_share_bind(mac_client_handle_t, uint64_t, uint64_t *);
179 extern void mac_share_unbind(mac_client_handle_t);
180 
181 extern int mac_set_mtu(mac_handle_t, uint_t, uint_t *);
182 
183 extern uint_t mac_hwgrp_num(mac_handle_t);
184 extern void mac_get_hwgrp_info(mac_handle_t, int, uint_t *, uint_t *,
185     uint_t *, uint_t *, char *);
186 
187 extern uint32_t mac_no_notification(mac_handle_t);
188 extern int mac_set_prop(mac_handle_t, mac_prop_t *, void *, uint_t);
189 extern int mac_get_prop(mac_handle_t, mac_prop_t *, void *, uint_t, uint_t *);
190 
191 extern boolean_t mac_is_vnic(mac_handle_t);
192 
193 #endif	/* _KERNEL */
194 
195 #ifdef	__cplusplus
196 }
197 #endif
198 
199 #endif /* _SYS_MAC_CLIENT_H */
200