xref: /illumos-gate/usr/src/uts/common/io/simnet/simnet_impl.h (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright 2019 Joyent, Inc.
25  */
26 
27 #ifndef	_SYS_SIMNET_IMPL_H
28 #define	_SYS_SIMNET_IMPL_H
29 
30 #include <sys/types.h>
31 #include <sys/list.h>
32 #include <sys/mutex.h>
33 #include <sys/mac.h>
34 #include <sys/net80211.h>
35 #include <inet/wifi_ioctl.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #define	MAX_SIMNET_ESSCONF	25	/* Max num of WiFi scan results */
42 #define	MAX_ESSLIST_ARGS	10	/* Max num of ESS list arguments */
43 #define	MAX_ESSLIST_ARGLEN	50	/* Max ESS list argument len */
44 
45 #define	SM_MAX_NUM_MCAST_ADDRS	1024
46 
47 struct simnet_dev;
48 
49 typedef struct simnet_wifidev {
50 	struct simnet_dev	*swd_sdev;
51 	wl_essid_t		swd_essid;
52 	wl_bssid_t		swd_bssid;
53 	wl_rssi_t		swd_rssi; /* signal strength */
54 	wl_linkstatus_t		swd_linkstatus;
55 	int			swd_esslist_num;
56 	wl_ess_conf_t		*swd_esslist[MAX_SIMNET_ESSCONF];
57 } simnet_wifidev_t;
58 
59 typedef struct simnet_stats {
60 	uint64_t		rbytes;
61 	uint64_t		obytes;
62 	uint64_t		xmit_errors;
63 	uint64_t		xmit_count;
64 	uint64_t		recv_count;
65 	uint64_t		recv_errors;
66 } simnet_stats_t;
67 
68 typedef struct simnet_dev {
69 	list_node_t		sd_listnode;
70 	uint_t			sd_type;	/* WiFi, Ethernet etc. */
71 	datalink_id_t		sd_link_id;
72 	zoneid_t		sd_zoneid;	/* zone where created */
73 	struct simnet_dev	*sd_peer_dev;	/* Attached peer, if any */
74 	uint_t			sd_flags;	/* Device flags SDF_* */
75 	uint_t			sd_refcount;
76 	/* Num of active threads using the device */
77 	uint_t			sd_threadcount;
78 	kcondvar_t		sd_threadwait;
79 	mac_handle_t		sd_mh;
80 	simnet_wifidev_t	*sd_wifidev;
81 	boolean_t		sd_promisc;
82 	kmutex_t		sd_instlock;
83 	/* Num of multicast addresses stored in sd_mcastaddrs */
84 	uint_t			sd_mcastaddr_count;
85 	/* Multicast address list stored in single buffer */
86 	struct ether_addr	sd_mcastaddrs[SM_MAX_NUM_MCAST_ADDRS];
87 	uint_t			sd_mac_len;
88 	uchar_t			sd_mac_addr[MAXMACADDRLEN];
89 	simnet_stats_t		sd_stats;
90 	link_state_t		sd_ls;
91 
92 	/* Capabilities */
93 	uint_t			sd_rx_cksum;
94 	uint_t			sd_tx_cksum;
95 	boolean_t		sd_lso;
96 } simnet_dev_t;
97 
98 /* Simnet dladm private properties. */
99 #define	SD_PROP_RX_IP_CKSUM	"_rx_ipv4_cksum"
100 #define	SD_PROP_TX_ULP_CKSUM	"_tx_ulp_cksum"
101 #define	SD_PROP_TX_IP_CKSUM	"_tx_ipv4_cksum"
102 #define	SD_PROP_LSO		"_lso"
103 #define	SD_PROP_LINKSTATE	"_linkstate"
104 
105 /* Simnet device flags */
106 #define	SDF_SHUTDOWN	0x00000001	/* Device shutdown, no new ops */
107 #define	SDF_STARTED	0x00000002	/* Device started, allow ops */
108 
109 #define	SIMNET_MAX_MTU	9000		/* Max MTU supported by simnet driver */
110 #define	SD_LSO_MAXLEN	65535		/* Max LSO supported by simnet driver */
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif /* _SYS_SIMNET_IMPL_H */
117