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