iw_cxgb4.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. /*
  2. * Copyright (c) 2009-2010 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. * - Redistributions in binary form must reproduce the above
  18. * copyright notice, this list of conditions and the following
  19. * disclaimer in the documentation and/or other materials
  20. * provided with the distribution.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  26. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29. * SOFTWARE.
  30. */
  31. #ifndef __IW_CXGB4_H__
  32. #define __IW_CXGB4_H__
  33. #include <linux/mutex.h>
  34. #include <linux/list.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/idr.h>
  37. #include <linux/workqueue.h>
  38. #include <linux/netdevice.h>
  39. #include <linux/sched.h>
  40. #include <linux/pci.h>
  41. #include <linux/dma-mapping.h>
  42. #include <linux/inet.h>
  43. #include <linux/wait.h>
  44. #include <linux/kref.h>
  45. #include <linux/timer.h>
  46. #include <linux/io.h>
  47. #include <linux/kfifo.h>
  48. #include <asm/byteorder.h>
  49. #include <net/net_namespace.h>
  50. #include <rdma/ib_verbs.h>
  51. #include <rdma/iw_cm.h>
  52. #include "cxgb4.h"
  53. #include "cxgb4_uld.h"
  54. #include "l2t.h"
  55. #include "user.h"
  56. #define DRV_NAME "iw_cxgb4"
  57. #define MOD DRV_NAME ":"
  58. extern int c4iw_debug;
  59. #define PDBG(fmt, args...) \
  60. do { \
  61. if (c4iw_debug) \
  62. printk(MOD fmt, ## args); \
  63. } while (0)
  64. #include "t4.h"
  65. #define PBL_OFF(rdev_p, a) ((a) - (rdev_p)->lldi.vr->pbl.start)
  66. #define RQT_OFF(rdev_p, a) ((a) - (rdev_p)->lldi.vr->rq.start)
  67. static inline void *cplhdr(struct sk_buff *skb)
  68. {
  69. return skb->data;
  70. }
  71. #define C4IW_WR_TO (10*HZ)
  72. struct c4iw_wr_wait {
  73. wait_queue_head_t wait;
  74. int done;
  75. int ret;
  76. };
  77. static inline void c4iw_init_wr_wait(struct c4iw_wr_wait *wr_waitp)
  78. {
  79. wr_waitp->ret = 0;
  80. wr_waitp->done = 0;
  81. init_waitqueue_head(&wr_waitp->wait);
  82. }
  83. struct c4iw_resource {
  84. struct kfifo tpt_fifo;
  85. spinlock_t tpt_fifo_lock;
  86. struct kfifo qid_fifo;
  87. spinlock_t qid_fifo_lock;
  88. struct kfifo pdid_fifo;
  89. spinlock_t pdid_fifo_lock;
  90. };
  91. struct c4iw_qid_list {
  92. struct list_head entry;
  93. u32 qid;
  94. };
  95. struct c4iw_dev_ucontext {
  96. struct list_head qpids;
  97. struct list_head cqids;
  98. struct mutex lock;
  99. };
  100. enum c4iw_rdev_flags {
  101. T4_FATAL_ERROR = (1<<0),
  102. };
  103. struct c4iw_rdev {
  104. struct c4iw_resource resource;
  105. unsigned long qpshift;
  106. u32 qpmask;
  107. unsigned long cqshift;
  108. u32 cqmask;
  109. struct c4iw_dev_ucontext uctx;
  110. struct gen_pool *pbl_pool;
  111. struct gen_pool *rqt_pool;
  112. u32 flags;
  113. struct cxgb4_lld_info lldi;
  114. };
  115. static inline int c4iw_fatal_error(struct c4iw_rdev *rdev)
  116. {
  117. return rdev->flags & T4_FATAL_ERROR;
  118. }
  119. static inline int c4iw_num_stags(struct c4iw_rdev *rdev)
  120. {
  121. return min((int)T4_MAX_NUM_STAG, (int)(rdev->lldi.vr->stag.size >> 5));
  122. }
  123. struct c4iw_dev {
  124. struct ib_device ibdev;
  125. struct c4iw_rdev rdev;
  126. u32 device_cap_flags;
  127. struct idr cqidr;
  128. struct idr qpidr;
  129. struct idr mmidr;
  130. spinlock_t lock;
  131. struct list_head entry;
  132. struct delayed_work db_drop_task;
  133. struct dentry *debugfs_root;
  134. u8 registered;
  135. };
  136. static inline struct c4iw_dev *to_c4iw_dev(struct ib_device *ibdev)
  137. {
  138. return container_of(ibdev, struct c4iw_dev, ibdev);
  139. }
  140. static inline struct c4iw_dev *rdev_to_c4iw_dev(struct c4iw_rdev *rdev)
  141. {
  142. return container_of(rdev, struct c4iw_dev, rdev);
  143. }
  144. static inline struct c4iw_cq *get_chp(struct c4iw_dev *rhp, u32 cqid)
  145. {
  146. return idr_find(&rhp->cqidr, cqid);
  147. }
  148. static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qpid)
  149. {
  150. return idr_find(&rhp->qpidr, qpid);
  151. }
  152. static inline struct c4iw_mr *get_mhp(struct c4iw_dev *rhp, u32 mmid)
  153. {
  154. return idr_find(&rhp->mmidr, mmid);
  155. }
  156. static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr,
  157. void *handle, u32 id)
  158. {
  159. int ret;
  160. int newid;
  161. do {
  162. if (!idr_pre_get(idr, GFP_KERNEL))
  163. return -ENOMEM;
  164. spin_lock_irq(&rhp->lock);
  165. ret = idr_get_new_above(idr, handle, id, &newid);
  166. BUG_ON(newid != id);
  167. spin_unlock_irq(&rhp->lock);
  168. } while (ret == -EAGAIN);
  169. return ret;
  170. }
  171. static inline void remove_handle(struct c4iw_dev *rhp, struct idr *idr, u32 id)
  172. {
  173. spin_lock_irq(&rhp->lock);
  174. idr_remove(idr, id);
  175. spin_unlock_irq(&rhp->lock);
  176. }
  177. struct c4iw_pd {
  178. struct ib_pd ibpd;
  179. u32 pdid;
  180. struct c4iw_dev *rhp;
  181. };
  182. static inline struct c4iw_pd *to_c4iw_pd(struct ib_pd *ibpd)
  183. {
  184. return container_of(ibpd, struct c4iw_pd, ibpd);
  185. }
  186. struct tpt_attributes {
  187. u64 len;
  188. u64 va_fbo;
  189. enum fw_ri_mem_perms perms;
  190. u32 stag;
  191. u32 pdid;
  192. u32 qpid;
  193. u32 pbl_addr;
  194. u32 pbl_size;
  195. u32 state:1;
  196. u32 type:2;
  197. u32 rsvd:1;
  198. u32 remote_invaliate_disable:1;
  199. u32 zbva:1;
  200. u32 mw_bind_enable:1;
  201. u32 page_size:5;
  202. };
  203. struct c4iw_mr {
  204. struct ib_mr ibmr;
  205. struct ib_umem *umem;
  206. struct c4iw_dev *rhp;
  207. u64 kva;
  208. struct tpt_attributes attr;
  209. };
  210. static inline struct c4iw_mr *to_c4iw_mr(struct ib_mr *ibmr)
  211. {
  212. return container_of(ibmr, struct c4iw_mr, ibmr);
  213. }
  214. struct c4iw_mw {
  215. struct ib_mw ibmw;
  216. struct c4iw_dev *rhp;
  217. u64 kva;
  218. struct tpt_attributes attr;
  219. };
  220. static inline struct c4iw_mw *to_c4iw_mw(struct ib_mw *ibmw)
  221. {
  222. return container_of(ibmw, struct c4iw_mw, ibmw);
  223. }
  224. struct c4iw_fr_page_list {
  225. struct ib_fast_reg_page_list ibpl;
  226. DEFINE_DMA_UNMAP_ADDR(mapping);
  227. dma_addr_t dma_addr;
  228. struct c4iw_dev *dev;
  229. int size;
  230. };
  231. static inline struct c4iw_fr_page_list *to_c4iw_fr_page_list(
  232. struct ib_fast_reg_page_list *ibpl)
  233. {
  234. return container_of(ibpl, struct c4iw_fr_page_list, ibpl);
  235. }
  236. struct c4iw_cq {
  237. struct ib_cq ibcq;
  238. struct c4iw_dev *rhp;
  239. struct t4_cq cq;
  240. spinlock_t lock;
  241. atomic_t refcnt;
  242. wait_queue_head_t wait;
  243. };
  244. static inline struct c4iw_cq *to_c4iw_cq(struct ib_cq *ibcq)
  245. {
  246. return container_of(ibcq, struct c4iw_cq, ibcq);
  247. }
  248. struct c4iw_mpa_attributes {
  249. u8 initiator;
  250. u8 recv_marker_enabled;
  251. u8 xmit_marker_enabled;
  252. u8 crc_enabled;
  253. u8 version;
  254. u8 p2p_type;
  255. };
  256. struct c4iw_qp_attributes {
  257. u32 scq;
  258. u32 rcq;
  259. u32 sq_num_entries;
  260. u32 rq_num_entries;
  261. u32 sq_max_sges;
  262. u32 sq_max_sges_rdma_write;
  263. u32 rq_max_sges;
  264. u32 state;
  265. u8 enable_rdma_read;
  266. u8 enable_rdma_write;
  267. u8 enable_bind;
  268. u8 enable_mmid0_fastreg;
  269. u32 max_ord;
  270. u32 max_ird;
  271. u32 pd;
  272. u32 next_state;
  273. char terminate_buffer[52];
  274. u32 terminate_msg_len;
  275. u8 is_terminate_local;
  276. struct c4iw_mpa_attributes mpa_attr;
  277. struct c4iw_ep *llp_stream_handle;
  278. };
  279. struct c4iw_qp {
  280. struct ib_qp ibqp;
  281. struct c4iw_dev *rhp;
  282. struct c4iw_ep *ep;
  283. struct c4iw_qp_attributes attr;
  284. struct t4_wq wq;
  285. spinlock_t lock;
  286. atomic_t refcnt;
  287. wait_queue_head_t wait;
  288. struct timer_list timer;
  289. };
  290. static inline struct c4iw_qp *to_c4iw_qp(struct ib_qp *ibqp)
  291. {
  292. return container_of(ibqp, struct c4iw_qp, ibqp);
  293. }
  294. struct c4iw_ucontext {
  295. struct ib_ucontext ibucontext;
  296. struct c4iw_dev_ucontext uctx;
  297. u32 key;
  298. spinlock_t mmap_lock;
  299. struct list_head mmaps;
  300. };
  301. static inline struct c4iw_ucontext *to_c4iw_ucontext(struct ib_ucontext *c)
  302. {
  303. return container_of(c, struct c4iw_ucontext, ibucontext);
  304. }
  305. struct c4iw_mm_entry {
  306. struct list_head entry;
  307. u64 addr;
  308. u32 key;
  309. unsigned len;
  310. };
  311. static inline struct c4iw_mm_entry *remove_mmap(struct c4iw_ucontext *ucontext,
  312. u32 key, unsigned len)
  313. {
  314. struct list_head *pos, *nxt;
  315. struct c4iw_mm_entry *mm;
  316. spin_lock(&ucontext->mmap_lock);
  317. list_for_each_safe(pos, nxt, &ucontext->mmaps) {
  318. mm = list_entry(pos, struct c4iw_mm_entry, entry);
  319. if (mm->key == key && mm->len == len) {
  320. list_del_init(&mm->entry);
  321. spin_unlock(&ucontext->mmap_lock);
  322. PDBG("%s key 0x%x addr 0x%llx len %d\n", __func__,
  323. key, (unsigned long long) mm->addr, mm->len);
  324. return mm;
  325. }
  326. }
  327. spin_unlock(&ucontext->mmap_lock);
  328. return NULL;
  329. }
  330. static inline void insert_mmap(struct c4iw_ucontext *ucontext,
  331. struct c4iw_mm_entry *mm)
  332. {
  333. spin_lock(&ucontext->mmap_lock);
  334. PDBG("%s key 0x%x addr 0x%llx len %d\n", __func__,
  335. mm->key, (unsigned long long) mm->addr, mm->len);
  336. list_add_tail(&mm->entry, &ucontext->mmaps);
  337. spin_unlock(&ucontext->mmap_lock);
  338. }
  339. enum c4iw_qp_attr_mask {
  340. C4IW_QP_ATTR_NEXT_STATE = 1 << 0,
  341. C4IW_QP_ATTR_ENABLE_RDMA_READ = 1 << 7,
  342. C4IW_QP_ATTR_ENABLE_RDMA_WRITE = 1 << 8,
  343. C4IW_QP_ATTR_ENABLE_RDMA_BIND = 1 << 9,
  344. C4IW_QP_ATTR_MAX_ORD = 1 << 11,
  345. C4IW_QP_ATTR_MAX_IRD = 1 << 12,
  346. C4IW_QP_ATTR_LLP_STREAM_HANDLE = 1 << 22,
  347. C4IW_QP_ATTR_STREAM_MSG_BUFFER = 1 << 23,
  348. C4IW_QP_ATTR_MPA_ATTR = 1 << 24,
  349. C4IW_QP_ATTR_QP_CONTEXT_ACTIVATE = 1 << 25,
  350. C4IW_QP_ATTR_VALID_MODIFY = (C4IW_QP_ATTR_ENABLE_RDMA_READ |
  351. C4IW_QP_ATTR_ENABLE_RDMA_WRITE |
  352. C4IW_QP_ATTR_MAX_ORD |
  353. C4IW_QP_ATTR_MAX_IRD |
  354. C4IW_QP_ATTR_LLP_STREAM_HANDLE |
  355. C4IW_QP_ATTR_STREAM_MSG_BUFFER |
  356. C4IW_QP_ATTR_MPA_ATTR |
  357. C4IW_QP_ATTR_QP_CONTEXT_ACTIVATE)
  358. };
  359. int c4iw_modify_qp(struct c4iw_dev *rhp,
  360. struct c4iw_qp *qhp,
  361. enum c4iw_qp_attr_mask mask,
  362. struct c4iw_qp_attributes *attrs,
  363. int internal);
  364. enum c4iw_qp_state {
  365. C4IW_QP_STATE_IDLE,
  366. C4IW_QP_STATE_RTS,
  367. C4IW_QP_STATE_ERROR,
  368. C4IW_QP_STATE_TERMINATE,
  369. C4IW_QP_STATE_CLOSING,
  370. C4IW_QP_STATE_TOT
  371. };
  372. static inline int c4iw_convert_state(enum ib_qp_state ib_state)
  373. {
  374. switch (ib_state) {
  375. case IB_QPS_RESET:
  376. case IB_QPS_INIT:
  377. return C4IW_QP_STATE_IDLE;
  378. case IB_QPS_RTS:
  379. return C4IW_QP_STATE_RTS;
  380. case IB_QPS_SQD:
  381. return C4IW_QP_STATE_CLOSING;
  382. case IB_QPS_SQE:
  383. return C4IW_QP_STATE_TERMINATE;
  384. case IB_QPS_ERR:
  385. return C4IW_QP_STATE_ERROR;
  386. default:
  387. return -1;
  388. }
  389. }
  390. static inline u32 c4iw_ib_to_tpt_access(int a)
  391. {
  392. return (a & IB_ACCESS_REMOTE_WRITE ? FW_RI_MEM_ACCESS_REM_WRITE : 0) |
  393. (a & IB_ACCESS_REMOTE_READ ? FW_RI_MEM_ACCESS_REM_READ : 0) |
  394. (a & IB_ACCESS_LOCAL_WRITE ? FW_RI_MEM_ACCESS_LOCAL_WRITE : 0) |
  395. FW_RI_MEM_ACCESS_LOCAL_READ;
  396. }
  397. static inline u32 c4iw_ib_to_tpt_bind_access(int acc)
  398. {
  399. return (acc & IB_ACCESS_REMOTE_WRITE ? FW_RI_MEM_ACCESS_REM_WRITE : 0) |
  400. (acc & IB_ACCESS_REMOTE_READ ? FW_RI_MEM_ACCESS_REM_READ : 0);
  401. }
  402. enum c4iw_mmid_state {
  403. C4IW_STAG_STATE_VALID,
  404. C4IW_STAG_STATE_INVALID
  405. };
  406. #define C4IW_NODE_DESC "cxgb4 Chelsio Communications"
  407. #define MPA_KEY_REQ "MPA ID Req Frame"
  408. #define MPA_KEY_REP "MPA ID Rep Frame"
  409. #define MPA_MAX_PRIVATE_DATA 256
  410. #define MPA_REJECT 0x20
  411. #define MPA_CRC 0x40
  412. #define MPA_MARKERS 0x80
  413. #define MPA_FLAGS_MASK 0xE0
  414. #define c4iw_put_ep(ep) { \
  415. PDBG("put_ep (via %s:%u) ep %p refcnt %d\n", __func__, __LINE__, \
  416. ep, atomic_read(&((ep)->kref.refcount))); \
  417. WARN_ON(atomic_read(&((ep)->kref.refcount)) < 1); \
  418. kref_put(&((ep)->kref), _c4iw_free_ep); \
  419. }
  420. #define c4iw_get_ep(ep) { \
  421. PDBG("get_ep (via %s:%u) ep %p, refcnt %d\n", __func__, __LINE__, \
  422. ep, atomic_read(&((ep)->kref.refcount))); \
  423. kref_get(&((ep)->kref)); \
  424. }
  425. void _c4iw_free_ep(struct kref *kref);
  426. struct mpa_message {
  427. u8 key[16];
  428. u8 flags;
  429. u8 revision;
  430. __be16 private_data_size;
  431. u8 private_data[0];
  432. };
  433. struct terminate_message {
  434. u8 layer_etype;
  435. u8 ecode;
  436. __be16 hdrct_rsvd;
  437. u8 len_hdrs[0];
  438. };
  439. #define TERM_MAX_LENGTH (sizeof(struct terminate_message) + 2 + 18 + 28)
  440. enum c4iw_layers_types {
  441. LAYER_RDMAP = 0x00,
  442. LAYER_DDP = 0x10,
  443. LAYER_MPA = 0x20,
  444. RDMAP_LOCAL_CATA = 0x00,
  445. RDMAP_REMOTE_PROT = 0x01,
  446. RDMAP_REMOTE_OP = 0x02,
  447. DDP_LOCAL_CATA = 0x00,
  448. DDP_TAGGED_ERR = 0x01,
  449. DDP_UNTAGGED_ERR = 0x02,
  450. DDP_LLP = 0x03
  451. };
  452. enum c4iw_rdma_ecodes {
  453. RDMAP_INV_STAG = 0x00,
  454. RDMAP_BASE_BOUNDS = 0x01,
  455. RDMAP_ACC_VIOL = 0x02,
  456. RDMAP_STAG_NOT_ASSOC = 0x03,
  457. RDMAP_TO_WRAP = 0x04,
  458. RDMAP_INV_VERS = 0x05,
  459. RDMAP_INV_OPCODE = 0x06,
  460. RDMAP_STREAM_CATA = 0x07,
  461. RDMAP_GLOBAL_CATA = 0x08,
  462. RDMAP_CANT_INV_STAG = 0x09,
  463. RDMAP_UNSPECIFIED = 0xff
  464. };
  465. enum c4iw_ddp_ecodes {
  466. DDPT_INV_STAG = 0x00,
  467. DDPT_BASE_BOUNDS = 0x01,
  468. DDPT_STAG_NOT_ASSOC = 0x02,
  469. DDPT_TO_WRAP = 0x03,
  470. DDPT_INV_VERS = 0x04,
  471. DDPU_INV_QN = 0x01,
  472. DDPU_INV_MSN_NOBUF = 0x02,
  473. DDPU_INV_MSN_RANGE = 0x03,
  474. DDPU_INV_MO = 0x04,
  475. DDPU_MSG_TOOBIG = 0x05,
  476. DDPU_INV_VERS = 0x06
  477. };
  478. enum c4iw_mpa_ecodes {
  479. MPA_CRC_ERR = 0x02,
  480. MPA_MARKER_ERR = 0x03
  481. };
  482. enum c4iw_ep_state {
  483. IDLE = 0,
  484. LISTEN,
  485. CONNECTING,
  486. MPA_REQ_WAIT,
  487. MPA_REQ_SENT,
  488. MPA_REQ_RCVD,
  489. MPA_REP_SENT,
  490. FPDU_MODE,
  491. ABORTING,
  492. CLOSING,
  493. MORIBUND,
  494. DEAD,
  495. };
  496. enum c4iw_ep_flags {
  497. PEER_ABORT_IN_PROGRESS = 0,
  498. ABORT_REQ_IN_PROGRESS = 1,
  499. RELEASE_RESOURCES = 2,
  500. CLOSE_SENT = 3,
  501. };
  502. struct c4iw_ep_common {
  503. struct iw_cm_id *cm_id;
  504. struct c4iw_qp *qp;
  505. struct c4iw_dev *dev;
  506. enum c4iw_ep_state state;
  507. struct kref kref;
  508. spinlock_t lock;
  509. struct sockaddr_in local_addr;
  510. struct sockaddr_in remote_addr;
  511. wait_queue_head_t waitq;
  512. int rpl_done;
  513. int rpl_err;
  514. unsigned long flags;
  515. };
  516. struct c4iw_listen_ep {
  517. struct c4iw_ep_common com;
  518. unsigned int stid;
  519. int backlog;
  520. };
  521. struct c4iw_ep {
  522. struct c4iw_ep_common com;
  523. struct c4iw_ep *parent_ep;
  524. struct timer_list timer;
  525. struct list_head entry;
  526. unsigned int atid;
  527. u32 hwtid;
  528. u32 snd_seq;
  529. u32 rcv_seq;
  530. struct l2t_entry *l2t;
  531. struct dst_entry *dst;
  532. struct sk_buff *mpa_skb;
  533. struct c4iw_mpa_attributes mpa_attr;
  534. u8 mpa_pkt[sizeof(struct mpa_message) + MPA_MAX_PRIVATE_DATA];
  535. unsigned int mpa_pkt_len;
  536. u32 ird;
  537. u32 ord;
  538. u32 smac_idx;
  539. u32 tx_chan;
  540. u32 mtu;
  541. u16 mss;
  542. u16 emss;
  543. u16 plen;
  544. u16 rss_qid;
  545. u16 txq_idx;
  546. u8 tos;
  547. };
  548. static inline struct c4iw_ep *to_ep(struct iw_cm_id *cm_id)
  549. {
  550. return cm_id->provider_data;
  551. }
  552. static inline struct c4iw_listen_ep *to_listen_ep(struct iw_cm_id *cm_id)
  553. {
  554. return cm_id->provider_data;
  555. }
  556. static inline int compute_wscale(int win)
  557. {
  558. int wscale = 0;
  559. while (wscale < 14 && (65535<<wscale) < win)
  560. wscale++;
  561. return wscale;
  562. }
  563. typedef int (*c4iw_handler_func)(struct c4iw_dev *dev, struct sk_buff *skb);
  564. int c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
  565. struct l2t_entry *l2t);
  566. void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qpid,
  567. struct c4iw_dev_ucontext *uctx);
  568. u32 c4iw_get_resource(struct kfifo *fifo, spinlock_t *lock);
  569. void c4iw_put_resource(struct kfifo *fifo, u32 entry, spinlock_t *lock);
  570. int c4iw_init_resource(struct c4iw_rdev *rdev, u32 nr_tpt, u32 nr_pdid);
  571. int c4iw_init_ctrl_qp(struct c4iw_rdev *rdev);
  572. int c4iw_pblpool_create(struct c4iw_rdev *rdev);
  573. int c4iw_rqtpool_create(struct c4iw_rdev *rdev);
  574. void c4iw_pblpool_destroy(struct c4iw_rdev *rdev);
  575. void c4iw_rqtpool_destroy(struct c4iw_rdev *rdev);
  576. void c4iw_destroy_resource(struct c4iw_resource *rscp);
  577. int c4iw_destroy_ctrl_qp(struct c4iw_rdev *rdev);
  578. int c4iw_register_device(struct c4iw_dev *dev);
  579. void c4iw_unregister_device(struct c4iw_dev *dev);
  580. int __init c4iw_cm_init(void);
  581. void __exit c4iw_cm_term(void);
  582. void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev,
  583. struct c4iw_dev_ucontext *uctx);
  584. void c4iw_init_dev_ucontext(struct c4iw_rdev *rdev,
  585. struct c4iw_dev_ucontext *uctx);
  586. int c4iw_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
  587. int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
  588. struct ib_send_wr **bad_wr);
  589. int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
  590. struct ib_recv_wr **bad_wr);
  591. int c4iw_bind_mw(struct ib_qp *qp, struct ib_mw *mw,
  592. struct ib_mw_bind *mw_bind);
  593. int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
  594. int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog);
  595. int c4iw_destroy_listen(struct iw_cm_id *cm_id);
  596. int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
  597. int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
  598. void c4iw_qp_add_ref(struct ib_qp *qp);
  599. void c4iw_qp_rem_ref(struct ib_qp *qp);
  600. void c4iw_free_fastreg_pbl(struct ib_fast_reg_page_list *page_list);
  601. struct ib_fast_reg_page_list *c4iw_alloc_fastreg_pbl(
  602. struct ib_device *device,
  603. int page_list_len);
  604. struct ib_mr *c4iw_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth);
  605. int c4iw_dealloc_mw(struct ib_mw *mw);
  606. struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd);
  607. struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start,
  608. u64 length, u64 virt, int acc,
  609. struct ib_udata *udata);
  610. struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc);
  611. struct ib_mr *c4iw_register_phys_mem(struct ib_pd *pd,
  612. struct ib_phys_buf *buffer_list,
  613. int num_phys_buf,
  614. int acc,
  615. u64 *iova_start);
  616. int c4iw_reregister_phys_mem(struct ib_mr *mr,
  617. int mr_rereg_mask,
  618. struct ib_pd *pd,
  619. struct ib_phys_buf *buffer_list,
  620. int num_phys_buf,
  621. int acc, u64 *iova_start);
  622. int c4iw_dereg_mr(struct ib_mr *ib_mr);
  623. int c4iw_destroy_cq(struct ib_cq *ib_cq);
  624. struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
  625. int vector,
  626. struct ib_ucontext *ib_context,
  627. struct ib_udata *udata);
  628. int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata);
  629. int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
  630. int c4iw_destroy_qp(struct ib_qp *ib_qp);
  631. struct ib_qp *c4iw_create_qp(struct ib_pd *pd,
  632. struct ib_qp_init_attr *attrs,
  633. struct ib_udata *udata);
  634. int c4iw_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
  635. int attr_mask, struct ib_udata *udata);
  636. struct ib_qp *c4iw_get_qp(struct ib_device *dev, int qpn);
  637. u32 c4iw_rqtpool_alloc(struct c4iw_rdev *rdev, int size);
  638. void c4iw_rqtpool_free(struct c4iw_rdev *rdev, u32 addr, int size);
  639. u32 c4iw_pblpool_alloc(struct c4iw_rdev *rdev, int size);
  640. void c4iw_pblpool_free(struct c4iw_rdev *rdev, u32 addr, int size);
  641. int c4iw_ofld_send(struct c4iw_rdev *rdev, struct sk_buff *skb);
  642. void c4iw_flush_hw_cq(struct t4_cq *cq);
  643. void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
  644. void c4iw_count_scqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
  645. int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp);
  646. int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count);
  647. int c4iw_flush_sq(struct t4_wq *wq, struct t4_cq *cq, int count);
  648. int c4iw_ev_handler(struct c4iw_dev *rnicp, u32 qid);
  649. u16 c4iw_rqes_posted(struct c4iw_qp *qhp);
  650. int c4iw_post_zb_read(struct c4iw_qp *qhp);
  651. int c4iw_post_terminate(struct c4iw_qp *qhp, struct t4_cqe *err_cqe);
  652. u32 c4iw_get_cqid(struct c4iw_rdev *rdev, struct c4iw_dev_ucontext *uctx);
  653. void c4iw_put_cqid(struct c4iw_rdev *rdev, u32 qid,
  654. struct c4iw_dev_ucontext *uctx);
  655. u32 c4iw_get_qpid(struct c4iw_rdev *rdev, struct c4iw_dev_ucontext *uctx);
  656. void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qid,
  657. struct c4iw_dev_ucontext *uctx);
  658. void c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe *err_cqe);
  659. extern struct cxgb4_client t4c_client;
  660. extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS];
  661. extern int c4iw_max_read_depth;
  662. #endif