iwch_cm.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
  3. * Copyright (c) 2006 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. #ifndef _IWCH_CM_H_
  34. #define _IWCH_CM_H_
  35. #include <linux/inet.h>
  36. #include <linux/wait.h>
  37. #include <linux/spinlock.h>
  38. #include <linux/kref.h>
  39. #include <rdma/ib_verbs.h>
  40. #include <rdma/iw_cm.h>
  41. #include "cxgb3_offload.h"
  42. #include "iwch_provider.h"
  43. #define MPA_KEY_REQ "MPA ID Req Frame"
  44. #define MPA_KEY_REP "MPA ID Rep Frame"
  45. #define MPA_MAX_PRIVATE_DATA 256
  46. #define MPA_REV 0 /* XXX - amso1100 uses rev 0 ! */
  47. #define MPA_REJECT 0x20
  48. #define MPA_CRC 0x40
  49. #define MPA_MARKERS 0x80
  50. #define MPA_FLAGS_MASK 0xE0
  51. #define put_ep(ep) { \
  52. PDBG("put_ep (via %s:%u) ep %p refcnt %d\n", __FUNCTION__, __LINE__, \
  53. ep, atomic_read(&((ep)->kref.refcount))); \
  54. kref_put(&((ep)->kref), __free_ep); \
  55. }
  56. #define get_ep(ep) { \
  57. PDBG("get_ep (via %s:%u) ep %p, refcnt %d\n", __FUNCTION__, __LINE__, \
  58. ep, atomic_read(&((ep)->kref.refcount))); \
  59. kref_get(&((ep)->kref)); \
  60. }
  61. struct mpa_message {
  62. u8 key[16];
  63. u8 flags;
  64. u8 revision;
  65. __be16 private_data_size;
  66. u8 private_data[0];
  67. };
  68. struct terminate_message {
  69. u8 layer_etype;
  70. u8 ecode;
  71. __be16 hdrct_rsvd;
  72. u8 len_hdrs[0];
  73. };
  74. #define TERM_MAX_LENGTH (sizeof(struct terminate_message) + 2 + 18 + 28)
  75. enum iwch_layers_types {
  76. LAYER_RDMAP = 0x00,
  77. LAYER_DDP = 0x10,
  78. LAYER_MPA = 0x20,
  79. RDMAP_LOCAL_CATA = 0x00,
  80. RDMAP_REMOTE_PROT = 0x01,
  81. RDMAP_REMOTE_OP = 0x02,
  82. DDP_LOCAL_CATA = 0x00,
  83. DDP_TAGGED_ERR = 0x01,
  84. DDP_UNTAGGED_ERR = 0x02,
  85. DDP_LLP = 0x03
  86. };
  87. enum iwch_rdma_ecodes {
  88. RDMAP_INV_STAG = 0x00,
  89. RDMAP_BASE_BOUNDS = 0x01,
  90. RDMAP_ACC_VIOL = 0x02,
  91. RDMAP_STAG_NOT_ASSOC = 0x03,
  92. RDMAP_TO_WRAP = 0x04,
  93. RDMAP_INV_VERS = 0x05,
  94. RDMAP_INV_OPCODE = 0x06,
  95. RDMAP_STREAM_CATA = 0x07,
  96. RDMAP_GLOBAL_CATA = 0x08,
  97. RDMAP_CANT_INV_STAG = 0x09,
  98. RDMAP_UNSPECIFIED = 0xff
  99. };
  100. enum iwch_ddp_ecodes {
  101. DDPT_INV_STAG = 0x00,
  102. DDPT_BASE_BOUNDS = 0x01,
  103. DDPT_STAG_NOT_ASSOC = 0x02,
  104. DDPT_TO_WRAP = 0x03,
  105. DDPT_INV_VERS = 0x04,
  106. DDPU_INV_QN = 0x01,
  107. DDPU_INV_MSN_NOBUF = 0x02,
  108. DDPU_INV_MSN_RANGE = 0x03,
  109. DDPU_INV_MO = 0x04,
  110. DDPU_MSG_TOOBIG = 0x05,
  111. DDPU_INV_VERS = 0x06
  112. };
  113. enum iwch_mpa_ecodes {
  114. MPA_CRC_ERR = 0x02,
  115. MPA_MARKER_ERR = 0x03
  116. };
  117. enum iwch_ep_state {
  118. IDLE = 0,
  119. LISTEN,
  120. CONNECTING,
  121. MPA_REQ_WAIT,
  122. MPA_REQ_SENT,
  123. MPA_REQ_RCVD,
  124. MPA_REP_SENT,
  125. FPDU_MODE,
  126. ABORTING,
  127. CLOSING,
  128. MORIBUND,
  129. DEAD,
  130. };
  131. struct iwch_ep_common {
  132. struct iw_cm_id *cm_id;
  133. struct iwch_qp *qp;
  134. struct t3cdev *tdev;
  135. enum iwch_ep_state state;
  136. struct kref kref;
  137. spinlock_t lock;
  138. struct sockaddr_in local_addr;
  139. struct sockaddr_in remote_addr;
  140. wait_queue_head_t waitq;
  141. int rpl_done;
  142. int rpl_err;
  143. };
  144. struct iwch_listen_ep {
  145. struct iwch_ep_common com;
  146. unsigned int stid;
  147. int backlog;
  148. };
  149. struct iwch_ep {
  150. struct iwch_ep_common com;
  151. struct iwch_ep *parent_ep;
  152. struct timer_list timer;
  153. unsigned int atid;
  154. u32 hwtid;
  155. u32 snd_seq;
  156. struct l2t_entry *l2t;
  157. struct dst_entry *dst;
  158. struct sk_buff *mpa_skb;
  159. struct iwch_mpa_attributes mpa_attr;
  160. unsigned int mpa_pkt_len;
  161. u8 mpa_pkt[sizeof(struct mpa_message) + MPA_MAX_PRIVATE_DATA];
  162. u8 tos;
  163. u16 emss;
  164. u16 plen;
  165. u32 ird;
  166. u32 ord;
  167. };
  168. static inline struct iwch_ep *to_ep(struct iw_cm_id *cm_id)
  169. {
  170. return cm_id->provider_data;
  171. }
  172. static inline struct iwch_listen_ep *to_listen_ep(struct iw_cm_id *cm_id)
  173. {
  174. return cm_id->provider_data;
  175. }
  176. static inline int compute_wscale(int win)
  177. {
  178. int wscale = 0;
  179. while (wscale < 14 && (65535<<wscale) < win)
  180. wscale++;
  181. return wscale;
  182. }
  183. /* CM prototypes */
  184. int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
  185. int iwch_create_listen(struct iw_cm_id *cm_id, int backlog);
  186. int iwch_destroy_listen(struct iw_cm_id *cm_id);
  187. int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
  188. int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
  189. int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp);
  190. int iwch_quiesce_tid(struct iwch_ep *ep);
  191. int iwch_resume_tid(struct iwch_ep *ep);
  192. void __free_ep(struct kref *kref);
  193. void iwch_rearp(struct iwch_ep *ep);
  194. int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, struct l2t_entry *l2t);
  195. int __init iwch_cm_init(void);
  196. void __exit iwch_cm_term(void);
  197. #endif /* _IWCH_CM_H_ */