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 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _VNET_H 28 #define _VNET_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #define VNET_SUCCESS (0) /* successful return */ 37 #define VNET_FAILURE (-1) /* unsuccessful return */ 38 39 #define KMEM_FREE(_p) kmem_free((_p), sizeof (*(_p))) 40 41 #define VNET_NTXDS 512 /* power of 2 tx descriptors */ 42 #define VNET_LDCWD_INTERVAL 1000 /* watchdog freq in msec */ 43 #define VNET_LDCWD_TXTIMEOUT 1000 /* tx timeout in msec */ 44 #define VNET_LDC_MTU 64 /* ldc mtu */ 45 #define VNET_NRBUFS 512 /* number of receive bufs */ 46 47 /* 48 * vnet proxy transport layer information. There is one instance of this for 49 * every transport being used by a vnet device and a list of these transports 50 * is maintained by vnet. 51 */ 52 typedef struct vp_tl { 53 struct vp_tl *nextp; /* next in list */ 54 mac_register_t *macp; /* transport ops */ 55 char name[LIFNAMSIZ]; /* device name */ 56 major_t major; /* driver major # */ 57 uint_t instance; /* dev instance */ 58 } vp_tl_t; 59 60 /* 61 * Forwarding database (FDB) entry, used by vnet to provide switching 62 * functionality. Each fdb entry corresponds to a destination vnet device 63 * within the ldoms which is directly reachable by invoking a transmit 64 * function provided by a vnet proxy transport layer. Currently, the generic 65 * transport layer adds/removes/modifies entries in fdb. 66 */ 67 typedef struct fdb { 68 struct fdb *nextp; /* next entry in the list */ 69 uint8_t macaddr[ETHERADDRL]; /* destination mac address */ 70 mac_tx_t m_tx; /* transmit function */ 71 void *txarg; /* arg to the transmit func */ 72 } fdb_t; 73 74 /* FDB hash queue head */ 75 typedef struct fdbf_s { 76 fdb_t *headp; /* head of fdb entries */ 77 krwlock_t rwlock; /* protect the list */ 78 } fdb_fanout_t; 79 80 #define VNET_NFDB_HASH 4 /* default number of hash queues in fdb */ 81 #define VNET_NFDB_HASH_MAX 32 /* max number of hash queues in fdb */ 82 83 /* Hash calculation using the mac address */ 84 #define MACHASH(a, n) ((*(((uchar_t *)(a)) + 0) ^ \ 85 *(((uchar_t *)(a)) + 1) ^ \ 86 *(((uchar_t *)(a)) + 2) ^ \ 87 *(((uchar_t *)(a)) + 3) ^ \ 88 *(((uchar_t *)(a)) + 4) ^ \ 89 *(((uchar_t *)(a)) + 5)) % (uint32_t)n) 90 91 /* rwlock macros */ 92 #define READ_ENTER(x) rw_enter(x, RW_READER) 93 #define WRITE_ENTER(x) rw_enter(x, RW_WRITER) 94 #define RW_EXIT(x) rw_exit(x) 95 96 /* 97 * vnet instance state information 98 */ 99 typedef struct vnet { 100 int instance; /* instance # */ 101 dev_info_t *dip; /* dev_info */ 102 struct vnet *nextp; /* next in list */ 103 mac_handle_t mh; /* handle to GLDv3 mac module */ 104 uchar_t vendor_addr[ETHERADDRL]; /* orig macadr */ 105 uchar_t curr_macaddr[ETHERADDRL]; /* current macadr */ 106 vp_tl_t *tlp; /* list of vp_tl */ 107 krwlock_t trwlock; /* lock for vp_tl list */ 108 char vgen_name[MAXNAMELEN]; /* name of generic tl */ 109 fdb_fanout_t *fdbhp; /* fdb hash queues */ 110 int nfdb_hash; /* num fdb hash queues */ 111 } vnet_t; 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif /* _VNET_H */ 118