xref: /illumos-gate/usr/src/uts/common/sys/mac_client.h (revision c61a1653)
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.
25b237158dSPatrick Mooney  * Copyright 2019 Joyent, Inc.
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() */
9184de666eSRyan Zezeski 
92da14cebeSEric Cheng #define	MAC_UNICAST_NODUPCHECK			0x0001
93da14cebeSEric Cheng #define	MAC_UNICAST_PRIMARY			0x0002
94da14cebeSEric Cheng #define	MAC_UNICAST_HW				0x0004
95da14cebeSEric Cheng #define	MAC_UNICAST_VNIC_PRIMARY		0x0008
964c91d6c6SVenugopal Iyer #define	MAC_UNICAST_TAG_DISABLE			0x0010
974c91d6c6SVenugopal Iyer #define	MAC_UNICAST_STRIP_DISABLE		0x0020
984c91d6c6SVenugopal Iyer #define	MAC_UNICAST_DISABLE_TX_VID_CHECK	0x0040
99da14cebeSEric Cheng 
100da14cebeSEric Cheng /* flags passed to mac_client_open */
101da14cebeSEric Cheng #define	MAC_OPEN_FLAGS_IS_VNIC			0x0001
102da14cebeSEric Cheng #define	MAC_OPEN_FLAGS_EXCLUSIVE		0x0002
1034c91d6c6SVenugopal Iyer #define	MAC_OPEN_FLAGS_IS_AGGR_PORT		0x0004
1040dc2366fSVenugopal Iyer #define	MAC_OPEN_FLAGS_SHARES_DESIRED		0x0008
1050dc2366fSVenugopal Iyer #define	MAC_OPEN_FLAGS_USE_DATALINK_NAME	0x0010
1060dc2366fSVenugopal Iyer #define	MAC_OPEN_FLAGS_MULTI_PRIMARY		0x0020
1070dc2366fSVenugopal Iyer #define	MAC_OPEN_FLAGS_NO_UNICAST_ADDR		0x0040
108da14cebeSEric Cheng 
109da14cebeSEric Cheng /* flags passed to mac_client_close */
110da14cebeSEric Cheng #define	MAC_CLOSE_FLAGS_IS_VNIC		0x0001
111da14cebeSEric Cheng #define	MAC_CLOSE_FLAGS_EXCLUSIVE	0x0002
112da14cebeSEric Cheng #define	MAC_CLOSE_FLAGS_IS_AGGR_PORT	0x0004
113da14cebeSEric Cheng 
114da14cebeSEric Cheng /* flags passed to mac_promisc_add() */
115da14cebeSEric Cheng #define	MAC_PROMISC_FLAGS_NO_TX_LOOP		0x0001
116da14cebeSEric Cheng #define	MAC_PROMISC_FLAGS_NO_PHYS		0x0002
117ae6aa22aSVenugopal Iyer #define	MAC_PROMISC_FLAGS_VLAN_TAG_STRIP	0x0004
1180a0e9771SDarren Reed #define	MAC_PROMISC_FLAGS_NO_COPY		0x0008
119da14cebeSEric Cheng 
120da14cebeSEric Cheng /* flags passed to mac_tx() */
121da14cebeSEric Cheng #define	MAC_DROP_ON_NO_DESC	0x01 /* freemsg() if no tx descs */
122da14cebeSEric Cheng #define	MAC_TX_NO_ENQUEUE	0x02 /* don't enqueue mblks if not xmit'ed */
123da14cebeSEric Cheng #define	MAC_TX_NO_HOLD		0x04 /* don't bump the active Tx count */
124da14cebeSEric Cheng 
125da14cebeSEric Cheng extern int mac_client_open(mac_handle_t, mac_client_handle_t *, char *,
126da14cebeSEric Cheng     uint16_t);
127da14cebeSEric Cheng extern void mac_client_close(mac_client_handle_t, uint16_t);
128da14cebeSEric Cheng 
129da14cebeSEric Cheng extern int mac_unicast_add(mac_client_handle_t, uint8_t *, uint16_t,
130da14cebeSEric Cheng     mac_unicast_handle_t *, uint16_t, mac_diag_t *);
131fc4e975dSVenugopal Iyer extern int mac_unicast_add_set_rx(mac_client_handle_t, uint8_t *, uint16_t,
132fc4e975dSVenugopal Iyer     mac_unicast_handle_t *, uint16_t, mac_diag_t *, mac_rx_t, void *);
133da14cebeSEric Cheng extern int mac_unicast_remove(mac_client_handle_t, mac_unicast_handle_t);
134da14cebeSEric Cheng 
135da14cebeSEric Cheng extern int mac_multicast_add(mac_client_handle_t, const uint8_t *);
136da14cebeSEric Cheng extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *);
137da14cebeSEric Cheng 
138da14cebeSEric Cheng extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *);
139da14cebeSEric Cheng extern void mac_rx_clear(mac_client_handle_t);
140b237158dSPatrick Mooney extern void mac_rx_barrier(mac_client_handle_t);
1411a41ca23SJerry Jelinek extern void mac_secondary_dup(mac_client_handle_t, mac_client_handle_t);
1421a41ca23SJerry Jelinek extern void mac_secondary_cleanup(mac_client_handle_t);
143da14cebeSEric Cheng extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *,
144da14cebeSEric Cheng     uintptr_t, uint16_t, mblk_t **);
145da14cebeSEric Cheng extern boolean_t mac_tx_is_flow_blocked(mac_client_handle_t, mac_tx_cookie_t);
146da14cebeSEric Cheng extern uint64_t mac_client_stat_get(mac_client_handle_t, uint_t);
147da14cebeSEric Cheng 
148da14cebeSEric Cheng extern int mac_promisc_add(mac_client_handle_t, mac_client_promisc_type_t,
149da14cebeSEric Cheng     mac_rx_t, void *, mac_promisc_handle_t *, uint16_t);
1505ecc58b1SGirish Moodalbail extern void mac_promisc_remove(mac_promisc_handle_t);
151da14cebeSEric Cheng 
152da14cebeSEric Cheng extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, void *);
153da14cebeSEric Cheng extern int mac_notify_remove(mac_notify_handle_t, boolean_t);
154da14cebeSEric Cheng extern void mac_notify_remove_wait(mac_handle_t);
155da14cebeSEric Cheng extern int mac_rename_primary(mac_handle_t, const char *);
156da14cebeSEric Cheng extern	char *mac_client_name(mac_client_handle_t);
157da14cebeSEric Cheng 
158da14cebeSEric Cheng extern int mac_open(const char *, mac_handle_t *);
159da14cebeSEric Cheng extern void mac_close(mac_handle_t);
160da14cebeSEric Cheng extern uint64_t mac_stat_get(mac_handle_t, uint_t);
161da14cebeSEric Cheng 
162da14cebeSEric Cheng extern int mac_unicast_primary_set(mac_handle_t, const uint8_t *);
163da14cebeSEric Cheng extern void mac_unicast_primary_get(mac_handle_t, uint8_t *);
164da14cebeSEric Cheng extern void mac_unicast_primary_info(mac_handle_t, char *, boolean_t *);
165da14cebeSEric Cheng 
1661a41ca23SJerry Jelinek extern void mac_unicast_secondary_get(mac_client_handle_t, uint8_t *);
1671a41ca23SJerry Jelinek 
1682b24ab6bSSebastien Roy extern boolean_t mac_dst_get(mac_handle_t, uint8_t *);
1692b24ab6bSSebastien Roy 
170da14cebeSEric Cheng extern int mac_addr_random(mac_client_handle_t, uint_t, uint8_t *,
171da14cebeSEric Cheng     mac_diag_t *);
172da14cebeSEric Cheng 
173da14cebeSEric Cheng extern int mac_addr_factory_reserve(mac_client_handle_t, int *);
174da14cebeSEric Cheng extern void mac_addr_factory_release(mac_client_handle_t, uint_t);
175da14cebeSEric Cheng extern void mac_addr_factory_value(mac_handle_t, int, uchar_t *, uint_t *,
176da14cebeSEric Cheng     char *, boolean_t *);
177da14cebeSEric Cheng extern uint_t mac_addr_factory_num(mac_handle_t);
178da14cebeSEric Cheng 
179da14cebeSEric Cheng extern mac_tx_notify_handle_t mac_client_tx_notify(mac_client_handle_t,
180da14cebeSEric Cheng     mac_tx_notify_t, void *);
181da14cebeSEric Cheng 
182da14cebeSEric Cheng extern int mac_client_set_resources(mac_client_handle_t,
183da14cebeSEric Cheng     mac_resource_props_t *);
184da14cebeSEric Cheng extern void mac_client_get_resources(mac_client_handle_t,
185da14cebeSEric Cheng     mac_resource_props_t *);
1860dc2366fSVenugopal Iyer extern void mac_client_get_eff_resources(mac_client_handle_t,
1870dc2366fSVenugopal Iyer     mac_resource_props_t *);
188da14cebeSEric Cheng 
1894eaa4710SRishi Srivatsavai /* bridging-related interfaces */
1904eaa4710SRishi Srivatsavai extern int mac_set_pvid(mac_handle_t, uint16_t);
1914eaa4710SRishi Srivatsavai extern uint16_t mac_get_pvid(mac_handle_t);
1924eaa4710SRishi Srivatsavai extern uint32_t mac_get_llimit(mac_handle_t);
1934eaa4710SRishi Srivatsavai extern uint32_t mac_get_ldecay(mac_handle_t);
1944eaa4710SRishi Srivatsavai 
195da14cebeSEric Cheng extern int mac_share_capable(mac_handle_t);
196da14cebeSEric Cheng extern int mac_share_bind(mac_client_handle_t, uint64_t, uint64_t *);
197da14cebeSEric Cheng extern void mac_share_unbind(mac_client_handle_t);
198da14cebeSEric Cheng 
199da14cebeSEric Cheng extern int mac_set_mtu(mac_handle_t, uint_t, uint_t *);
200da14cebeSEric Cheng 
2010dc2366fSVenugopal Iyer extern void mac_client_set_rings(mac_client_handle_t, int, int);
202ae6aa22aSVenugopal Iyer 
203*c61a1653SRyan Zezeski extern void mac_hw_emul(mblk_t **, mblk_t **, uint_t *, mac_emul_t);
204*c61a1653SRyan Zezeski 
205da14cebeSEric Cheng #endif	/* _KERNEL */
206da14cebeSEric Cheng 
207da14cebeSEric Cheng #ifdef	__cplusplus
208da14cebeSEric Cheng }
209da14cebeSEric Cheng #endif
210da14cebeSEric Cheng 
211da14cebeSEric Cheng #endif /* _SYS_MAC_CLIENT_H */
212