mad_priv.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 5596 2006-03-03 01:00:07Z 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_rmpp_segment {
  77. struct list_head list;
  78. u32 num;
  79. u8 data[0];
  80. };
  81. struct ib_mad_agent_private {
  82. struct list_head agent_list;
  83. struct ib_mad_agent agent;
  84. struct ib_mad_reg_req *reg_req;
  85. struct ib_mad_qp_info *qp_info;
  86. spinlock_t lock;
  87. struct list_head send_list;
  88. struct list_head wait_list;
  89. struct list_head done_list;
  90. struct work_struct timed_work;
  91. unsigned long timeout;
  92. struct list_head local_list;
  93. struct work_struct local_work;
  94. struct list_head rmpp_list;
  95. atomic_t refcount;
  96. wait_queue_head_t wait;
  97. };
  98. struct ib_mad_snoop_private {
  99. struct ib_mad_agent agent;
  100. struct ib_mad_qp_info *qp_info;
  101. int snoop_index;
  102. int mad_snoop_flags;
  103. atomic_t refcount;
  104. wait_queue_head_t wait;
  105. };
  106. struct ib_mad_send_wr_private {
  107. struct ib_mad_list_head mad_list;
  108. struct list_head agent_list;
  109. struct ib_mad_agent_private *mad_agent_priv;
  110. struct ib_mad_send_buf send_buf;
  111. DECLARE_PCI_UNMAP_ADDR(header_mapping)
  112. DECLARE_PCI_UNMAP_ADDR(payload_mapping)
  113. struct ib_send_wr send_wr;
  114. struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
  115. __be64 tid;
  116. unsigned long timeout;
  117. int retries;
  118. int retry;
  119. int refcount;
  120. enum ib_wc_status status;
  121. /* RMPP control */
  122. struct list_head rmpp_list;
  123. struct ib_rmpp_segment *last_ack_seg;
  124. struct ib_rmpp_segment *cur_seg;
  125. int last_ack;
  126. int seg_num;
  127. int newwin;
  128. int pad;
  129. };
  130. struct ib_mad_local_private {
  131. struct list_head completion_list;
  132. struct ib_mad_private *mad_priv;
  133. struct ib_mad_agent_private *recv_mad_agent;
  134. struct ib_mad_send_wr_private *mad_send_wr;
  135. };
  136. struct ib_mad_mgmt_method_table {
  137. struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
  138. };
  139. struct ib_mad_mgmt_class_table {
  140. struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
  141. };
  142. struct ib_mad_mgmt_vendor_class {
  143. u8 oui[MAX_MGMT_OUI][3];
  144. struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
  145. };
  146. struct ib_mad_mgmt_vendor_class_table {
  147. struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
  148. };
  149. struct ib_mad_mgmt_version_table {
  150. struct ib_mad_mgmt_class_table *class;
  151. struct ib_mad_mgmt_vendor_class_table *vendor;
  152. };
  153. struct ib_mad_queue {
  154. spinlock_t lock;
  155. struct list_head list;
  156. int count;
  157. int max_active;
  158. struct ib_mad_qp_info *qp_info;
  159. };
  160. struct ib_mad_qp_info {
  161. struct ib_mad_port_private *port_priv;
  162. struct ib_qp *qp;
  163. struct ib_mad_queue send_queue;
  164. struct ib_mad_queue recv_queue;
  165. struct list_head overflow_list;
  166. spinlock_t snoop_lock;
  167. struct ib_mad_snoop_private **snoop_table;
  168. int snoop_table_size;
  169. atomic_t snoop_count;
  170. };
  171. struct ib_mad_port_private {
  172. struct list_head port_list;
  173. struct ib_device *device;
  174. int port_num;
  175. struct ib_cq *cq;
  176. struct ib_pd *pd;
  177. struct ib_mr *mr;
  178. spinlock_t reg_lock;
  179. struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
  180. struct list_head agent_list;
  181. struct workqueue_struct *wq;
  182. struct work_struct work;
  183. struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
  184. };
  185. extern kmem_cache_t *ib_mad_cache;
  186. int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
  187. struct ib_mad_send_wr_private *
  188. ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
  189. struct ib_mad_recv_wc *mad_recv_wc);
  190. void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
  191. struct ib_mad_send_wc *mad_send_wc);
  192. void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr);
  193. void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
  194. int timeout_ms);
  195. #endif /* __IB_MAD_PRIV_H__ */