csio_init.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. /*
  2. * This file is part of the Chelsio FCoE driver for Linux.
  3. *
  4. * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  35. #include <linux/kernel.h>
  36. #include <linux/module.h>
  37. #include <linux/init.h>
  38. #include <linux/pci.h>
  39. #include <linux/aer.h>
  40. #include <linux/mm.h>
  41. #include <linux/notifier.h>
  42. #include <linux/kdebug.h>
  43. #include <linux/seq_file.h>
  44. #include <linux/debugfs.h>
  45. #include <linux/string.h>
  46. #include <linux/export.h>
  47. #include "csio_init.h"
  48. #include "csio_defs.h"
  49. #define CSIO_MIN_MEMPOOL_SZ 64
  50. static struct dentry *csio_debugfs_root;
  51. static struct scsi_transport_template *csio_fcoe_transport;
  52. static struct scsi_transport_template *csio_fcoe_transport_vport;
  53. /*
  54. * debugfs support
  55. */
  56. static int
  57. csio_mem_open(struct inode *inode, struct file *file)
  58. {
  59. file->private_data = inode->i_private;
  60. return 0;
  61. }
  62. static ssize_t
  63. csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
  64. {
  65. loff_t pos = *ppos;
  66. loff_t avail = file->f_path.dentry->d_inode->i_size;
  67. unsigned int mem = (uintptr_t)file->private_data & 3;
  68. struct csio_hw *hw = file->private_data - mem;
  69. if (pos < 0)
  70. return -EINVAL;
  71. if (pos >= avail)
  72. return 0;
  73. if (count > avail - pos)
  74. count = avail - pos;
  75. while (count) {
  76. size_t len;
  77. int ret, ofst;
  78. __be32 data[16];
  79. if (mem == MEM_MC)
  80. ret = csio_hw_mc_read(hw, pos, data, NULL);
  81. else
  82. ret = csio_hw_edc_read(hw, mem, pos, data, NULL);
  83. if (ret)
  84. return ret;
  85. ofst = pos % sizeof(data);
  86. len = min(count, sizeof(data) - ofst);
  87. if (copy_to_user(buf, (u8 *)data + ofst, len))
  88. return -EFAULT;
  89. buf += len;
  90. pos += len;
  91. count -= len;
  92. }
  93. count = pos - *ppos;
  94. *ppos = pos;
  95. return count;
  96. }
  97. static const struct file_operations csio_mem_debugfs_fops = {
  98. .owner = THIS_MODULE,
  99. .open = csio_mem_open,
  100. .read = csio_mem_read,
  101. .llseek = default_llseek,
  102. };
  103. static void csio_add_debugfs_mem(struct csio_hw *hw, const char *name,
  104. unsigned int idx, unsigned int size_mb)
  105. {
  106. struct dentry *de;
  107. de = debugfs_create_file(name, S_IRUSR, hw->debugfs_root,
  108. (void *)hw + idx, &csio_mem_debugfs_fops);
  109. if (de && de->d_inode)
  110. de->d_inode->i_size = size_mb << 20;
  111. }
  112. static int csio_setup_debugfs(struct csio_hw *hw)
  113. {
  114. int i;
  115. if (IS_ERR_OR_NULL(hw->debugfs_root))
  116. return -1;
  117. i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE);
  118. if (i & EDRAM0_ENABLE)
  119. csio_add_debugfs_mem(hw, "edc0", MEM_EDC0, 5);
  120. if (i & EDRAM1_ENABLE)
  121. csio_add_debugfs_mem(hw, "edc1", MEM_EDC1, 5);
  122. if (i & EXT_MEM_ENABLE)
  123. csio_add_debugfs_mem(hw, "mc", MEM_MC,
  124. EXT_MEM_SIZE_GET(csio_rd_reg32(hw, MA_EXT_MEMORY_BAR)));
  125. return 0;
  126. }
  127. /*
  128. * csio_dfs_create - Creates and sets up per-hw debugfs.
  129. *
  130. */
  131. static int
  132. csio_dfs_create(struct csio_hw *hw)
  133. {
  134. if (csio_debugfs_root) {
  135. hw->debugfs_root = debugfs_create_dir(pci_name(hw->pdev),
  136. csio_debugfs_root);
  137. csio_setup_debugfs(hw);
  138. }
  139. return 0;
  140. }
  141. /*
  142. * csio_dfs_destroy - Destroys per-hw debugfs.
  143. */
  144. static int
  145. csio_dfs_destroy(struct csio_hw *hw)
  146. {
  147. if (hw->debugfs_root)
  148. debugfs_remove_recursive(hw->debugfs_root);
  149. return 0;
  150. }
  151. /*
  152. * csio_dfs_init - Debug filesystem initialization for the module.
  153. *
  154. */
  155. static int
  156. csio_dfs_init(void)
  157. {
  158. csio_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
  159. if (!csio_debugfs_root)
  160. pr_warn("Could not create debugfs entry, continuing\n");
  161. return 0;
  162. }
  163. /*
  164. * csio_dfs_exit - debugfs cleanup for the module.
  165. */
  166. static void
  167. csio_dfs_exit(void)
  168. {
  169. debugfs_remove(csio_debugfs_root);
  170. }
  171. /*
  172. * csio_pci_init - PCI initialization.
  173. * @pdev: PCI device.
  174. * @bars: Bitmask of bars to be requested.
  175. *
  176. * Initializes the PCI function by enabling MMIO, setting bus
  177. * mastership and setting DMA mask.
  178. */
  179. static int
  180. csio_pci_init(struct pci_dev *pdev, int *bars)
  181. {
  182. int rv = -ENODEV;
  183. *bars = pci_select_bars(pdev, IORESOURCE_MEM);
  184. if (pci_enable_device_mem(pdev))
  185. goto err;
  186. if (pci_request_selected_regions(pdev, *bars, KBUILD_MODNAME))
  187. goto err_disable_device;
  188. pci_set_master(pdev);
  189. pci_try_set_mwi(pdev);
  190. if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
  191. pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
  192. } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
  193. pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  194. } else {
  195. dev_err(&pdev->dev, "No suitable DMA available.\n");
  196. goto err_release_regions;
  197. }
  198. return 0;
  199. err_release_regions:
  200. pci_release_selected_regions(pdev, *bars);
  201. err_disable_device:
  202. pci_disable_device(pdev);
  203. err:
  204. return rv;
  205. }
  206. /*
  207. * csio_pci_exit - PCI unitialization.
  208. * @pdev: PCI device.
  209. * @bars: Bars to be released.
  210. *
  211. */
  212. static void
  213. csio_pci_exit(struct pci_dev *pdev, int *bars)
  214. {
  215. pci_release_selected_regions(pdev, *bars);
  216. pci_disable_device(pdev);
  217. }
  218. /*
  219. * csio_hw_init_workers - Initialize the HW module's worker threads.
  220. * @hw: HW module.
  221. *
  222. */
  223. static void
  224. csio_hw_init_workers(struct csio_hw *hw)
  225. {
  226. INIT_WORK(&hw->evtq_work, csio_evtq_worker);
  227. }
  228. static void
  229. csio_hw_exit_workers(struct csio_hw *hw)
  230. {
  231. cancel_work_sync(&hw->evtq_work);
  232. flush_scheduled_work();
  233. }
  234. static int
  235. csio_create_queues(struct csio_hw *hw)
  236. {
  237. int i, j;
  238. struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw);
  239. int rv;
  240. struct csio_scsi_cpu_info *info;
  241. if (hw->flags & CSIO_HWF_Q_FW_ALLOCED)
  242. return 0;
  243. if (hw->intr_mode != CSIO_IM_MSIX) {
  244. rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx,
  245. 0, hw->pport[0].portid, false, NULL);
  246. if (rv != 0) {
  247. csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv);
  248. return rv;
  249. }
  250. }
  251. /* FW event queue */
  252. rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx,
  253. csio_get_fwevt_intr_idx(hw),
  254. hw->pport[0].portid, true, NULL);
  255. if (rv != 0) {
  256. csio_err(hw, "FW event IQ config failed!: %d\n", rv);
  257. return rv;
  258. }
  259. /* Create mgmt queue */
  260. rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx,
  261. mgmtm->iq_idx, hw->pport[0].portid, NULL);
  262. if (rv != 0) {
  263. csio_err(hw, "Mgmt EQ create failed!: %d\n", rv);
  264. goto err;
  265. }
  266. /* Create SCSI queues */
  267. for (i = 0; i < hw->num_pports; i++) {
  268. info = &hw->scsi_cpu_info[i];
  269. for (j = 0; j < info->max_cpus; j++) {
  270. struct csio_scsi_qset *sqset = &hw->sqset[i][j];
  271. rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx,
  272. sqset->intr_idx, i, false, NULL);
  273. if (rv != 0) {
  274. csio_err(hw,
  275. "SCSI module IQ config failed [%d][%d]:%d\n",
  276. i, j, rv);
  277. goto err;
  278. }
  279. rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx,
  280. sqset->iq_idx, i, NULL);
  281. if (rv != 0) {
  282. csio_err(hw,
  283. "SCSI module EQ config failed [%d][%d]:%d\n",
  284. i, j, rv);
  285. goto err;
  286. }
  287. } /* for all CPUs */
  288. } /* For all ports */
  289. hw->flags |= CSIO_HWF_Q_FW_ALLOCED;
  290. return 0;
  291. err:
  292. csio_wr_destroy_queues(hw, true);
  293. return -EINVAL;
  294. }
  295. /*
  296. * csio_config_queues - Configure the DMA queues.
  297. * @hw: HW module.
  298. *
  299. * Allocates memory for queues are registers them with FW.
  300. */
  301. int
  302. csio_config_queues(struct csio_hw *hw)
  303. {
  304. int i, j, idx, k = 0;
  305. int rv;
  306. struct csio_scsi_qset *sqset;
  307. struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw);
  308. struct csio_scsi_qset *orig;
  309. struct csio_scsi_cpu_info *info;
  310. if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED)
  311. return csio_create_queues(hw);
  312. /* Calculate number of SCSI queues for MSIX we would like */
  313. hw->num_scsi_msix_cpus = num_online_cpus();
  314. hw->num_sqsets = num_online_cpus() * hw->num_pports;
  315. if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) {
  316. hw->num_sqsets = CSIO_MAX_SCSI_QSETS;
  317. hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU;
  318. }
  319. /* Initialize max_cpus, may get reduced during msix allocations */
  320. for (i = 0; i < hw->num_pports; i++)
  321. hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus;
  322. csio_dbg(hw, "nsqsets:%d scpus:%d\n",
  323. hw->num_sqsets, hw->num_scsi_msix_cpus);
  324. csio_intr_enable(hw);
  325. if (hw->intr_mode != CSIO_IM_MSIX) {
  326. /* Allocate Forward interrupt iq. */
  327. hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE,
  328. CSIO_INTR_WRSIZE, CSIO_INGRESS,
  329. (void *)hw, 0, 0, NULL);
  330. if (hw->intr_iq_idx == -1) {
  331. csio_err(hw,
  332. "Forward interrupt queue creation failed\n");
  333. goto intr_disable;
  334. }
  335. }
  336. /* Allocate the FW evt queue */
  337. hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE,
  338. CSIO_FWEVT_WRSIZE,
  339. CSIO_INGRESS, (void *)hw,
  340. CSIO_FWEVT_FLBUFS, 0,
  341. csio_fwevt_intx_handler);
  342. if (hw->fwevt_iq_idx == -1) {
  343. csio_err(hw, "FW evt queue creation failed\n");
  344. goto intr_disable;
  345. }
  346. /* Allocate the mgmt queue */
  347. mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE,
  348. CSIO_MGMT_EQ_WRSIZE,
  349. CSIO_EGRESS, (void *)hw, 0, 0, NULL);
  350. if (mgmtm->eq_idx == -1) {
  351. csio_err(hw, "Failed to alloc egress queue for mgmt module\n");
  352. goto intr_disable;
  353. }
  354. /* Use FW IQ for MGMT req completion */
  355. mgmtm->iq_idx = hw->fwevt_iq_idx;
  356. /* Allocate SCSI queues */
  357. for (i = 0; i < hw->num_pports; i++) {
  358. info = &hw->scsi_cpu_info[i];
  359. for (j = 0; j < hw->num_scsi_msix_cpus; j++) {
  360. sqset = &hw->sqset[i][j];
  361. if (j >= info->max_cpus) {
  362. k = j % info->max_cpus;
  363. orig = &hw->sqset[i][k];
  364. sqset->eq_idx = orig->eq_idx;
  365. sqset->iq_idx = orig->iq_idx;
  366. continue;
  367. }
  368. idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0,
  369. CSIO_EGRESS, (void *)hw, 0, 0,
  370. NULL);
  371. if (idx == -1) {
  372. csio_err(hw, "EQ creation failed for idx:%d\n",
  373. idx);
  374. goto intr_disable;
  375. }
  376. sqset->eq_idx = idx;
  377. idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE,
  378. CSIO_SCSI_IQ_WRSZ, CSIO_INGRESS,
  379. (void *)hw, 0, 0,
  380. csio_scsi_intx_handler);
  381. if (idx == -1) {
  382. csio_err(hw, "IQ creation failed for idx:%d\n",
  383. idx);
  384. goto intr_disable;
  385. }
  386. sqset->iq_idx = idx;
  387. } /* for all CPUs */
  388. } /* For all ports */
  389. hw->flags |= CSIO_HWF_Q_MEM_ALLOCED;
  390. rv = csio_create_queues(hw);
  391. if (rv != 0)
  392. goto intr_disable;
  393. /*
  394. * Now request IRQs for the vectors. In the event of a failure,
  395. * cleanup is handled internally by this function.
  396. */
  397. rv = csio_request_irqs(hw);
  398. if (rv != 0)
  399. return -EINVAL;
  400. return 0;
  401. intr_disable:
  402. csio_intr_disable(hw, false);
  403. return -EINVAL;
  404. }
  405. static int
  406. csio_resource_alloc(struct csio_hw *hw)
  407. {
  408. struct csio_wrm *wrm = csio_hw_to_wrm(hw);
  409. int rv = -ENOMEM;
  410. wrm->num_q = ((CSIO_MAX_SCSI_QSETS * 2) + CSIO_HW_NIQ +
  411. CSIO_HW_NEQ + CSIO_HW_NFLQ + CSIO_HW_NINTXQ);
  412. hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ,
  413. sizeof(struct csio_mb));
  414. if (!hw->mb_mempool)
  415. goto err;
  416. hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ,
  417. sizeof(struct csio_rnode));
  418. if (!hw->rnode_mempool)
  419. goto err_free_mb_mempool;
  420. hw->scsi_pci_pool = pci_pool_create("csio_scsi_pci_pool", hw->pdev,
  421. CSIO_SCSI_RSP_LEN, 8, 0);
  422. if (!hw->scsi_pci_pool)
  423. goto err_free_rn_pool;
  424. return 0;
  425. err_free_rn_pool:
  426. mempool_destroy(hw->rnode_mempool);
  427. hw->rnode_mempool = NULL;
  428. err_free_mb_mempool:
  429. mempool_destroy(hw->mb_mempool);
  430. hw->mb_mempool = NULL;
  431. err:
  432. return rv;
  433. }
  434. static void
  435. csio_resource_free(struct csio_hw *hw)
  436. {
  437. pci_pool_destroy(hw->scsi_pci_pool);
  438. hw->scsi_pci_pool = NULL;
  439. mempool_destroy(hw->rnode_mempool);
  440. hw->rnode_mempool = NULL;
  441. mempool_destroy(hw->mb_mempool);
  442. hw->mb_mempool = NULL;
  443. }
  444. /*
  445. * csio_hw_alloc - Allocate and initialize the HW module.
  446. * @pdev: PCI device.
  447. *
  448. * Allocates HW structure, DMA, memory resources, maps BARS to
  449. * host memory and initializes HW module.
  450. */
  451. static struct csio_hw *csio_hw_alloc(struct pci_dev *pdev)
  452. {
  453. struct csio_hw *hw;
  454. hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL);
  455. if (!hw)
  456. goto err;
  457. hw->pdev = pdev;
  458. strncpy(hw->drv_version, CSIO_DRV_VERSION, 32);
  459. /* memory pool/DMA pool allocation */
  460. if (csio_resource_alloc(hw))
  461. goto err_free_hw;
  462. /* Get the start address of registers from BAR 0 */
  463. hw->regstart = ioremap_nocache(pci_resource_start(pdev, 0),
  464. pci_resource_len(pdev, 0));
  465. if (!hw->regstart) {
  466. csio_err(hw, "Could not map BAR 0, regstart = %p\n",
  467. hw->regstart);
  468. goto err_resource_free;
  469. }
  470. csio_hw_init_workers(hw);
  471. if (csio_hw_init(hw))
  472. goto err_unmap_bar;
  473. csio_dfs_create(hw);
  474. csio_dbg(hw, "hw:%p\n", hw);
  475. return hw;
  476. err_unmap_bar:
  477. csio_hw_exit_workers(hw);
  478. iounmap(hw->regstart);
  479. err_resource_free:
  480. csio_resource_free(hw);
  481. err_free_hw:
  482. kfree(hw);
  483. err:
  484. return NULL;
  485. }
  486. /*
  487. * csio_hw_free - Uninitialize and free the HW module.
  488. * @hw: The HW module
  489. *
  490. * Disable interrupts, uninit the HW module, free resources, free hw.
  491. */
  492. static void
  493. csio_hw_free(struct csio_hw *hw)
  494. {
  495. csio_intr_disable(hw, true);
  496. csio_hw_exit_workers(hw);
  497. csio_hw_exit(hw);
  498. iounmap(hw->regstart);
  499. csio_dfs_destroy(hw);
  500. csio_resource_free(hw);
  501. kfree(hw);
  502. }
  503. /**
  504. * csio_shost_init - Create and initialize the lnode module.
  505. * @hw: The HW module.
  506. * @dev: The device associated with this invocation.
  507. * @probe: Called from probe context or not?
  508. * @os_pln: Parent lnode if any.
  509. *
  510. * Allocates lnode structure via scsi_host_alloc, initializes
  511. * shost, initializes lnode module and registers with SCSI ML
  512. * via scsi_host_add. This function is shared between physical and
  513. * virtual node ports.
  514. */
  515. struct csio_lnode *
  516. csio_shost_init(struct csio_hw *hw, struct device *dev,
  517. bool probe, struct csio_lnode *pln)
  518. {
  519. struct Scsi_Host *shost = NULL;
  520. struct csio_lnode *ln;
  521. csio_fcoe_shost_template.cmd_per_lun = csio_lun_qdepth;
  522. csio_fcoe_shost_vport_template.cmd_per_lun = csio_lun_qdepth;
  523. /*
  524. * hw->pdev is the physical port's PCI dev structure,
  525. * which will be different from the NPIV dev structure.
  526. */
  527. if (dev == &hw->pdev->dev)
  528. shost = scsi_host_alloc(
  529. &csio_fcoe_shost_template,
  530. sizeof(struct csio_lnode));
  531. else
  532. shost = scsi_host_alloc(
  533. &csio_fcoe_shost_vport_template,
  534. sizeof(struct csio_lnode));
  535. if (!shost)
  536. goto err;
  537. ln = shost_priv(shost);
  538. memset(ln, 0, sizeof(struct csio_lnode));
  539. /* Link common lnode to this lnode */
  540. ln->dev_num = (shost->host_no << 16);
  541. shost->can_queue = CSIO_MAX_QUEUE;
  542. shost->this_id = -1;
  543. shost->unique_id = shost->host_no;
  544. shost->max_cmd_len = 16; /* Max CDB length supported */
  545. shost->max_id = min_t(uint32_t, csio_fcoe_rnodes,
  546. hw->fres_info.max_ssns);
  547. shost->max_lun = CSIO_MAX_LUN;
  548. if (dev == &hw->pdev->dev)
  549. shost->transportt = csio_fcoe_transport;
  550. else
  551. shost->transportt = csio_fcoe_transport_vport;
  552. /* root lnode */
  553. if (!hw->rln)
  554. hw->rln = ln;
  555. /* Other initialization here: Common, Transport specific */
  556. if (csio_lnode_init(ln, hw, pln))
  557. goto err_shost_put;
  558. if (scsi_add_host(shost, dev))
  559. goto err_lnode_exit;
  560. return ln;
  561. err_lnode_exit:
  562. csio_lnode_exit(ln);
  563. err_shost_put:
  564. scsi_host_put(shost);
  565. err:
  566. return NULL;
  567. }
  568. /**
  569. * csio_shost_exit - De-instantiate the shost.
  570. * @ln: The lnode module corresponding to the shost.
  571. *
  572. */
  573. void
  574. csio_shost_exit(struct csio_lnode *ln)
  575. {
  576. struct Scsi_Host *shost = csio_ln_to_shost(ln);
  577. struct csio_hw *hw = csio_lnode_to_hw(ln);
  578. /* Inform transport */
  579. fc_remove_host(shost);
  580. /* Inform SCSI ML */
  581. scsi_remove_host(shost);
  582. /* Flush all the events, so that any rnode removal events
  583. * already queued are all handled, before we remove the lnode.
  584. */
  585. spin_lock_irq(&hw->lock);
  586. csio_evtq_flush(hw);
  587. spin_unlock_irq(&hw->lock);
  588. csio_lnode_exit(ln);
  589. scsi_host_put(shost);
  590. }
  591. struct csio_lnode *
  592. csio_lnode_alloc(struct csio_hw *hw)
  593. {
  594. return csio_shost_init(hw, &hw->pdev->dev, false, NULL);
  595. }
  596. void
  597. csio_lnodes_block_request(struct csio_hw *hw)
  598. {
  599. struct Scsi_Host *shost;
  600. struct csio_lnode *sln;
  601. struct csio_lnode *ln;
  602. struct list_head *cur_ln, *cur_cln;
  603. struct csio_lnode **lnode_list;
  604. int cur_cnt = 0, ii;
  605. lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
  606. GFP_KERNEL);
  607. if (!lnode_list) {
  608. csio_err(hw, "Failed to allocate lnodes_list");
  609. return;
  610. }
  611. spin_lock_irq(&hw->lock);
  612. /* Traverse sibling lnodes */
  613. list_for_each(cur_ln, &hw->sln_head) {
  614. sln = (struct csio_lnode *) cur_ln;
  615. lnode_list[cur_cnt++] = sln;
  616. /* Traverse children lnodes */
  617. list_for_each(cur_cln, &sln->cln_head)
  618. lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln;
  619. }
  620. spin_unlock_irq(&hw->lock);
  621. for (ii = 0; ii < cur_cnt; ii++) {
  622. csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]);
  623. ln = lnode_list[ii];
  624. shost = csio_ln_to_shost(ln);
  625. scsi_block_requests(shost);
  626. }
  627. kfree(lnode_list);
  628. }
  629. void
  630. csio_lnodes_unblock_request(struct csio_hw *hw)
  631. {
  632. struct csio_lnode *ln;
  633. struct Scsi_Host *shost;
  634. struct csio_lnode *sln;
  635. struct list_head *cur_ln, *cur_cln;
  636. struct csio_lnode **lnode_list;
  637. int cur_cnt = 0, ii;
  638. lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
  639. GFP_KERNEL);
  640. if (!lnode_list) {
  641. csio_err(hw, "Failed to allocate lnodes_list");
  642. return;
  643. }
  644. spin_lock_irq(&hw->lock);
  645. /* Traverse sibling lnodes */
  646. list_for_each(cur_ln, &hw->sln_head) {
  647. sln = (struct csio_lnode *) cur_ln;
  648. lnode_list[cur_cnt++] = sln;
  649. /* Traverse children lnodes */
  650. list_for_each(cur_cln, &sln->cln_head)
  651. lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln;
  652. }
  653. spin_unlock_irq(&hw->lock);
  654. for (ii = 0; ii < cur_cnt; ii++) {
  655. csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]);
  656. ln = lnode_list[ii];
  657. shost = csio_ln_to_shost(ln);
  658. scsi_unblock_requests(shost);
  659. }
  660. kfree(lnode_list);
  661. }
  662. void
  663. csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid)
  664. {
  665. struct csio_lnode *ln;
  666. struct Scsi_Host *shost;
  667. struct csio_lnode *sln;
  668. struct list_head *cur_ln, *cur_cln;
  669. struct csio_lnode **lnode_list;
  670. int cur_cnt = 0, ii;
  671. lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
  672. GFP_KERNEL);
  673. if (!lnode_list) {
  674. csio_err(hw, "Failed to allocate lnodes_list");
  675. return;
  676. }
  677. spin_lock_irq(&hw->lock);
  678. /* Traverse sibling lnodes */
  679. list_for_each(cur_ln, &hw->sln_head) {
  680. sln = (struct csio_lnode *) cur_ln;
  681. if (sln->portid != portid)
  682. continue;
  683. lnode_list[cur_cnt++] = sln;
  684. /* Traverse children lnodes */
  685. list_for_each(cur_cln, &sln->cln_head)
  686. lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln;
  687. }
  688. spin_unlock_irq(&hw->lock);
  689. for (ii = 0; ii < cur_cnt; ii++) {
  690. csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]);
  691. ln = lnode_list[ii];
  692. shost = csio_ln_to_shost(ln);
  693. scsi_block_requests(shost);
  694. }
  695. kfree(lnode_list);
  696. }
  697. void
  698. csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid)
  699. {
  700. struct csio_lnode *ln;
  701. struct Scsi_Host *shost;
  702. struct csio_lnode *sln;
  703. struct list_head *cur_ln, *cur_cln;
  704. struct csio_lnode **lnode_list;
  705. int cur_cnt = 0, ii;
  706. lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
  707. GFP_KERNEL);
  708. if (!lnode_list) {
  709. csio_err(hw, "Failed to allocate lnodes_list");
  710. return;
  711. }
  712. spin_lock_irq(&hw->lock);
  713. /* Traverse sibling lnodes */
  714. list_for_each(cur_ln, &hw->sln_head) {
  715. sln = (struct csio_lnode *) cur_ln;
  716. if (sln->portid != portid)
  717. continue;
  718. lnode_list[cur_cnt++] = sln;
  719. /* Traverse children lnodes */
  720. list_for_each(cur_cln, &sln->cln_head)
  721. lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln;
  722. }
  723. spin_unlock_irq(&hw->lock);
  724. for (ii = 0; ii < cur_cnt; ii++) {
  725. csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]);
  726. ln = lnode_list[ii];
  727. shost = csio_ln_to_shost(ln);
  728. scsi_unblock_requests(shost);
  729. }
  730. kfree(lnode_list);
  731. }
  732. void
  733. csio_lnodes_exit(struct csio_hw *hw, bool npiv)
  734. {
  735. struct csio_lnode *sln;
  736. struct csio_lnode *ln;
  737. struct list_head *cur_ln, *cur_cln;
  738. struct csio_lnode **lnode_list;
  739. int cur_cnt = 0, ii;
  740. lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
  741. GFP_KERNEL);
  742. if (!lnode_list) {
  743. csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n");
  744. return;
  745. }
  746. /* Get all child lnodes(NPIV ports) */
  747. spin_lock_irq(&hw->lock);
  748. list_for_each(cur_ln, &hw->sln_head) {
  749. sln = (struct csio_lnode *) cur_ln;
  750. /* Traverse children lnodes */
  751. list_for_each(cur_cln, &sln->cln_head)
  752. lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln;
  753. }
  754. spin_unlock_irq(&hw->lock);
  755. /* Delete NPIV lnodes */
  756. for (ii = 0; ii < cur_cnt; ii++) {
  757. csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]);
  758. ln = lnode_list[ii];
  759. fc_vport_terminate(ln->fc_vport);
  760. }
  761. /* Delete only npiv lnodes */
  762. if (npiv)
  763. goto free_lnodes;
  764. cur_cnt = 0;
  765. /* Get all physical lnodes */
  766. spin_lock_irq(&hw->lock);
  767. /* Traverse sibling lnodes */
  768. list_for_each(cur_ln, &hw->sln_head) {
  769. sln = (struct csio_lnode *) cur_ln;
  770. lnode_list[cur_cnt++] = sln;
  771. }
  772. spin_unlock_irq(&hw->lock);
  773. /* Delete physical lnodes */
  774. for (ii = 0; ii < cur_cnt; ii++) {
  775. csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]);
  776. csio_shost_exit(lnode_list[ii]);
  777. }
  778. free_lnodes:
  779. kfree(lnode_list);
  780. }
  781. /*
  782. * csio_lnode_init_post: Set lnode attributes after starting HW.
  783. * @ln: lnode.
  784. *
  785. */
  786. static void
  787. csio_lnode_init_post(struct csio_lnode *ln)
  788. {
  789. struct Scsi_Host *shost = csio_ln_to_shost(ln);
  790. csio_fchost_attr_init(ln);
  791. scsi_scan_host(shost);
  792. }
  793. /*
  794. * csio_probe_one - Instantiate this function.
  795. * @pdev: PCI device
  796. * @id: Device ID
  797. *
  798. * This is the .probe() callback of the driver. This function:
  799. * - Initializes the PCI function by enabling MMIO, setting bus
  800. * mastership and setting DMA mask.
  801. * - Allocates HW structure, DMA, memory resources, maps BARS to
  802. * host memory and initializes HW module.
  803. * - Allocates lnode structure via scsi_host_alloc, initializes
  804. * shost, initialized lnode module and registers with SCSI ML
  805. * via scsi_host_add.
  806. * - Enables interrupts, and starts the chip by kicking off the
  807. * HW state machine.
  808. * - Once hardware is ready, initiated scan of the host via
  809. * scsi_scan_host.
  810. */
  811. static int csio_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
  812. {
  813. int rv;
  814. int bars;
  815. int i;
  816. struct csio_hw *hw;
  817. struct csio_lnode *ln;
  818. rv = csio_pci_init(pdev, &bars);
  819. if (rv)
  820. goto err;
  821. hw = csio_hw_alloc(pdev);
  822. if (!hw) {
  823. rv = -ENODEV;
  824. goto err_pci_exit;
  825. }
  826. pci_set_drvdata(pdev, hw);
  827. if (csio_hw_start(hw) != 0) {
  828. dev_err(&pdev->dev,
  829. "Failed to start FW, continuing in debug mode.\n");
  830. return 0;
  831. }
  832. sprintf(hw->fwrev_str, "%u.%u.%u.%u\n",
  833. FW_HDR_FW_VER_MAJOR_GET(hw->fwrev),
  834. FW_HDR_FW_VER_MINOR_GET(hw->fwrev),
  835. FW_HDR_FW_VER_MICRO_GET(hw->fwrev),
  836. FW_HDR_FW_VER_BUILD_GET(hw->fwrev));
  837. for (i = 0; i < hw->num_pports; i++) {
  838. ln = csio_shost_init(hw, &pdev->dev, true, NULL);
  839. if (!ln) {
  840. rv = -ENODEV;
  841. break;
  842. }
  843. /* Initialize portid */
  844. ln->portid = hw->pport[i].portid;
  845. spin_lock_irq(&hw->lock);
  846. if (csio_lnode_start(ln) != 0)
  847. rv = -ENODEV;
  848. spin_unlock_irq(&hw->lock);
  849. if (rv)
  850. break;
  851. csio_lnode_init_post(ln);
  852. }
  853. if (rv)
  854. goto err_lnode_exit;
  855. return 0;
  856. err_lnode_exit:
  857. csio_lnodes_block_request(hw);
  858. spin_lock_irq(&hw->lock);
  859. csio_hw_stop(hw);
  860. spin_unlock_irq(&hw->lock);
  861. csio_lnodes_unblock_request(hw);
  862. pci_set_drvdata(hw->pdev, NULL);
  863. csio_lnodes_exit(hw, 0);
  864. csio_hw_free(hw);
  865. err_pci_exit:
  866. csio_pci_exit(pdev, &bars);
  867. err:
  868. dev_err(&pdev->dev, "probe of device failed: %d\n", rv);
  869. return rv;
  870. }
  871. /*
  872. * csio_remove_one - Remove one instance of the driver at this PCI function.
  873. * @pdev: PCI device
  874. *
  875. * Used during hotplug operation.
  876. */
  877. static void csio_remove_one(struct pci_dev *pdev)
  878. {
  879. struct csio_hw *hw = pci_get_drvdata(pdev);
  880. int bars = pci_select_bars(pdev, IORESOURCE_MEM);
  881. csio_lnodes_block_request(hw);
  882. spin_lock_irq(&hw->lock);
  883. /* Stops lnode, Rnode s/m
  884. * Quiesce IOs.
  885. * All sessions with remote ports are unregistered.
  886. */
  887. csio_hw_stop(hw);
  888. spin_unlock_irq(&hw->lock);
  889. csio_lnodes_unblock_request(hw);
  890. csio_lnodes_exit(hw, 0);
  891. csio_hw_free(hw);
  892. pci_set_drvdata(pdev, NULL);
  893. csio_pci_exit(pdev, &bars);
  894. }
  895. /*
  896. * csio_pci_error_detected - PCI error was detected
  897. * @pdev: PCI device
  898. *
  899. */
  900. static pci_ers_result_t
  901. csio_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
  902. {
  903. struct csio_hw *hw = pci_get_drvdata(pdev);
  904. csio_lnodes_block_request(hw);
  905. spin_lock_irq(&hw->lock);
  906. /* Post PCI error detected evt to HW s/m
  907. * HW s/m handles this evt by quiescing IOs, unregisters rports
  908. * and finally takes the device to offline.
  909. */
  910. csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED);
  911. spin_unlock_irq(&hw->lock);
  912. csio_lnodes_unblock_request(hw);
  913. csio_lnodes_exit(hw, 0);
  914. csio_intr_disable(hw, true);
  915. pci_disable_device(pdev);
  916. return state == pci_channel_io_perm_failure ?
  917. PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
  918. }
  919. /*
  920. * csio_pci_slot_reset - PCI slot has been reset.
  921. * @pdev: PCI device
  922. *
  923. */
  924. static pci_ers_result_t
  925. csio_pci_slot_reset(struct pci_dev *pdev)
  926. {
  927. struct csio_hw *hw = pci_get_drvdata(pdev);
  928. int ready;
  929. if (pci_enable_device(pdev)) {
  930. dev_err(&pdev->dev, "cannot re-enable device in slot reset\n");
  931. return PCI_ERS_RESULT_DISCONNECT;
  932. }
  933. pci_set_master(pdev);
  934. pci_restore_state(pdev);
  935. pci_save_state(pdev);
  936. pci_cleanup_aer_uncorrect_error_status(pdev);
  937. /* Bring HW s/m to ready state.
  938. * but don't resume IOs.
  939. */
  940. spin_lock_irq(&hw->lock);
  941. csio_post_event(&hw->sm, CSIO_HWE_PCIERR_SLOT_RESET);
  942. ready = csio_is_hw_ready(hw);
  943. spin_unlock_irq(&hw->lock);
  944. if (ready) {
  945. return PCI_ERS_RESULT_RECOVERED;
  946. } else {
  947. dev_err(&pdev->dev, "Can't initialize HW when in slot reset\n");
  948. return PCI_ERS_RESULT_DISCONNECT;
  949. }
  950. }
  951. /*
  952. * csio_pci_resume - Resume normal operations
  953. * @pdev: PCI device
  954. *
  955. */
  956. static void
  957. csio_pci_resume(struct pci_dev *pdev)
  958. {
  959. struct csio_hw *hw = pci_get_drvdata(pdev);
  960. struct csio_lnode *ln;
  961. int rv = 0;
  962. int i;
  963. /* Bring the LINK UP and Resume IO */
  964. for (i = 0; i < hw->num_pports; i++) {
  965. ln = csio_shost_init(hw, &pdev->dev, true, NULL);
  966. if (!ln) {
  967. rv = -ENODEV;
  968. break;
  969. }
  970. /* Initialize portid */
  971. ln->portid = hw->pport[i].portid;
  972. spin_lock_irq(&hw->lock);
  973. if (csio_lnode_start(ln) != 0)
  974. rv = -ENODEV;
  975. spin_unlock_irq(&hw->lock);
  976. if (rv)
  977. break;
  978. csio_lnode_init_post(ln);
  979. }
  980. if (rv)
  981. goto err_resume_exit;
  982. return;
  983. err_resume_exit:
  984. csio_lnodes_block_request(hw);
  985. spin_lock_irq(&hw->lock);
  986. csio_hw_stop(hw);
  987. spin_unlock_irq(&hw->lock);
  988. csio_lnodes_unblock_request(hw);
  989. csio_lnodes_exit(hw, 0);
  990. csio_hw_free(hw);
  991. dev_err(&pdev->dev, "resume of device failed: %d\n", rv);
  992. }
  993. static struct pci_error_handlers csio_err_handler = {
  994. .error_detected = csio_pci_error_detected,
  995. .slot_reset = csio_pci_slot_reset,
  996. .resume = csio_pci_resume,
  997. };
  998. static DEFINE_PCI_DEVICE_TABLE(csio_pci_tbl) = {
  999. CSIO_DEVICE(CSIO_DEVID_T440DBG_FCOE, 0), /* T440DBG FCOE */
  1000. CSIO_DEVICE(CSIO_DEVID_T420CR_FCOE, 0), /* T420CR FCOE */
  1001. CSIO_DEVICE(CSIO_DEVID_T422CR_FCOE, 0), /* T422CR FCOE */
  1002. CSIO_DEVICE(CSIO_DEVID_T440CR_FCOE, 0), /* T440CR FCOE */
  1003. CSIO_DEVICE(CSIO_DEVID_T420BCH_FCOE, 0), /* T420BCH FCOE */
  1004. CSIO_DEVICE(CSIO_DEVID_T440BCH_FCOE, 0), /* T440BCH FCOE */
  1005. CSIO_DEVICE(CSIO_DEVID_T440CH_FCOE, 0), /* T440CH FCOE */
  1006. CSIO_DEVICE(CSIO_DEVID_T420SO_FCOE, 0), /* T420SO FCOE */
  1007. CSIO_DEVICE(CSIO_DEVID_T420CX_FCOE, 0), /* T420CX FCOE */
  1008. CSIO_DEVICE(CSIO_DEVID_T420BT_FCOE, 0), /* T420BT FCOE */
  1009. CSIO_DEVICE(CSIO_DEVID_T404BT_FCOE, 0), /* T404BT FCOE */
  1010. CSIO_DEVICE(CSIO_DEVID_B420_FCOE, 0), /* B420 FCOE */
  1011. CSIO_DEVICE(CSIO_DEVID_B404_FCOE, 0), /* B404 FCOE */
  1012. CSIO_DEVICE(CSIO_DEVID_T480CR_FCOE, 0), /* T480 CR FCOE */
  1013. CSIO_DEVICE(CSIO_DEVID_T440LPCR_FCOE, 0), /* T440 LP-CR FCOE */
  1014. CSIO_DEVICE(CSIO_DEVID_PE10K, 0), /* PE10K FCOE */
  1015. CSIO_DEVICE(CSIO_DEVID_PE10K_PF1, 0), /* PE10K FCOE on PF1 */
  1016. { 0, 0, 0, 0, 0, 0, 0 }
  1017. };
  1018. static struct pci_driver csio_pci_driver = {
  1019. .name = KBUILD_MODNAME,
  1020. .driver = {
  1021. .owner = THIS_MODULE,
  1022. },
  1023. .id_table = csio_pci_tbl,
  1024. .probe = csio_probe_one,
  1025. .remove = csio_remove_one,
  1026. .err_handler = &csio_err_handler,
  1027. };
  1028. /*
  1029. * csio_init - Chelsio storage driver initialization function.
  1030. *
  1031. */
  1032. static int __init
  1033. csio_init(void)
  1034. {
  1035. int rv = -ENOMEM;
  1036. pr_info("%s %s\n", CSIO_DRV_DESC, CSIO_DRV_VERSION);
  1037. csio_dfs_init();
  1038. csio_fcoe_transport = fc_attach_transport(&csio_fc_transport_funcs);
  1039. if (!csio_fcoe_transport)
  1040. goto err;
  1041. csio_fcoe_transport_vport =
  1042. fc_attach_transport(&csio_fc_transport_vport_funcs);
  1043. if (!csio_fcoe_transport_vport)
  1044. goto err_vport;
  1045. rv = pci_register_driver(&csio_pci_driver);
  1046. if (rv)
  1047. goto err_pci;
  1048. return 0;
  1049. err_pci:
  1050. fc_release_transport(csio_fcoe_transport_vport);
  1051. err_vport:
  1052. fc_release_transport(csio_fcoe_transport);
  1053. err:
  1054. csio_dfs_exit();
  1055. return rv;
  1056. }
  1057. /*
  1058. * csio_exit - Chelsio storage driver uninitialization .
  1059. *
  1060. * Function that gets called in the unload path.
  1061. */
  1062. static void __exit
  1063. csio_exit(void)
  1064. {
  1065. pci_unregister_driver(&csio_pci_driver);
  1066. csio_dfs_exit();
  1067. fc_release_transport(csio_fcoe_transport_vport);
  1068. fc_release_transport(csio_fcoe_transport);
  1069. }
  1070. module_init(csio_init);
  1071. module_exit(csio_exit);
  1072. MODULE_AUTHOR(CSIO_DRV_AUTHOR);
  1073. MODULE_DESCRIPTION(CSIO_DRV_DESC);
  1074. MODULE_LICENSE(CSIO_DRV_LICENSE);
  1075. MODULE_DEVICE_TABLE(pci, csio_pci_tbl);
  1076. MODULE_VERSION(CSIO_DRV_VERSION);
  1077. MODULE_FIRMWARE(CSIO_FW_FNAME);