xref: /illumos-gate/usr/src/uts/sun4v/sys/vsw_fdb.h (revision c1c61f44)
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 /*
23*c1c61f44Ssb  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
241ae08745Sheppo  * Use is subject to license terms.
251ae08745Sheppo  */
261ae08745Sheppo 
271ae08745Sheppo #ifndef	_VSW_FDB_H
281ae08745Sheppo #define	_VSW_FDB_H
291ae08745Sheppo 
301ae08745Sheppo #pragma ident	"%Z%%M%	%I%	%E% SMI"
311ae08745Sheppo 
321ae08745Sheppo #ifdef	__cplusplus
331ae08745Sheppo extern "C" {
341ae08745Sheppo #endif
351ae08745Sheppo 
361ae08745Sheppo /*
371ae08745Sheppo  * Convert ethernet (mac) address to hash table key.
381ae08745Sheppo  */
391ae08745Sheppo #define	KEY_HASH(key, addr) \
40*c1c61f44Ssb 	(key = ((((uint64_t)(addr)->ether_addr_octet[0]) << 40) | \
41*c1c61f44Ssb 	(((uint64_t)(addr)->ether_addr_octet[1]) << 32) | \
42*c1c61f44Ssb 	(((uint64_t)(addr)->ether_addr_octet[2]) << 24) | \
43*c1c61f44Ssb 	(((uint64_t)(addr)->ether_addr_octet[3]) << 16) | \
44*c1c61f44Ssb 	(((uint64_t)(addr)->ether_addr_octet[4]) << 8) | \
45*c1c61f44Ssb 	((uint64_t)(addr)->ether_addr_octet[5])));
46*c1c61f44Ssb 
47*c1c61f44Ssb #define	VLAN_ID_KEY(key)	((mod_hash_key_t)(uintptr_t)(key))
481ae08745Sheppo 
491ae08745Sheppo /*
501ae08745Sheppo  * Multicast forwarding database (mFDB) is a hashtable
511ae08745Sheppo  * keyed off the mac address, with the value being a linked
521ae08745Sheppo  * list of mfdb_ent_t structures, each of which is a destination
531ae08745Sheppo  * (either a vsw_port or the vsw instance itself when plumbed as
541ae08745Sheppo  * a network device) to which the multicast pkt should be forwarded.
551ae08745Sheppo  */
561ae08745Sheppo typedef struct mfdb_ent {
571ae08745Sheppo 	struct mfdb_ent		*nextp;		/* next entry in list */
581ae08745Sheppo 	void			*d_addr;	/* address of dest */
591ae08745Sheppo 	uint8_t			d_type;		/* destination type */
601ae08745Sheppo } mfdb_ent_t;
611ae08745Sheppo 
62*c1c61f44Ssb /*
63*c1c61f44Ssb  * Forwarding database entry. Each member port of a vsw will have an entry in
64*c1c61f44Ssb  * the vsw's fdb. Ref count is bumped up while sending a packet destined to a
65*c1c61f44Ssb  * port corresponding to the fdb entry.
66*c1c61f44Ssb  */
67*c1c61f44Ssb typedef struct vsw_fdbe {
68*c1c61f44Ssb 	void		*portp;	/* pointer to the vnet_port */
69*c1c61f44Ssb 	uint32_t	refcnt;	/* reference count */
70*c1c61f44Ssb } vsw_fdbe_t;
71*c1c61f44Ssb 
721ae08745Sheppo #ifdef	__cplusplus
731ae08745Sheppo }
741ae08745Sheppo #endif
751ae08745Sheppo 
761ae08745Sheppo #endif	/* _VSW_FDB_H */
77