changeset 13110:496fd9979cfc

PSARC/2010/308 Extensions for LDC transport API FWARC/2010/301 maximum size of LDC mapin space 6949300 ldc should support more than 64MB of shared memory mapins
author WENTAO YANG <Wentao.Yang@Sun.COM>
date Thu, 12 Aug 2010 17:51:26 -0700
parents babcda726f5a
children 186dcc2a6f67
files usr/src/uts/sun4v/io/ldc.c usr/src/uts/sun4v/io/ldc_shm.c usr/src/uts/sun4v/io/vnet_gen.c usr/src/uts/sun4v/io/vnet_rxdring.c usr/src/uts/sun4v/io/vsw.c usr/src/uts/sun4v/io/vsw_ldc.c usr/src/uts/sun4v/io/vsw_rxdring.c usr/src/uts/sun4v/ml/hcall.s usr/src/uts/sun4v/sys/hypervisor_api.h usr/src/uts/sun4v/sys/ldc.h usr/src/uts/sun4v/sys/ldc_impl.h usr/src/uts/sun4v/sys/vnet_common.h usr/src/uts/sun4v/sys/vnet_gen.h usr/src/uts/sun4v/sys/vsw_ldc.h
diffstat 14 files changed, 275 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/sun4v/io/ldc.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/ldc.c	Thu Aug 12 17:51:26 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -125,6 +124,11 @@
 static int i_ldc_process_RDX(ldc_chan_t *ldcp, ldc_msg_t *msg);
 static int i_ldc_process_data_ACK(ldc_chan_t *ldcp, ldc_msg_t *msg);
 
+/* Imported functions */
+extern void i_ldc_mem_set_hsvc_vers(uint64_t major, uint64_t minor);
+extern void i_ldc_init_mapin(ldc_soft_state_t *ldcssp, uint64_t major,
+	uint64_t minor);
+
 /* LDC Version */
 static ldc_ver_t ldc_versions[] = { {1, 0} };
 
@@ -151,7 +155,7 @@
 
 static uint64_t ldc_sup_minor;		/* Supported minor number */
 static hsvc_info_t ldc_hsvc = {
-	HSVC_REV_1, NULL, HSVC_GROUP_LDC, 1, 1, "ldc"
+	HSVC_REV_1, NULL, HSVC_GROUP_LDC, 1, 2, "ldc"
 };
 
 /*
@@ -209,6 +213,17 @@
  */
 clock_t ldc_close_delay = LDC_CLOSE_DELAY;
 
+
+/*
+ * Reserved mapin space for descriptor rings.
+ */
+uint64_t ldc_dring_direct_map_rsvd = LDC_DIRECT_MAP_SIZE_DEFAULT;
+
+/*
+ * Maximum direct map space allowed per channel.
+ */
+uint64_t	ldc_direct_map_size_max = (16 * 1024 * 1024);	/* 16 MB */
+
 #ifdef DEBUG
 
 /*
@@ -374,7 +389,6 @@
 _init(void)
 {
 	int status;
-	extern void i_ldc_mem_set_hsvc_vers(uint64_t major, uint64_t minor);
 
 	status = hsvc_register(&ldc_hsvc, &ldc_sup_minor);
 	if (status != 0) {
@@ -391,6 +405,8 @@
 	/* allocate soft state structure */
 	ldcssp = kmem_zalloc(sizeof (ldc_soft_state_t), KM_SLEEP);
 
+	i_ldc_init_mapin(ldcssp, ldc_hsvc.hsvc_major, ldc_sup_minor);
+
 	/* Link the module into the system */
 	status = mod_install(&ml);
 	if (status != 0) {
@@ -4712,3 +4728,55 @@
 
 	return (0);
 }
+
+int
+ldc_info(ldc_handle_t handle, ldc_info_t *info)
+{
+	ldc_chan_t	*ldcp;
+	uint64_t	avail;
+
+	if (handle == NULL || info == NULL) {
+		DWARN(DBG_ALL_LDCS, "ldc_get_info: invalid args\n");
+		return (EINVAL);
+	}
+
+	ldcp = (ldc_chan_t *)handle;
+
+	mutex_enter(&ldcp->lock);
+
+	/* check to see if channel is initalized */
+	if ((ldcp->tstate & ~TS_IN_RESET) < TS_INIT) {
+		DWARN(ldcp->id,
+		    "ldc_get_info: (0x%llx) channel not initialized\n",
+		    ldcp->id);
+		mutex_exit(&ldcp->lock);
+		return (EINVAL);
+	}
+
+	mutex_exit(&ldcp->lock);
+
+	/*
+	 * ldcssp->mapin_size is the max amount of shared memory supported by
+	 * the Hypervisor per guest. e.g, legacy HV supports 64MB; latest HV
+	 * support 1GB. This size is read during ldc module initialization.
+	 *
+	 * ldc_dring_direct_map_rsvd is the amount of memory reserved for
+	 * mapping in descriptor rings. In the initial implementation, we use a
+	 * simple approach to determine the amount of mapin space available per
+	 * channel. In future, we may implement strict accounting of the actual
+	 * memory consumed to determine the exact amount available per channel.
+	 */
+	if (ldcssp->mapin_size <= ldc_dring_direct_map_rsvd) {
+		info->direct_map_size_max = 0;
+		return (0);
+	}
+
+	avail = ldcssp->mapin_size - ldc_dring_direct_map_rsvd;
+	if (avail >= ldc_direct_map_size_max) {
+		info->direct_map_size_max = ldc_direct_map_size_max;
+	} else {
+		info->direct_map_size_max = 0;
+	}
+
+	return (0);
+}
--- a/usr/src/uts/sun4v/io/ldc_shm.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/ldc_shm.c	Thu Aug 12 17:51:26 2010 -0700
@@ -20,12 +20,9 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * sun4v LDC Link Layer Shared Memory Routines
  */
@@ -85,7 +82,7 @@
  * support is currently implemented via shadow copy.
  * Direct map can be enabled by setting 'ldc_shmem_enabled'
  */
-int ldc_shmem_enabled = 0;
+int ldc_shmem_enabled = 1;
 
 /*
  * Use of directly mapped shared memory for LDC descriptor
@@ -122,6 +119,20 @@
 	(((pg_szc) << LDC_COOKIE_PGSZC_SHIFT) | ((idx) << (pg_shift)))
 
 /*
+ * Pages imported over each channel are maintained in a global (per-guest)
+ * mapin table. Starting with HV LDC API version 1.2, HV supports APIs to
+ * obtain information about the total size of the memory that can be direct
+ * mapped through this mapin table. The minimum size of the mapin area that we
+ * expect is defined below.
+ */
+#define	GIGABYTE		((uint64_t)(1 << 30))
+uint64_t ldc_mapin_size_min = GIGABYTE;
+
+/* HV LDC API version that supports mapin size info */
+#define	LDC_MAPIN_VER_MAJOR	1
+#define	LDC_MAPIN_VER_MINOR	2
+
+/*
  * Sets ldc_dring_shmem_hv_ok to a non-zero value if the HV LDC
  * API version supports directly mapped shared memory or if it has
  * been explicitly enabled via ldc_dring_shmem_hv_force.
@@ -138,6 +149,41 @@
 }
 
 /*
+ * initialize mapin table.
+ */
+void
+i_ldc_init_mapin(ldc_soft_state_t *ldcssp, uint64_t major, uint64_t minor)
+{
+	int		rv;
+	uint64_t	sz;
+	uint64_t	table_type = LDC_MAPIN_TYPE_REGULAR;
+
+	/* set mapin size to default. */
+	ldcssp->mapin_size = LDC_DIRECT_MAP_SIZE_DEFAULT;
+
+	/* Check if the HV supports mapin size API. */
+	if ((major == LDC_MAPIN_VER_MAJOR &&
+	    minor < LDC_MAPIN_VER_MINOR) ||
+	    (major < LDC_MAPIN_VER_MAJOR)) {
+		/* Older version of HV. */
+		return;
+	}
+
+	/* Get info about the mapin size supported by HV */
+	rv = hv_ldc_mapin_size_max(table_type, &sz);
+	if (rv != 0) {
+		cmn_err(CE_NOTE, "Failed to get mapin information\n");
+		return;
+	}
+
+	/* Save the table size */
+	ldcssp->mapin_size = sz;
+
+	D1(DBG_ALL_LDCS, "%s: mapin_size read from HV is (0x%llx)\n",
+	    __func__, sz);
+}
+
+/*
  * Allocate a memory handle for the channel and link it into the list
  * Also choose which memory table to use if this is the first handle
  * being assigned to this channel
--- a/usr/src/uts/sun4v/io/vnet_gen.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/vnet_gen.c	Thu Aug 12 17:51:26 2010 -0700
@@ -141,6 +141,7 @@
 static void vgen_destroy_dring(vgen_ldc_t *ldcp);
 static int vgen_map_dring(vgen_ldc_t *ldcp, void *pkt);
 static void vgen_unmap_dring(vgen_ldc_t *ldcp);
+static int vgen_mapin_avail(vgen_ldc_t *ldcp);
 
 /* VIO Message Processing */
 static int vgen_handshake(vgen_ldc_t *ldcp);
@@ -317,14 +318,7 @@
 uint32_t vgen_ldc_max_resets = 5;
 
 /*
- * We provide a tunable to enable RxDringData mode for versions >= 1.6. By
- * default, this tunable is set to 1 (VIO_TX_DRING). To enable RxDringData mode
- * set this tunable to 4 (VIO_RX_DRING_DATA).
  * See comments in vsw.c for details on the dring modes supported.
- */
-uint8_t  vgen_dring_mode = VIO_TX_DRING;
-
-/*
  * In RxDringData mode, # of buffers is determined by multiplying the # of
  * descriptors with the factor below. Note that the factor must be > 1; i.e,
  * the # of buffers must always be > # of descriptors. This is needed because,
@@ -449,6 +443,7 @@
 extern proc_t	p0;
 extern uint32_t	vnet_ethermtu;
 extern uint16_t	vnet_default_vlan_id;
+extern uint32_t vnet_num_descriptors;
 
 #ifdef DEBUG
 
@@ -3655,16 +3650,15 @@
 	 *
 	 * However, for versions >= 1.6, we can force to only use TxDring mode.
 	 * This could happen if RxDringData mode has been disabled (see
-	 * vgen_dring_mode) on this guest or on the peer guest. This info is
-	 * determined as part of attr exchange phase of handshake. Hence, we
-	 * setup these pointers for v1.6 after attr msg phase completes during
-	 * handshake.
+	 * below) on this guest or on the peer guest. This info is determined
+	 * as part of attr exchange phase of handshake. Hence, we setup these
+	 * pointers for v1.6 after attr msg phase completes during handshake.
 	 */
 	if (VGEN_VER_GTEQ(ldcp, 1, 6)) {	/* Ver >= 1.6 */
 		/*
 		 * Set data dring mode for vgen_send_attr_info().
 		 */
-		if (vgen_dring_mode == VIO_RX_DRING_DATA) {
+		if (vgen_mapin_avail(ldcp) == B_TRUE) {
 			lp->dring_mode = (VIO_RX_DRING_DATA | VIO_TX_DRING);
 		} else {
 			lp->dring_mode = VIO_TX_DRING;
@@ -4603,7 +4597,7 @@
 		 * that can be negotiated.
 		 */
 		if ((msg->options & VIO_RX_DRING_DATA) != 0 &&
-		    vgen_dring_mode == VIO_RX_DRING_DATA) {
+		    vgen_mapin_avail(ldcp) == B_TRUE) {
 			/*
 			 * We are capable of handling RxDringData AND the peer
 			 * is also capable of it; we enable RxDringData mode on
@@ -5757,6 +5751,30 @@
 	msg->dring_ident = 0;
 }
 
+static int
+vgen_mapin_avail(vgen_ldc_t *ldcp)
+{
+	int		rv;
+	ldc_info_t	info;
+	uint64_t	mapin_sz_req;
+	uint64_t	dblk_sz;
+	vgen_t		*vgenp = LDC_TO_VGEN(ldcp);
+
+	rv = ldc_info(ldcp->ldc_handle, &info);
+	if (rv != 0) {
+		return (B_FALSE);
+	}
+
+	dblk_sz = RXDRING_DBLK_SZ(vgenp->max_frame_size);
+	mapin_sz_req = (VGEN_RXDRING_NRBUFS * dblk_sz);
+
+	if (info.direct_map_size_max >= mapin_sz_req) {
+		return (B_TRUE);
+	}
+
+	return (B_FALSE);
+}
+
 #if DEBUG
 
 /*
--- a/usr/src/uts/sun4v/io/vnet_rxdring.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/vnet_rxdring.c	Thu Aug 12 17:51:26 2010 -0700
@@ -127,7 +127,7 @@
 
 	rxdsize = sizeof (vnet_rx_dringdata_desc_t);
 	ldcp->num_rxds = vnet_num_descriptors;
-	ldcp->num_rbufs = vnet_num_descriptors * vgen_nrbufs_factor;
+	ldcp->num_rbufs = VGEN_RXDRING_NRBUFS;
 
 	/* Create the receive descriptor ring */
 	rv = ldc_mem_dring_create(ldcp->num_rxds, rxdsize,
@@ -173,8 +173,7 @@
 	 * (receiver) manage the individual buffers and their state (see
 	 * VIO_MBLK_STATEs in vio_util.h).
 	 */
-	data_sz = vgenp->max_frame_size + VNET_IPALIGN + VNET_LDCALIGN;
-	data_sz = VNET_ROUNDUP_2K(data_sz);
+	data_sz = RXDRING_DBLK_SZ(vgenp->max_frame_size);
 
 	ldcp->rx_data_sz = data_sz * ldcp->num_rbufs;
 	ldcp->rx_dblk_sz = data_sz;
@@ -510,6 +509,7 @@
 	vio_dring_reg_msg_t	*msg = (vio_dring_reg_msg_t *)pkt;
 	uint8_t			*buf = (uint8_t *)msg->cookie;
 	vgen_t			*vgenp = LDC_TO_VGEN(ldcp);
+	ldc_mem_info_t		minfo;
 
 	/* skip over dring cookies */
 	ASSERT(msg->ncookies == 1);
@@ -539,8 +539,19 @@
 	    (caddr_t *)&ldcp->tx_datap, NULL);
 	if (rv != 0) {
 		DWARN(vgenp, ldcp, "ldc_mem_map() failed: %d\n", rv);
-		(void) ldc_mem_free_handle(ldcp->tx_data_handle);
-		ldcp->tx_data_handle = 0;
+		return (VGEN_FAILURE);
+	}
+
+	/* get the map info */
+	rv = ldc_mem_info(ldcp->tx_data_handle, &minfo);
+	if (rv != 0) {
+		DWARN(vgenp, ldcp, "ldc_mem_info() failed: %d\n", rv);
+		return (VGEN_FAILURE);
+	}
+
+	if (minfo.mtype != LDC_DIRECT_MAP) {
+		DWARN(vgenp, ldcp, "mtype(%d) is not direct map\n",
+		    minfo.mtype);
 		return (VGEN_FAILURE);
 	}
 
--- a/usr/src/uts/sun4v/io/vsw.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/vsw.c	Thu Aug 12 17:51:26 2010 -0700
@@ -286,14 +286,10 @@
  * specified in the descriptor. The receiver simply picks up the data buffer
  * (owned by itself) without any copy operation into the receiving guest.
  *
- * We provide a tunable to enable RxDringData mode for versions >= v1.6 of VIO
- * Protocol. By default, this tunable is set to 1 (VIO_TX_DRING). To enable
- * RxDringData mode set this tunable to 4 (VIO_RX_DRING_DATA). This enables us
- * to negotiate RxDringData mode with peers that support versions >= v1.6. For
- * peers that support version < v1.6, we continue to operate in TxDring mode
- * with them though the tunable is enabled.
+ * We enable RxDringData mode during handshake negotiations if LDC supports
+ * mapping in large areas of shared memory(see ldc_is_viotsb_configured() API),
+ * which is required to support RxDringData mode.
  */
-uint8_t  vsw_dring_mode = VIO_TX_DRING;
 
 /*
  * Number of descriptors;  must be power of 2.
--- a/usr/src/uts/sun4v/io/vsw_ldc.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/vsw_ldc.c	Thu Aug 12 17:51:26 2010 -0700
@@ -151,6 +151,7 @@
 static void vsw_set_lane_attr(vsw_t *, lane_t *);
 dring_info_t *vsw_map_dring_cmn(vsw_ldc_t *ldcp,
     vio_dring_reg_msg_t *dring_pkt);
+static int vsw_mapin_avail(vsw_ldc_t *ldcp);
 
 /* tx/msg/rcv thread routines */
 static void vsw_stop_tx_thread(vsw_ldc_t *ldcp);
@@ -234,6 +235,7 @@
 extern uint32_t vsw_max_tx_qcount;
 extern boolean_t vsw_obp_ver_proto_workaround;
 extern uint32_t vsw_publish_macaddr_count;
+extern uint32_t vsw_nrbufs_factor;
 
 #define	LDC_ENTER_LOCK(ldcp)	\
 				mutex_enter(&((ldcp)->ldc_cblock));\
@@ -1938,10 +1940,9 @@
 	 *
 	 * However, for versions >= 1.6, we could still fallback to TxDring
 	 * mode. This could happen if RxDringData mode has been disabled (see
-	 * vsw_dring_mode) on this guest or on the peer guest. This info is
-	 * determined as part of attr exchange phase of handshake. Hence, we
-	 * setup these pointers for v1.6 after attr msg phase completes during
-	 * handshake.
+	 * below) on this guest or on the peer guest. This info is determined
+	 * as part of attr exchange phase of handshake. Hence, we setup these
+	 * pointers for v1.6 after attr msg phase completes during handshake.
 	 */
 	if (VSW_VER_GTEQ(ldcp, 1, 6)) {
 		/*
@@ -1949,7 +1950,7 @@
 		 * thread in TxDring mode or rcv worker thread in RxDringData
 		 * mode when attr phase of handshake completes.
 		 */
-		if (vsw_dring_mode == VIO_RX_DRING_DATA) {
+		if (vsw_mapin_avail(ldcp) == B_TRUE) {
 			lp->dring_mode = (VIO_RX_DRING_DATA | VIO_TX_DRING);
 		} else {
 			lp->dring_mode = VIO_TX_DRING;
@@ -2576,7 +2577,7 @@
 		 * that can be negotiated.
 		 */
 		if ((msg->options & VIO_RX_DRING_DATA) != 0 &&
-		    vsw_dring_mode == VIO_RX_DRING_DATA) {
+		    vsw_mapin_avail(ldcp) == B_TRUE) {
 			/*
 			 * The peer is capable of handling RxDringData AND we
 			 * are also capable of it; we enable RxDringData mode
@@ -4599,6 +4600,7 @@
 	vio_dring_reg_msg_t	*msg = pkt;
 	uint8_t			*buf = (uint8_t *)msg->cookie;
 	vsw_t			*vswp = ldcp->ldc_vswp;
+	ldc_mem_info_t		minfo;
 
 	/* skip over dring cookies */
 	ASSERT(msg->ncookies == 1);
@@ -4635,6 +4637,21 @@
 		return (1);
 	}
 
+	/* get the map info */
+	rv = ldc_mem_info(dp->data_handle, &minfo);
+	if (rv != 0) {
+		cmn_err(CE_WARN, "ldc_mem_info failed\n");
+		DWARN(vswp, "%s (%lld) ldc_mem_info() failed: %d\n",
+		    __func__, ldcp->ldc_id, rv);
+		return (1);
+	}
+
+	if (minfo.mtype != LDC_DIRECT_MAP) {
+		DWARN(vswp, "%s (%lld) mtype(%d) is not direct map\n",
+		    __func__, ldcp->ldc_id, minfo.mtype);
+		return (1);
+	}
+
 	/* allocate memory for data area cookies */
 	dp->data_cookie = kmem_zalloc(emsg->data_ncookies *
 	    sizeof (ldc_mem_cookie_t), KM_SLEEP);
@@ -4787,6 +4804,30 @@
 	D1(vswp, "%s(%lld):exit\n", __func__, ldcp->ldc_id);
 }
 
+static int
+vsw_mapin_avail(vsw_ldc_t *ldcp)
+{
+	int		rv;
+	ldc_info_t	info;
+	uint64_t	mapin_sz_req;
+	uint64_t	dblk_sz;
+	vsw_t		*vswp = ldcp->ldc_vswp;
+
+	rv = ldc_info(ldcp->ldc_handle, &info);
+	if (rv != 0) {
+		return (B_FALSE);
+	}
+
+	dblk_sz = RXDRING_DBLK_SZ(vswp->max_frame_size);
+	mapin_sz_req = (VSW_RXDRING_NRBUFS * dblk_sz);
+
+	if (info.direct_map_size_max >= mapin_sz_req) {
+		return (B_TRUE);
+	}
+
+	return (B_FALSE);
+}
+
 /*
  * Debugging routines
  */
--- a/usr/src/uts/sun4v/io/vsw_rxdring.c	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/io/vsw_rxdring.c	Thu Aug 12 17:51:26 2010 -0700
@@ -201,7 +201,7 @@
 	dp->descriptor_size = sizeof (vnet_rx_dringdata_desc_t);
 	dp->options = VIO_RX_DRING_DATA;
 	dp->dring_ncookies = 1;	/* guaranteed by ldc */
-	dp->num_bufs = vsw_num_descriptors * vsw_nrbufs_factor;
+	dp->num_bufs = VSW_RXDRING_NRBUFS;
 
 	/*
 	 * Allocate a table that maps descriptor to its associated buffer;
@@ -277,8 +277,7 @@
 	 * (receiver) manage the individual buffers and their state (see
 	 * VIO_MBLK_STATEs in vio_util.h).
 	 */
-	data_sz = vswp->max_frame_size + VNET_IPALIGN + VNET_LDCALIGN;
-	data_sz = VNET_ROUNDUP_2K(data_sz);
+	data_sz = RXDRING_DBLK_SZ(vswp->max_frame_size);
 
 	dp->desc_data_sz = data_sz;
 	dp->data_sz = (dp->num_bufs * data_sz);
--- a/usr/src/uts/sun4v/ml/hcall.s	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/ml/hcall.s	Thu Aug 12 17:51:26 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -1052,6 +1051,16 @@
 	  nop
 	SET_SIZE(hv_ldc_revoke)
 
+	/*
+	 * hv_ldc_mapin_size_max(uint64_t tbl_type, uint64_t *sz)
+	 */
+	ENTRY(hv_ldc_mapin_size_max)
+	mov	%o1, %g1
+	mov     LDC_MAPIN_SIZE_MAX, %o5
+	ta      FAST_TRAP
+	retl
+	  stx     %o1, [%g1]
+	SET_SIZE(hv_ldc_mapin_size_max)
 
 	/*
 	 * hvldc_intr_getcookie(uint64_t dev_hdl, uint32_t devino,
--- a/usr/src/uts/sun4v/sys/hypervisor_api.h	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/sys/hypervisor_api.h	Thu Aug 12 17:51:26 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef _SYS_HYPERVISOR_API_H
@@ -162,6 +161,7 @@
 #define	LDC_MAPIN		0xed
 #define	LDC_UNMAP		0xee
 #define	LDC_REVOKE		0xef
+#define	LDC_MAPIN_SIZE_MAX	0x187
 
 #ifdef SET_MMU_STATS
 #define	MMU_STAT_AREA		0xfc
@@ -335,6 +335,12 @@
 #define	LDC_CHANNEL_UP		0x1
 #define	LDC_CHANNEL_RESET	0x2
 
+/*
+ * LDC mapin table types
+ */
+#define	LDC_MAPIN_TYPE_REGULAR	0x1		/* 8K page-size table */
+#define	LDC_MAPIN_TYPE_LARGE	0x2		/* Large page-size table */
+
 #ifndef _ASM
 
 extern uint64_t hv_mmu_map_perm_addr(void *, int, uint64_t, int);
@@ -427,6 +433,7 @@
 extern uint64_t hv_ldc_unmap(uint64_t raddr);
 extern uint64_t hv_ldc_revoke(uint64_t channel, uint64_t cookie,
     uint64_t revoke_cookie);
+extern uint64_t hv_ldc_mapin_size_max(uint64_t tbl_type, uint64_t *sz);
 extern uint64_t hv_api_get_version(uint64_t api_group, uint64_t *majorp,
     uint64_t *minorp);
 extern uint64_t hv_api_set_version(uint64_t api_group, uint64_t major,
--- a/usr/src/uts/sun4v/sys/ldc.h	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/sys/ldc.h	Thu Aug 12 17:51:26 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef _LDC_H
@@ -126,6 +125,11 @@
 #define	LDC_DIRECT_MAP		0x2	/* share mem direct access */
 #define	LDC_IO_MAP		0x4	/* share mem for IOMMU/DMA access */
 
+/*
+ * Default mapin size supported with legacy f/w.
+ */
+#define	LDC_DIRECT_MAP_SIZE_DEFAULT	(64 * 1024 * 1024)
+
 /* LDC Memory Access Permissions  */
 #define	LDC_MEM_R		0x1	/* Memory region is read only */
 #define	LDC_MEM_W		0x2	/* Memory region is write only */
@@ -153,6 +157,11 @@
 	ldc_mstatus_t	status;		/* dring/mem handle status */
 } ldc_mem_info_t;
 
+/* LDC channel info */
+typedef struct ldc_info {
+	uint64_t direct_map_size_max;	/* Max direct mapin space size */
+} ldc_info_t;
+
 /* API functions */
 int ldc_register(ldc_cnex_t *cinfo);
 int ldc_unregister(ldc_cnex_t *cinfo);
@@ -207,6 +216,7 @@
     uint64_t end);
 int ldc_mem_dring_release(ldc_dring_handle_t dhandle, uint64_t start,
     uint64_t end);
+int ldc_info(ldc_handle_t handle, ldc_info_t *info);
 
 /*
  * Shared Memory (Direct Map) Acquire and Release API
--- a/usr/src/uts/sun4v/sys/ldc_impl.h	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/sys/ldc_impl.h	Thu Aug 12 17:51:26 2010 -0700
@@ -20,15 +20,12 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef _LDC_IMPL_H
 #define	_LDC_IMPL_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -505,6 +502,8 @@
 
 	kmem_cache_t	*memhdl_cache;	/* Memory handle cache */
 	kmem_cache_t	*memseg_cache;	/* Memory segment cache */
+
+	uint64_t	mapin_size;		/* Total mapin sz per guest  */
 } ldc_soft_state_t;
 
 
--- a/usr/src/uts/sun4v/sys/vnet_common.h	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/sys/vnet_common.h	Thu Aug 12 17:51:26 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef _VNET_COMMON_H
@@ -96,6 +95,12 @@
 
 #define	VNET_NUM_HANDSHAKES	6	/* # of handshake attempts */
 
+/*
+ * Max frame size to data block size in RxDringData mode
+ */
+#define	RXDRING_DBLK_SZ(mfs) \
+	(VNET_ROUNDUP_2K((mfs) + VNET_IPALIGN + VNET_LDCALIGN))
+
 /* vnet descriptor */
 typedef struct vnet_public_desc {
 	vio_dring_entry_hdr_t	hdr;		/* descriptor header */
--- a/usr/src/uts/sun4v/sys/vnet_gen.h	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/sys/vnet_gen.h	Thu Aug 12 17:51:26 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef _VNET_GEN_H
@@ -92,6 +91,11 @@
 
 #define	VGEN_NUM_DESCRIPTORS_MIN	128	/* min # of descriptors */
 
+/*
+ * Number of rcv buffers in RxDringData mode
+ */
+#define	VGEN_RXDRING_NRBUFS	(vnet_num_descriptors * vgen_nrbufs_factor)
+
 static struct ether_addr etherbroadcastaddr = {
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 };
--- a/usr/src/uts/sun4v/sys/vsw_ldc.h	Thu Aug 12 17:41:20 2010 -0700
+++ b/usr/src/uts/sun4v/sys/vsw_ldc.h	Thu Aug 12 17:51:26 2010 -0700
@@ -204,6 +204,11 @@
  */
 #define	VSW_NUM_MBLKS	1024
 
+/*
+ * Number of rcv buffers in RxDringData mode
+ */
+#define	VSW_RXDRING_NRBUFS	(vsw_num_descriptors * vsw_nrbufs_factor)
+
 /* increment recv index */
 #define	INCR_DESC_INDEX(dp, i)	\
 		((i) = (((i) + 1) & ((dp)->num_descriptors - 1)))