4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_MULTIDATA_H
28 #define _SYS_MULTIDATA_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 * Multidata interface declarations.
38 * These interfaces are still evolving; do not use them in unbundled drivers.
42 * Multidata packet attribute information.
44 typedef struct pattrinfo_s
{
45 uint_t type
; /* attribute type value */
46 uint_t len
; /* attribute length */
47 void *buf
; /* pointer to user data area */
51 * Maximum number of payload areas for a single packet descriptor.
53 #define MULTIDATA_MAX_PBUFS 16
56 * Multidata buffer information.
58 typedef struct mbufinfo_s
{
59 uchar_t
*hbuf_rptr
; /* start address of header buffer */
60 uchar_t
*hbuf_wptr
; /* end address of header buffer */
61 uint_t pbuf_cnt
; /* number of payload buffer */
63 uchar_t
*pbuf_rptr
; /* start address of payload buffer */
64 uchar_t
*pbuf_wptr
; /* end address of payload buffer */
65 } pbuf_ary
[MULTIDATA_MAX_PBUFS
];
69 * Multidata packet descriptor information.
72 int pld_pbuf_idx
; /* payload buffer index */
73 uchar_t
*pld_rptr
; /* start address of payload data */
74 uchar_t
*pld_wptr
; /* pointer to end of payload data */
77 #define PDESCINFO_STRUCT(elems) \
79 uint_t flags; /* misc. flags */ \
80 uchar_t *hdr_base; /* start address of header area */ \
81 uchar_t *hdr_rptr; /* start address of header data */ \
82 uchar_t *hdr_wptr; /* end address of header data */ \
83 uchar_t *hdr_lim; /* end address of header area */ \
84 uint_t pld_cnt; /* number of payload area */ \
85 struct pld_ary_s pld_ary[(elems)]; \
88 typedef struct pdescinfo_s
PDESCINFO_STRUCT(MULTIDATA_MAX_PBUFS
) pdescinfo_t
;
91 * Possible values for flags
93 #define PDESC_HBUF_REF 0x1 /* descriptor uses header buffer */
94 #define PDESC_PBUF_REF 0x2 /* descriptor uses payload buffer(s) */
96 #define PDESC_HDRSIZE(p) ((p)->hdr_lim - (p)->hdr_base)
97 #define PDESC_HDRL(p) ((p)->hdr_wptr - (p)->hdr_rptr)
98 #define PDESC_HDRHEAD(p) ((p)->hdr_rptr - (p)->hdr_base)
99 #define PDESC_HDRTAIL(p) ((p)->hdr_lim - (p)->hdr_wptr)
101 #define PDESC_HDR_ADD(p, base, head, len, tail) { \
102 (p)->hdr_base = (base); \
103 (p)->hdr_rptr = (base) + (head); \
104 (p)->hdr_wptr = (p)->hdr_rptr + (len); \
105 (p)->hdr_lim = (p)->hdr_wptr + (tail); \
108 #define PDESC_PLD_INIT(p) ((p)->pld_cnt = 0)
110 #define PDESC_PLD_SPAN_SIZE(p, n) \
111 ((p)->pld_ary[(n)].pld_wptr - (p)->pld_ary[(n)].pld_rptr)
113 #define PDESC_PLDL(p, n) PDESC_PLD_SPAN_SIZE(p, n)
115 #define PDESC_PLD_SPAN_TRIM(p, n, b) { \
116 ((p)->pld_ary[(n)].pld_wptr -= (b)); \
117 ASSERT((p)->pld_ary[(n)].pld_wptr >= (p)->pld_ary[(n)].pld_rptr); \
120 #define PDESC_PLD_SPAN_CLEAR(p, n) \
121 PDESC_PLD_SPAN_TRIM(p, n, PDESC_PLD_SPAN_SIZE(p, n))
123 #define PDESC_PLD_SPAN_ADD(p, pbuf_idx, rptr, len) { \
124 ASSERT((p)->pld_cnt < MULTIDATA_MAX_PBUFS); \
125 (p)->pld_ary[(p)->pld_cnt].pld_pbuf_idx = (pbuf_idx); \
126 (p)->pld_ary[(p)->pld_cnt].pld_rptr = (rptr); \
127 (p)->pld_ary[(p)->pld_cnt].pld_wptr = (rptr) + (len); \
132 * These structures are opaque to multidata clients.
135 typedef struct pdesc_s pdesc_t
;
138 typedef struct pattr_s pattr_t
;
141 typedef struct multidata_s multidata_t
;
145 extern multidata_t
*mmd_alloc(mblk_t
*, mblk_t
**, int);
146 extern int mmd_addpldbuf(multidata_t
*, mblk_t
*);
147 extern multidata_t
*mmd_getmultidata(mblk_t
*);
148 extern void mmd_getregions(multidata_t
*, mbufinfo_t
*);
149 extern uint_t
mmd_getcnt(multidata_t
*, uint_t
*, uint_t
*);
150 extern pdesc_t
*mmd_addpdesc(multidata_t
*, pdescinfo_t
*, int *, int);
151 extern void mmd_rempdesc(pdesc_t
*);
152 extern pdesc_t
*mmd_getfirstpdesc(multidata_t
*, pdescinfo_t
*);
153 extern pdesc_t
*mmd_getlastpdesc(multidata_t
*, pdescinfo_t
*);
154 extern pdesc_t
*mmd_getnextpdesc(pdesc_t
*, pdescinfo_t
*);
155 extern pdesc_t
*mmd_getprevpdesc(pdesc_t
*, pdescinfo_t
*);
156 extern pdesc_t
*mmd_adjpdesc(pdesc_t
*, pdescinfo_t
*);
157 extern mblk_t
*mmd_transform(pdesc_t
*);
158 extern mblk_t
*mmd_transform_link(pdesc_t
*);
159 extern int mmd_dupbufs(multidata_t
*, mblk_t
**, mblk_t
**);
160 extern int mmd_getpdescinfo(pdesc_t
*, pdescinfo_t
*);
161 extern pattr_t
*mmd_addpattr(multidata_t
*, pdesc_t
*, pattrinfo_t
*,
163 extern void mmd_rempattr(pattr_t
*);
164 extern pattr_t
*mmd_getpattr(multidata_t
*, pdesc_t
*, pattrinfo_t
*);
165 extern void mmd_getsize(multidata_t
*, uint_t
*, uint_t
*);
173 #endif /* _SYS_MULTIDATA_H */