summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/simnet/simnet_impl.h
blob: 50f611697fb16c668c53aca7cadc1f325f148d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2019 Joyent, Inc.
 */

#ifndef	_SYS_SIMNET_IMPL_H
#define	_SYS_SIMNET_IMPL_H

#include <sys/types.h>
#include <sys/list.h>
#include <sys/mutex.h>
#include <sys/mac.h>
#include <sys/net80211.h>
#include <inet/wifi_ioctl.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	MAX_SIMNET_ESSCONF	25	/* Max num of WiFi scan results */
#define	MAX_ESSLIST_ARGS	10	/* Max num of ESS list arguments */
#define	MAX_ESSLIST_ARGLEN	50	/* Max ESS list argument len */

#define	SM_MAX_NUM_MCAST_ADDRS	1024

struct simnet_dev;

typedef struct simnet_wifidev {
	struct simnet_dev	*swd_sdev;
	wl_essid_t		swd_essid;
	wl_bssid_t		swd_bssid;
	wl_rssi_t		swd_rssi; /* signal strength */
	wl_linkstatus_t		swd_linkstatus;
	int			swd_esslist_num;
	wl_ess_conf_t		*swd_esslist[MAX_SIMNET_ESSCONF];
} simnet_wifidev_t;

typedef struct simnet_stats {
	uint64_t		rbytes;
	uint64_t		obytes;
	uint64_t		xmit_errors;
	uint64_t		xmit_count;
	uint64_t		recv_count;
	uint64_t		recv_errors;
} simnet_stats_t;

typedef struct simnet_dev {
	list_node_t		sd_listnode;
	uint_t			sd_type;	/* WiFi, Ethernet etc. */
	datalink_id_t		sd_link_id;
	zoneid_t		sd_zoneid;	/* zone where created */
	struct simnet_dev	*sd_peer_dev;	/* Attached peer, if any */
	uint_t			sd_flags;	/* Device flags SDF_* */
	uint_t			sd_refcount;
	/* Num of active threads using the device */
	uint_t			sd_threadcount;
	kcondvar_t		sd_threadwait;
	mac_handle_t		sd_mh;
	simnet_wifidev_t	*sd_wifidev;
	boolean_t		sd_promisc;
	kmutex_t		sd_instlock;
	/* Num of multicast addresses stored in sd_mcastaddrs */
	uint_t			sd_mcastaddr_count;
	/* Multicast address list stored in single buffer */
	struct ether_addr	sd_mcastaddrs[SM_MAX_NUM_MCAST_ADDRS];
	uint_t			sd_mac_len;
	uchar_t			sd_mac_addr[MAXMACADDRLEN];
	simnet_stats_t		sd_stats;

	/* Capabilities */
	uint_t			sd_rx_cksum;
	uint_t			sd_tx_cksum;
	boolean_t		sd_lso;
} simnet_dev_t;

/* Simnet dladm private properties. */
#define	SD_PROP_RX_IP_CKSUM	"_rx_ipv4_cksum"
#define	SD_PROP_TX_ULP_CKSUM	"_tx_ulp_cksum"
#define	SD_PROP_TX_IP_CKSUM	"_tx_ipv4_cksum"
#define	SD_PROP_LSO		"_lso"

/* Simnet device flags */
#define	SDF_SHUTDOWN	0x00000001	/* Device shutdown, no new ops */
#define	SDF_STARTED	0x00000002	/* Device started, allow ops */

#define	SIMNET_MAX_MTU	9000		/* Max MTU supported by simnet driver */
#define	SD_LSO_MAXLEN	65535		/* Max LSO supported by simnet driver */

#ifdef	__cplusplus
}
#endif

#endif /* _SYS_SIMNET_IMPL_H */