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 #ifndef _VNET_H 281ae08745Sheppo #define _VNET_H 291ae08745Sheppo 301ae08745Sheppo #pragma ident "%Z%%M% %I% %E% SMI" 311ae08745Sheppo 321ae08745Sheppo #ifdef __cplusplus 331ae08745Sheppo extern "C" { 341ae08745Sheppo #endif 351ae08745Sheppo 361ae08745Sheppo #define VNET_SUCCESS (0) /* successful return */ 371ae08745Sheppo #define VNET_FAILURE (-1) /* unsuccessful return */ 381ae08745Sheppo 391ae08745Sheppo #define KMEM_FREE(_p) kmem_free((_p), sizeof (*(_p))) 401ae08745Sheppo 411ae08745Sheppo #define VNET_NTXDS 512 /* power of 2 tx descriptors */ 421ae08745Sheppo #define VNET_RECLAIM_LOWAT 32 /* tx reclaim low watermark */ 431ae08745Sheppo #define VNET_RECLAIM_HIWAT (512 - 32) /* tx reclaim high watermark */ 441ae08745Sheppo #define VNET_LDCWD_INTERVAL 1000 /* watchdog freq in msec */ 451ae08745Sheppo #define VNET_LDCWD_TXTIMEOUT 1000 /* tx timeout in msec */ 46*e1ebb9ecSlm66018 #define VNET_LDC_MTU 64 /* ldc mtu */ 47d10e4ef2Snarayan #define VNET_NRBUFS 512 /* number of receive bufs */ 481ae08745Sheppo 491ae08745Sheppo /* 501ae08745Sheppo * vnet proxy transport layer information. There is one instance of this for 511ae08745Sheppo * every transport being used by a vnet device and a list of these transports 521ae08745Sheppo * is maintained by vnet. 531ae08745Sheppo */ 541ae08745Sheppo typedef struct vp_tl { 551ae08745Sheppo struct vp_tl *nextp; /* next in list */ 56ba2e4443Sseb mac_register_t *macp; /* transport ops */ 571ae08745Sheppo char name[LIFNAMSIZ]; /* device name */ 581ae08745Sheppo major_t major; /* driver major # */ 591ae08745Sheppo uint_t instance; /* dev instance */ 601ae08745Sheppo } vp_tl_t; 611ae08745Sheppo 621ae08745Sheppo /* 631ae08745Sheppo * Forwarding database (FDB) entry, used by vnet to provide switching 641ae08745Sheppo * functionality. Each fdb entry corresponds to a destination vnet device 651ae08745Sheppo * within the ldoms which is directly reachable by invoking a transmit 661ae08745Sheppo * function provided by a vnet proxy transport layer. Currently, the generic 671ae08745Sheppo * transport layer adds/removes/modifies entries in fdb. 681ae08745Sheppo */ 691ae08745Sheppo typedef struct fdb { 701ae08745Sheppo struct fdb *nextp; /* next entry in the list */ 711ae08745Sheppo uint8_t macaddr[ETHERADDRL]; /* destination mac address */ 721ae08745Sheppo mac_tx_t m_tx; /* transmit function */ 731ae08745Sheppo void *txarg; /* arg to the transmit func */ 741ae08745Sheppo } fdb_t; 751ae08745Sheppo 761ae08745Sheppo /* FDB hash queue head */ 771ae08745Sheppo typedef struct fdbf_s { 781ae08745Sheppo fdb_t *headp; /* head of fdb entries */ 791ae08745Sheppo krwlock_t rwlock; /* protect the list */ 801ae08745Sheppo } fdb_fanout_t; 811ae08745Sheppo 821ae08745Sheppo #define VNET_NFDB_HASH 4 /* default number of hash queues in fdb */ 831ae08745Sheppo #define VNET_NFDB_HASH_MAX 32 /* max number of hash queues in fdb */ 841ae08745Sheppo 851ae08745Sheppo /* Hash calculation using the mac address */ 861ae08745Sheppo #define MACHASH(a, n) ((*(((uchar_t *)(a)) + 0) ^ \ 871ae08745Sheppo *(((uchar_t *)(a)) + 1) ^ \ 881ae08745Sheppo *(((uchar_t *)(a)) + 2) ^ \ 891ae08745Sheppo *(((uchar_t *)(a)) + 3) ^ \ 901ae08745Sheppo *(((uchar_t *)(a)) + 4) ^ \ 911ae08745Sheppo *(((uchar_t *)(a)) + 5)) % (uint32_t)n) 921ae08745Sheppo 931ae08745Sheppo /* rwlock macros */ 941ae08745Sheppo #define READ_ENTER(x) rw_enter(x, RW_READER) 951ae08745Sheppo #define WRITE_ENTER(x) rw_enter(x, RW_WRITER) 961ae08745Sheppo #define RW_EXIT(x) rw_exit(x) 971ae08745Sheppo 981ae08745Sheppo /* 991ae08745Sheppo * vnet instance state information 1001ae08745Sheppo */ 1011ae08745Sheppo typedef struct vnet { 1021ae08745Sheppo int instance; /* instance # */ 1031ae08745Sheppo dev_info_t *dip; /* dev_info */ 1041ae08745Sheppo struct vnet *nextp; /* next in list */ 105ba2e4443Sseb mac_handle_t mh; /* handle to GLDv3 mac module */ 1061ae08745Sheppo uchar_t vendor_addr[ETHERADDRL]; /* orig macadr */ 1071ae08745Sheppo uchar_t curr_macaddr[ETHERADDRL]; /* current macadr */ 1081ae08745Sheppo vp_tl_t *tlp; /* list of vp_tl */ 1091ae08745Sheppo krwlock_t trwlock; /* lock for vp_tl list */ 1101ae08745Sheppo char vgen_name[MAXNAMELEN]; /* name of generic tl */ 1111ae08745Sheppo fdb_fanout_t *fdbhp; /* fdb hash queues */ 1121ae08745Sheppo int nfdb_hash; /* num fdb hash queues */ 1131ae08745Sheppo } vnet_t; 1141ae08745Sheppo 1151ae08745Sheppo #ifdef __cplusplus 1161ae08745Sheppo } 1171ae08745Sheppo #endif 1181ae08745Sheppo 1191ae08745Sheppo #endif /* _VNET_H */ 120