[openib-general] Re: common userspace support

Sean Hefty mshefty at ichips.intel.com
Wed Nov 2 14:15:44 PST 2005


Michael S. Tsirkin wrote:
> Common header files/structures might make some sense, but what would
> the routines do, besides copy to/from user?
> Could you give an example?

The "copies" aren't memory copies, but field by field assignments.  The function 
below is used by ib_ucm to copy QP attributes from the kernel to the userspace 
app.  The same functionality is needed by rdma_ucm.

- Sean

static void ib_ucm_copy_qp_attr(struct ib_ucm_init_qp_attr_resp *dest_attr,
				struct ib_qp_attr *src_attr)
{
	dest_attr->cur_qp_state = src_attr->cur_qp_state;
	dest_attr->path_mtu = src_attr->path_mtu;
	dest_attr->path_mig_state = src_attr->path_mig_state;
	dest_attr->qkey = src_attr->qkey;
	dest_attr->rq_psn = src_attr->rq_psn;
	dest_attr->sq_psn = src_attr->sq_psn;
	dest_attr->dest_qp_num = src_attr->dest_qp_num;
	dest_attr->qp_access_flags = src_attr->qp_access_flags;

	dest_attr->max_send_wr = src_attr->cap.max_send_wr;
	dest_attr->max_recv_wr = src_attr->cap.max_recv_wr;
	dest_attr->max_send_sge = src_attr->cap.max_send_sge;
	dest_attr->max_recv_sge = src_attr->cap.max_recv_sge;
	dest_attr->max_inline_data = src_attr->cap.max_inline_data;

	ib_ucm_copy_ah_attr(&dest_attr->ah_attr, &src_attr->ah_attr);
	ib_ucm_copy_ah_attr(&dest_attr->alt_ah_attr, &src_attr->alt_ah_attr);

	dest_attr->pkey_index = src_attr->pkey_index;
	dest_attr->alt_pkey_index = src_attr->alt_pkey_index;
	dest_attr->en_sqd_async_notify = src_attr->en_sqd_async_notify;
	dest_attr->sq_draining = src_attr->sq_draining;
	dest_attr->max_rd_atomic = src_attr->max_rd_atomic;
	dest_attr->max_dest_rd_atomic = src_attr->max_dest_rd_atomic;
	dest_attr->min_rnr_timer = src_attr->min_rnr_timer;
	dest_attr->port_num = src_attr->port_num;
	dest_attr->timeout = src_attr->timeout;
	dest_attr->retry_cnt = src_attr->retry_cnt;
	dest_attr->rnr_retry = src_attr->rnr_retry;
	dest_attr->alt_port_num = src_attr->alt_port_num;
	dest_attr->alt_timeout = src_attr->alt_timeout;
}




More information about the general mailing list