iwch.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright (c) 2006 Chelsio, 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. #ifndef __IWCH_H__
  33. #define __IWCH_H__
  34. #include <linux/mutex.h>
  35. #include <linux/list.h>
  36. #include <linux/spinlock.h>
  37. #include <linux/idr.h>
  38. #include <linux/workqueue.h>
  39. #include <rdma/ib_verbs.h>
  40. #include "cxio_hal.h"
  41. #include "cxgb3_offload.h"
  42. struct iwch_pd;
  43. struct iwch_cq;
  44. struct iwch_qp;
  45. struct iwch_mr;
  46. struct iwch_rnic_attributes {
  47. u32 max_qps;
  48. u32 max_wrs; /* Max for any SQ/RQ */
  49. u32 max_sge_per_wr;
  50. u32 max_sge_per_rdma_write_wr; /* for RDMA Write WR */
  51. u32 max_cqs;
  52. u32 max_cqes_per_cq;
  53. u32 max_mem_regs;
  54. u32 max_phys_buf_entries; /* for phys buf list */
  55. u32 max_pds;
  56. /*
  57. * The memory page sizes supported by this RNIC.
  58. * Bit position i in bitmap indicates page of
  59. * size (4k)^i. Phys block list mode unsupported.
  60. */
  61. u32 mem_pgsizes_bitmask;
  62. u64 max_mr_size;
  63. u8 can_resize_wq;
  64. /*
  65. * The maximum number of RDMA Reads that can be outstanding
  66. * per QP with this RNIC as the target.
  67. */
  68. u32 max_rdma_reads_per_qp;
  69. /*
  70. * The maximum number of resources used for RDMA Reads
  71. * by this RNIC with this RNIC as the target.
  72. */
  73. u32 max_rdma_read_resources;
  74. /*
  75. * The max depth per QP for initiation of RDMA Read
  76. * by this RNIC.
  77. */
  78. u32 max_rdma_read_qp_depth;
  79. /*
  80. * The maximum depth for initiation of RDMA Read
  81. * operations by this RNIC on all QPs
  82. */
  83. u32 max_rdma_read_depth;
  84. u8 rq_overflow_handled;
  85. u32 can_modify_ird;
  86. u32 can_modify_ord;
  87. u32 max_mem_windows;
  88. u32 stag0_value;
  89. u8 zbva_support;
  90. u8 local_invalidate_fence;
  91. u32 cq_overflow_detection;
  92. };
  93. struct iwch_dev {
  94. struct ib_device ibdev;
  95. struct cxio_rdev rdev;
  96. u32 device_cap_flags;
  97. struct iwch_rnic_attributes attr;
  98. struct idr cqidr;
  99. struct idr qpidr;
  100. struct idr mmidr;
  101. spinlock_t lock;
  102. struct list_head entry;
  103. struct delayed_work db_drop_task;
  104. };
  105. static inline struct iwch_dev *to_iwch_dev(struct ib_device *ibdev)
  106. {
  107. return container_of(ibdev, struct iwch_dev, ibdev);
  108. }
  109. static inline struct iwch_dev *rdev_to_iwch_dev(struct cxio_rdev *rdev)
  110. {
  111. return container_of(rdev, struct iwch_dev, rdev);
  112. }
  113. static inline int t3b_device(const struct iwch_dev *rhp)
  114. {
  115. return rhp->rdev.t3cdev_p->type == T3B;
  116. }
  117. static inline int t3a_device(const struct iwch_dev *rhp)
  118. {
  119. return rhp->rdev.t3cdev_p->type == T3A;
  120. }
  121. static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid)
  122. {
  123. return idr_find(&rhp->cqidr, cqid);
  124. }
  125. static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid)
  126. {
  127. return idr_find(&rhp->qpidr, qpid);
  128. }
  129. static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid)
  130. {
  131. return idr_find(&rhp->mmidr, mmid);
  132. }
  133. static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr,
  134. void *handle, u32 id)
  135. {
  136. int ret;
  137. int newid;
  138. do {
  139. if (!idr_pre_get(idr, GFP_KERNEL)) {
  140. return -ENOMEM;
  141. }
  142. spin_lock_irq(&rhp->lock);
  143. ret = idr_get_new_above(idr, handle, id, &newid);
  144. BUG_ON(newid != id);
  145. spin_unlock_irq(&rhp->lock);
  146. } while (ret == -EAGAIN);
  147. return ret;
  148. }
  149. static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id)
  150. {
  151. spin_lock_irq(&rhp->lock);
  152. idr_remove(idr, id);
  153. spin_unlock_irq(&rhp->lock);
  154. }
  155. extern struct cxgb3_client t3c_client;
  156. extern cxgb3_cpl_handler_func t3c_handlers[NUM_CPL_CMDS];
  157. extern void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb);
  158. #endif