1321936Shselasky/*
2321936Shselasky * Copyright (c) 2005 Intel Corporation.  All rights reserved.
3321936Shselasky *
4321936Shselasky * This software is available to you under a choice of one of two
5321936Shselasky * licenses.  You may choose to be licensed under the terms of the GNU
6321936Shselasky * General Public License (GPL) Version 2, available from the file
7321936Shselasky * COPYING in the main directory of this source tree, or the
8321936Shselasky * OpenIB.org BSD license below:
9321936Shselasky *
10321936Shselasky *     Redistribution and use in source and binary forms, with or
11321936Shselasky *     without modification, are permitted provided that the following
12321936Shselasky *     conditions are met:
13321936Shselasky *
14321936Shselasky *      - Redistributions of source code must retain the above
15321936Shselasky *        copyright notice, this list of conditions and the following
16321936Shselasky *        disclaimer.
17321936Shselasky *
18321936Shselasky *      - Redistributions in binary form must reproduce the above
19321936Shselasky *        copyright notice, this list of conditions and the following
20321936Shselasky *        disclaimer in the documentation and/or other materials
21321936Shselasky *        provided with the distribution.
22321936Shselasky *
23321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30321936Shselasky * SOFTWARE.
31321936Shselasky */
32321936Shselasky
33321936Shselasky#include <config.h>
34321936Shselasky
35321936Shselasky#include <string.h>
36321936Shselasky
37321936Shselasky#include <infiniband/marshall.h>
38321936Shselasky
39321936Shselaskyvoid ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
40321936Shselasky				struct ibv_kern_ah_attr *src)
41321936Shselasky{
42321936Shselasky	memcpy(dst->grh.dgid.raw, src->grh.dgid, sizeof dst->grh.dgid);
43321936Shselasky	dst->grh.flow_label = src->grh.flow_label;
44321936Shselasky	dst->grh.sgid_index = src->grh.sgid_index;
45321936Shselasky	dst->grh.hop_limit = src->grh.hop_limit;
46321936Shselasky	dst->grh.traffic_class = src->grh.traffic_class;
47321936Shselasky
48321936Shselasky	dst->dlid = src->dlid;
49321936Shselasky	dst->sl = src->sl;
50321936Shselasky	dst->src_path_bits = src->src_path_bits;
51321936Shselasky	dst->static_rate = src->static_rate;
52321936Shselasky	dst->is_global = src->is_global;
53321936Shselasky	dst->port_num = src->port_num;
54321936Shselasky}
55321936Shselasky
56321936Shselaskyvoid ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
57321936Shselasky				struct ibv_kern_qp_attr *src)
58321936Shselasky{
59321936Shselasky	dst->cur_qp_state = src->cur_qp_state;
60321936Shselasky	dst->path_mtu = src->path_mtu;
61321936Shselasky	dst->path_mig_state = src->path_mig_state;
62321936Shselasky	dst->qkey = src->qkey;
63321936Shselasky	dst->rq_psn = src->rq_psn;
64321936Shselasky	dst->sq_psn = src->sq_psn;
65321936Shselasky	dst->dest_qp_num = src->dest_qp_num;
66321936Shselasky	dst->qp_access_flags = src->qp_access_flags;
67321936Shselasky
68321936Shselasky	dst->cap.max_send_wr = src->max_send_wr;
69321936Shselasky	dst->cap.max_recv_wr = src->max_recv_wr;
70321936Shselasky	dst->cap.max_send_sge = src->max_send_sge;
71321936Shselasky	dst->cap.max_recv_sge = src->max_recv_sge;
72321936Shselasky	dst->cap.max_inline_data = src->max_inline_data;
73321936Shselasky
74321936Shselasky	ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
75321936Shselasky	ibv_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr);
76321936Shselasky
77321936Shselasky	dst->pkey_index = src->pkey_index;
78321936Shselasky	dst->alt_pkey_index = src->alt_pkey_index;
79321936Shselasky	dst->en_sqd_async_notify = src->en_sqd_async_notify;
80321936Shselasky	dst->sq_draining = src->sq_draining;
81321936Shselasky	dst->max_rd_atomic = src->max_rd_atomic;
82321936Shselasky	dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
83321936Shselasky	dst->min_rnr_timer = src->min_rnr_timer;
84321936Shselasky	dst->port_num = src->port_num;
85321936Shselasky	dst->timeout = src->timeout;
86321936Shselasky	dst->retry_cnt = src->retry_cnt;
87321936Shselasky	dst->rnr_retry = src->rnr_retry;
88321936Shselasky	dst->alt_port_num = src->alt_port_num;
89321936Shselasky	dst->alt_timeout = src->alt_timeout;
90321936Shselasky}
91321936Shselasky
92321936Shselaskyvoid ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
93321936Shselasky				 struct ib_user_path_rec *src)
94321936Shselasky{
95321936Shselasky	memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
96321936Shselasky	memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
97321936Shselasky
98321936Shselasky	dst->dlid		= src->dlid;
99321936Shselasky	dst->slid		= src->slid;
100321936Shselasky	dst->raw_traffic	= src->raw_traffic;
101321936Shselasky	dst->flow_label		= src->flow_label;
102321936Shselasky	dst->hop_limit		= src->hop_limit;
103321936Shselasky	dst->traffic_class	= src->traffic_class;
104321936Shselasky	dst->reversible		= src->reversible;
105321936Shselasky	dst->numb_path		= src->numb_path;
106321936Shselasky	dst->pkey		= src->pkey;
107321936Shselasky	dst->sl			= src->sl;
108321936Shselasky	dst->mtu_selector	= src->mtu_selector;
109321936Shselasky	dst->mtu		= src->mtu;
110321936Shselasky	dst->rate_selector	= src->rate_selector;
111321936Shselasky	dst->rate		= src->rate;
112321936Shselasky	dst->packet_life_time	= src->packet_life_time;
113321936Shselasky	dst->preference		= src->preference;
114321936Shselasky	dst->packet_life_time_selector = src->packet_life_time_selector;
115321936Shselasky}
116321936Shselasky
117321936Shselaskyvoid ibv_copy_path_rec_to_kern(struct ib_user_path_rec *dst,
118321936Shselasky			       struct ibv_sa_path_rec *src)
119321936Shselasky{
120321936Shselasky	memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
121321936Shselasky	memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
122321936Shselasky
123321936Shselasky	dst->dlid		= src->dlid;
124321936Shselasky	dst->slid		= src->slid;
125321936Shselasky	dst->raw_traffic	= src->raw_traffic;
126321936Shselasky	dst->flow_label		= src->flow_label;
127321936Shselasky	dst->hop_limit		= src->hop_limit;
128321936Shselasky	dst->traffic_class	= src->traffic_class;
129321936Shselasky	dst->reversible		= src->reversible;
130321936Shselasky	dst->numb_path		= src->numb_path;
131321936Shselasky	dst->pkey		= src->pkey;
132321936Shselasky	dst->sl			= src->sl;
133321936Shselasky	dst->mtu_selector	= src->mtu_selector;
134321936Shselasky	dst->mtu		= src->mtu;
135321936Shselasky	dst->rate_selector	= src->rate_selector;
136321936Shselasky	dst->rate		= src->rate;
137321936Shselasky	dst->packet_life_time	= src->packet_life_time;
138321936Shselasky	dst->preference		= src->preference;
139321936Shselasky	dst->packet_life_time_selector = src->packet_life_time_selector;
140321936Shselasky}
141