• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MBLKL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MBLKL函数的典型用法代码示例。如果您正苦于以下问题:C++ MBLKL函数的具体用法?C++ MBLKL怎么用?C++ MBLKL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MBLKL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dm2s_prep_scatgath

/*
 * dm2s_prep_scatgath - Prepare scatter/gather elements for transmission
 * of a streams message.
 */
static int
dm2s_prep_scatgath(mblk_t *mp, uint32_t *numsg, mscat_gath_t *sgp, int maxsg)
{
	uint32_t num = 0;
	mblk_t *tmp = mp;

	while ((tmp != NULL) && (num < maxsg)) {
		sgp[num].msc_dptr = (caddr_t)tmp->b_rptr;
		sgp[num].msc_len = MBLKL(tmp);
		tmp = tmp->b_cont;
		num++;
	}

	if (tmp != NULL) {
		/*
		 * Number of scatter/gather elements available are not
		 * enough, so lets pullup the msg.
		 */
		if (pullupmsg(mp, -1) != 1) {
			return (EAGAIN);
		}
		sgp[0].msc_dptr = (caddr_t)mp->b_rptr;
		sgp[0].msc_len = MBLKL(mp);
		num = 1;
	}
	*numsg = num;
	return (0);
}
开发者ID:andreiw,项目名称:polaris,代码行数:32,代码来源:dm2s.c


示例2: xdrmblk_putmblk

/*
 * We avoid a copy by merely adding this mblk to the list.  The caller is
 * responsible for allocating and filling in the mblk. If len is
 * not a multiple of BYTES_PER_XDR_UNIT, the caller has the option
 * of making the data a BYTES_PER_XDR_UNIT multiple (b_wptr - b_rptr is
 * a BYTES_PER_XDR_UNIT multiple), but in this case the caller has to ensure
 * that the filler bytes are initialized to zero.
 */
bool_t
xdrmblk_putmblk(XDR *xdrs, mblk_t *m, uint_t len)
{
	struct xdrmblk_params *p;
	int32_t llen = (int32_t)len;

	if ((DLEN(m) % BYTES_PER_XDR_UNIT) != 0)
		return (FALSE);
	if (!xdrmblk_putint32(xdrs, &llen))
		return (FALSE);

	p = (struct xdrmblk_params *)xdrs->x_private;

	/* LINTED pointer alignment */
	((mblk_t *)xdrs->x_base)->b_cont = m;
	p->apos += p->rpos;

	/* base points to the last mblk */
	while (m->b_cont) {
		p->apos += MBLKL(m);
		m = m->b_cont;
	}
	xdrs->x_base = (caddr_t)m;
	xdrs->x_handy = 0;
	p->rpos = MBLKL(m);
	return (TRUE);
}
开发者ID:ryao,项目名称:openzfs,代码行数:35,代码来源:xdr_mblk.c


示例3: xdrmblk_getmblk

bool_t
xdrmblk_getmblk(XDR *xdrs, mblk_t **mm, uint_t *lenp)
{
	mblk_t *m, *nextm;
	struct xdrmblk_params *p;
	int len;
	uint32_t llen;

	if (!xdrmblk_getint32(xdrs, (int32_t *)&llen))
		return (FALSE);

	*lenp = llen;
	/* LINTED pointer alignment */
	m = (mblk_t *)xdrs->x_base;
	*mm = m;

	/*
	 * Walk the mblk chain until we get to the end or we've gathered
	 * enough data.
	 */
	len = 0;
	llen = roundup(llen, BYTES_PER_XDR_UNIT);
	while (m != NULL && len + (int)MBLKL(m) <= llen) {
		len += (int)MBLKL(m);
		m = m->b_cont;
	}
	if (len < llen) {
		if (m == NULL) {
			return (FALSE);
		} else {
			int tail_bytes = llen - len;

			/*
			 * Split the mblk with the last chunk of data and
			 * insert it into the chain.  The new mblk goes
			 * after the existing one so that it will get freed
			 * properly.
			 */
			nextm = dupb(m);
			if (nextm == NULL)
				return (FALSE);
			nextm->b_cont = m->b_cont;
			m->b_cont = nextm;
			m->b_wptr = m->b_rptr + tail_bytes;
			nextm->b_rptr += tail_bytes;
			ASSERT(nextm->b_rptr != nextm->b_wptr);

			m = nextm;	/* for x_base */
		}
	}
	xdrs->x_base = (caddr_t)m;
	xdrs->x_handy = m != NULL ? MBLKL(m) : 0;

	p = (struct xdrmblk_params *)xdrs->x_private;
	p->apos += p->rpos + llen;
	p->rpos = 0;

	return (TRUE);
}
开发者ID:ryao,项目名称:openzfs,代码行数:59,代码来源:xdr_mblk.c


示例4: BnxeDumpPkt

void BnxeDumpPkt(um_device_t * pUM,
                 char *        pTag,
                 mblk_t *      pMblk,
                 boolean_t     contents)
{
    char buf[256];
    char c[32];
    u8_t * pMem;
    int  i, xx = 0;

    mutex_enter(&bnxeLoaderMutex);

    cmn_err(CE_WARN, "!%s ++++++++++++ %s", BnxeDevName(pUM), pTag);

    while (pMblk)
    {
        pMem = pMblk->b_rptr;
        strcpy(buf, "!** > ");
        snprintf(c, sizeof(c), "%03x", xx);
        strcat(buf, c);
        strcat(buf, ": ");

        if (contents)
        {
            for (i = 0; i < MBLKL(pMblk); i++)
            {
                if ((xx != 0) && (xx % 16 == 0))
                {
                    cmn_err(CE_WARN, buf);
                    strcpy(buf, "!**   ");
                    snprintf(c, sizeof(c), "%03x", xx);
                    strcat(buf, c);
                    strcat(buf, ": ");
                }

                snprintf(c, sizeof(c), "%02x ", *pMem);
                strcat(buf, c);

                pMem++;
                xx++;
            }
        }
        else
        {
            snprintf(c, sizeof(c), "%d", (int)MBLKL(pMblk));
            strcat(buf, c);
            xx += MBLKL(pMblk);
        }

        cmn_err(CE_WARN, buf);
        pMblk = pMblk->b_cont;
    }

    cmn_err(CE_WARN, "!%s ------------ %s", BnxeDevName(pUM), pTag);

    mutex_exit(&bnxeLoaderMutex);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:57,代码来源:bnxe_debug.c


示例5: dl_capab

static int
dl_capab(ldi_handle_t lh, mblk_t **mpp)
{
	dl_capability_req_t	*capb;
	union DL_primitives	*dl_prim;
	mblk_t			*mp;
	int			err;

	if ((mp = allocb(sizeof (dl_capability_req_t), BPRI_MED)) == NULL)
		return (ENOMEM);
	mp->b_datap->db_type = M_PROTO;

	capb = (dl_capability_req_t *)mp->b_wptr;
	mp->b_wptr += sizeof (dl_capability_req_t);
	bzero(mp->b_rptr, sizeof (dl_capability_req_t));
	capb->dl_primitive = DL_CAPABILITY_REQ;

	(void) ldi_putmsg(lh, mp);
	if ((err = ldi_getmsg(lh, &mp, (timestruc_t *)NULL)) != 0)
		return (err);

	dl_prim = (union DL_primitives *)mp->b_rptr;
	switch (dl_prim->dl_primitive) {
	case DL_CAPABILITY_ACK:
		if (MBLKL(mp) < DL_CAPABILITY_ACK_SIZE) {
			printf("dl_capability: DL_CAPABILITY_ACK "
			    "protocol err\n");
			break;
		}
		*mpp = mp;
		return (0);

	case DL_ERROR_ACK:
		if (MBLKL(mp) < DL_ERROR_ACK_SIZE) {
			printf("dl_capability: DL_ERROR_ACK protocol err\n");
			break;
		}
		if (((dl_error_ack_t *)dl_prim)->dl_error_primitive !=
		    DL_CAPABILITY_REQ) {
			printf("dl_capability: DL_ERROR_ACK rtnd prim %u\n",
			    ((dl_error_ack_t *)dl_prim)->dl_error_primitive);
			break;
		}

		*mpp = mp;
		return (0);

	default:
		printf("dl_capability: bad ACK header %u\n",
		    dl_prim->dl_primitive);
		break;
	}

	freemsg(mp);
	return (-1);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:56,代码来源:softmac_capab.c


示例6: skein_digest_final_mblk

/*
 * Performs a Final on a context and writes to an mblk digest output.
 */
static int
skein_digest_final_mblk(skein_ctx_t *ctx, crypto_data_t *digest,
    crypto_req_handle_t req)
{
	off_t	offset = digest->cd_offset;
	mblk_t	*mp;

	/* Jump to the first mblk_t that will be used to store the digest. */
	for (mp = digest->cd_mp; mp != NULL && offset >= MBLKL(mp);
	    offset -= MBLKL(mp), mp = mp->b_cont)
		;
	if (mp == NULL) {
		/* caller specified offset is too large */
		return (CRYPTO_DATA_LEN_RANGE);
	}

	if (offset + CRYPTO_BITS2BYTES(ctx->sc_digest_bitlen) <= MBLKL(mp)) {
		/* The digest will fit in the current mblk. */
		SKEIN_OP(ctx, Final, mp->b_rptr + offset);
	} else {
		/* Split the digest up between the individual buffers. */
		uint8_t *digest_tmp;
		off_t scratch_offset = 0;
		size_t length = CRYPTO_BITS2BYTES(ctx->sc_digest_bitlen);
		size_t cur_len;

		digest_tmp = kmem_alloc(CRYPTO_BITS2BYTES(
		    ctx->sc_digest_bitlen), crypto_kmflag(req));
		if (digest_tmp == NULL)
			return (CRYPTO_HOST_MEMORY);
		SKEIN_OP(ctx, Final, digest_tmp);
		while (mp != NULL && length > 0) {
			cur_len = MIN(MBLKL(mp) - offset, length);
			bcopy(digest_tmp + scratch_offset,
			    mp->b_rptr + offset, cur_len);
			length -= cur_len;
			mp = mp->b_cont;
			scratch_offset += cur_len;
			offset = 0;
		}
		kmem_free(digest_tmp, CRYPTO_BITS2BYTES(ctx->sc_digest_bitlen));
		if (mp == NULL && length > 0) {
			/* digest too long to fit in the mblk buffers */
			return (CRYPTO_DATA_LEN_RANGE);
		}
	}

	return (CRYPTO_SUCCESS);
}
开发者ID:cbreak-black,项目名称:zfs,代码行数:52,代码来源:skein_mod.c


示例7: mmd_getsize

/*
 * Return total size of buffers and total size of areas referenced
 * by all in-use (unremoved) packet descriptors.
 */
void
mmd_getsize(multidata_t *mmd, uint_t *ptotal, uint_t *pinuse)
{
	pdesc_t *pd;
	pdescinfo_t *pdi;
	int i;

	ASSERT(mmd != NULL);
	ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);

	mutex_enter(&mmd->mmd_pd_slab_lock);
	if (ptotal != NULL) {
		*ptotal = 0;

		if (mmd->mmd_hbuf != NULL)
			*ptotal += MBLKL(mmd->mmd_hbuf);

		for (i = 0; i < mmd->mmd_pbuf_cnt; i++) {
			ASSERT(mmd->mmd_pbuf[i] != NULL);
			*ptotal += MBLKL(mmd->mmd_pbuf[i]);
		}
	}
	if (pinuse != NULL) {
		*pinuse = 0;

		/* first pdesc */
		pd = mmd_getpdesc(mmd, NULL, NULL, 1, B_TRUE);
		while (pd != NULL) {
			pdi = &pd->pd_pdi;

			/* next pdesc */
			pd = mmd_getpdesc(mmd, pd, NULL, 1, B_TRUE);

			/* skip over removed descriptor */
			if (pdi->flags & PDESC_REM_DEFER)
				continue;

			if (pdi->flags & PDESC_HBUF_REF)
				*pinuse += PDESC_HDRL(pdi);

			if (pdi->flags & PDESC_PBUF_REF) {
				for (i = 0; i < pdi->pld_cnt; i++)
					*pinuse += PDESC_PLDL(pdi, i);
			}
		}
	}
	mutex_exit(&mmd->mmd_pd_slab_lock);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:52,代码来源:multidata.c


示例8: uftdi_send_data

static int
uftdi_send_data(uftdi_state_t *uf, mblk_t *data)
{
	usb_bulk_req_t *br;
	int len = MBLKL(data);
	int rval;

	USB_DPRINTF_L4(DPRINT_OUT_PIPE, uf->uf_lh,
	    "uftdi_send_data: %d 0x%x 0x%x 0x%x", len, data->b_rptr[0],
	    (len > 1) ? data->b_rptr[1] : 0, (len > 2) ? data->b_rptr[2] : 0);

	ASSERT(!mutex_owned(&uf->uf_lock));

	br = usb_alloc_bulk_req(uf->uf_dip, 0, USB_FLAGS_SLEEP);
	br->bulk_data = data;
	br->bulk_len = len;
	br->bulk_timeout = UFTDI_BULKOUT_TIMEOUT;
	br->bulk_cb = uftdi_bulkout_cb;
	br->bulk_exc_cb = uftdi_bulkout_cb;
	br->bulk_client_private = (usb_opaque_t)uf;
	br->bulk_attributes = USB_ATTRS_AUTOCLEARING;

	rval = usb_pipe_bulk_xfer(uf->uf_bulkout_ph, br, 0);

	if (rval != USB_SUCCESS) {
		USB_DPRINTF_L2(DPRINT_OUT_PIPE, uf->uf_lh,
		    "uftdi_send_data: xfer failed %d", rval);
		br->bulk_data = NULL;
		usb_free_bulk_req(br);
	}

	return (rval);
}
开发者ID:madhavsuresh,项目名称:illumos-gate,代码行数:33,代码来源:uftdi_dsd.c


示例9: proto_detach_req

/*
 * DL_DETACH_REQ
 */
static void
proto_detach_req(dld_str_t *dsp, mblk_t *mp)
{
	queue_t		*q = dsp->ds_wq;
	t_uscalar_t	dl_err;

	if (MBLKL(mp) < sizeof (dl_detach_req_t)) {
		dl_err = DL_BADPRIM;
		goto failed;
	}

	if (dsp->ds_dlstate != DL_UNBOUND) {
		dl_err = DL_OUTSTATE;
		goto failed;
	}

	if (dsp->ds_style == DL_STYLE1) {
		dl_err = DL_BADPRIM;
		goto failed;
	}

	ASSERT(dsp->ds_datathr_cnt == 0);
	dsp->ds_dlstate = DL_DETACH_PENDING;

	dld_str_detach(dsp);
	dlokack(dsp->ds_wq, mp, DL_DETACH_REQ);
	return;

failed:
	dlerrorack(q, mp, DL_DETACH_REQ, dl_err, 0);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:34,代码来源:dld_proto.c


示例10: xdrmblk_skip_fully_read_mblks

/*
 * Skip fully read or empty mblks
 */
static void
xdrmblk_skip_fully_read_mblks(XDR *xdrs)
{
	mblk_t *m;
	struct xdrmblk_params *p;

	if (xdrs->x_handy != 0)
		return;

	/* LINTED pointer alignment */
	m = (mblk_t *)xdrs->x_base;
	if (m == NULL)
		return;

	p = (struct xdrmblk_params *)xdrs->x_private;
	p->apos += p->rpos;
	p->rpos = 0;

	do {
		m = m->b_cont;
		if (m == NULL)
			break;

		xdrs->x_handy = (int)MBLKL(m);
	} while (xdrs->x_handy == 0);

	xdrs->x_base = (caddr_t)m;
}
开发者ID:ryao,项目名称:openzfs,代码行数:31,代码来源:xdr_mblk.c


示例11: proto_unbind_req

/*
 * DL_UNBIND_REQ
 */
static void
proto_unbind_req(dld_str_t *dsp, mblk_t *mp)
{
	queue_t		*q = dsp->ds_wq;
	t_uscalar_t	dl_err;
	mac_perim_handle_t	mph;

	if (MBLKL(mp) < sizeof (dl_unbind_req_t)) {
		dl_err = DL_BADPRIM;
		goto failed;
	}

	if (dsp->ds_dlstate != DL_IDLE) {
		dl_err = DL_OUTSTATE;
		goto failed;
	}

	mutex_enter(&dsp->ds_lock);
	while (dsp->ds_datathr_cnt != 0)
		cv_wait(&dsp->ds_datathr_cv, &dsp->ds_lock);

	dsp->ds_dlstate = DL_UNBIND_PENDING;
	mutex_exit(&dsp->ds_lock);

	mac_perim_enter_by_mh(dsp->ds_mh, &mph);
	/*
	 * Unbind the channel to stop packets being received.
	 */
	dls_unbind(dsp);

	/*
	 * Disable polling mode, if it is enabled.
	 */
	(void) dld_capab_poll_disable(dsp, NULL);

	/*
	 * Clear LSO flags.
	 */
	dsp->ds_lso = B_FALSE;
	dsp->ds_lso_max = 0;

	/*
	 * Clear the receive callback.
	 */
	dls_rx_set(dsp, NULL, NULL);
	dsp->ds_direct = B_FALSE;

	/*
	 * Set the mode back to the default (unitdata).
	 */
	dsp->ds_mode = DLD_UNITDATA;
	dsp->ds_dlstate = DL_UNBOUND;

	dls_active_clear(dsp, B_FALSE);
	mac_perim_exit(mph);
	dlokack(dsp->ds_wq, mp, DL_UNBIND_REQ);
	return;
failed:
	dlerrorack(q, mp, DL_UNBIND_REQ, dl_err, 0);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:63,代码来源:dld_proto.c


示例12: proto_udqos_req

/*
 * DL_UDQOS_REQ
 */
static void
proto_udqos_req(dld_str_t *dsp, mblk_t *mp)
{
	dl_udqos_req_t *dlp = (dl_udqos_req_t *)mp->b_rptr;
	dl_qos_cl_sel1_t *selp;
	int		off, len;
	t_uscalar_t	dl_err;
	queue_t		*q = dsp->ds_wq;

	off = dlp->dl_qos_offset;
	len = dlp->dl_qos_length;

	if (MBLKL(mp) < sizeof (dl_udqos_req_t) || !MBLKIN(mp, off, len)) {
		dl_err = DL_BADPRIM;
		goto failed;
	}

	selp = (dl_qos_cl_sel1_t *)(mp->b_rptr + off);
	if (selp->dl_qos_type != DL_QOS_CL_SEL1) {
		dl_err = DL_BADQOSTYPE;
		goto failed;
	}

	if (selp->dl_priority > (1 << VLAN_PRI_SIZE) - 1 ||
	    selp->dl_priority < 0) {
		dl_err = DL_BADQOSPARAM;
		goto failed;
	}

	dsp->ds_pri = selp->dl_priority;
	dlokack(q, mp, DL_UDQOS_REQ);
	return;
failed:
	dlerrorack(q, mp, DL_UDQOS_REQ, dl_err, 0);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:38,代码来源:dld_proto.c


示例13: mac_ether_header_info

/* ARGSUSED */
int
mac_ether_header_info(mblk_t *mp, void *mac_pdata, mac_header_info_t *hdr_info)
{
	struct ether_header	*ehp;
	uint16_t		ether_type;

	if (MBLKL(mp) < sizeof (struct ether_header))
		return (EINVAL);

	ehp = (void *)mp->b_rptr;
	ether_type = ntohs(ehp->ether_type);

	hdr_info->mhi_hdrsize = sizeof (struct ether_header);
	hdr_info->mhi_daddr = (const uint8_t *)&(ehp->ether_dhost);
	hdr_info->mhi_saddr = (const uint8_t *)&(ehp->ether_shost);
	hdr_info->mhi_origsap = ether_type;
	hdr_info->mhi_bindsap = (ether_type > ETHERMTU) ?
	    ether_type : DLS_SAP_LLC;
	hdr_info->mhi_pktsize = (hdr_info->mhi_bindsap == DLS_SAP_LLC) ?
	    hdr_info->mhi_hdrsize + ether_type : 0;

	if (mac_ether_unicst_verify(hdr_info->mhi_daddr, NULL) == 0)
		hdr_info->mhi_dsttype = MAC_ADDRTYPE_UNICAST;
	else if (mac_ether_multicst_verify(hdr_info->mhi_daddr, NULL) == 0)
		hdr_info->mhi_dsttype = MAC_ADDRTYPE_MULTICAST;
	else
		hdr_info->mhi_dsttype = MAC_ADDRTYPE_BROADCAST;

	return (0);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:31,代码来源:mac_ether.c


示例14: proto_passive_req

/*
 * DL_PASSIVE_REQ
 */
static void
proto_passive_req(dld_str_t *dsp, mblk_t *mp)
{
	t_uscalar_t dl_err;

	/*
	 * If we've already become active by issuing an active primitive,
	 * then it's too late to try to become passive.
	 */
	if (dsp->ds_passivestate == DLD_ACTIVE) {
		dl_err = DL_OUTSTATE;
		goto failed;
	}

	if (MBLKL(mp) < sizeof (dl_passive_req_t)) {
		dl_err = DL_BADPRIM;
		goto failed;
	}

	dsp->ds_passivestate = DLD_PASSIVE;
	dlokack(dsp->ds_wq, mp, DL_PASSIVE_REQ);
	return;
failed:
	dlerrorack(dsp->ds_wq, mp, DL_PASSIVE_REQ, dl_err, 0);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:28,代码来源:dld_proto.c


示例15: uftdi_bulkout_cb

/*ARGSUSED*/
static void
uftdi_bulkout_cb(usb_pipe_handle_t pipe, usb_bulk_req_t *req)
{
	uftdi_state_t	*uf = (uftdi_state_t *)req->bulk_client_private;
	int		data_len;
	mblk_t		*data = req->bulk_data;

	data_len = data ? MBLKL(data) : 0;

	USB_DPRINTF_L4(DPRINT_OUT_PIPE, uf->uf_lh,
	    "uftdi_bulkout_cb: cr=%d len=%d",
	    req->bulk_completion_reason, data_len);

	if (uf->uf_port_state == UFTDI_PORT_OPEN &&
	    req->bulk_completion_reason && data_len > 0) {
		uftdi_put_head(&uf->uf_tx_mp, data);
		req->bulk_data = NULL;
	}

	usb_free_bulk_req(req);

	/* notify GSD */
	if (uf->uf_cb.cb_tx)
		uf->uf_cb.cb_tx(uf->uf_cb.cb_arg);

	/* send more */
	mutex_enter(&uf->uf_lock);
	uf->uf_bulkout_state = UFTDI_PIPE_IDLE;
	if (uf->uf_tx_mp == NULL)
		cv_broadcast(&uf->uf_tx_cv);
	else
		uftdi_tx_start(uf, NULL);
	mutex_exit(&uf->uf_lock);
}
开发者ID:madhavsuresh,项目名称:illumos-gate,代码行数:35,代码来源:uftdi_dsd.c


示例16: proto_enabmulti_req

/*
 * DL_ENABMULTI_REQ
 */
static void
proto_enabmulti_req(dld_str_t *dsp, mblk_t *mp)
{
	dl_enabmulti_req_t *dlp = (dl_enabmulti_req_t *)mp->b_rptr;
	int		err = 0;
	t_uscalar_t	dl_err;
	queue_t		*q = dsp->ds_wq;
	mac_perim_handle_t	mph;

	if (dsp->ds_dlstate == DL_UNATTACHED ||
	    DL_ACK_PENDING(dsp->ds_dlstate)) {
		dl_err = DL_OUTSTATE;
		goto failed;
	}

	if (MBLKL(mp) < sizeof (dl_enabmulti_req_t) ||
	    !MBLKIN(mp, dlp->dl_addr_offset, dlp->dl_addr_length) ||
	    dlp->dl_addr_length != dsp->ds_mip->mi_addr_length) {
		dl_err = DL_BADPRIM;
		goto failed;
	}

	mac_perim_enter_by_mh(dsp->ds_mh, &mph);

	if ((dsp->ds_dmap == NULL) && (err = dls_active_set(dsp)) != 0) {
		dl_err = DL_SYSERR;
		goto failed2;
	}

	err = dls_multicst_add(dsp, mp->b_rptr + dlp->dl_addr_offset);
	if (err != 0) {
		switch (err) {
		case EINVAL:
			dl_err = DL_BADADDR;
			err = 0;
			break;
		case ENOSPC:
			dl_err = DL_TOOMANY;
			err = 0;
			break;
		default:
			dl_err = DL_SYSERR;
			break;
		}
		if (dsp->ds_dmap == NULL)
			dls_active_clear(dsp, B_FALSE);
		goto failed2;
	}

	mac_perim_exit(mph);

	dlokack(q, mp, DL_ENABMULTI_REQ);
	return;

failed2:
	mac_perim_exit(mph);
failed:
	dlerrorack(q, mp, DL_ENABMULTI_REQ, dl_err, (t_uscalar_t)err);
}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:62,代码来源:dld_proto.c


示例17: xdrmblk_getbytes

static bool_t
xdrmblk_getbytes(XDR *xdrs, caddr_t addr, int len)
{
	mblk_t *m;
	struct xdrmblk_params *p;
	int i;

	/* LINTED pointer alignment */
	m = (mblk_t *)xdrs->x_base;
	if (m == NULL)
		return (FALSE);

	p = (struct xdrmblk_params *)xdrs->x_private;

	/*
	 * Performance tweak: converted explicit bcopy()
	 * call to simple in-line. This function is called
	 * to process things like readdir reply filenames
	 * which are small strings--typically 12 bytes or less.
	 * Overhead of calling bcopy() is obnoxious for such
	 * small copies.
	 */
	while (xdrs->x_handy < len) {
		if (xdrs->x_handy > 0) {
			if (xdrs->x_handy < XDRMBLK_BCOPY_LIMIT) {
				for (i = 0; i < xdrs->x_handy; i++)
					*addr++ = *m->b_rptr++;
			} else {
				bcopy(m->b_rptr, addr, xdrs->x_handy);
				m->b_rptr += xdrs->x_handy;
				addr += xdrs->x_handy;
			}
			len -= xdrs->x_handy;
			p->rpos += xdrs->x_handy;
		}
		m = m->b_cont;
		xdrs->x_base = (caddr_t)m;
		p->apos += p->rpos;
		p->rpos = 0;
		if (m == NULL) {
			xdrs->x_handy = 0;
			return (FALSE);
		}
		xdrs->x_handy = (int)MBLKL(m);
	}

	xdrs->x_handy -= len;
	p->rpos += len;

	if (len < XDRMBLK_BCOPY_LIMIT) {
		for (i = 0; i < len; i++)
			*addr++ = *m->b_rptr++;
	} else {
		bcopy(m->b_rptr, addr, len);
		m->b_rptr += len;
	}

	return (TRUE);
}
开发者ID:ryao,项目名称:openzfs,代码行数:59,代码来源:xdr_mblk.c


示例18: hxge_rtrace_ioctl

/*ARGSUSED*/
static void
hxge_rtrace_ioctl(p_hxge_t hxgep, queue_t *wq, mblk_t *mp,
    struct iocblk *iocp)
{
	ssize_t		size;
	rtrace_t	*rtp;
	mblk_t		*nmp;
	uint32_t	i, j;
	uint32_t	start_blk;
	uint32_t	base_entry;
	uint32_t	num_entries;

	HXGE_DEBUG_MSG((hxgep, STR_CTL, "==> hxge_rtrace_ioctl"));

	size = 1024;
	if (mp->b_cont == NULL || MBLKL(mp->b_cont) < size) {
		HXGE_DEBUG_MSG((hxgep, STR_CTL,
		    "malformed M_IOCTL MBLKL = %d size = %d",
		    MBLKL(mp->b_cont), size));
		miocnak(wq, mp, 0, EINVAL);
		return;
	}

	nmp = mp->b_cont;
	rtp = (rtrace_t *)nmp->b_rptr;
	start_blk = rtp->next_idx;
	num_entries = rtp->last_idx;
	base_entry = start_blk * MAX_RTRACE_IOC_ENTRIES;

	HXGE_DEBUG_MSG((hxgep, STR_CTL, "start_blk = %d\n", start_blk));
	HXGE_DEBUG_MSG((hxgep, STR_CTL, "num_entries = %d\n", num_entries));
	HXGE_DEBUG_MSG((hxgep, STR_CTL, "base_entry = %d\n", base_entry));

	rtp->next_idx = hpi_rtracebuf.next_idx;
	rtp->last_idx = hpi_rtracebuf.last_idx;
	rtp->wrapped = hpi_rtracebuf.wrapped;
	for (i = 0, j = base_entry; i < num_entries; i++, j++) {
		rtp->buf[i].ctl_addr = hpi_rtracebuf.buf[j].ctl_addr;
		rtp->buf[i].val_l32 = hpi_rtracebuf.buf[j].val_l32;
		rtp->buf[i].val_h32 = hpi_rtracebuf.buf[j].val_h32;
	}

	nmp->b_wptr = nmp->b_rptr + size;
	HXGE_DEBUG_MSG((hxgep, STR_CTL, "<== hxge_rtrace_ioctl"));
	miocack(wq, mp, (int)size, 0);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:47,代码来源:hxge_hw.c


示例19: oce_bcopy_wqe

/*
 * function to copy the packet to preallocated Tx buffer
 *
 * wq - pointer to WQ
 * wqed - Pointer to WQE descriptor
 * mp - Pointer to packet chain
 * pktlen - Size of the packet
 *
 * return 0=>success, error code otherwise
 */
static int
oce_bcopy_wqe(struct oce_wq *wq, oce_wqe_desc_t *wqed, mblk_t *mp,
    uint32_t pkt_len)
{
	oce_wq_bdesc_t *wqbd;
	caddr_t buf_va;
	struct oce_dev *dev = wq->parent;
	int len = 0;

	wqbd = oce_wqb_alloc(wq);
	if (wqbd == NULL) {
		atomic_inc_32(&dev->tx_noxmtbuf);
		oce_log(dev, CE_WARN, MOD_TX, "%s",
		    "wqb pool empty");
		return (ENOMEM);
	}

	/* create a fragment wqe for the packet */
	wqed->frag[wqed->frag_idx].u0.s.frag_pa_hi = wqbd->frag_addr.dw.addr_hi;
	wqed->frag[wqed->frag_idx].u0.s.frag_pa_lo = wqbd->frag_addr.dw.addr_lo;
	buf_va = DBUF_VA(wqbd->wqb);

	/* copy pkt into buffer */
	for (len = 0; mp != NULL && len < pkt_len; mp = mp->b_cont) {
		bcopy(mp->b_rptr, buf_va, MBLKL(mp));
		buf_va += MBLKL(mp);
		len += MBLKL(mp);
	}

	(void) ddi_dma_sync(DBUF_DHDL(wqbd->wqb), 0, pkt_len,
	    DDI_DMA_SYNC_FORDEV);

	if (oce_fm_check_dma_handle(dev, DBUF_DHDL(wqbd->wqb))) {
		ddi_fm_service_impact(dev->dip, DDI_SERVICE_DEGRADED);
		/* Free the buffer */
		oce_wqb_free(wq, wqbd);
		return (EIO);
	}
	wqed->frag[wqed->frag_idx].u0.s.frag_len   =  pkt_len;
	wqed->hdesc[wqed->nhdl].hdl = (void *)(wqbd);
	wqed->hdesc[wqed->nhdl].type = COPY_WQE;
	wqed->frag_cnt++;
	wqed->frag_idx++;
	wqed->nhdl++;
	return (0);
} /* oce_bcopy_wqe */
开发者ID:apprisi,项目名称:illumos-gate,代码行数:56,代码来源:oce_tx.c


示例20: uftdi_rxerr_put

static void
uftdi_rxerr_put(mblk_t **rx_mpp, mblk_t *data, uint8_t lsr)
{
	uchar_t errflg;

	if (lsr & FTDI_LSR_STATUS_BI) {
		/*
		 * parity and framing errors only "count" if they
		 * occur independently of a break being received.
		 */
		lsr &= ~(uint8_t)(FTDI_LSR_STATUS_PE | FTDI_LSR_STATUS_FE);
	}
	errflg =
	    ((lsr & FTDI_LSR_STATUS_OE) ? DS_OVERRUN_ERR : 0) |
	    ((lsr & FTDI_LSR_STATUS_PE) ? DS_PARITY_ERR : 0) |
	    ((lsr & FTDI_LSR_STATUS_FE) ? DS_FRAMING_ERR : 0) |
	    ((lsr & FTDI_LSR_STATUS_BI) ? DS_BREAK_ERR : 0);

	/*
	 * If there's no actual data, we send a NUL character along
	 * with the error flags.  Otherwise, the data mblk contains
	 * some number of highly questionable characters.
	 *
	 * According to FTDI tech support, there is no synchronous
	 * error reporting i.e. we cannot assume that only the
	 * first character in the mblk is bad -- so we treat all
	 * of them them as if they have the error noted in the LSR.
	 */
	do {
		mblk_t *mp;
		uchar_t c = (MBLKL(data) == 0) ? '\0' : *data->b_rptr++;

		if ((mp = allocb(2, BPRI_HI)) != NULL) {
			DB_TYPE(mp) = M_BREAK;
			*mp->b_wptr++ = errflg;
			*mp->b_wptr++ = c;
			uftdi_put_tail(rx_mpp, mp);
		} else {
			/*
			 * low memory - just discard the bad data
			 */
			data->b_rptr = data->b_wptr;
			break;
		}
	} while (MBLKL(data) > 0);
}
开发者ID:madhavsuresh,项目名称:illumos-gate,代码行数:46,代码来源:uftdi_dsd.c



注:本文中的MBLKL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MCA_SPML_CALL函数代码示例发布时间:2022-05-30
下一篇:
C++ MBGL_CHECK_ERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap