[openib-general] Re: [openib-commits] r2256 - in gen2/trunk/src/linux-kernel/infiniband: core include

Hal Rosenstock halr at voltaire.com
Wed May 4 11:25:57 PDT 2005


On Wed, 2005-05-04 at 14:16, sean.hefty at openib.org wrote:
> +void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc, void *buf)
> +{
> +	struct ib_mad_recv_buf *seg_buf;
> +	struct ib_rmpp_mad *rmpp_mad;
> +	void *data;
> +	int size, len, offset;
> +	u8 flags;
> +
> +	len = mad_recv_wc->mad_len;
> +	if (len <= sizeof(struct ib_mad)) {
> +		memcpy(buf, mad_recv_wc->recv_buf.mad, len);
> +		return;
> +	}
> +
> +	offset = data_offset(mad_recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
> +
> +	list_for_each_entry(seg_buf, &mad_recv_wc->rmpp_list, list) {
> +		rmpp_mad = (struct ib_rmpp_mad *)seg_buf->mad;
> +		flags = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr);
> +
> +		if (flags & IB_MGMT_RMPP_FLAG_FIRST) {
> +			data = rmpp_mad;
> +			size = sizeof(*rmpp_mad);
> +		} else {
> +			data = rmpp_mad + offset;
> +			if (flags & IB_MGMT_RMPP_FLAG_LAST) 
> +				size = len;
> +			else
> +				size = sizeof(*rmpp_mad) - offset;
> +		}
> +
> +		memcpy(buf, data, size);
> +		len -= size;
> +		buf += size;
> +	}
> +}

So user_mad should have similar code on the receive side with
copy_to_user rather than memcpy, as it should be the only consumer which
needs this, right ?

-- Hal




More information about the general mailing list