1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_MULTIDATA_H 28*0Sstevel@tonic-gate #define _SYS_MULTIDATA_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * Multidata interface declarations. 38*0Sstevel@tonic-gate * These interfaces are still evolving; do not use them in unbundled drivers. 39*0Sstevel@tonic-gate */ 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* 42*0Sstevel@tonic-gate * Multidata packet attribute information. 43*0Sstevel@tonic-gate */ 44*0Sstevel@tonic-gate typedef struct pattrinfo_s { 45*0Sstevel@tonic-gate uint_t type; /* attribute type value */ 46*0Sstevel@tonic-gate uint_t len; /* attribute length */ 47*0Sstevel@tonic-gate void *buf; /* pointer to user data area */ 48*0Sstevel@tonic-gate } pattrinfo_t; 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Maximum number of payload areas for a single packet descriptor. 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate #define MULTIDATA_MAX_PBUFS 16 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate /* 56*0Sstevel@tonic-gate * Multidata buffer information. 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate typedef struct mbufinfo_s { 59*0Sstevel@tonic-gate uchar_t *hbuf_rptr; /* start address of header buffer */ 60*0Sstevel@tonic-gate uchar_t *hbuf_wptr; /* end address of header buffer */ 61*0Sstevel@tonic-gate uint_t pbuf_cnt; /* number of payload buffer */ 62*0Sstevel@tonic-gate struct pbuf_ary_s { 63*0Sstevel@tonic-gate uchar_t *pbuf_rptr; /* start address of payload buffer */ 64*0Sstevel@tonic-gate uchar_t *pbuf_wptr; /* end address of payload buffer */ 65*0Sstevel@tonic-gate } pbuf_ary[MULTIDATA_MAX_PBUFS]; 66*0Sstevel@tonic-gate } mbufinfo_t; 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * Multidata packet descriptor information. 70*0Sstevel@tonic-gate */ 71*0Sstevel@tonic-gate typedef struct pdescinfo_s { 72*0Sstevel@tonic-gate uint_t flags; /* misc. flags */ 73*0Sstevel@tonic-gate uchar_t *hdr_base; /* start address of header area */ 74*0Sstevel@tonic-gate uchar_t *hdr_rptr; /* start address of header data */ 75*0Sstevel@tonic-gate uchar_t *hdr_wptr; /* end address of header data */ 76*0Sstevel@tonic-gate uchar_t *hdr_lim; /* end address of header area */ 77*0Sstevel@tonic-gate uint_t pld_cnt; /* number of payload area */ 78*0Sstevel@tonic-gate struct pld_ary_s { 79*0Sstevel@tonic-gate int pld_pbuf_idx; /* payload buffer index */ 80*0Sstevel@tonic-gate uchar_t *pld_rptr; /* start address of payload data */ 81*0Sstevel@tonic-gate uchar_t *pld_wptr; /* pointer to end of payload data */ 82*0Sstevel@tonic-gate } pld_ary[MULTIDATA_MAX_PBUFS]; 83*0Sstevel@tonic-gate } pdescinfo_t; 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* 86*0Sstevel@tonic-gate * Possible values for flags 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate #define PDESC_HBUF_REF 0x1 /* descriptor uses header buffer */ 89*0Sstevel@tonic-gate #define PDESC_PBUF_REF 0x2 /* descriptor uses payload buffer(s) */ 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate #define PDESC_HDRSIZE(p) ((p)->hdr_lim - (p)->hdr_base) 92*0Sstevel@tonic-gate #define PDESC_HDRL(p) ((p)->hdr_wptr - (p)->hdr_rptr) 93*0Sstevel@tonic-gate #define PDESC_HDRHEAD(p) ((p)->hdr_rptr - (p)->hdr_base) 94*0Sstevel@tonic-gate #define PDESC_HDRTAIL(p) ((p)->hdr_lim - (p)->hdr_wptr) 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate #define PDESC_HDR_ADD(p, base, head, len, tail) { \ 97*0Sstevel@tonic-gate (p)->hdr_base = (base); \ 98*0Sstevel@tonic-gate (p)->hdr_rptr = (base) + (head); \ 99*0Sstevel@tonic-gate (p)->hdr_wptr = (p)->hdr_rptr + (len); \ 100*0Sstevel@tonic-gate (p)->hdr_lim = (p)->hdr_wptr + (tail); \ 101*0Sstevel@tonic-gate } 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate #define PDESC_PLD_INIT(p) ((p)->pld_cnt = 0) 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate #define PDESC_PLD_SPAN_SIZE(p, n) \ 106*0Sstevel@tonic-gate ((p)->pld_ary[(n)].pld_wptr - (p)->pld_ary[(n)].pld_rptr) 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate #define PDESC_PLDL(p, n) PDESC_PLD_SPAN_SIZE(p, n) 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate #define PDESC_PLD_SPAN_TRIM(p, n, b) { \ 111*0Sstevel@tonic-gate ((p)->pld_ary[(n)].pld_wptr -= (b)); \ 112*0Sstevel@tonic-gate ASSERT((p)->pld_ary[(n)].pld_wptr >= (p)->pld_ary[(n)].pld_rptr); \ 113*0Sstevel@tonic-gate } 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #define PDESC_PLD_SPAN_CLEAR(p, n) \ 116*0Sstevel@tonic-gate PDESC_PLD_SPAN_TRIM(p, n, PDESC_PLD_SPAN_SIZE(p, n)) 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate #define PDESC_PLD_SPAN_ADD(p, pbuf_idx, rptr, len) { \ 119*0Sstevel@tonic-gate ASSERT((p)->pld_cnt < MULTIDATA_MAX_PBUFS); \ 120*0Sstevel@tonic-gate (p)->pld_ary[(p)->pld_cnt].pld_pbuf_idx = (pbuf_idx); \ 121*0Sstevel@tonic-gate (p)->pld_ary[(p)->pld_cnt].pld_rptr = (rptr); \ 122*0Sstevel@tonic-gate (p)->pld_ary[(p)->pld_cnt].pld_wptr = (rptr) + (len); \ 123*0Sstevel@tonic-gate (p)->pld_cnt++; \ 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate /* 127*0Sstevel@tonic-gate * These structures are opaque to multidata clients. 128*0Sstevel@tonic-gate */ 129*0Sstevel@tonic-gate struct pdesc_s; 130*0Sstevel@tonic-gate typedef struct pdesc_s pdesc_t; 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate struct pattr_s; 133*0Sstevel@tonic-gate typedef struct pattr_s pattr_t; 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate struct multidata_s; 136*0Sstevel@tonic-gate typedef struct multidata_s multidata_t; 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate #ifdef _KERNEL 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate extern multidata_t *mmd_alloc(mblk_t *, mblk_t **, int); 141*0Sstevel@tonic-gate extern int mmd_addpldbuf(multidata_t *, mblk_t *); 142*0Sstevel@tonic-gate extern multidata_t *mmd_getmultidata(mblk_t *); 143*0Sstevel@tonic-gate extern void mmd_getregions(multidata_t *, mbufinfo_t *); 144*0Sstevel@tonic-gate extern uint_t mmd_getcnt(multidata_t *, uint_t *, uint_t *); 145*0Sstevel@tonic-gate extern pdesc_t *mmd_addpdesc(multidata_t *, pdescinfo_t *, int *, int); 146*0Sstevel@tonic-gate extern void mmd_rempdesc(pdesc_t *); 147*0Sstevel@tonic-gate extern pdesc_t *mmd_getfirstpdesc(multidata_t *, pdescinfo_t *); 148*0Sstevel@tonic-gate extern pdesc_t *mmd_getlastpdesc(multidata_t *, pdescinfo_t *); 149*0Sstevel@tonic-gate extern pdesc_t *mmd_getnextpdesc(pdesc_t *, pdescinfo_t *); 150*0Sstevel@tonic-gate extern pdesc_t *mmd_getprevpdesc(pdesc_t *, pdescinfo_t *); 151*0Sstevel@tonic-gate extern pdesc_t *mmd_adjpdesc(pdesc_t *, pdescinfo_t *); 152*0Sstevel@tonic-gate extern mblk_t *mmd_transform(pdesc_t *); 153*0Sstevel@tonic-gate extern mblk_t *mmd_transform_link(pdesc_t *); 154*0Sstevel@tonic-gate extern int mmd_dupbufs(multidata_t *, mblk_t **, mblk_t **); 155*0Sstevel@tonic-gate extern int mmd_getpdescinfo(pdesc_t *, pdescinfo_t *); 156*0Sstevel@tonic-gate extern pattr_t *mmd_addpattr(multidata_t *, pdesc_t *, pattrinfo_t *, 157*0Sstevel@tonic-gate boolean_t, int); 158*0Sstevel@tonic-gate extern void mmd_rempattr(pattr_t *); 159*0Sstevel@tonic-gate extern pattr_t *mmd_getpattr(multidata_t *, pdesc_t *, pattrinfo_t *); 160*0Sstevel@tonic-gate extern void mmd_getsize(multidata_t *, uint_t *, uint_t *); 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate #endif /* _KERNEL */ 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate #ifdef __cplusplus 165*0Sstevel@tonic-gate } 166*0Sstevel@tonic-gate #endif 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate #endif /* _SYS_MULTIDATA_H */ 169