idn_smr.h revision e0731422366620894c16c1ee6515551c5f00733d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*
* Inter-Domain Network - SMR support.
*/
#ifndef _SYS_IDN_SMR_H
#define _SYS_IDN_SMR_H
#include <sys/sysmacros.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint_t smr_offset_t;
/*
* ---------------------------------------------------------------------
* Data in the SMR is automatically aligned on 64 byte boundaries due
* to the large IDN_SMR_BUFSIZE, however the streams buffers may not be
* so we bump them in order to allow us to align appropriately and thus
* maximize bcopy performance.
* ---------------------------------------------------------------------
*/
#define IDN_ALIGNSIZE 64
/*
* Align the pointer "p" to the same relative offset as the reference
* pointer "r" within IDN_ALIGNSIZE bytes.
*/
(uintptr_t)(p)) & \
#define IDN_BUF2HDR(b) ((smr_pkthdr_t *)(b))
#define IDN_CKSUM_PKT(h) \
(IDN_CHECKSUM ? \
typedef struct smr_pkthdr {
int b_length;
} smr_pkthdr_t;
/*
* ---------------------------------------------------------------------
* IDN Slab related definitions.
*
* Domains are allocated SMR buffers in slabs. Slaves keep track of
* their own slabs in their respective idn_domain entry. The Master
* keeps track of slave slabs via their respective idn_domain entry.
* The global slab pools representing all of the SMR and managed by
* the master are maintained in the idn_global structure.
*
* The minimum number of slabs is chosen so that there is at least
* one slab available for every possible domain that might be attached.
*
* NOTE: idn_slab_bufcount * idn_smr_bufsize should be on a 64-byte
* (IDN_ALIGNSIZE) boundary for maximum bcopy performance.
* ---------------------------------------------------------------------
*/
#define IDN_SLAB_BUFCOUNT idn_slab_bufcount
#define IDN_SLAB_MINPERPOOL 3
#define IDN_SLAB_MINTOTAL idn_slab_mintotal
#define IDN_SLAB_PREALLOC idn_slab_prealloc
/*
* ---------------------------------------------------------------------
* Maximum number of slabs per domain the master will
* allow to be allocated. Further requests simply result
* in a failed allocation.
* Nominal value is 1/6 of the total available (~10).
* Maximum number of bufs a domain can expect based on
* IDN_SLAB_MAXPERDOMAIN.
* ---------------------------------------------------------------------
*/
/*
* ---------------------------------------------------------------------
* If the total number of available slabs managed by the master
* goes below this minimum total threshold, then the master kicks
* off a reap request to all domains to check for free slabs and
* to give them up. For performance reasons, domains do not
* automatically flush out free slabs. They rely on the master
* to tell them to look for some.
* ---------------------------------------------------------------------
*/
(IDN_SLAB_MINTOTAL + \
(IDN_SLAB_MINTOTAL / 5)))
#define SMR_SLAB_HASH(p, d) \
#define SMR_SLAB_HASHSTEP(p, s) \
/*
* ---------------------------------------------------------------------
* There is one smr_slabbuf for each buffer in the respective slab.
*
* sb_domid Domainid currently owning respective buffer.
* Local domains use this field to determine what buffers
* are outstanding at which domains. The master uses this
* field to know which domain owns given slab.
* sb_bufp Actual pointer to (VA) buffer.
* sb_next Used to manage free and in-use lists.
* ---------------------------------------------------------------------
*/
typedef struct smr_slabbuf {
int sb_domid;
struct smr_slabbuf *sb_next;
/*
* ---------------------------------------------------------------------
* There is one smr_slab per slab of buffers.
*
* sl_next List of slabs allocated to same requester.
* sl_start Base virtual address (SMR) of slab.
* sl_end Points to byte immediately following end of slab.
* sl_domid Used by Master to indicate which slave owns
* respective slab.
* sl_free Freelist of available buffers.
* sl_inuse List of buffers currently allocated and in-use.
* sl_head Pointer to memory allocated to hold smr_slabbuf_t's.
* ---------------------------------------------------------------------
*/
typedef struct smr_slab {
union {
int _sl_domid;
struct {
} _s;
} _u;
} smr_slab_t;
/*
* ---------------------------------------------------------------------
* ---------------------------------------------------------------------
*/
extern int smr_buf_free_all(int domid);
int serrno);
extern int smr_slabwaiter_init();
extern void smr_slabwaiter_deinit();
extern void smr_slabpool_deinit();
extern int idn_slab_prealloc;
#ifdef __cplusplus
}
#endif
#endif /* _SYS_IDN_SMR_H */