mad_priv.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.
  3. * Copyright (c) 2005 Intel Corporation. All rights reserved.
  4. * Copyright (c) 2005 Sun Microsystems, Inc. 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. #ifndef __IB_MAD_PRIV_H__
  35. #define __IB_MAD_PRIV_H__
  36. #include <linux/completion.h>
  37. #include <linux/err.h>
  38. #include <linux/workqueue.h>
  39. #include <rdma/ib_mad.h>
  40. #include <rdma/ib_smi.h>
  41. #define PFX "ib_mad: "
  42. #define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */
  43. /* QP and CQ parameters */
  44. #define IB_MAD_QP_SEND_SIZE 128
  45. #define IB_MAD_QP_RECV_SIZE 512
  46. #define IB_MAD_SEND_REQ_MAX_SG 2
  47. #define IB_MAD_RECV_REQ_MAX_SG 1
  48. #define IB_MAD_SEND_Q_PSN 0
  49. /* Registration table sizes */
  50. #define MAX_MGMT_CLASS 80
  51. #define MAX_MGMT_VERSION 8
  52. #define MAX_MGMT_OUI 8
  53. #define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \
  54. IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
  55. struct ib_mad_list_head {
  56. struct list_head list;
  57. struct ib_mad_queue *mad_queue;
  58. };
  59. struct ib_mad_private_header {
  60. struct ib_mad_list_head mad_list;
  61. struct ib_mad_recv_wc recv_wc;
  62. struct ib_wc wc;
  63. u64 mapping;
  64. } __attribute__ ((packed));
  65. struct ib_mad_private {
  66. struct ib_mad_private_header header;
  67. struct ib_grh grh;
  68. union {
  69. struct ib_mad mad;
  70. struct ib_rmpp_mad rmpp_mad;
  71. struct ib_smp smp;
  72. } mad;
  73. } __attribute__ ((packed));
  74. struct ib_rmpp_segment {
  75. struct list_head list;
  76. u32 num;
  77. u8 data[0];
  78. };
  79. struct ib_mad_agent_private {
  80. struct list_head agent_list;
  81. struct ib_mad_agent agent;
  82. struct ib_mad_reg_req *reg_req;
  83. struct ib_mad_qp_info *qp_info;
  84. spinlock_t lock;
  85. struct list_head send_list;
  86. struct list_head wait_list;
  87. struct list_head done_list;
  88. struct delayed_work timed_work;
  89. unsigned long timeout;
  90. struct list_head local_list;
  91. struct work_struct local_work;
  92. struct list_head rmpp_list;
  93. atomic_t refcount;
  94. struct completion comp;
  95. };
  96. struct ib_mad_snoop_private {
  97. struct ib_mad_agent agent;
  98. struct ib_mad_qp_info *qp_info;
  99. int snoop_index;
  100. int mad_snoop_flags;
  101. atomic_t refcount;
  102. struct completion comp;
  103. };
  104. struct ib_mad_send_wr_private {
  105. struct ib_mad_list_head mad_list;
  106. struct list_head agent_list;
  107. struct ib_mad_agent_private *mad_agent_priv;
  108. struct ib_mad_send_buf send_buf;
  109. u64 header_mapping;
  110. u64 payload_mapping;
  111. struct ib_send_wr send_wr;
  112. struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
  113. __be64 tid;
  114. unsigned long timeout;
  115. int max_retries;
  116. int retries_left;
  117. int retry;
  118. int refcount;
  119. enum ib_wc_status status;
  120. /* RMPP control */
  121. struct list_head rmpp_list;
  122. struct ib_rmpp_segment *last_ack_seg;
  123. struct ib_rmpp_segment *cur_seg;
  124. int last_ack;
  125. int seg_num;
  126. int newwin;
  127. int pad;
  128. };
  129. struct ib_mad_local_private {
  130. struct list_head completion_list;
  131. struct ib_mad_private *mad_priv;
  132. struct ib_mad_agent_private *recv_mad_agent;
  133. struct ib_mad_send_wr_private *mad_send_wr;
  134. };
  135. struct ib_mad_mgmt_method_table {
  136. struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
  137. };
  138. struct ib_mad_mgmt_class_table {
  139. struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
  140. };
  141. struct ib_mad_mgmt_vendor_class {
  142. u8 oui[MAX_MGMT_OUI][3];
  143. struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
  144. };
  145. struct ib_mad_mgmt_vendor_class_table {
  146. struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
  147. };
  148. struct ib_mad_mgmt_version_table {
  149. struct ib_mad_mgmt_class_table *class;
  150. struct ib_mad_mgmt_vendor_class_table *vendor;
  151. };
  152. struct ib_mad_queue {
  153. spinlock_t lock;
  154. struct list_head list;
  155. int count;
  156. int max_active;
  157. struct ib_mad_qp_info *qp_info;
  158. };
  159. struct ib_mad_qp_info {
  160. struct ib_mad_port_private *port_priv;
  161. struct ib_qp *qp;
  162. struct ib_mad_queue send_queue;
  163. struct ib_mad_queue recv_queue;
  164. struct list_head overflow_list;
  165. spinlock_t snoop_lock;
  166. struct ib_mad_snoop_private **snoop_table;
  167. int snoop_table_size;
  168. atomic_t snoop_count;
  169. };
  170. struct ib_mad_port_private {
  171. struct list_head port_list;
  172. struct ib_device *device;
  173. int port_num;
  174. struct ib_cq *cq;
  175. struct ib_pd *pd;
  176. struct ib_mr *mr;
  177. spinlock_t reg_lock;
  178. struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
  179. struct list_head agent_list;
  180. struct workqueue_struct *wq;
  181. struct work_struct work;
  182. struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
  183. };
  184. int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
  185. struct ib_mad_send_wr_private *
  186. ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
  187. struct ib_mad_recv_wc *mad_recv_wc);
  188. void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
  189. struct ib_mad_send_wc *mad_send_wc);
  190. void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr);
  191. void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
  192. int timeout_ms);
  193. #endif /* __IB_MAD_PRIV_H__ */