uverbs_marshall.c 5.2 KB

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