]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
MFV r337197: 9456 ztest failure in zil_commit_waiter_timeout
[FreeBSD/FreeBSD.git] / sys / ofed / drivers / infiniband / core / ib_uverbs_marshall.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
37
38 #include <rdma/ib_marshall.h>
39
40 void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
41                              struct ib_ah_attr *src)
42 {
43         memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);
44         dst->grh.flow_label        = src->grh.flow_label;
45         dst->grh.sgid_index        = src->grh.sgid_index;
46         dst->grh.hop_limit         = src->grh.hop_limit;
47         dst->grh.traffic_class     = src->grh.traffic_class;
48         memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
49         dst->dlid                  = src->dlid;
50         dst->sl                    = src->sl;
51         dst->src_path_bits         = src->src_path_bits;
52         dst->static_rate           = src->static_rate;
53         dst->is_global             = src->ah_flags & IB_AH_GRH ? 1 : 0;
54         dst->port_num              = src->port_num;
55         dst->reserved              = 0;
56 }
57 EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
58
59 void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
60                              struct ib_qp_attr *src)
61 {
62         dst->qp_state           = src->qp_state;
63         dst->cur_qp_state       = src->cur_qp_state;
64         dst->path_mtu           = src->path_mtu;
65         dst->path_mig_state     = src->path_mig_state;
66         dst->qkey               = src->qkey;
67         dst->rq_psn             = src->rq_psn;
68         dst->sq_psn             = src->sq_psn;
69         dst->dest_qp_num        = src->dest_qp_num;
70         dst->qp_access_flags    = src->qp_access_flags;
71
72         dst->max_send_wr        = src->cap.max_send_wr;
73         dst->max_recv_wr        = src->cap.max_recv_wr;
74         dst->max_send_sge       = src->cap.max_send_sge;
75         dst->max_recv_sge       = src->cap.max_recv_sge;
76         dst->max_inline_data    = src->cap.max_inline_data;
77
78         ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
79         ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);
80
81         dst->pkey_index         = src->pkey_index;
82         dst->alt_pkey_index     = src->alt_pkey_index;
83         dst->en_sqd_async_notify = src->en_sqd_async_notify;
84         dst->sq_draining        = src->sq_draining;
85         dst->max_rd_atomic      = src->max_rd_atomic;
86         dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
87         dst->min_rnr_timer      = src->min_rnr_timer;
88         dst->port_num           = src->port_num;
89         dst->timeout            = src->timeout;
90         dst->retry_cnt          = src->retry_cnt;
91         dst->rnr_retry          = src->rnr_retry;
92         dst->alt_port_num       = src->alt_port_num;
93         dst->alt_timeout        = src->alt_timeout;
94         memset(dst->reserved, 0, sizeof(dst->reserved));
95 }
96 EXPORT_SYMBOL(ib_copy_qp_attr_to_user);
97
98 void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
99                               struct ib_sa_path_rec *src)
100 {
101         memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
102         memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
103
104         dst->dlid               = src->dlid;
105         dst->slid               = src->slid;
106         dst->raw_traffic        = src->raw_traffic;
107         dst->flow_label         = src->flow_label;
108         dst->hop_limit          = src->hop_limit;
109         dst->traffic_class      = src->traffic_class;
110         dst->reversible         = src->reversible;
111         dst->numb_path          = src->numb_path;
112         dst->pkey               = src->pkey;
113         dst->sl                 = src->sl;
114         dst->mtu_selector       = src->mtu_selector;
115         dst->mtu                = src->mtu;
116         dst->rate_selector      = src->rate_selector;
117         dst->rate               = src->rate;
118         dst->packet_life_time   = src->packet_life_time;
119         dst->preference         = src->preference;
120         dst->packet_life_time_selector = src->packet_life_time_selector;
121 }
122 EXPORT_SYMBOL(ib_copy_path_rec_to_user);
123
124 void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
125                                 struct ib_user_path_rec *src)
126 {
127         memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
128         memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
129
130         dst->dlid               = src->dlid;
131         dst->slid               = src->slid;
132         dst->raw_traffic        = src->raw_traffic;
133         dst->flow_label         = src->flow_label;
134         dst->hop_limit          = src->hop_limit;
135         dst->traffic_class      = src->traffic_class;
136         dst->reversible         = src->reversible;
137         dst->numb_path          = src->numb_path;
138         dst->pkey               = src->pkey;
139         dst->sl                 = src->sl;
140         dst->mtu_selector       = src->mtu_selector;
141         dst->mtu                = src->mtu;
142         dst->rate_selector      = src->rate_selector;
143         dst->rate               = src->rate;
144         dst->packet_life_time   = src->packet_life_time;
145         dst->preference         = src->preference;
146         dst->packet_life_time_selector = src->packet_life_time_selector;
147
148         memset(dst->dmac, 0, sizeof(dst->dmac));
149         dst->net = NULL;
150         dst->ifindex = 0;
151         dst->gid_type = IB_GID_TYPE_IB;
152 }
153 EXPORT_SYMBOL(ib_copy_path_rec_from_user);