mad_priv.h 5.9 KB

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