xref: /illumos-gate/usr/src/uts/common/sys/vnic_impl.h (revision 069e6b7e31ba5dcbc5441b98af272714d9a5455c)
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  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright 2018 Joyent, Inc.
25  */
26 
27 #ifndef	_SYS_VNIC_IMPL_H
28 #define	_SYS_VNIC_IMPL_H
29 
30 #include <sys/cred.h>
31 #include <sys/mac_provider.h>
32 #include <sys/mac_client.h>
33 #include <sys/mac_client_priv.h>
34 #include <sys/vnic.h>
35 #include <sys/mac_flow.h>
36 #include <sys/ksynch.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 typedef struct vnic_s {
43 	datalink_id_t		vn_id;
44 	uint32_t
45 				vn_enabled : 1,
46 				vn_pad_to_bit_31 : 31;
47 
48 	mac_handle_t		vn_mh;
49 	mac_handle_t		vn_lower_mh;
50 	uint_t			vn_nhandles; /* # of secondary mac handles */
51 	/* The primary handle is always the first element in the array */
52 	mac_client_handle_t	vn_mc_handles[MPT_MAXMACADDR];
53 	mac_unicast_handle_t	vn_mu_handles[MPT_MAXMACADDR];
54 	uint32_t		vn_margin;
55 	int			vn_slot_id;
56 	vnic_mac_addr_type_t	vn_addr_type;
57 	uint8_t			vn_addr[MAXMACADDRLEN];
58 	size_t			vn_addr_len;
59 	uint16_t		vn_vid;
60 	vrid_t			vn_vrid;
61 	int			vn_af;
62 	boolean_t		vn_force;
63 	datalink_id_t		vn_link_id;
64 	mac_notify_handle_t	vn_mnh;
65 
66 	uint32_t		vn_hcksum_txflags;
67 	mac_capab_lso_t		vn_cap_lso;
68 	uint32_t		vn_mtu;
69 	link_state_t		vn_ls;
70 } vnic_t;
71 
72 #define	vn_mch	vn_mc_handles[0]
73 #define	vn_muh	vn_mu_handles[0]
74 
75 extern int vnic_dev_create(datalink_id_t, datalink_id_t, vnic_mac_addr_type_t *,
76     int *, uchar_t *, int *, uint_t, uint16_t, vrid_t, int,
77     mac_resource_props_t *, uint32_t, vnic_ioc_diag_t *, cred_t *);
78 extern int vnic_dev_modify(datalink_id_t, uint_t, vnic_mac_addr_type_t,
79     uint_t, uchar_t *, uint_t, mac_resource_props_t *);
80 extern int vnic_dev_delete(datalink_id_t, uint32_t, cred_t *);
81 
82 extern void vnic_dev_init(void);
83 extern void vnic_dev_fini(void);
84 extern uint_t vnic_dev_count(void);
85 extern dev_info_t *vnic_get_dip(void);
86 
87 extern int vnic_info(vnic_info_t *, cred_t *);
88 
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _SYS_VNIC_IMPL_H */
94