]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
MFV r331712:
[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  * $FreeBSD$
35  */
36
37 #include <rdma/ib_marshall.h>
38
39 void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
40                              struct ib_ah_attr *src)
41 {
42         memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);
43         dst->grh.flow_label        = src->grh.flow_label;
44         dst->grh.sgid_index        = src->grh.sgid_index;
45         dst->grh.hop_limit         = src->grh.hop_limit;
46         dst->grh.traffic_class     = src->grh.traffic_class;
47         memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
48         dst->dlid                  = src->dlid;
49         dst->sl                    = src->sl;
50         dst->src_path_bits         = src->src_path_bits;
51         dst->static_rate           = src->static_rate;
52         dst->is_global             = src->ah_flags & IB_AH_GRH ? 1 : 0;
53         dst->port_num              = src->port_num;
54         dst->reserved              = 0;
55 }
56 EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
57
58 void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
59                              struct ib_qp_attr *src)
60 {
61         dst->qp_state           = src->qp_state;
62         dst->cur_qp_state       = src->cur_qp_state;
63         dst->path_mtu           = src->path_mtu;
64         dst->path_mig_state     = src->path_mig_state;
65         dst->qkey               = src->qkey;
66         dst->rq_psn             = src->rq_psn;
67         dst->sq_psn             = src->sq_psn;
68         dst->dest_qp_num        = src->dest_qp_num;
69         dst->qp_access_flags    = src->qp_access_flags;
70
71         dst->max_send_wr        = src->cap.max_send_wr;
72         dst->max_recv_wr        = src->cap.max_recv_wr;
73         dst->max_send_sge       = src->cap.max_send_sge;
74         dst->max_recv_sge       = src->cap.max_recv_sge;
75         dst->max_inline_data    = src->cap.max_inline_data;
76
77         ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
78         ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);
79
80         dst->pkey_index         = src->pkey_index;
81         dst->alt_pkey_index     = src->alt_pkey_index;
82         dst->en_sqd_async_notify = src->en_sqd_async_notify;
83         dst->sq_draining        = src->sq_draining;
84         dst->max_rd_atomic      = src->max_rd_atomic;
85         dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
86         dst->min_rnr_timer      = src->min_rnr_timer;
87         dst->port_num           = src->port_num;
88         dst->timeout            = src->timeout;
89         dst->retry_cnt          = src->retry_cnt;
90         dst->rnr_retry          = src->rnr_retry;
91         dst->alt_port_num       = src->alt_port_num;
92         dst->alt_timeout        = src->alt_timeout;
93         memset(dst->reserved, 0, sizeof(dst->reserved));
94 }
95 EXPORT_SYMBOL(ib_copy_qp_attr_to_user);
96
97 void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
98                               struct ib_sa_path_rec *src)
99 {
100         memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
101         memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
102
103         dst->dlid               = src->dlid;
104         dst->slid               = src->slid;
105         dst->raw_traffic        = src->raw_traffic;
106         dst->flow_label         = src->flow_label;
107         dst->hop_limit          = src->hop_limit;
108         dst->traffic_class      = src->traffic_class;
109         dst->reversible         = src->reversible;
110         dst->numb_path          = src->numb_path;
111         dst->pkey               = src->pkey;
112         dst->sl                 = src->sl;
113         dst->mtu_selector       = src->mtu_selector;
114         dst->mtu                = src->mtu;
115         dst->rate_selector      = src->rate_selector;
116         dst->rate               = src->rate;
117         dst->packet_life_time   = src->packet_life_time;
118         dst->preference         = src->preference;
119         dst->packet_life_time_selector = src->packet_life_time_selector;
120 }
121 EXPORT_SYMBOL(ib_copy_path_rec_to_user);
122
123 void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
124                                 struct ib_user_path_rec *src)
125 {
126         memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
127         memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
128
129         dst->dlid               = src->dlid;
130         dst->slid               = src->slid;
131         dst->raw_traffic        = src->raw_traffic;
132         dst->flow_label         = src->flow_label;
133         dst->hop_limit          = src->hop_limit;
134         dst->traffic_class      = src->traffic_class;
135         dst->reversible         = src->reversible;
136         dst->numb_path          = src->numb_path;
137         dst->pkey               = src->pkey;
138         dst->sl                 = src->sl;
139         dst->mtu_selector       = src->mtu_selector;
140         dst->mtu                = src->mtu;
141         dst->rate_selector      = src->rate_selector;
142         dst->rate               = src->rate;
143         dst->packet_life_time   = src->packet_life_time;
144         dst->preference         = src->preference;
145         dst->packet_life_time_selector = src->packet_life_time_selector;
146
147         memset(dst->dmac, 0, sizeof(dst->dmac));
148         dst->net = NULL;
149         dst->ifindex = 0;
150         dst->gid_type = IB_GID_TYPE_IB;
151 }
152 EXPORT_SYMBOL(ib_copy_path_rec_from_user);