17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*ff550d0eSmasputra * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_MULTIDATA_H 287c478bd9Sstevel@tonic-gate #define _SYS_MULTIDATA_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * Multidata interface declarations. 387c478bd9Sstevel@tonic-gate * These interfaces are still evolving; do not use them in unbundled drivers. 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Multidata packet attribute information. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate typedef struct pattrinfo_s { 457c478bd9Sstevel@tonic-gate uint_t type; /* attribute type value */ 467c478bd9Sstevel@tonic-gate uint_t len; /* attribute length */ 477c478bd9Sstevel@tonic-gate void *buf; /* pointer to user data area */ 487c478bd9Sstevel@tonic-gate } pattrinfo_t; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Maximum number of payload areas for a single packet descriptor. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate #define MULTIDATA_MAX_PBUFS 16 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Multidata buffer information. 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate typedef struct mbufinfo_s { 597c478bd9Sstevel@tonic-gate uchar_t *hbuf_rptr; /* start address of header buffer */ 607c478bd9Sstevel@tonic-gate uchar_t *hbuf_wptr; /* end address of header buffer */ 617c478bd9Sstevel@tonic-gate uint_t pbuf_cnt; /* number of payload buffer */ 627c478bd9Sstevel@tonic-gate struct pbuf_ary_s { 637c478bd9Sstevel@tonic-gate uchar_t *pbuf_rptr; /* start address of payload buffer */ 647c478bd9Sstevel@tonic-gate uchar_t *pbuf_wptr; /* end address of payload buffer */ 657c478bd9Sstevel@tonic-gate } pbuf_ary[MULTIDATA_MAX_PBUFS]; 667c478bd9Sstevel@tonic-gate } mbufinfo_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Multidata packet descriptor information. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate struct pld_ary_s { 727c478bd9Sstevel@tonic-gate int pld_pbuf_idx; /* payload buffer index */ 737c478bd9Sstevel@tonic-gate uchar_t *pld_rptr; /* start address of payload data */ 747c478bd9Sstevel@tonic-gate uchar_t *pld_wptr; /* pointer to end of payload data */ 75*ff550d0eSmasputra }; 76*ff550d0eSmasputra 77*ff550d0eSmasputra #define PDESCINFO_STRUCT(elems) \ 78*ff550d0eSmasputra { \ 79*ff550d0eSmasputra uint_t flags; /* misc. flags */ \ 80*ff550d0eSmasputra uchar_t *hdr_base; /* start address of header area */ \ 81*ff550d0eSmasputra uchar_t *hdr_rptr; /* start address of header data */ \ 82*ff550d0eSmasputra uchar_t *hdr_wptr; /* end address of header data */ \ 83*ff550d0eSmasputra uchar_t *hdr_lim; /* end address of header area */ \ 84*ff550d0eSmasputra uint_t pld_cnt; /* number of payload area */ \ 85*ff550d0eSmasputra struct pld_ary_s pld_ary[(elems)]; \ 86*ff550d0eSmasputra } 87*ff550d0eSmasputra 88*ff550d0eSmasputra typedef struct pdescinfo_s PDESCINFO_STRUCT(MULTIDATA_MAX_PBUFS) pdescinfo_t; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * Possible values for flags 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate #define PDESC_HBUF_REF 0x1 /* descriptor uses header buffer */ 947c478bd9Sstevel@tonic-gate #define PDESC_PBUF_REF 0x2 /* descriptor uses payload buffer(s) */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define PDESC_HDRSIZE(p) ((p)->hdr_lim - (p)->hdr_base) 977c478bd9Sstevel@tonic-gate #define PDESC_HDRL(p) ((p)->hdr_wptr - (p)->hdr_rptr) 987c478bd9Sstevel@tonic-gate #define PDESC_HDRHEAD(p) ((p)->hdr_rptr - (p)->hdr_base) 997c478bd9Sstevel@tonic-gate #define PDESC_HDRTAIL(p) ((p)->hdr_lim - (p)->hdr_wptr) 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define PDESC_HDR_ADD(p, base, head, len, tail) { \ 1027c478bd9Sstevel@tonic-gate (p)->hdr_base = (base); \ 1037c478bd9Sstevel@tonic-gate (p)->hdr_rptr = (base) + (head); \ 1047c478bd9Sstevel@tonic-gate (p)->hdr_wptr = (p)->hdr_rptr + (len); \ 1057c478bd9Sstevel@tonic-gate (p)->hdr_lim = (p)->hdr_wptr + (tail); \ 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define PDESC_PLD_INIT(p) ((p)->pld_cnt = 0) 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #define PDESC_PLD_SPAN_SIZE(p, n) \ 1117c478bd9Sstevel@tonic-gate ((p)->pld_ary[(n)].pld_wptr - (p)->pld_ary[(n)].pld_rptr) 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define PDESC_PLDL(p, n) PDESC_PLD_SPAN_SIZE(p, n) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #define PDESC_PLD_SPAN_TRIM(p, n, b) { \ 1167c478bd9Sstevel@tonic-gate ((p)->pld_ary[(n)].pld_wptr -= (b)); \ 1177c478bd9Sstevel@tonic-gate ASSERT((p)->pld_ary[(n)].pld_wptr >= (p)->pld_ary[(n)].pld_rptr); \ 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #define PDESC_PLD_SPAN_CLEAR(p, n) \ 1217c478bd9Sstevel@tonic-gate PDESC_PLD_SPAN_TRIM(p, n, PDESC_PLD_SPAN_SIZE(p, n)) 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #define PDESC_PLD_SPAN_ADD(p, pbuf_idx, rptr, len) { \ 1247c478bd9Sstevel@tonic-gate ASSERT((p)->pld_cnt < MULTIDATA_MAX_PBUFS); \ 1257c478bd9Sstevel@tonic-gate (p)->pld_ary[(p)->pld_cnt].pld_pbuf_idx = (pbuf_idx); \ 1267c478bd9Sstevel@tonic-gate (p)->pld_ary[(p)->pld_cnt].pld_rptr = (rptr); \ 1277c478bd9Sstevel@tonic-gate (p)->pld_ary[(p)->pld_cnt].pld_wptr = (rptr) + (len); \ 1287c478bd9Sstevel@tonic-gate (p)->pld_cnt++; \ 1297c478bd9Sstevel@tonic-gate } 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * These structures are opaque to multidata clients. 1337c478bd9Sstevel@tonic-gate */ 1347c478bd9Sstevel@tonic-gate struct pdesc_s; 1357c478bd9Sstevel@tonic-gate typedef struct pdesc_s pdesc_t; 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate struct pattr_s; 1387c478bd9Sstevel@tonic-gate typedef struct pattr_s pattr_t; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate struct multidata_s; 1417c478bd9Sstevel@tonic-gate typedef struct multidata_s multidata_t; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate extern multidata_t *mmd_alloc(mblk_t *, mblk_t **, int); 1467c478bd9Sstevel@tonic-gate extern int mmd_addpldbuf(multidata_t *, mblk_t *); 1477c478bd9Sstevel@tonic-gate extern multidata_t *mmd_getmultidata(mblk_t *); 1487c478bd9Sstevel@tonic-gate extern void mmd_getregions(multidata_t *, mbufinfo_t *); 1497c478bd9Sstevel@tonic-gate extern uint_t mmd_getcnt(multidata_t *, uint_t *, uint_t *); 1507c478bd9Sstevel@tonic-gate extern pdesc_t *mmd_addpdesc(multidata_t *, pdescinfo_t *, int *, int); 1517c478bd9Sstevel@tonic-gate extern void mmd_rempdesc(pdesc_t *); 1527c478bd9Sstevel@tonic-gate extern pdesc_t *mmd_getfirstpdesc(multidata_t *, pdescinfo_t *); 1537c478bd9Sstevel@tonic-gate extern pdesc_t *mmd_getlastpdesc(multidata_t *, pdescinfo_t *); 1547c478bd9Sstevel@tonic-gate extern pdesc_t *mmd_getnextpdesc(pdesc_t *, pdescinfo_t *); 1557c478bd9Sstevel@tonic-gate extern pdesc_t *mmd_getprevpdesc(pdesc_t *, pdescinfo_t *); 1567c478bd9Sstevel@tonic-gate extern pdesc_t *mmd_adjpdesc(pdesc_t *, pdescinfo_t *); 1577c478bd9Sstevel@tonic-gate extern mblk_t *mmd_transform(pdesc_t *); 1587c478bd9Sstevel@tonic-gate extern mblk_t *mmd_transform_link(pdesc_t *); 1597c478bd9Sstevel@tonic-gate extern int mmd_dupbufs(multidata_t *, mblk_t **, mblk_t **); 1607c478bd9Sstevel@tonic-gate extern int mmd_getpdescinfo(pdesc_t *, pdescinfo_t *); 1617c478bd9Sstevel@tonic-gate extern pattr_t *mmd_addpattr(multidata_t *, pdesc_t *, pattrinfo_t *, 1627c478bd9Sstevel@tonic-gate boolean_t, int); 1637c478bd9Sstevel@tonic-gate extern void mmd_rempattr(pattr_t *); 1647c478bd9Sstevel@tonic-gate extern pattr_t *mmd_getpattr(multidata_t *, pdesc_t *, pattrinfo_t *); 1657c478bd9Sstevel@tonic-gate extern void mmd_getsize(multidata_t *, uint_t *, uint_t *); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate #endif 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate #endif /* _SYS_MULTIDATA_H */ 174