mbuf.h revision 8622ec4569457733001d4982ef7f5b44427069be
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef _SMBSRV_MBUF_H
#define _SMBSRV_MBUF_H
/*
* PBSHORTCUT This file should be removed from the PB port but is required
* for now to get it to compile. This file has also been modified.
*/
#ifdef __cplusplus
extern "C" {
#endif
#define MSIZE 256
#define MCLBYTES 2048
#define MCLSHIFT 11
#define NBPG 4096
#define PB_PAGESIZE 4096
/*
* Mbufs are of a single size, MSIZE (machine/machparam.h), which
* includes overhead. An mbuf may add a single "mbuf cluster" of size
* MCLBYTES (also in machine/machparam.h), which has no additional overhead
* and is used instead of the internal data area; this is done when
* at least MINCLSIZE of data must be stored.
*/
/*
* Macros for type conversion
* mtod(m,t) - convert mbuf pointer to data pointer of correct type
*/
/* header at beginning of each mbuf: */
struct m_hdr {
int mh_len; /* amount of data in this mbuf */
short mh_type; /* type of data in this mbuf */
short mh_flags; /* flags; see below */
};
struct pkthdr {
int len; /* total packet length */
};
/* XXX probably do not need m_ext */
/* description of external storage mapped into mbuf, valid if M_EXT set */
struct m_ext {
int (*ext_ref)(); /* refcount adjust function */
};
typedef struct mbuf {
union {
struct {
union {
char MH_databuf[MHLEN];
} MH_dat;
} MH;
} M_dat;
} mbuf_t;
/* mbuf flags */
/* mbuf pkthdr flags, also in m_flags */
/* flags copied when copying m_pkthdr */
/* XXX probably only need MT_DATA */
/* mbuf types */
#define MT_FREE 0 /* should be on free list */
/*
* flags to malloc: PBSHORTCUT
*/
#define M_WAITOK 0x0000
#define M_NOWAIT 0x0001
#define M_DONTWAIT M_NOWAIT
/*
* mbuf allocation/deallocation macros:
*
* MGET(struct mbuf *m, int how, int type)
* allocates an mbuf and initializes it to contain internal data.
*
* MGETHDR(struct mbuf *m, int how, int type)
* allocates an mbuf and initializes it to contain a packet header
* and internal data.
*/
(m)->m_flags = 0; \
}
}
extern int mclref();
extern int mclrefnoop();
{ \
}
/*
* MFREE(struct mbuf *m, struct mbuf *nn)
* Free a single mbuf and associated external storage.
* Place the successor, if any, in nn.
*/
{ \
} \
(m)->m_next = 0; \
MEM_FREE("mbuf", m); \
}
/*
* or initialized by M_COPY_PKTHDR.
*/
#define SMB_MBC_MAGIC 0x4D42435F
typedef struct mbuf_chain {
} mbuf_chain_t;
void smb_mbc_init(void);
void smb_mbc_fini(void);
void smb_mbc_free(mbuf_chain_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SMBSRV_MBUF_H */