Lines Matching defs:mmd
39 * Available as http://sac.sfbay/PSARC/2002/276/materials/mmd.pdf.
188 multidata_t *mmd;
207 mmd = (multidata_t *)(buf_info + 1);
208 mmd_mplen = sizeof (*mmd);
210 if ((*mmd_mp = desballoc((uchar_t *)mmd, mmd_mplen, BPRI_HI,
218 mmd->mmd_dp = (*mmd_mp)->b_datap;
219 mmd->mmd_hbuf = hdr_mp;
221 return (mmd);
228 mmd_addpldbuf(multidata_t *mmd, mblk_t *pld_mp)
232 ASSERT(mmd != NULL);
233 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
236 mutex_enter(&mmd->mmd_pd_slab_lock);
238 mmd->mmd_pbuf_cnt < MULTIDATA_MAX_PBUFS; i++) {
239 if (mmd->mmd_pbuf[i] == pld_mp) {
242 "pld 0x%p to mmd 0x%p since it has been "
244 (void *)pld_mp, (void *)mmd, i, mmd->mmd_pbuf_cnt));
245 mutex_exit(&mmd->mmd_pd_slab_lock);
247 } else if (mmd->mmd_pbuf[i] == NULL) {
248 mmd->mmd_pbuf[i] = pld_mp;
249 mmd->mmd_pbuf_cnt++;
250 mutex_exit(&mmd->mmd_pd_slab_lock);
256 MMD_DEBUG((CE_WARN, "mmd_addpldbuf: error adding pld 0x%p to mmd 0x%p "
258 (void *)mmd, mmd->mmd_pbuf_cnt, MULTIDATA_MAX_PBUFS));
259 mutex_exit(&mmd->mmd_pd_slab_lock);
272 multidata_t *mmd;
280 mmd = (multidata_t *)(buf_info + 1);
281 mmd->mmd_magic = MULTIDATA_MAGIC;
283 mutex_init(&(mmd->mmd_pd_slab_lock), NULL, MUTEX_DRIVER, NULL);
284 QL_INIT(&(mmd->mmd_pd_slab_q));
285 QL_INIT(&(mmd->mmd_pd_q));
297 multidata_t *mmd;
302 mmd = (multidata_t *)((uchar_t *)buf + sizeof (struct mmd_buf_info));
304 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
305 ASSERT(mmd->mmd_dp == NULL);
306 ASSERT(mmd->mmd_hbuf == NULL);
307 ASSERT(mmd->mmd_pbuf_cnt == 0);
310 ASSERT(mmd->mmd_pbuf[i] == NULL);
312 ASSERT(mmd->mmd_pattbl == NULL);
314 mutex_destroy(&(mmd->mmd_pd_slab_lock));
315 ASSERT(mmd->mmd_pd_slab_q.ql_next == &(mmd->mmd_pd_slab_q));
316 ASSERT(mmd->mmd_slab_cnt == 0);
317 ASSERT(mmd->mmd_pd_q.ql_next == &(mmd->mmd_pd_q));
318 ASSERT(mmd->mmd_pd_cnt == 0);
319 ASSERT(mmd->mmd_hbuf_ref == 0);
320 ASSERT(mmd->mmd_pbuf_ref == 0);
329 multidata_t *mmd;
337 mmd = (multidata_t *)(buf + sizeof (struct mmd_buf_info));
338 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
340 ASSERT(mmd->mmd_dp != NULL);
341 ASSERT(mmd->mmd_dp->db_ref == 1);
344 pd = Q2PD(mmd->mmd_pd_q.ql_next);
345 while (pd != Q2PD(&(mmd->mmd_pd_q)))
346 pd = mmd_destroy_pdesc(mmd, pd);
348 ASSERT(mmd->mmd_pd_q.ql_next == &(mmd->mmd_pd_q));
349 ASSERT(mmd->mmd_pd_cnt == 0);
350 ASSERT(mmd->mmd_hbuf_ref == 0);
351 ASSERT(mmd->mmd_pbuf_ref == 0);
354 if (mmd->mmd_pattbl != NULL)
355 mmd_destroy_pattbl(&(mmd->mmd_pattbl));
358 slab = Q2PDSLAB(mmd->mmd_pd_slab_q.ql_next);
359 while (slab != Q2PDSLAB(&(mmd->mmd_pd_slab_q))) {
369 ASSERT(mmd->mmd_slab_cnt > 0);
370 mmd->mmd_slab_cnt--;
373 ASSERT(mmd->mmd_pd_slab_q.ql_next == &(mmd->mmd_pd_slab_q));
374 ASSERT(mmd->mmd_slab_cnt == 0);
376 mmd->mmd_dp = NULL;
379 if (mmd->mmd_hbuf != NULL) {
380 freeb(mmd->mmd_hbuf);
381 mmd->mmd_hbuf = NULL;
385 if (mmd->mmd_pbuf[i] != NULL) {
386 freeb(mmd->mmd_pbuf[i]);
387 mmd->mmd_pbuf[i] = NULL;
388 ASSERT(mmd->mmd_pbuf_cnt > 0);
389 mmd->mmd_pbuf_cnt--;
393 ASSERT(mmd->mmd_pbuf_cnt == 0);
394 ASSERT(MUTEX_NOT_HELD(&(mmd->mmd_pd_slab_lock)));
408 multidata_t *mmd, *n_mmd;
426 mmd = mmd_getmultidata(bp);
429 if (mmd->mmd_hbuf != NULL && (n_hbuf = copyb(mmd->mmd_hbuf)) == NULL)
433 mutex_enter(&mmd->mmd_pd_slab_lock);
435 n_pbuf_cnt = mmd->mmd_pbuf_cnt;
437 ASSERT(mmd->mmd_pbuf[i] != NULL);
438 n_pbuf[i] = copyb(mmd->mmd_pbuf[i]);
441 mutex_exit(&mmd->mmd_pd_slab_lock);
453 mutex_exit(&mmd->mmd_pd_slab_lock);
468 mutex_exit(&mmd->mmd_pd_slab_lock);
474 if (mmd->mmd_pattbl != NULL &&
475 mmd_copy_pattbl(mmd->mmd_pattbl, n_mmd, NULL, kmflags) < 0) {
477 mutex_exit(&mmd->mmd_pd_slab_lock);
482 pd = mmd_getpdesc(mmd, NULL, NULL, 1, B_TRUE); /* first pdesc */
509 base = mmd->mmd_hbuf->b_rptr;
526 ASSERT(mmd->mmd_pbuf[idx] != NULL);
529 base = mmd->mmd_pbuf[idx]->b_rptr;
552 mutex_exit(&mmd->mmd_pd_slab_lock);
561 mutex_exit(&mmd->mmd_pd_slab_lock);
571 multidata_t *mmd;
578 mmd = (multidata_t *)mp->b_rptr;
579 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
581 return (mmd);
588 mmd_getregions(multidata_t *mmd, mbufinfo_t *mbi)
592 ASSERT(mmd != NULL);
593 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
598 if (mmd->mmd_hbuf != NULL) {
599 mbi->hbuf_rptr = mmd->mmd_hbuf->b_rptr;
600 mbi->hbuf_wptr = mmd->mmd_hbuf->b_wptr;
603 mutex_enter(&mmd->mmd_pd_slab_lock);
604 for (i = 0; i < mmd->mmd_pbuf_cnt; i++) {
605 ASSERT(mmd->mmd_pbuf[i] != NULL);
606 mbi->pbuf_ary[i].pbuf_rptr = mmd->mmd_pbuf[i]->b_rptr;
607 mbi->pbuf_ary[i].pbuf_wptr = mmd->mmd_pbuf[i]->b_wptr;
610 mbi->pbuf_cnt = mmd->mmd_pbuf_cnt;
611 mutex_exit(&mmd->mmd_pd_slab_lock);
618 mmd_getcnt(multidata_t *mmd, uint_t *hbuf_ref, uint_t *pbuf_ref)
622 ASSERT(mmd != NULL);
623 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
625 mutex_enter(&(mmd->mmd_pd_slab_lock));
627 *hbuf_ref = mmd->mmd_hbuf_ref;
629 *pbuf_ref = mmd->mmd_pbuf_ref;
630 pd_cnt = mmd->mmd_pd_cnt;
631 mutex_exit(&(mmd->mmd_pd_slab_lock));
636 #define HBUF_REF_VALID(mmd, pdi) \
637 ((mmd)->mmd_hbuf != NULL && (pdi)->hdr_rptr != NULL && \
643 (pdi)->hdr_base >= (mmd)->mmd_hbuf->b_rptr && \
644 MBLKIN((mmd)->mmd_hbuf, \
645 (pdi->hdr_base - (mmd)->mmd_hbuf->b_rptr), \
652 pbuf_ref_valid(multidata_t *mmd, pdescinfo_t *pdi)
658 mutex_enter(&mmd->mmd_pd_slab_lock);
659 if (pdi->pld_cnt == 0 || pdi->pld_cnt > mmd->mmd_pbuf_cnt) {
660 mutex_exit(&mmd->mmd_pd_slab_lock);
666 valid = (((idx = pa->pld_pbuf_idx) < mmd->mmd_pbuf_cnt) &&
669 pa->pld_rptr >= mmd->mmd_pbuf[idx]->b_rptr &&
670 MBLKIN(mmd->mmd_pbuf[idx], (pa->pld_rptr -
671 mmd->mmd_pbuf[idx]->b_rptr),
681 i, pdi->pld_cnt, idx, mmd->mmd_pbuf_cnt,
685 (void *)mmd->mmd_pbuf[idx]->b_rptr,
686 (void *)mmd->mmd_pbuf[idx]->b_wptr,
687 (int)MBLKL(mmd->mmd_pbuf[idx])));
695 mutex_exit(&mmd->mmd_pd_slab_lock);
703 mmd_addpdesc(multidata_t *mmd, pdescinfo_t *pdi, int *err, int kmflags)
705 ASSERT(mmd != NULL);
706 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
712 (((pdi->flags & PDESC_HBUF_REF) && !HBUF_REF_VALID(mmd, pdi)) ||
713 ((pdi->flags & PDESC_PBUF_REF) && !pbuf_ref_valid(mmd, pdi)))) {
719 return (mmd_addpdesc_int(mmd, pdi, err, kmflags));
727 mmd_addpdesc_int(multidata_t *mmd, pdescinfo_t *pdi, int *err, int kmflags)
733 ASSERT(!(pdi->flags & PDESC_HBUF_REF) || HBUF_REF_VALID(mmd, pdi));
734 ASSERT(!(pdi->flags & PDESC_PBUF_REF) || pbuf_ref_valid(mmd, pdi));
739 mutex_enter(&(mmd->mmd_pd_slab_lock));
745 slab_last = Q2PDSLAB(mmd->mmd_pd_slab_q.ql_prev);
746 if (mmd->mmd_pd_slab_q.ql_next == &(mmd->mmd_pd_slab_q) ||
752 mutex_exit(&(mmd->mmd_pd_slab_lock));
755 slab->pds_mmd = mmd;
761 insque(&(slab->pds_next), mmd->mmd_pd_slab_q.ql_prev);
762 mmd->mmd_slab_cnt++;
778 mmd->mmd_hbuf_ref++;
780 mmd->mmd_pbuf_ref += pd->pd_pdi.pld_cnt;
781 mmd->mmd_pd_cnt++;
784 insque(&(pd->pd_next), mmd->mmd_pd_q.ql_prev);
785 mutex_exit(&(mmd->mmd_pd_slab_lock));
839 mmd_destroy_pdesc(multidata_t *mmd, pdesc_t *pd)
853 ASSERT(mmd->mmd_hbuf_ref > 0);
854 mmd->mmd_hbuf_ref--;
857 ASSERT(mmd->mmd_pbuf_ref > 0);
858 mmd->mmd_pbuf_ref -= pd->pd_pdi.pld_cnt;
860 ASSERT(mmd->mmd_pd_cnt > 0);
861 mmd->mmd_pd_cnt--;
872 multidata_t *mmd;
877 mmd = pd->pd_slab->pds_mmd;
878 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
880 mutex_enter(&(mmd->mmd_pd_slab_lock));
888 if (mmd->mmd_dp->db_ref > 1) {
891 ASSERT(mmd->mmd_hbuf_ref > 0);
892 mmd->mmd_hbuf_ref--;
895 ASSERT(mmd->mmd_pbuf_ref > 0);
896 mmd->mmd_pbuf_ref -= pd->pd_pdi.pld_cnt;
898 ASSERT(mmd->mmd_pd_cnt > 0);
899 mmd->mmd_pd_cnt--;
901 (void) mmd_destroy_pdesc(mmd, pd);
903 mutex_exit(&(mmd->mmd_pd_slab_lock));
910 mmd_getpdesc(multidata_t *mmd, pdesc_t *pd, pdescinfo_t *pdi, uint_t forw,
915 ASSERT(pd == NULL || pd->pd_slab->pds_mmd == mmd);
916 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
917 ASSERT(!mutex_held || MUTEX_HELD(&(mmd->mmd_pd_slab_lock)));
920 mutex_enter(&(mmd->mmd_pd_slab_lock));
921 pd_head = Q2PD(&(mmd->mmd_pd_q));
928 pd = forw ? Q2PD(mmd->mmd_pd_q.ql_next) :
929 Q2PD(mmd->mmd_pd_q.ql_prev);
945 mutex_exit(&(mmd->mmd_pd_slab_lock));
964 mmd_getfirstpdesc(multidata_t *mmd, pdescinfo_t *pdi)
966 return (mmd_getpdesc(mmd, NULL, pdi, 1, B_FALSE));
973 mmd_getlastpdesc(multidata_t *mmd, pdescinfo_t *pdi)
975 return (mmd_getpdesc(mmd, NULL, pdi, 0, B_FALSE));
1037 multidata_t *mmd;
1044 mmd = pd->pd_slab->pds_mmd;
1045 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1057 (((pdi->flags & PDESC_HBUF_REF) && !HBUF_REF_VALID(mmd, pdi)) ||
1058 ((pdi->flags & PDESC_PBUF_REF) && !pbuf_ref_valid(mmd, pdi))))
1081 multidata_t *mmd;
1090 mmd = pd->pd_slab->pds_mmd;
1091 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1097 mutex_enter(&mmd->mmd_pd_slab_lock);
1109 mutex_exit(&mmd->mmd_pd_slab_lock);
1131 mutex_exit(&mmd->mmd_pd_slab_lock);
1141 multidata_t *mmd;
1148 mmd = pd->pd_slab->pds_mmd;
1149 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1159 if ((nmp = dupb(mmd->mmd_hbuf)) == NULL)
1171 mutex_enter(&mmd->mmd_pd_slab_lock);
1173 ASSERT(mmd->mmd_pbuf[pa->pld_pbuf_idx] != NULL);
1179 mp = dupb(mmd->mmd_pbuf[pa->pld_pbuf_idx]);
1183 mutex_exit(&mmd->mmd_pd_slab_lock);
1193 mutex_exit(&mmd->mmd_pd_slab_lock);
1203 mmd_dupbufs(multidata_t *mmd, mblk_t **hmp, mblk_t **pmp)
1205 ASSERT(mmd != NULL);
1206 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1210 if (mmd->mmd_hbuf != NULL &&
1211 (*hmp = dupb(mmd->mmd_hbuf)) == NULL)
1219 mutex_enter(&mmd->mmd_pd_slab_lock);
1221 for (i = 0; i < mmd->mmd_pbuf_cnt; i++) {
1222 ASSERT(mmd->mmd_pbuf[i] != NULL);
1223 mp = dupb(mmd->mmd_pbuf[i]);
1229 mutex_exit(&mmd->mmd_pd_slab_lock);
1237 mutex_exit(&mmd->mmd_pd_slab_lock);
1270 mmd_addpattr(multidata_t *mmd, pdesc_t *pd, pattrinfo_t *pai,
1279 ASSERT(mmd != NULL);
1280 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1285 tbl_p = pd != NULL ? &(pd->pd_pattbl) : &(mmd->mmd_pattbl);
1316 pa->pat_mmd = mmd;
1525 mmd_getpattr(multidata_t *mmd, pdesc_t *pd, pattrinfo_t *pai)
1530 ASSERT(mmd != NULL);
1531 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1535 tbl = pd != NULL ? pd->pd_pattbl : mmd->mmd_pattbl;
1559 mmd_getsize(multidata_t *mmd, uint_t *ptotal, uint_t *pinuse)
1565 ASSERT(mmd != NULL);
1566 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1568 mutex_enter(&mmd->mmd_pd_slab_lock);
1572 if (mmd->mmd_hbuf != NULL)
1573 *ptotal += MBLKL(mmd->mmd_hbuf);
1575 for (i = 0; i < mmd->mmd_pbuf_cnt; i++) {
1576 ASSERT(mmd->mmd_pbuf[i] != NULL);
1577 *ptotal += MBLKL(mmd->mmd_pbuf[i]);
1584 pd = mmd_getpdesc(mmd, NULL, NULL, 1, B_TRUE);
1589 pd = mmd_getpdesc(mmd, pd, NULL, 1, B_TRUE);
1604 mutex_exit(&mmd->mmd_pd_slab_lock);