mad_priv.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * Copyright (c) 2004, 2005, Voltaire, Inc. 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. * $Id: mad_priv.h 1389 2004-12-27 22:56:47Z roland $
  33. */
  34. #ifndef __IB_MAD_PRIV_H__
  35. #define __IB_MAD_PRIV_H__
  36. #include <linux/pci.h>
  37. #include <linux/kthread.h>
  38. #include <linux/workqueue.h>
  39. #include <ib_mad.h>
  40. #include <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. DECLARE_PCI_UNMAP_ADDR(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_mad_agent_private {
  75. struct list_head agent_list;
  76. struct ib_mad_agent agent;
  77. struct ib_mad_reg_req *reg_req;
  78. struct ib_mad_qp_info *qp_info;
  79. spinlock_t lock;
  80. struct list_head send_list;
  81. struct list_head wait_list;
  82. struct work_struct timed_work;
  83. unsigned long timeout;
  84. struct list_head local_list;
  85. struct work_struct local_work;
  86. struct list_head canceled_list;
  87. struct work_struct canceled_work;
  88. atomic_t refcount;
  89. wait_queue_head_t wait;
  90. u8 rmpp_version;
  91. };
  92. struct ib_mad_snoop_private {
  93. struct ib_mad_agent agent;
  94. struct ib_mad_qp_info *qp_info;
  95. int snoop_index;
  96. int mad_snoop_flags;
  97. atomic_t refcount;
  98. wait_queue_head_t wait;
  99. };
  100. struct ib_mad_send_wr_private {
  101. struct ib_mad_list_head mad_list;
  102. struct list_head agent_list;
  103. struct ib_mad_agent *agent;
  104. struct ib_send_wr send_wr;
  105. struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
  106. u64 wr_id; /* client WR ID */
  107. u64 tid;
  108. unsigned long timeout;
  109. int retry;
  110. int refcount;
  111. enum ib_wc_status status;
  112. };
  113. struct ib_mad_local_private {
  114. struct list_head completion_list;
  115. struct ib_mad_private *mad_priv;
  116. struct ib_mad_agent_private *recv_mad_agent;
  117. struct ib_send_wr send_wr;
  118. struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
  119. u64 wr_id; /* client WR ID */
  120. u64 tid;
  121. };
  122. struct ib_mad_mgmt_method_table {
  123. struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
  124. };
  125. struct ib_mad_mgmt_class_table {
  126. struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
  127. };
  128. struct ib_mad_mgmt_vendor_class {
  129. u8 oui[MAX_MGMT_OUI][3];
  130. struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
  131. };
  132. struct ib_mad_mgmt_vendor_class_table {
  133. struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
  134. };
  135. struct ib_mad_mgmt_version_table {
  136. struct ib_mad_mgmt_class_table *class;
  137. struct ib_mad_mgmt_vendor_class_table *vendor;
  138. };
  139. struct ib_mad_queue {
  140. spinlock_t lock;
  141. struct list_head list;
  142. int count;
  143. int max_active;
  144. struct ib_mad_qp_info *qp_info;
  145. };
  146. struct ib_mad_qp_info {
  147. struct ib_mad_port_private *port_priv;
  148. struct ib_qp *qp;
  149. struct ib_mad_queue send_queue;
  150. struct ib_mad_queue recv_queue;
  151. struct list_head overflow_list;
  152. spinlock_t snoop_lock;
  153. struct ib_mad_snoop_private **snoop_table;
  154. int snoop_table_size;
  155. atomic_t snoop_count;
  156. };
  157. struct ib_mad_port_private {
  158. struct list_head port_list;
  159. struct ib_device *device;
  160. int port_num;
  161. struct ib_cq *cq;
  162. struct ib_pd *pd;
  163. struct ib_mr *mr;
  164. spinlock_t reg_lock;
  165. struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
  166. struct list_head agent_list;
  167. struct workqueue_struct *wq;
  168. struct work_struct work;
  169. struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
  170. };
  171. extern kmem_cache_t *ib_mad_cache;
  172. #endif /* __IB_MAD_PRIV_H__ */