c2_provider.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright (c) 2005 Ammasso, Inc. All rights reserved.
  3. * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. *
  33. */
  34. #ifndef C2_PROVIDER_H
  35. #define C2_PROVIDER_H
  36. #include <linux/inetdevice.h>
  37. #include <rdma/ib_verbs.h>
  38. #include <rdma/ib_pack.h>
  39. #include "c2_mq.h"
  40. #include <rdma/iw_cm.h>
  41. #define C2_MPT_FLAG_ATOMIC (1 << 14)
  42. #define C2_MPT_FLAG_REMOTE_WRITE (1 << 13)
  43. #define C2_MPT_FLAG_REMOTE_READ (1 << 12)
  44. #define C2_MPT_FLAG_LOCAL_WRITE (1 << 11)
  45. #define C2_MPT_FLAG_LOCAL_READ (1 << 10)
  46. struct c2_buf_list {
  47. void *buf;
  48. DEFINE_DMA_UNMAP_ADDR(mapping);
  49. };
  50. /* The user context keeps track of objects allocated for a
  51. * particular user-mode client. */
  52. struct c2_ucontext {
  53. struct ib_ucontext ibucontext;
  54. };
  55. struct c2_mtt;
  56. /* All objects associated with a PD are kept in the
  57. * associated user context if present.
  58. */
  59. struct c2_pd {
  60. struct ib_pd ibpd;
  61. u32 pd_id;
  62. };
  63. struct c2_mr {
  64. struct ib_mr ibmr;
  65. struct c2_pd *pd;
  66. struct ib_umem *umem;
  67. };
  68. struct c2_av;
  69. enum c2_ah_type {
  70. C2_AH_ON_HCA,
  71. C2_AH_PCI_POOL,
  72. C2_AH_KMALLOC
  73. };
  74. struct c2_ah {
  75. struct ib_ah ibah;
  76. };
  77. struct c2_cq {
  78. struct ib_cq ibcq;
  79. spinlock_t lock;
  80. atomic_t refcount;
  81. int cqn;
  82. int is_kernel;
  83. wait_queue_head_t wait;
  84. u32 adapter_handle;
  85. struct c2_mq mq;
  86. };
  87. struct c2_wq {
  88. spinlock_t lock;
  89. };
  90. struct iw_cm_id;
  91. struct c2_qp {
  92. struct ib_qp ibqp;
  93. struct iw_cm_id *cm_id;
  94. spinlock_t lock;
  95. atomic_t refcount;
  96. wait_queue_head_t wait;
  97. int qpn;
  98. u32 adapter_handle;
  99. u32 send_sgl_depth;
  100. u32 recv_sgl_depth;
  101. u32 rdma_write_sgl_depth;
  102. u8 state;
  103. struct c2_mq sq_mq;
  104. struct c2_mq rq_mq;
  105. };
  106. struct c2_cr_query_attrs {
  107. u32 local_addr;
  108. u32 remote_addr;
  109. u16 local_port;
  110. u16 remote_port;
  111. };
  112. static inline struct c2_pd *to_c2pd(struct ib_pd *ibpd)
  113. {
  114. return container_of(ibpd, struct c2_pd, ibpd);
  115. }
  116. static inline struct c2_ucontext *to_c2ucontext(struct ib_ucontext *ibucontext)
  117. {
  118. return container_of(ibucontext, struct c2_ucontext, ibucontext);
  119. }
  120. static inline struct c2_mr *to_c2mr(struct ib_mr *ibmr)
  121. {
  122. return container_of(ibmr, struct c2_mr, ibmr);
  123. }
  124. static inline struct c2_ah *to_c2ah(struct ib_ah *ibah)
  125. {
  126. return container_of(ibah, struct c2_ah, ibah);
  127. }
  128. static inline struct c2_cq *to_c2cq(struct ib_cq *ibcq)
  129. {
  130. return container_of(ibcq, struct c2_cq, ibcq);
  131. }
  132. static inline struct c2_qp *to_c2qp(struct ib_qp *ibqp)
  133. {
  134. return container_of(ibqp, struct c2_qp, ibqp);
  135. }
  136. static inline int is_rnic_addr(struct net_device *netdev, u32 addr)
  137. {
  138. struct in_device *ind;
  139. int ret = 0;
  140. ind = in_dev_get(netdev);
  141. if (!ind)
  142. return 0;
  143. for_ifa(ind) {
  144. if (ifa->ifa_address == addr) {
  145. ret = 1;
  146. break;
  147. }
  148. }
  149. endfor_ifa(ind);
  150. in_dev_put(ind);
  151. return ret;
  152. }
  153. #endif /* C2_PROVIDER_H */