1219820Sjeff/*
2219820Sjeff * Copyright (c) 2005 Intel Corporation.  All rights reserved.
3219820Sjeff *
4219820Sjeff * This software is available to you under a choice of one of two
5219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
6219820Sjeff * General Public License (GPL) Version 2, available from the file
7219820Sjeff * COPYING in the main directory of this source tree, or the
8219820Sjeff * OpenIB.org BSD license below:
9219820Sjeff *
10219820Sjeff *     Redistribution and use in source and binary forms, with or
11219820Sjeff *     without modification, are permitted provided that the following
12219820Sjeff *     conditions are met:
13219820Sjeff *
14219820Sjeff *      - Redistributions of source code must retain the above
15219820Sjeff *        copyright notice, this list of conditions and the following
16219820Sjeff *        disclaimer.
17219820Sjeff *
18219820Sjeff *      - Redistributions in binary form must reproduce the above
19219820Sjeff *        copyright notice, this list of conditions and the following
20219820Sjeff *        disclaimer in the documentation and/or other materials
21219820Sjeff *        provided with the distribution.
22219820Sjeff *
23219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30219820Sjeff * SOFTWARE.
31219820Sjeff */
32219820Sjeff
33219820Sjeff#if HAVE_CONFIG_H
34219820Sjeff#  include <config.h>
35219820Sjeff#endif /* HAVE_CONFIG_H */
36219820Sjeff
37219820Sjeff#include <string.h>
38219820Sjeff
39219820Sjeff#include <infiniband/marshall.h>
40219820Sjeff
41219820Sjeffvoid ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
42219820Sjeff				struct ibv_kern_ah_attr *src)
43219820Sjeff{
44219820Sjeff	memcpy(dst->grh.dgid.raw, src->grh.dgid, sizeof dst->grh.dgid);
45219820Sjeff	dst->grh.flow_label = src->grh.flow_label;
46219820Sjeff	dst->grh.sgid_index = src->grh.sgid_index;
47219820Sjeff	dst->grh.hop_limit = src->grh.hop_limit;
48219820Sjeff	dst->grh.traffic_class = src->grh.traffic_class;
49219820Sjeff
50219820Sjeff	dst->dlid = src->dlid;
51219820Sjeff	dst->sl = src->sl;
52219820Sjeff	dst->src_path_bits = src->src_path_bits;
53219820Sjeff	dst->static_rate = src->static_rate;
54219820Sjeff	dst->is_global = src->is_global;
55219820Sjeff	dst->port_num = src->port_num;
56219820Sjeff}
57219820Sjeff
58219820Sjeffvoid ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
59219820Sjeff				struct ibv_kern_qp_attr *src)
60219820Sjeff{
61219820Sjeff	dst->cur_qp_state = src->cur_qp_state;
62219820Sjeff	dst->path_mtu = src->path_mtu;
63219820Sjeff	dst->path_mig_state = src->path_mig_state;
64219820Sjeff	dst->qkey = src->qkey;
65219820Sjeff	dst->rq_psn = src->rq_psn;
66219820Sjeff	dst->sq_psn = src->sq_psn;
67219820Sjeff	dst->dest_qp_num = src->dest_qp_num;
68219820Sjeff	dst->qp_access_flags = src->qp_access_flags;
69219820Sjeff
70219820Sjeff	dst->cap.max_send_wr = src->max_send_wr;
71219820Sjeff	dst->cap.max_recv_wr = src->max_recv_wr;
72219820Sjeff	dst->cap.max_send_sge = src->max_send_sge;
73219820Sjeff	dst->cap.max_recv_sge = src->max_recv_sge;
74219820Sjeff	dst->cap.max_inline_data = src->max_inline_data;
75219820Sjeff
76219820Sjeff	ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
77219820Sjeff	ibv_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr);
78219820Sjeff
79219820Sjeff	dst->pkey_index = src->pkey_index;
80219820Sjeff	dst->alt_pkey_index = src->alt_pkey_index;
81219820Sjeff	dst->en_sqd_async_notify = src->en_sqd_async_notify;
82219820Sjeff	dst->sq_draining = src->sq_draining;
83219820Sjeff	dst->max_rd_atomic = src->max_rd_atomic;
84219820Sjeff	dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
85219820Sjeff	dst->min_rnr_timer = src->min_rnr_timer;
86219820Sjeff	dst->port_num = src->port_num;
87219820Sjeff	dst->timeout = src->timeout;
88219820Sjeff	dst->retry_cnt = src->retry_cnt;
89219820Sjeff	dst->rnr_retry = src->rnr_retry;
90219820Sjeff	dst->alt_port_num = src->alt_port_num;
91219820Sjeff	dst->alt_timeout = src->alt_timeout;
92219820Sjeff}
93219820Sjeff
94219820Sjeffvoid ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
95219820Sjeff				 struct ibv_kern_path_rec *src)
96219820Sjeff{
97219820Sjeff	memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
98219820Sjeff	memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
99219820Sjeff
100219820Sjeff	dst->dlid		= src->dlid;
101219820Sjeff	dst->slid		= src->slid;
102219820Sjeff	dst->raw_traffic	= src->raw_traffic;
103219820Sjeff	dst->flow_label		= src->flow_label;
104219820Sjeff	dst->hop_limit		= src->hop_limit;
105219820Sjeff	dst->traffic_class	= src->traffic_class;
106219820Sjeff	dst->reversible		= src->reversible;
107219820Sjeff	dst->numb_path		= src->numb_path;
108219820Sjeff	dst->pkey		= src->pkey;
109219820Sjeff	dst->sl			= src->sl;
110219820Sjeff	dst->mtu_selector	= src->mtu_selector;
111219820Sjeff	dst->mtu		= src->mtu;
112219820Sjeff	dst->rate_selector	= src->rate_selector;
113219820Sjeff	dst->rate		= src->rate;
114219820Sjeff	dst->packet_life_time	= src->packet_life_time;
115219820Sjeff	dst->preference		= src->preference;
116219820Sjeff	dst->packet_life_time_selector = src->packet_life_time_selector;
117219820Sjeff}
118219820Sjeff
119219820Sjeffvoid ibv_copy_path_rec_to_kern(struct ibv_kern_path_rec *dst,
120219820Sjeff			       struct ibv_sa_path_rec *src)
121219820Sjeff{
122219820Sjeff	memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
123219820Sjeff	memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
124219820Sjeff
125219820Sjeff	dst->dlid		= src->dlid;
126219820Sjeff	dst->slid		= src->slid;
127219820Sjeff	dst->raw_traffic	= src->raw_traffic;
128219820Sjeff	dst->flow_label		= src->flow_label;
129219820Sjeff	dst->hop_limit		= src->hop_limit;
130219820Sjeff	dst->traffic_class	= src->traffic_class;
131219820Sjeff	dst->reversible		= src->reversible;
132219820Sjeff	dst->numb_path		= src->numb_path;
133219820Sjeff	dst->pkey		= src->pkey;
134219820Sjeff	dst->sl			= src->sl;
135219820Sjeff	dst->mtu_selector	= src->mtu_selector;
136219820Sjeff	dst->mtu		= src->mtu;
137219820Sjeff	dst->rate_selector	= src->rate_selector;
138219820Sjeff	dst->rate		= src->rate;
139219820Sjeff	dst->packet_life_time	= src->packet_life_time;
140219820Sjeff	dst->preference		= src->preference;
141219820Sjeff	dst->packet_life_time_selector = src->packet_life_time_selector;
142219820Sjeff}
143