Path: blob/master/drivers/infiniband/core/uverbs_marshall.c
37212 views
/*1* Copyright (c) 2005 Intel Corporation. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/3132#include <rdma/ib_marshall.h>3334void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,35struct ib_ah_attr *src)36{37memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);38dst->grh.flow_label = src->grh.flow_label;39dst->grh.sgid_index = src->grh.sgid_index;40dst->grh.hop_limit = src->grh.hop_limit;41dst->grh.traffic_class = src->grh.traffic_class;42memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));43dst->dlid = src->dlid;44dst->sl = src->sl;45dst->src_path_bits = src->src_path_bits;46dst->static_rate = src->static_rate;47dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;48dst->port_num = src->port_num;49dst->reserved = 0;50}51EXPORT_SYMBOL(ib_copy_ah_attr_to_user);5253void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,54struct ib_qp_attr *src)55{56dst->qp_state = src->qp_state;57dst->cur_qp_state = src->cur_qp_state;58dst->path_mtu = src->path_mtu;59dst->path_mig_state = src->path_mig_state;60dst->qkey = src->qkey;61dst->rq_psn = src->rq_psn;62dst->sq_psn = src->sq_psn;63dst->dest_qp_num = src->dest_qp_num;64dst->qp_access_flags = src->qp_access_flags;6566dst->max_send_wr = src->cap.max_send_wr;67dst->max_recv_wr = src->cap.max_recv_wr;68dst->max_send_sge = src->cap.max_send_sge;69dst->max_recv_sge = src->cap.max_recv_sge;70dst->max_inline_data = src->cap.max_inline_data;7172ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);73ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);7475dst->pkey_index = src->pkey_index;76dst->alt_pkey_index = src->alt_pkey_index;77dst->en_sqd_async_notify = src->en_sqd_async_notify;78dst->sq_draining = src->sq_draining;79dst->max_rd_atomic = src->max_rd_atomic;80dst->max_dest_rd_atomic = src->max_dest_rd_atomic;81dst->min_rnr_timer = src->min_rnr_timer;82dst->port_num = src->port_num;83dst->timeout = src->timeout;84dst->retry_cnt = src->retry_cnt;85dst->rnr_retry = src->rnr_retry;86dst->alt_port_num = src->alt_port_num;87dst->alt_timeout = src->alt_timeout;88memset(dst->reserved, 0, sizeof(dst->reserved));89}90EXPORT_SYMBOL(ib_copy_qp_attr_to_user);9192void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,93struct ib_sa_path_rec *src)94{95memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);96memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);9798dst->dlid = src->dlid;99dst->slid = src->slid;100dst->raw_traffic = src->raw_traffic;101dst->flow_label = src->flow_label;102dst->hop_limit = src->hop_limit;103dst->traffic_class = src->traffic_class;104dst->reversible = src->reversible;105dst->numb_path = src->numb_path;106dst->pkey = src->pkey;107dst->sl = src->sl;108dst->mtu_selector = src->mtu_selector;109dst->mtu = src->mtu;110dst->rate_selector = src->rate_selector;111dst->rate = src->rate;112dst->packet_life_time = src->packet_life_time;113dst->preference = src->preference;114dst->packet_life_time_selector = src->packet_life_time_selector;115}116EXPORT_SYMBOL(ib_copy_path_rec_to_user);117118void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,119struct ib_user_path_rec *src)120{121memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);122memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);123124dst->dlid = src->dlid;125dst->slid = src->slid;126dst->raw_traffic = src->raw_traffic;127dst->flow_label = src->flow_label;128dst->hop_limit = src->hop_limit;129dst->traffic_class = src->traffic_class;130dst->reversible = src->reversible;131dst->numb_path = src->numb_path;132dst->pkey = src->pkey;133dst->sl = src->sl;134dst->mtu_selector = src->mtu_selector;135dst->mtu = src->mtu;136dst->rate_selector = src->rate_selector;137dst->rate = src->rate;138dst->packet_life_time = src->packet_life_time;139dst->preference = src->preference;140dst->packet_life_time_selector = src->packet_life_time_selector;141}142EXPORT_SYMBOL(ib_copy_path_rec_from_user);143144145