device.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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. *
  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. #include <linux/module.h>
  33. #include <linux/moduleparam.h>
  34. #include <linux/debugfs.h>
  35. #include <rdma/ib_verbs.h>
  36. #include "iw_cxgb4.h"
  37. #define DRV_VERSION "0.1"
  38. MODULE_AUTHOR("Steve Wise");
  39. MODULE_DESCRIPTION("Chelsio T4 RDMA Driver");
  40. MODULE_LICENSE("Dual BSD/GPL");
  41. MODULE_VERSION(DRV_VERSION);
  42. static LIST_HEAD(dev_list);
  43. static DEFINE_MUTEX(dev_mutex);
  44. static struct dentry *c4iw_debugfs_root;
  45. struct c4iw_debugfs_data {
  46. struct c4iw_dev *devp;
  47. char *buf;
  48. int bufsize;
  49. int pos;
  50. };
  51. static int count_idrs(int id, void *p, void *data)
  52. {
  53. int *countp = data;
  54. *countp = *countp + 1;
  55. return 0;
  56. }
  57. static ssize_t debugfs_read(struct file *file, char __user *buf, size_t count,
  58. loff_t *ppos)
  59. {
  60. struct c4iw_debugfs_data *d = file->private_data;
  61. loff_t pos = *ppos;
  62. loff_t avail = d->pos;
  63. if (pos < 0)
  64. return -EINVAL;
  65. if (pos >= avail)
  66. return 0;
  67. if (count > avail - pos)
  68. count = avail - pos;
  69. while (count) {
  70. size_t len = 0;
  71. len = min((int)count, (int)d->pos - (int)pos);
  72. if (copy_to_user(buf, d->buf + pos, len))
  73. return -EFAULT;
  74. if (len == 0)
  75. return -EINVAL;
  76. buf += len;
  77. pos += len;
  78. count -= len;
  79. }
  80. count = pos - *ppos;
  81. *ppos = pos;
  82. return count;
  83. }
  84. static int dump_qp(int id, void *p, void *data)
  85. {
  86. struct c4iw_qp *qp = p;
  87. struct c4iw_debugfs_data *qpd = data;
  88. int space;
  89. int cc;
  90. if (id != qp->wq.sq.qid)
  91. return 0;
  92. space = qpd->bufsize - qpd->pos - 1;
  93. if (space == 0)
  94. return 1;
  95. if (qp->ep)
  96. cc = snprintf(qpd->buf + qpd->pos, space, "qp id %u state %u "
  97. "ep tid %u state %u %pI4:%u->%pI4:%u\n",
  98. qp->wq.sq.qid, (int)qp->attr.state,
  99. qp->ep->hwtid, (int)qp->ep->com.state,
  100. &qp->ep->com.local_addr.sin_addr.s_addr,
  101. ntohs(qp->ep->com.local_addr.sin_port),
  102. &qp->ep->com.remote_addr.sin_addr.s_addr,
  103. ntohs(qp->ep->com.remote_addr.sin_port));
  104. else
  105. cc = snprintf(qpd->buf + qpd->pos, space, "qp id %u state %u\n",
  106. qp->wq.sq.qid, (int)qp->attr.state);
  107. if (cc < space)
  108. qpd->pos += cc;
  109. return 0;
  110. }
  111. static int qp_release(struct inode *inode, struct file *file)
  112. {
  113. struct c4iw_debugfs_data *qpd = file->private_data;
  114. if (!qpd) {
  115. printk(KERN_INFO "%s null qpd?\n", __func__);
  116. return 0;
  117. }
  118. kfree(qpd->buf);
  119. kfree(qpd);
  120. return 0;
  121. }
  122. static int qp_open(struct inode *inode, struct file *file)
  123. {
  124. struct c4iw_debugfs_data *qpd;
  125. int ret = 0;
  126. int count = 1;
  127. qpd = kmalloc(sizeof *qpd, GFP_KERNEL);
  128. if (!qpd) {
  129. ret = -ENOMEM;
  130. goto out;
  131. }
  132. qpd->devp = inode->i_private;
  133. qpd->pos = 0;
  134. spin_lock_irq(&qpd->devp->lock);
  135. idr_for_each(&qpd->devp->qpidr, count_idrs, &count);
  136. spin_unlock_irq(&qpd->devp->lock);
  137. qpd->bufsize = count * 128;
  138. qpd->buf = kmalloc(qpd->bufsize, GFP_KERNEL);
  139. if (!qpd->buf) {
  140. ret = -ENOMEM;
  141. goto err1;
  142. }
  143. spin_lock_irq(&qpd->devp->lock);
  144. idr_for_each(&qpd->devp->qpidr, dump_qp, qpd);
  145. spin_unlock_irq(&qpd->devp->lock);
  146. qpd->buf[qpd->pos++] = 0;
  147. file->private_data = qpd;
  148. goto out;
  149. err1:
  150. kfree(qpd);
  151. out:
  152. return ret;
  153. }
  154. static const struct file_operations qp_debugfs_fops = {
  155. .owner = THIS_MODULE,
  156. .open = qp_open,
  157. .release = qp_release,
  158. .read = debugfs_read,
  159. .llseek = default_llseek,
  160. };
  161. static int dump_stag(int id, void *p, void *data)
  162. {
  163. struct c4iw_debugfs_data *stagd = data;
  164. int space;
  165. int cc;
  166. space = stagd->bufsize - stagd->pos - 1;
  167. if (space == 0)
  168. return 1;
  169. cc = snprintf(stagd->buf + stagd->pos, space, "0x%x\n", id<<8);
  170. if (cc < space)
  171. stagd->pos += cc;
  172. return 0;
  173. }
  174. static int stag_release(struct inode *inode, struct file *file)
  175. {
  176. struct c4iw_debugfs_data *stagd = file->private_data;
  177. if (!stagd) {
  178. printk(KERN_INFO "%s null stagd?\n", __func__);
  179. return 0;
  180. }
  181. kfree(stagd->buf);
  182. kfree(stagd);
  183. return 0;
  184. }
  185. static int stag_open(struct inode *inode, struct file *file)
  186. {
  187. struct c4iw_debugfs_data *stagd;
  188. int ret = 0;
  189. int count = 1;
  190. stagd = kmalloc(sizeof *stagd, GFP_KERNEL);
  191. if (!stagd) {
  192. ret = -ENOMEM;
  193. goto out;
  194. }
  195. stagd->devp = inode->i_private;
  196. stagd->pos = 0;
  197. spin_lock_irq(&stagd->devp->lock);
  198. idr_for_each(&stagd->devp->mmidr, count_idrs, &count);
  199. spin_unlock_irq(&stagd->devp->lock);
  200. stagd->bufsize = count * sizeof("0x12345678\n");
  201. stagd->buf = kmalloc(stagd->bufsize, GFP_KERNEL);
  202. if (!stagd->buf) {
  203. ret = -ENOMEM;
  204. goto err1;
  205. }
  206. spin_lock_irq(&stagd->devp->lock);
  207. idr_for_each(&stagd->devp->mmidr, dump_stag, stagd);
  208. spin_unlock_irq(&stagd->devp->lock);
  209. stagd->buf[stagd->pos++] = 0;
  210. file->private_data = stagd;
  211. goto out;
  212. err1:
  213. kfree(stagd);
  214. out:
  215. return ret;
  216. }
  217. static const struct file_operations stag_debugfs_fops = {
  218. .owner = THIS_MODULE,
  219. .open = stag_open,
  220. .release = stag_release,
  221. .read = debugfs_read,
  222. .llseek = default_llseek,
  223. };
  224. static int setup_debugfs(struct c4iw_dev *devp)
  225. {
  226. struct dentry *de;
  227. if (!devp->debugfs_root)
  228. return -1;
  229. de = debugfs_create_file("qps", S_IWUSR, devp->debugfs_root,
  230. (void *)devp, &qp_debugfs_fops);
  231. if (de && de->d_inode)
  232. de->d_inode->i_size = 4096;
  233. de = debugfs_create_file("stags", S_IWUSR, devp->debugfs_root,
  234. (void *)devp, &stag_debugfs_fops);
  235. if (de && de->d_inode)
  236. de->d_inode->i_size = 4096;
  237. return 0;
  238. }
  239. void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev,
  240. struct c4iw_dev_ucontext *uctx)
  241. {
  242. struct list_head *pos, *nxt;
  243. struct c4iw_qid_list *entry;
  244. mutex_lock(&uctx->lock);
  245. list_for_each_safe(pos, nxt, &uctx->qpids) {
  246. entry = list_entry(pos, struct c4iw_qid_list, entry);
  247. list_del_init(&entry->entry);
  248. if (!(entry->qid & rdev->qpmask))
  249. c4iw_put_resource(&rdev->resource.qid_fifo, entry->qid,
  250. &rdev->resource.qid_fifo_lock);
  251. kfree(entry);
  252. }
  253. list_for_each_safe(pos, nxt, &uctx->qpids) {
  254. entry = list_entry(pos, struct c4iw_qid_list, entry);
  255. list_del_init(&entry->entry);
  256. kfree(entry);
  257. }
  258. mutex_unlock(&uctx->lock);
  259. }
  260. void c4iw_init_dev_ucontext(struct c4iw_rdev *rdev,
  261. struct c4iw_dev_ucontext *uctx)
  262. {
  263. INIT_LIST_HEAD(&uctx->qpids);
  264. INIT_LIST_HEAD(&uctx->cqids);
  265. mutex_init(&uctx->lock);
  266. }
  267. /* Caller takes care of locking if needed */
  268. static int c4iw_rdev_open(struct c4iw_rdev *rdev)
  269. {
  270. int err;
  271. c4iw_init_dev_ucontext(rdev, &rdev->uctx);
  272. /*
  273. * qpshift is the number of bits to shift the qpid left in order
  274. * to get the correct address of the doorbell for that qp.
  275. */
  276. rdev->qpshift = PAGE_SHIFT - ilog2(rdev->lldi.udb_density);
  277. rdev->qpmask = rdev->lldi.udb_density - 1;
  278. rdev->cqshift = PAGE_SHIFT - ilog2(rdev->lldi.ucq_density);
  279. rdev->cqmask = rdev->lldi.ucq_density - 1;
  280. PDBG("%s dev %s stag start 0x%0x size 0x%0x num stags %d "
  281. "pbl start 0x%0x size 0x%0x rq start 0x%0x size 0x%0x "
  282. "qp qid start %u size %u cq qid start %u size %u\n",
  283. __func__, pci_name(rdev->lldi.pdev), rdev->lldi.vr->stag.start,
  284. rdev->lldi.vr->stag.size, c4iw_num_stags(rdev),
  285. rdev->lldi.vr->pbl.start,
  286. rdev->lldi.vr->pbl.size, rdev->lldi.vr->rq.start,
  287. rdev->lldi.vr->rq.size,
  288. rdev->lldi.vr->qp.start,
  289. rdev->lldi.vr->qp.size,
  290. rdev->lldi.vr->cq.start,
  291. rdev->lldi.vr->cq.size);
  292. PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu "
  293. "qpmask 0x%x cqshift %lu cqmask 0x%x\n",
  294. (unsigned)pci_resource_len(rdev->lldi.pdev, 2),
  295. (void *)pci_resource_start(rdev->lldi.pdev, 2),
  296. rdev->lldi.db_reg,
  297. rdev->lldi.gts_reg,
  298. rdev->qpshift, rdev->qpmask,
  299. rdev->cqshift, rdev->cqmask);
  300. if (c4iw_num_stags(rdev) == 0) {
  301. err = -EINVAL;
  302. goto err1;
  303. }
  304. err = c4iw_init_resource(rdev, c4iw_num_stags(rdev), T4_MAX_NUM_PD);
  305. if (err) {
  306. printk(KERN_ERR MOD "error %d initializing resources\n", err);
  307. goto err1;
  308. }
  309. err = c4iw_pblpool_create(rdev);
  310. if (err) {
  311. printk(KERN_ERR MOD "error %d initializing pbl pool\n", err);
  312. goto err2;
  313. }
  314. err = c4iw_rqtpool_create(rdev);
  315. if (err) {
  316. printk(KERN_ERR MOD "error %d initializing rqt pool\n", err);
  317. goto err3;
  318. }
  319. err = c4iw_ocqp_pool_create(rdev);
  320. if (err) {
  321. printk(KERN_ERR MOD "error %d initializing ocqp pool\n", err);
  322. goto err4;
  323. }
  324. return 0;
  325. err4:
  326. c4iw_rqtpool_destroy(rdev);
  327. err3:
  328. c4iw_pblpool_destroy(rdev);
  329. err2:
  330. c4iw_destroy_resource(&rdev->resource);
  331. err1:
  332. return err;
  333. }
  334. static void c4iw_rdev_close(struct c4iw_rdev *rdev)
  335. {
  336. c4iw_pblpool_destroy(rdev);
  337. c4iw_rqtpool_destroy(rdev);
  338. c4iw_destroy_resource(&rdev->resource);
  339. }
  340. static void c4iw_remove(struct c4iw_dev *dev)
  341. {
  342. PDBG("%s c4iw_dev %p\n", __func__, dev);
  343. cancel_delayed_work_sync(&dev->db_drop_task);
  344. list_del(&dev->entry);
  345. if (dev->registered)
  346. c4iw_unregister_device(dev);
  347. c4iw_rdev_close(&dev->rdev);
  348. idr_destroy(&dev->cqidr);
  349. idr_destroy(&dev->qpidr);
  350. idr_destroy(&dev->mmidr);
  351. iounmap(dev->rdev.oc_mw_kva);
  352. ib_dealloc_device(&dev->ibdev);
  353. }
  354. static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
  355. {
  356. struct c4iw_dev *devp;
  357. int ret;
  358. devp = (struct c4iw_dev *)ib_alloc_device(sizeof(*devp));
  359. if (!devp) {
  360. printk(KERN_ERR MOD "Cannot allocate ib device\n");
  361. return NULL;
  362. }
  363. devp->rdev.lldi = *infop;
  364. devp->rdev.oc_mw_pa = pci_resource_start(devp->rdev.lldi.pdev, 2) +
  365. (pci_resource_len(devp->rdev.lldi.pdev, 2) -
  366. roundup_pow_of_two(devp->rdev.lldi.vr->ocq.size));
  367. devp->rdev.oc_mw_kva = ioremap_wc(devp->rdev.oc_mw_pa,
  368. devp->rdev.lldi.vr->ocq.size);
  369. printk(KERN_INFO MOD "ocq memory: "
  370. "hw_start 0x%x size %u mw_pa 0x%lx mw_kva %p\n",
  371. devp->rdev.lldi.vr->ocq.start, devp->rdev.lldi.vr->ocq.size,
  372. devp->rdev.oc_mw_pa, devp->rdev.oc_mw_kva);
  373. mutex_lock(&dev_mutex);
  374. ret = c4iw_rdev_open(&devp->rdev);
  375. if (ret) {
  376. mutex_unlock(&dev_mutex);
  377. printk(KERN_ERR MOD "Unable to open CXIO rdev err %d\n", ret);
  378. ib_dealloc_device(&devp->ibdev);
  379. return NULL;
  380. }
  381. idr_init(&devp->cqidr);
  382. idr_init(&devp->qpidr);
  383. idr_init(&devp->mmidr);
  384. spin_lock_init(&devp->lock);
  385. list_add_tail(&devp->entry, &dev_list);
  386. mutex_unlock(&dev_mutex);
  387. if (c4iw_debugfs_root) {
  388. devp->debugfs_root = debugfs_create_dir(
  389. pci_name(devp->rdev.lldi.pdev),
  390. c4iw_debugfs_root);
  391. setup_debugfs(devp);
  392. }
  393. return devp;
  394. }
  395. static void *c4iw_uld_add(const struct cxgb4_lld_info *infop)
  396. {
  397. struct c4iw_dev *dev;
  398. static int vers_printed;
  399. int i;
  400. if (!vers_printed++)
  401. printk(KERN_INFO MOD "Chelsio T4 RDMA Driver - version %s\n",
  402. DRV_VERSION);
  403. dev = c4iw_alloc(infop);
  404. if (!dev)
  405. goto out;
  406. PDBG("%s found device %s nchan %u nrxq %u ntxq %u nports %u\n",
  407. __func__, pci_name(dev->rdev.lldi.pdev),
  408. dev->rdev.lldi.nchan, dev->rdev.lldi.nrxq,
  409. dev->rdev.lldi.ntxq, dev->rdev.lldi.nports);
  410. for (i = 0; i < dev->rdev.lldi.nrxq; i++)
  411. PDBG("rxqid[%u] %u\n", i, dev->rdev.lldi.rxq_ids[i]);
  412. out:
  413. return dev;
  414. }
  415. static struct sk_buff *t4_pktgl_to_skb(const struct pkt_gl *gl,
  416. unsigned int skb_len,
  417. unsigned int pull_len)
  418. {
  419. struct sk_buff *skb;
  420. struct skb_shared_info *ssi;
  421. if (gl->tot_len <= 512) {
  422. skb = alloc_skb(gl->tot_len, GFP_ATOMIC);
  423. if (unlikely(!skb))
  424. goto out;
  425. __skb_put(skb, gl->tot_len);
  426. skb_copy_to_linear_data(skb, gl->va, gl->tot_len);
  427. } else {
  428. skb = alloc_skb(skb_len, GFP_ATOMIC);
  429. if (unlikely(!skb))
  430. goto out;
  431. __skb_put(skb, pull_len);
  432. skb_copy_to_linear_data(skb, gl->va, pull_len);
  433. ssi = skb_shinfo(skb);
  434. ssi->frags[0].page = gl->frags[0].page;
  435. ssi->frags[0].page_offset = gl->frags[0].page_offset + pull_len;
  436. ssi->frags[0].size = gl->frags[0].size - pull_len;
  437. if (gl->nfrags > 1)
  438. memcpy(&ssi->frags[1], &gl->frags[1],
  439. (gl->nfrags - 1) * sizeof(skb_frag_t));
  440. ssi->nr_frags = gl->nfrags;
  441. skb->len = gl->tot_len;
  442. skb->data_len = skb->len - pull_len;
  443. skb->truesize += skb->data_len;
  444. /* Get a reference for the last page, we don't own it */
  445. get_page(gl->frags[gl->nfrags - 1].page);
  446. }
  447. out:
  448. return skb;
  449. }
  450. static int c4iw_uld_rx_handler(void *handle, const __be64 *rsp,
  451. const struct pkt_gl *gl)
  452. {
  453. struct c4iw_dev *dev = handle;
  454. struct sk_buff *skb;
  455. const struct cpl_act_establish *rpl;
  456. unsigned int opcode;
  457. if (gl == NULL) {
  458. /* omit RSS and rsp_ctrl at end of descriptor */
  459. unsigned int len = 64 - sizeof(struct rsp_ctrl) - 8;
  460. skb = alloc_skb(256, GFP_ATOMIC);
  461. if (!skb)
  462. goto nomem;
  463. __skb_put(skb, len);
  464. skb_copy_to_linear_data(skb, &rsp[1], len);
  465. } else if (gl == CXGB4_MSG_AN) {
  466. const struct rsp_ctrl *rc = (void *)rsp;
  467. u32 qid = be32_to_cpu(rc->pldbuflen_qid);
  468. c4iw_ev_handler(dev, qid);
  469. return 0;
  470. } else {
  471. skb = t4_pktgl_to_skb(gl, 128, 128);
  472. if (unlikely(!skb))
  473. goto nomem;
  474. }
  475. rpl = cplhdr(skb);
  476. opcode = rpl->ot.opcode;
  477. if (c4iw_handlers[opcode])
  478. c4iw_handlers[opcode](dev, skb);
  479. else
  480. printk(KERN_INFO "%s no handler opcode 0x%x...\n", __func__,
  481. opcode);
  482. return 0;
  483. nomem:
  484. return -1;
  485. }
  486. static int c4iw_uld_state_change(void *handle, enum cxgb4_state new_state)
  487. {
  488. struct c4iw_dev *dev = handle;
  489. PDBG("%s new_state %u\n", __func__, new_state);
  490. switch (new_state) {
  491. case CXGB4_STATE_UP:
  492. printk(KERN_INFO MOD "%s: Up\n", pci_name(dev->rdev.lldi.pdev));
  493. if (!dev->registered) {
  494. int ret;
  495. ret = c4iw_register_device(dev);
  496. if (ret)
  497. printk(KERN_ERR MOD
  498. "%s: RDMA registration failed: %d\n",
  499. pci_name(dev->rdev.lldi.pdev), ret);
  500. }
  501. break;
  502. case CXGB4_STATE_DOWN:
  503. printk(KERN_INFO MOD "%s: Down\n",
  504. pci_name(dev->rdev.lldi.pdev));
  505. if (dev->registered)
  506. c4iw_unregister_device(dev);
  507. break;
  508. case CXGB4_STATE_START_RECOVERY:
  509. printk(KERN_INFO MOD "%s: Fatal Error\n",
  510. pci_name(dev->rdev.lldi.pdev));
  511. if (dev->registered)
  512. c4iw_unregister_device(dev);
  513. break;
  514. case CXGB4_STATE_DETACH:
  515. printk(KERN_INFO MOD "%s: Detach\n",
  516. pci_name(dev->rdev.lldi.pdev));
  517. mutex_lock(&dev_mutex);
  518. c4iw_remove(dev);
  519. mutex_unlock(&dev_mutex);
  520. break;
  521. }
  522. return 0;
  523. }
  524. static struct cxgb4_uld_info c4iw_uld_info = {
  525. .name = DRV_NAME,
  526. .add = c4iw_uld_add,
  527. .rx_handler = c4iw_uld_rx_handler,
  528. .state_change = c4iw_uld_state_change,
  529. };
  530. static int __init c4iw_init_module(void)
  531. {
  532. int err;
  533. err = c4iw_cm_init();
  534. if (err)
  535. return err;
  536. c4iw_debugfs_root = debugfs_create_dir(DRV_NAME, NULL);
  537. if (!c4iw_debugfs_root)
  538. printk(KERN_WARNING MOD
  539. "could not create debugfs entry, continuing\n");
  540. cxgb4_register_uld(CXGB4_ULD_RDMA, &c4iw_uld_info);
  541. return 0;
  542. }
  543. static void __exit c4iw_exit_module(void)
  544. {
  545. struct c4iw_dev *dev, *tmp;
  546. mutex_lock(&dev_mutex);
  547. list_for_each_entry_safe(dev, tmp, &dev_list, entry) {
  548. c4iw_remove(dev);
  549. }
  550. mutex_unlock(&dev_mutex);
  551. cxgb4_unregister_uld(CXGB4_ULD_RDMA);
  552. c4iw_cm_term();
  553. debugfs_remove_recursive(c4iw_debugfs_root);
  554. }
  555. module_init(c4iw_init_module);
  556. module_exit(c4iw_exit_module);