xref: /titanic_53/usr/src/uts/sun4v/sys/vsw.h (revision ba2e4443695ee6a6f420a35cd4fc3d3346d22932)
11ae08745Sheppo /*
21ae08745Sheppo  * CDDL HEADER START
31ae08745Sheppo  *
41ae08745Sheppo  * The contents of this file are subject to the terms of the
51ae08745Sheppo  * Common Development and Distribution License (the "License").
61ae08745Sheppo  * You may not use this file except in compliance with the License.
71ae08745Sheppo  *
81ae08745Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91ae08745Sheppo  * or http://www.opensolaris.org/os/licensing.
101ae08745Sheppo  * See the License for the specific language governing permissions
111ae08745Sheppo  * and limitations under the License.
121ae08745Sheppo  *
131ae08745Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
141ae08745Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151ae08745Sheppo  * If applicable, add the following below this CDDL HEADER, with the
161ae08745Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
171ae08745Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
181ae08745Sheppo  *
191ae08745Sheppo  * CDDL HEADER END
201ae08745Sheppo  */
211ae08745Sheppo 
221ae08745Sheppo /*
231ae08745Sheppo  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
241ae08745Sheppo  * Use is subject to license terms.
251ae08745Sheppo  */
261ae08745Sheppo 
271ae08745Sheppo /*
281ae08745Sheppo  * This header file contains the basic data structures which the
291ae08745Sheppo  * virtual switch (vsw) uses to communicate with its clients and
301ae08745Sheppo  * the outside world.
311ae08745Sheppo  *
321ae08745Sheppo  * The virtual switch reads the machine description (MD) to
331ae08745Sheppo  * determine how many port_t structures to create (each port_t
341ae08745Sheppo  * can support communications to a single network device). The
351ae08745Sheppo  * port_t's are maintained in a linked list.
361ae08745Sheppo  *
371ae08745Sheppo  * Each port in turn contains a number of logical domain channels
381ae08745Sheppo  * (ldc's) which are inter domain communications channels which
391ae08745Sheppo  * are used for passing small messages between the domains. Their
401ae08745Sheppo  * may be an unlimited number of channels associated with each port,
411ae08745Sheppo  * though most devices only use a single channel.
421ae08745Sheppo  *
431ae08745Sheppo  * The ldc is a bi-directional channel, which is divided up into
441ae08745Sheppo  * two directional 'lanes', one outbound from the switch to the
451ae08745Sheppo  * virtual network device, the other inbound to the switch.
461ae08745Sheppo  * Depending on the type of device each lane may have seperate
471ae08745Sheppo  * communication paramaters (such as mtu etc).
481ae08745Sheppo  *
491ae08745Sheppo  * For those network clients which use descriptor rings the
501ae08745Sheppo  * rings are associated with the appropriate lane. I.e. rings
511ae08745Sheppo  * which the switch exports are associated with the outbound lanes
521ae08745Sheppo  * while those which the network clients are exporting to the switch
531ae08745Sheppo  * are associated with the inbound lane.
541ae08745Sheppo  *
551ae08745Sheppo  * In diagram form the data structures look as follows:
561ae08745Sheppo  *
571ae08745Sheppo  * vsw instance
581ae08745Sheppo  *     |
591ae08745Sheppo  *     +----->port_t----->port_t----->port_t----->
601ae08745Sheppo  *		|
611ae08745Sheppo  *		+--->ldc_t--->ldc_t--->ldc_t--->
621ae08745Sheppo  *		       |
631ae08745Sheppo  *		       +--->lane_t (inbound)
641ae08745Sheppo  *		       |       |
651ae08745Sheppo  *		       |       +--->dring--->dring--->
661ae08745Sheppo  *		       |
671ae08745Sheppo  *		       +--->lane_t (outbound)
681ae08745Sheppo  *			       |
691ae08745Sheppo  *			       +--->dring--->dring--->
701ae08745Sheppo  *
711ae08745Sheppo  */
721ae08745Sheppo 
731ae08745Sheppo #ifndef	_VSW_H
741ae08745Sheppo #define	_VSW_H
751ae08745Sheppo 
761ae08745Sheppo #pragma ident	"%Z%%M%	%I%	%E% SMI"
771ae08745Sheppo 
781ae08745Sheppo #ifdef	__cplusplus
791ae08745Sheppo extern "C" {
801ae08745Sheppo #endif
811ae08745Sheppo 
821ae08745Sheppo #include <sys/vio_mailbox.h>
831ae08745Sheppo #include <sys/vnet_common.h>
841ae08745Sheppo #include <sys/ethernet.h>
851ae08745Sheppo 
861ae08745Sheppo /*
871ae08745Sheppo  * Default message type.
881ae08745Sheppo  */
891ae08745Sheppo typedef struct def_msg {
901ae08745Sheppo 	uint64_t	data[8];
911ae08745Sheppo } def_msg_t;
921ae08745Sheppo 
931ae08745Sheppo /*
941ae08745Sheppo  * Currently only support one major/minor pair.
951ae08745Sheppo  */
961ae08745Sheppo #define	VSW_NUM_VER	1
971ae08745Sheppo 
981ae08745Sheppo typedef struct ver_sup {
991ae08745Sheppo 	uint32_t	ver_major:16,
1001ae08745Sheppo 			ver_minor:16;
1011ae08745Sheppo } ver_sup_t;
1021ae08745Sheppo 
1031ae08745Sheppo /*
1041ae08745Sheppo  * Only support ETHER mtu at moment.
1051ae08745Sheppo  */
1061ae08745Sheppo #define	VSW_MTU		ETHERMAX
1071ae08745Sheppo 
1081ae08745Sheppo /*
1091ae08745Sheppo  * Lane states.
1101ae08745Sheppo  */
1111ae08745Sheppo #define	VSW_LANE_INACTIV	0x0	/* No params set for lane */
1121ae08745Sheppo 
1131ae08745Sheppo #define	VSW_VER_INFO_SENT	0x1	/* Version # sent to peer */
1141ae08745Sheppo #define	VSW_VER_INFO_RECV	0x2	/* Version # recv from peer */
1151ae08745Sheppo #define	VSW_VER_ACK_RECV	0x4
1161ae08745Sheppo #define	VSW_VER_ACK_SENT	0x8
1171ae08745Sheppo #define	VSW_VER_NACK_RECV	0x10
1181ae08745Sheppo #define	VSW_VER_NACK_SENT	0x20
1191ae08745Sheppo 
1201ae08745Sheppo #define	VSW_ATTR_INFO_SENT	0x40	/* Attributes sent to peer */
1211ae08745Sheppo #define	VSW_ATTR_INFO_RECV	0x80	/* Peer attributes received */
1221ae08745Sheppo #define	VSW_ATTR_ACK_SENT	0x100
1231ae08745Sheppo #define	VSW_ATTR_ACK_RECV	0x200
1241ae08745Sheppo #define	VSW_ATTR_NACK_SENT	0x400
1251ae08745Sheppo #define	VSW_ATTR_NACK_RECV	0x800
1261ae08745Sheppo 
1271ae08745Sheppo #define	VSW_DRING_INFO_SENT	0x1000	/* Dring info sent to peer */
1281ae08745Sheppo #define	VSW_DRING_INFO_RECV	0x2000	/* Dring info received */
1291ae08745Sheppo #define	VSW_DRING_ACK_SENT	0x4000
1301ae08745Sheppo #define	VSW_DRING_ACK_RECV	0x8000
1311ae08745Sheppo #define	VSW_DRING_NACK_SENT	0x10000
1321ae08745Sheppo #define	VSW_DRING_NACK_RECV	0x20000
1331ae08745Sheppo 
1341ae08745Sheppo #define	VSW_RDX_INFO_SENT	0x40000	/* RDX sent to peer */
1351ae08745Sheppo #define	VSW_RDX_INFO_RECV	0x80000	/* RDX received from peer */
1361ae08745Sheppo #define	VSW_RDX_ACK_SENT	0x100000
1371ae08745Sheppo #define	VSW_RDX_ACK_RECV	0x200000
1381ae08745Sheppo #define	VSW_RDX_NACK_SENT	0x400000
1391ae08745Sheppo #define	VSW_RDX_NACK_RECV	0x800000
1401ae08745Sheppo 
1411ae08745Sheppo #define	VSW_MCST_INFO_SENT	0x1000000
1421ae08745Sheppo #define	VSW_MCST_INFO_RECV	0x2000000
1431ae08745Sheppo #define	VSW_MCST_ACK_SENT	0x4000000
1441ae08745Sheppo #define	VSW_MCST_ACK_RECV	0x8000000
1451ae08745Sheppo #define	VSW_MCST_NACK_SENT	0x10000000
1461ae08745Sheppo #define	VSW_MCST_NACK_RECV	0x20000000
1471ae08745Sheppo 
1481ae08745Sheppo #define	VSW_LANE_ACTIVE		0x40000000	/* Lane open to xmit data */
1491ae08745Sheppo 
1501ae08745Sheppo /* Handshake milestones */
1511ae08745Sheppo #define	VSW_MILESTONE0		0x1	/* ver info exchanged */
1521ae08745Sheppo #define	VSW_MILESTONE1		0x2	/* attribute exchanged */
1531ae08745Sheppo #define	VSW_MILESTONE2		0x4	/* dring info exchanged */
1541ae08745Sheppo #define	VSW_MILESTONE3		0x8	/* rdx exchanged */
1551ae08745Sheppo #define	VSW_MILESTONE4		0x10	/* handshake complete */
1561ae08745Sheppo 
1571ae08745Sheppo /*
1581ae08745Sheppo  * Lane direction (relative to ourselves).
1591ae08745Sheppo  */
1601ae08745Sheppo #define	INBOUND			0x1
1611ae08745Sheppo #define	OUTBOUND		0x2
1621ae08745Sheppo 
1631ae08745Sheppo /* Peer session id received */
1641ae08745Sheppo #define	VSW_PEER_SESSION	0x1
1651ae08745Sheppo 
1661ae08745Sheppo /*
1671ae08745Sheppo  * Maximum number of consecutive reads of data from channel
1681ae08745Sheppo  */
1691ae08745Sheppo #define	VSW_MAX_CHAN_READ	50
1701ae08745Sheppo 
1711ae08745Sheppo /*
1721ae08745Sheppo  * LDC queue length
1731ae08745Sheppo  */
1741ae08745Sheppo #define	VSW_LDC_QLEN		1024
1751ae08745Sheppo 
1761ae08745Sheppo /*
1771ae08745Sheppo  * Currently only support one ldc per port.
1781ae08745Sheppo  */
1791ae08745Sheppo #define	VSW_PORT_MAX_LDCS	1	/* max # of ldcs per port */
1801ae08745Sheppo 
1811ae08745Sheppo /*
1821ae08745Sheppo  * Used for port add/deletion.
1831ae08745Sheppo  */
1841ae08745Sheppo #define	VSW_PORT_UPDATED	0x1
1851ae08745Sheppo 
1861ae08745Sheppo #define	LDC_TX_SUCCESS		0	/* ldc transmit success */
1871ae08745Sheppo #define	LDC_TX_FAILURE		1	/* ldc transmit failure */
1881ae08745Sheppo #define	LDC_TX_NORESOURCES	2	/* out of descriptors */
1891ae08745Sheppo 
1901ae08745Sheppo /* ID of the source of a frame being switched */
1911ae08745Sheppo #define	VSW_PHYSDEV		1	/* physical device associated */
1921ae08745Sheppo #define	VSW_VNETPORT		2	/* port connected to vnet (over ldc) */
1931ae08745Sheppo #define	VSW_LOCALDEV		4	/* vsw configured as an eth interface */
1941ae08745Sheppo 
1951ae08745Sheppo /*
1961ae08745Sheppo  * Descriptor ring info
1971ae08745Sheppo  *
1981ae08745Sheppo  * Each descriptor element has a pre-allocated data buffer
1991ae08745Sheppo  * associated with it, into which data being transmitted is
2001ae08745Sheppo  * copied. By pre-allocating we speed up the copying process.
2011ae08745Sheppo  * The buffer is re-used once the peer has indicated that it is
2021ae08745Sheppo  * finished with the descriptor.
2031ae08745Sheppo  */
2041ae08745Sheppo #define	VSW_RING_NUM_EL		512	/* Num of entries in ring */
2051ae08745Sheppo #define	VSW_RING_EL_DATA_SZ	2048	/* Size of data section (bytes) */
2061ae08745Sheppo #define	VSW_PRIV_SIZE	sizeof (vnet_private_desc_t)
2071ae08745Sheppo #define	VSW_PUB_SIZE	sizeof (vnet_public_desc_t)
2081ae08745Sheppo 
2091ae08745Sheppo #define	VSW_MAX_COOKIES		((ETHERMTU >> MMU_PAGESHIFT) + 2)
2101ae08745Sheppo 
2111ae08745Sheppo /*
2121ae08745Sheppo  * Private descriptor
2131ae08745Sheppo  */
2141ae08745Sheppo typedef struct vsw_private_desc {
2151ae08745Sheppo 	uint64_t		dstate;
2161ae08745Sheppo 	vnet_public_desc_t	*descp;
2171ae08745Sheppo 	ldc_mem_handle_t	memhandle;
2181ae08745Sheppo 	void			*datap;
2191ae08745Sheppo 	uint64_t		datalen;
2201ae08745Sheppo 	uint64_t		ncookies;
2211ae08745Sheppo 	ldc_mem_cookie_t	memcookie[VSW_MAX_COOKIES];
2221ae08745Sheppo 	int			bound;
2231ae08745Sheppo } vsw_private_desc_t;
2241ae08745Sheppo 
2251ae08745Sheppo /*
2261ae08745Sheppo  * Descriptor ring structure
2271ae08745Sheppo  */
2281ae08745Sheppo typedef struct dring_info {
2291ae08745Sheppo 	struct	dring_info	*next;	/* next ring in chain */
2301ae08745Sheppo 	kmutex_t		dlock;
2311ae08745Sheppo 	uint32_t		num_descriptors;
2321ae08745Sheppo 	uint32_t		descriptor_size;
2331ae08745Sheppo 	uint32_t		options;
2341ae08745Sheppo 	uint32_t		ncookies;
2351ae08745Sheppo 	ldc_mem_cookie_t	cookie[1];
2361ae08745Sheppo 
2371ae08745Sheppo 	ldc_dring_handle_t	handle;
2381ae08745Sheppo 	uint64_t		ident;	/* identifier sent to peer */
2391ae08745Sheppo 	uint64_t		end_idx;	/* last idx processed */
2401ae08745Sheppo 
2411ae08745Sheppo 	/*
2421ae08745Sheppo 	 * base address of private and public portions of the
2431ae08745Sheppo 	 * ring (where appropriate), and data block.
2441ae08745Sheppo 	 */
2451ae08745Sheppo 	void			*pub_addr;	/* base of public section */
2461ae08745Sheppo 	void			*priv_addr;	/* base of private section */
2471ae08745Sheppo 	void			*data_addr;	/* base of data section */
2481ae08745Sheppo 	size_t			data_sz;	/* size of data section */
2491ae08745Sheppo } dring_info_t;
2501ae08745Sheppo 
2511ae08745Sheppo /*
2521ae08745Sheppo  * Each ldc connection is comprised of two lanes, incoming
2531ae08745Sheppo  * from a peer, and outgoing to that peer. Each lane shares
2541ae08745Sheppo  * common ldc parameters and also has private lane-specific
2551ae08745Sheppo  * parameters.
2561ae08745Sheppo  */
2571ae08745Sheppo typedef struct lane {
2581ae08745Sheppo 	uint64_t	lstate;		/* Lane state */
2591ae08745Sheppo 	uint32_t	ver_major:16,	/* Version major number */
2601ae08745Sheppo 			ver_minor:16;	/* Version minor number */
2611ae08745Sheppo 	uint64_t	seq_num;	/* Sequence number */
2621ae08745Sheppo 	uint64_t	mtu;		/* ETHERMTU */
2631ae08745Sheppo 	uint64_t	addr;		/* Unique physical address */
2641ae08745Sheppo 	uint8_t		addr_type;	/* Only MAC address at moment */
2651ae08745Sheppo 	uint8_t		xfer_mode;	/* Dring or Pkt based */
2661ae08745Sheppo 	uint8_t		ack_freq;	/* Only non zero for Pkt based xfer */
2671ae08745Sheppo 	dring_info_t	*dringp;	/* List of drings for this lane */
2681ae08745Sheppo } lane_t;
2691ae08745Sheppo 
2701ae08745Sheppo /* channel drain states */
2711ae08745Sheppo #define	VSW_LDC_INIT		0x1	/* Initial non-drain state */
2721ae08745Sheppo #define	VSW_LDC_DRAINING	0x2	/* Channel draining */
2731ae08745Sheppo 
2741ae08745Sheppo /* ldc information associated with a vsw-port */
2751ae08745Sheppo typedef struct vsw_ldc {
2761ae08745Sheppo 	struct vsw_ldc		*ldc_next;	/* next ldc in the list */
2771ae08745Sheppo 	struct vsw_port		*ldc_port;	/* associated port */
2781ae08745Sheppo 	struct vsw		*ldc_vswp;	/* associated vsw */
2791ae08745Sheppo 	kmutex_t		ldc_cblock;	/* sync callback processing */
2801ae08745Sheppo 	kmutex_t		ldc_txlock;	/* sync transmits */
2811ae08745Sheppo 	uint64_t		ldc_id;		/* channel number */
2821ae08745Sheppo 	ldc_handle_t		ldc_handle;	/* channel handle */
2831ae08745Sheppo 	kmutex_t		drain_cv_lock;
2841ae08745Sheppo 	kcondvar_t		drain_cv;	/* channel draining */
2851ae08745Sheppo 	int			drain_state;
2861ae08745Sheppo 	uint32_t		hphase;		/* handshake phase */
2871ae08745Sheppo 	int			hcnt;		/* # handshake attempts */
2881ae08745Sheppo 	ldc_status_t		ldc_status;	/* channel status */
2891ae08745Sheppo 	uint64_t		local_session;	/* Our session id */
2901ae08745Sheppo 	uint64_t		peer_session;	/* Our peers session id */
2911ae08745Sheppo 	uint8_t			session_status;	/* Session recv'd, sent */
2921ae08745Sheppo 	kmutex_t		hss_lock;
2931ae08745Sheppo 	uint32_t		hss_id;		/* Handshake session id */
2941ae08745Sheppo 	uint64_t		next_ident;	/* Next dring ident # to use */
2951ae08745Sheppo 	lane_t			lane_in;	/* Inbound lane */
2961ae08745Sheppo 	lane_t			lane_out;	/* Outbound lane */
2971ae08745Sheppo 	uint8_t			dev_class;	/* Peer device class */
2981ae08745Sheppo } vsw_ldc_t;
2991ae08745Sheppo 
3001ae08745Sheppo /* list of ldcs per port */
3011ae08745Sheppo typedef struct vsw_ldc_list {
3021ae08745Sheppo 	vsw_ldc_t	*head;		/* head of the list */
3031ae08745Sheppo 	krwlock_t	lockrw;		/* sync access(rw) to the list */
3041ae08745Sheppo 	int		num_ldcs;	/* number of ldcs in the list */
3051ae08745Sheppo } vsw_ldc_list_t;
3061ae08745Sheppo 
3071ae08745Sheppo /* multicast addresses port is interested in */
3081ae08745Sheppo typedef struct mcst_addr {
3091ae08745Sheppo 	struct mcst_addr	*nextp;
3101ae08745Sheppo 	uint64_t		addr;
3111ae08745Sheppo } mcst_addr_t;
3121ae08745Sheppo 
3131ae08745Sheppo /* Port detach states */
3141ae08745Sheppo #define	VSW_PORT_INIT		0x1	/* Initial non-detach state */
3151ae08745Sheppo #define	VSW_PORT_DETACHING	0x2	/* In process of being detached */
3161ae08745Sheppo #define	VSW_PORT_DETACHABLE	0x4	/* Safe to detach */
3171ae08745Sheppo 
3181ae08745Sheppo /* port information associated with a vsw */
3191ae08745Sheppo typedef struct vsw_port {
3201ae08745Sheppo 	int			p_instance;	/* port instance */
3211ae08745Sheppo 	struct vsw_port		*p_next;	/* next port in the list */
3221ae08745Sheppo 	struct vsw		*p_vswp;	/* associated vsw */
3231ae08745Sheppo 	vsw_ldc_list_t		p_ldclist;	/* list of ldcs for this port */
3241ae08745Sheppo 
3251ae08745Sheppo 	kmutex_t		tx_lock;	/* transmit lock */
3261ae08745Sheppo 	int			(*transmit)(vsw_ldc_t *, mblk_t *);
3271ae08745Sheppo 
3281ae08745Sheppo 	int			state;		/* port state */
3291ae08745Sheppo 	kmutex_t		state_lock;
3301ae08745Sheppo 	kcondvar_t		state_cv;
3311ae08745Sheppo 
3321ae08745Sheppo 	int			ref_cnt;	/* # of active references */
3331ae08745Sheppo 	kmutex_t		ref_lock;
3341ae08745Sheppo 	kcondvar_t		ref_cv;
3351ae08745Sheppo 
3361ae08745Sheppo 	kmutex_t		mca_lock;	/* multicast lock */
3371ae08745Sheppo 	mcst_addr_t		*mcap;		/* list of multicast addrs */
3381ae08745Sheppo 
3391ae08745Sheppo 	/*
3401ae08745Sheppo 	 * mac address of the port & connected device
3411ae08745Sheppo 	 */
3421ae08745Sheppo 	struct ether_addr	p_macaddr;
3431ae08745Sheppo } vsw_port_t;
3441ae08745Sheppo 
3451ae08745Sheppo /* list of ports per vsw */
3461ae08745Sheppo typedef struct vsw_port_list {
3471ae08745Sheppo 	vsw_port_t	*head;		/* head of the list */
3481ae08745Sheppo 	krwlock_t	lockrw;		/* sync access(rw) to the list */
3491ae08745Sheppo 	int		num_ports;	/* number of ports in the list */
3501ae08745Sheppo } vsw_port_list_t;
3511ae08745Sheppo 
3521ae08745Sheppo /*
3531ae08745Sheppo  * Taskq control message
3541ae08745Sheppo  */
3551ae08745Sheppo typedef struct vsw_ctrl_task {
3561ae08745Sheppo 	vsw_ldc_t	*ldcp;
3571ae08745Sheppo 	def_msg_t	pktp;
3581ae08745Sheppo 	uint32_t	hss_id;
3591ae08745Sheppo } vsw_ctrl_task_t;
3601ae08745Sheppo 
3611ae08745Sheppo /*
3621ae08745Sheppo  * Number of hash chains in the multicast forwarding database.
3631ae08745Sheppo  */
3641ae08745Sheppo #define		VSW_NCHAINS	8
3651ae08745Sheppo 
3661ae08745Sheppo /*
3671ae08745Sheppo  * State of interface if switch plumbed as network device.
3681ae08745Sheppo  */
369*ba2e4443Sseb #define		VSW_IF_REG	0x1	/* interface was registered */
370*ba2e4443Sseb #define		VSW_IF_UP	0x2	/* Interface UP */
371*ba2e4443Sseb #define		VSW_IF_PROMISC	0x4	/* Interface in promiscious mode */
3721ae08745Sheppo 
3731ae08745Sheppo #define		VSW_U_P(state)	\
3741ae08745Sheppo 			(state == (VSW_IF_UP | VSW_IF_PROMISC))
3751ae08745Sheppo 
3761ae08745Sheppo /*
3771ae08745Sheppo  * Switching modes.
3781ae08745Sheppo  */
3791ae08745Sheppo #define		VSW_LAYER2		0x1	/* Layer 2 - MAC switching */
3801ae08745Sheppo #define		VSW_LAYER2_PROMISC	0x2	/* Layer 2 + promisc mode */
3811ae08745Sheppo #define		VSW_LAYER3		0x4	/* Layer 3 - IP switching */
3821ae08745Sheppo 
3831ae08745Sheppo #define		NUM_SMODES	3	/* number of switching modes */
3841ae08745Sheppo 
3851ae08745Sheppo /*
3861ae08745Sheppo  * Bits indicating which properties we've read from MD.
3871ae08745Sheppo  */
3881ae08745Sheppo #define		VSW_MD_PHYSNAME	0x1
3891ae08745Sheppo #define		VSW_MD_MACADDR	0x2
3901ae08745Sheppo #define		VSW_MD_SMODE	0x4
3911ae08745Sheppo 
3921ae08745Sheppo /*
3931ae08745Sheppo  * vsw instance state information.
3941ae08745Sheppo  */
3951ae08745Sheppo typedef struct	vsw {
3961ae08745Sheppo 	int			instance;	/* instance # */
3971ae08745Sheppo 	dev_info_t		*dip;		/* associated dev_info */
3981ae08745Sheppo 	struct vsw		*next;		/* next in list */
3991ae08745Sheppo 	char			physname[LIFNAMSIZ];	/* phys-dev */
4001ae08745Sheppo 	uint8_t			smode[NUM_SMODES];	/* switching mode */
4011ae08745Sheppo 	int			smode_idx;	/* curr pos in smode array */
4021ae08745Sheppo 	uint8_t			mdprops;	/* bitmask of props found */
4031ae08745Sheppo 	vsw_port_list_t		plist;		/* associated ports */
4041ae08745Sheppo 	ddi_taskq_t		*taskq_p;	/* VIO ctrl msg taskq */
4051ae08745Sheppo 	mod_hash_t		*fdb;		/* forwarding database */
4061ae08745Sheppo 
4071ae08745Sheppo 	mod_hash_t		*mfdb;		/* multicast FDB */
4081ae08745Sheppo 	krwlock_t		mfdbrw;		/* rwlock for mFDB */
4091ae08745Sheppo 
4101ae08745Sheppo 	/* mac layer */
4111ae08745Sheppo 	mac_handle_t		mh;
4121ae08745Sheppo 	mac_rx_handle_t		mrh;
4131ae08745Sheppo 	mac_notify_handle_t	mnh;
4141ae08745Sheppo 	const mac_txinfo_t	*txinfo;	/* MAC tx routine */
4151ae08745Sheppo 
4161ae08745Sheppo 	/* Initial promisc setting of interface */
4171ae08745Sheppo 	boolean_t		init_promisc;
4181ae08745Sheppo 
4191ae08745Sheppo 	/* Machine Description updates  */
4201ae08745Sheppo 	mdeg_node_spec_t	*inst_spec;
4211ae08745Sheppo 	mdeg_handle_t		mdeg_hdl;
4221ae08745Sheppo 
4231ae08745Sheppo 	/* if configured as an ethernet interface */
424*ba2e4443Sseb 	mac_handle_t		if_mh;		/* MAC handle */
4251ae08745Sheppo 	struct ether_addr	if_addr;	/* interface address */
4261ae08745Sheppo 	krwlock_t		if_lockrw;
4271ae08745Sheppo 	uint8_t			if_state;	/* interface state */
4281ae08745Sheppo 
4291ae08745Sheppo 	/* multicast addresses when configured as eth interface */
4301ae08745Sheppo 	kmutex_t		mca_lock;	/* multicast lock */
4311ae08745Sheppo 	mcst_addr_t		*mcap;		/* list of multicast addrs */
4321ae08745Sheppo } vsw_t;
4331ae08745Sheppo 
4341ae08745Sheppo 
4351ae08745Sheppo /*
4361ae08745Sheppo  * Ethernet broadcast address definition.
4371ae08745Sheppo  */
4381ae08745Sheppo static	struct	ether_addr	etherbroadcastaddr = {
4391ae08745Sheppo 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
4401ae08745Sheppo };
4411ae08745Sheppo 
4421ae08745Sheppo #define	IS_BROADCAST(ehp) \
4431ae08745Sheppo 	(ether_cmp(&ehp->ether_dhost, &etherbroadcastaddr) == 0)
4441ae08745Sheppo #define	IS_MULTICAST(ehp) \
4451ae08745Sheppo 	((ehp->ether_dhost.ether_addr_octet[0] & 01) == 1)
4461ae08745Sheppo 
4471ae08745Sheppo #define	READ_ENTER(x)	rw_enter(x, RW_READER)
4481ae08745Sheppo #define	WRITE_ENTER(x)	rw_enter(x, RW_WRITER)
4491ae08745Sheppo #define	RW_EXIT(x)	rw_exit(x)
4501ae08745Sheppo 
4511ae08745Sheppo #ifdef	__cplusplus
4521ae08745Sheppo }
4531ae08745Sheppo #endif
4541ae08745Sheppo 
4551ae08745Sheppo #endif	/* _VSW_H */
456