fnic_main.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. /*
  2. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  3. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  4. *
  5. * This program is free software; you may redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  12. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  13. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  14. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. * SOFTWARE.
  17. */
  18. #include <linux/module.h>
  19. #include <linux/mempool.h>
  20. #include <linux/string.h>
  21. #include <linux/slab.h>
  22. #include <linux/errno.h>
  23. #include <linux/init.h>
  24. #include <linux/pci.h>
  25. #include <linux/skbuff.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/spinlock.h>
  28. #include <linux/workqueue.h>
  29. #include <linux/if_ether.h>
  30. #include <scsi/fc/fc_fip.h>
  31. #include <scsi/scsi_host.h>
  32. #include <scsi/scsi_transport.h>
  33. #include <scsi/scsi_transport_fc.h>
  34. #include <scsi/scsi_tcq.h>
  35. #include <scsi/libfc.h>
  36. #include <scsi/fc_frame.h>
  37. #include "vnic_dev.h"
  38. #include "vnic_intr.h"
  39. #include "vnic_stats.h"
  40. #include "fnic_io.h"
  41. #include "fnic_fip.h"
  42. #include "fnic.h"
  43. #define PCI_DEVICE_ID_CISCO_FNIC 0x0045
  44. /* Timer to poll notification area for events. Used for MSI interrupts */
  45. #define FNIC_NOTIFY_TIMER_PERIOD (2 * HZ)
  46. static struct kmem_cache *fnic_sgl_cache[FNIC_SGL_NUM_CACHES];
  47. static struct kmem_cache *fnic_io_req_cache;
  48. LIST_HEAD(fnic_list);
  49. DEFINE_SPINLOCK(fnic_list_lock);
  50. /* Supported devices by fnic module */
  51. static struct pci_device_id fnic_id_table[] = {
  52. { PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_FNIC) },
  53. { 0, }
  54. };
  55. MODULE_DESCRIPTION(DRV_DESCRIPTION);
  56. MODULE_AUTHOR("Abhijeet Joglekar <abjoglek@cisco.com>, "
  57. "Joseph R. Eykholt <jeykholt@cisco.com>");
  58. MODULE_LICENSE("GPL v2");
  59. MODULE_VERSION(DRV_VERSION);
  60. MODULE_DEVICE_TABLE(pci, fnic_id_table);
  61. unsigned int fnic_log_level;
  62. module_param(fnic_log_level, int, S_IRUGO|S_IWUSR);
  63. MODULE_PARM_DESC(fnic_log_level, "bit mask of fnic logging levels");
  64. unsigned int fnic_trace_max_pages = 16;
  65. module_param(fnic_trace_max_pages, uint, S_IRUGO|S_IWUSR);
  66. MODULE_PARM_DESC(fnic_trace_max_pages, "Total allocated memory pages "
  67. "for fnic trace buffer");
  68. static struct libfc_function_template fnic_transport_template = {
  69. .frame_send = fnic_send,
  70. .lport_set_port_id = fnic_set_port_id,
  71. .fcp_abort_io = fnic_empty_scsi_cleanup,
  72. .fcp_cleanup = fnic_empty_scsi_cleanup,
  73. .exch_mgr_reset = fnic_exch_mgr_reset
  74. };
  75. static int fnic_slave_alloc(struct scsi_device *sdev)
  76. {
  77. struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
  78. sdev->tagged_supported = 1;
  79. if (!rport || fc_remote_port_chkready(rport))
  80. return -ENXIO;
  81. scsi_activate_tcq(sdev, FNIC_DFLT_QUEUE_DEPTH);
  82. return 0;
  83. }
  84. static struct scsi_host_template fnic_host_template = {
  85. .module = THIS_MODULE,
  86. .name = DRV_NAME,
  87. .queuecommand = fnic_queuecommand,
  88. .eh_abort_handler = fnic_abort_cmd,
  89. .eh_device_reset_handler = fnic_device_reset,
  90. .eh_host_reset_handler = fnic_host_reset,
  91. .slave_alloc = fnic_slave_alloc,
  92. .change_queue_depth = fc_change_queue_depth,
  93. .change_queue_type = fc_change_queue_type,
  94. .this_id = -1,
  95. .cmd_per_lun = 3,
  96. .can_queue = FNIC_MAX_IO_REQ,
  97. .use_clustering = ENABLE_CLUSTERING,
  98. .sg_tablesize = FNIC_MAX_SG_DESC_CNT,
  99. .max_sectors = 0xffff,
  100. .shost_attrs = fnic_attrs,
  101. };
  102. static void
  103. fnic_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
  104. {
  105. if (timeout)
  106. rport->dev_loss_tmo = timeout;
  107. else
  108. rport->dev_loss_tmo = 1;
  109. }
  110. static void fnic_get_host_speed(struct Scsi_Host *shost);
  111. static struct scsi_transport_template *fnic_fc_transport;
  112. static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *);
  113. static void fnic_reset_host_stats(struct Scsi_Host *);
  114. static struct fc_function_template fnic_fc_functions = {
  115. .show_host_node_name = 1,
  116. .show_host_port_name = 1,
  117. .show_host_supported_classes = 1,
  118. .show_host_supported_fc4s = 1,
  119. .show_host_active_fc4s = 1,
  120. .show_host_maxframe_size = 1,
  121. .show_host_port_id = 1,
  122. .show_host_supported_speeds = 1,
  123. .get_host_speed = fnic_get_host_speed,
  124. .show_host_speed = 1,
  125. .show_host_port_type = 1,
  126. .get_host_port_state = fc_get_host_port_state,
  127. .show_host_port_state = 1,
  128. .show_host_symbolic_name = 1,
  129. .show_rport_maxframe_size = 1,
  130. .show_rport_supported_classes = 1,
  131. .show_host_fabric_name = 1,
  132. .show_starget_node_name = 1,
  133. .show_starget_port_name = 1,
  134. .show_starget_port_id = 1,
  135. .show_rport_dev_loss_tmo = 1,
  136. .set_rport_dev_loss_tmo = fnic_set_rport_dev_loss_tmo,
  137. .issue_fc_host_lip = fnic_reset,
  138. .get_fc_host_stats = fnic_get_stats,
  139. .reset_fc_host_stats = fnic_reset_host_stats,
  140. .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
  141. .terminate_rport_io = fnic_terminate_rport_io,
  142. .bsg_request = fc_lport_bsg_request,
  143. };
  144. static void fnic_get_host_speed(struct Scsi_Host *shost)
  145. {
  146. struct fc_lport *lp = shost_priv(shost);
  147. struct fnic *fnic = lport_priv(lp);
  148. u32 port_speed = vnic_dev_port_speed(fnic->vdev);
  149. /* Add in other values as they get defined in fw */
  150. switch (port_speed) {
  151. case 10000:
  152. fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
  153. break;
  154. default:
  155. fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
  156. break;
  157. }
  158. }
  159. static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host)
  160. {
  161. int ret;
  162. struct fc_lport *lp = shost_priv(host);
  163. struct fnic *fnic = lport_priv(lp);
  164. struct fc_host_statistics *stats = &lp->host_stats;
  165. struct vnic_stats *vs;
  166. unsigned long flags;
  167. if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT))
  168. return stats;
  169. fnic->stats_time = jiffies;
  170. spin_lock_irqsave(&fnic->fnic_lock, flags);
  171. ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats);
  172. spin_unlock_irqrestore(&fnic->fnic_lock, flags);
  173. if (ret) {
  174. FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host,
  175. "fnic: Get vnic stats failed"
  176. " 0x%x", ret);
  177. return stats;
  178. }
  179. vs = fnic->stats;
  180. stats->tx_frames = vs->tx.tx_unicast_frames_ok;
  181. stats->tx_words = vs->tx.tx_unicast_bytes_ok / 4;
  182. stats->rx_frames = vs->rx.rx_unicast_frames_ok;
  183. stats->rx_words = vs->rx.rx_unicast_bytes_ok / 4;
  184. stats->error_frames = vs->tx.tx_errors + vs->rx.rx_errors;
  185. stats->dumped_frames = vs->tx.tx_drops + vs->rx.rx_drop;
  186. stats->invalid_crc_count = vs->rx.rx_crc_errors;
  187. stats->seconds_since_last_reset =
  188. (jiffies - fnic->stats_reset_time) / HZ;
  189. stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000);
  190. stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000);
  191. return stats;
  192. }
  193. /*
  194. * fnic_dump_fchost_stats
  195. * note : dumps fc_statistics into system logs
  196. */
  197. void fnic_dump_fchost_stats(struct Scsi_Host *host,
  198. struct fc_host_statistics *stats)
  199. {
  200. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  201. "fnic: seconds since last reset = %llu\n",
  202. stats->seconds_since_last_reset);
  203. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  204. "fnic: tx frames = %llu\n",
  205. stats->tx_frames);
  206. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  207. "fnic: tx words = %llu\n",
  208. stats->tx_words);
  209. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  210. "fnic: rx frames = %llu\n",
  211. stats->rx_frames);
  212. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  213. "fnic: rx words = %llu\n",
  214. stats->rx_words);
  215. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  216. "fnic: lip count = %llu\n",
  217. stats->lip_count);
  218. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  219. "fnic: nos count = %llu\n",
  220. stats->nos_count);
  221. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  222. "fnic: error frames = %llu\n",
  223. stats->error_frames);
  224. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  225. "fnic: dumped frames = %llu\n",
  226. stats->dumped_frames);
  227. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  228. "fnic: link failure count = %llu\n",
  229. stats->link_failure_count);
  230. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  231. "fnic: loss of sync count = %llu\n",
  232. stats->loss_of_sync_count);
  233. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  234. "fnic: loss of signal count = %llu\n",
  235. stats->loss_of_signal_count);
  236. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  237. "fnic: prim seq protocol err count = %llu\n",
  238. stats->prim_seq_protocol_err_count);
  239. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  240. "fnic: invalid tx word count= %llu\n",
  241. stats->invalid_tx_word_count);
  242. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  243. "fnic: invalid crc count = %llu\n",
  244. stats->invalid_crc_count);
  245. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  246. "fnic: fcp input requests = %llu\n",
  247. stats->fcp_input_requests);
  248. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  249. "fnic: fcp output requests = %llu\n",
  250. stats->fcp_output_requests);
  251. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  252. "fnic: fcp control requests = %llu\n",
  253. stats->fcp_control_requests);
  254. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  255. "fnic: fcp input megabytes = %llu\n",
  256. stats->fcp_input_megabytes);
  257. FNIC_MAIN_NOTE(KERN_NOTICE, host,
  258. "fnic: fcp output megabytes = %llu\n",
  259. stats->fcp_output_megabytes);
  260. return;
  261. }
  262. /*
  263. * fnic_reset_host_stats : clears host stats
  264. * note : called when reset_statistics set under sysfs dir
  265. */
  266. static void fnic_reset_host_stats(struct Scsi_Host *host)
  267. {
  268. int ret;
  269. struct fc_lport *lp = shost_priv(host);
  270. struct fnic *fnic = lport_priv(lp);
  271. struct fc_host_statistics *stats;
  272. unsigned long flags;
  273. /* dump current stats, before clearing them */
  274. stats = fnic_get_stats(host);
  275. fnic_dump_fchost_stats(host, stats);
  276. spin_lock_irqsave(&fnic->fnic_lock, flags);
  277. ret = vnic_dev_stats_clear(fnic->vdev);
  278. spin_unlock_irqrestore(&fnic->fnic_lock, flags);
  279. if (ret) {
  280. FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host,
  281. "fnic: Reset vnic stats failed"
  282. " 0x%x", ret);
  283. return;
  284. }
  285. fnic->stats_reset_time = jiffies;
  286. memset(stats, 0, sizeof(*stats));
  287. return;
  288. }
  289. void fnic_log_q_error(struct fnic *fnic)
  290. {
  291. unsigned int i;
  292. u32 error_status;
  293. for (i = 0; i < fnic->raw_wq_count; i++) {
  294. error_status = ioread32(&fnic->wq[i].ctrl->error_status);
  295. if (error_status)
  296. shost_printk(KERN_ERR, fnic->lport->host,
  297. "WQ[%d] error_status"
  298. " %d\n", i, error_status);
  299. }
  300. for (i = 0; i < fnic->rq_count; i++) {
  301. error_status = ioread32(&fnic->rq[i].ctrl->error_status);
  302. if (error_status)
  303. shost_printk(KERN_ERR, fnic->lport->host,
  304. "RQ[%d] error_status"
  305. " %d\n", i, error_status);
  306. }
  307. for (i = 0; i < fnic->wq_copy_count; i++) {
  308. error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status);
  309. if (error_status)
  310. shost_printk(KERN_ERR, fnic->lport->host,
  311. "CWQ[%d] error_status"
  312. " %d\n", i, error_status);
  313. }
  314. }
  315. void fnic_handle_link_event(struct fnic *fnic)
  316. {
  317. unsigned long flags;
  318. spin_lock_irqsave(&fnic->fnic_lock, flags);
  319. if (fnic->stop_rx_link_events) {
  320. spin_unlock_irqrestore(&fnic->fnic_lock, flags);
  321. return;
  322. }
  323. spin_unlock_irqrestore(&fnic->fnic_lock, flags);
  324. queue_work(fnic_event_queue, &fnic->link_work);
  325. }
  326. static int fnic_notify_set(struct fnic *fnic)
  327. {
  328. int err;
  329. switch (vnic_dev_get_intr_mode(fnic->vdev)) {
  330. case VNIC_DEV_INTR_MODE_INTX:
  331. err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY);
  332. break;
  333. case VNIC_DEV_INTR_MODE_MSI:
  334. err = vnic_dev_notify_set(fnic->vdev, -1);
  335. break;
  336. case VNIC_DEV_INTR_MODE_MSIX:
  337. err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY);
  338. break;
  339. default:
  340. shost_printk(KERN_ERR, fnic->lport->host,
  341. "Interrupt mode should be set up"
  342. " before devcmd notify set %d\n",
  343. vnic_dev_get_intr_mode(fnic->vdev));
  344. err = -1;
  345. break;
  346. }
  347. return err;
  348. }
  349. static void fnic_notify_timer(unsigned long data)
  350. {
  351. struct fnic *fnic = (struct fnic *)data;
  352. fnic_handle_link_event(fnic);
  353. mod_timer(&fnic->notify_timer,
  354. round_jiffies(jiffies + FNIC_NOTIFY_TIMER_PERIOD));
  355. }
  356. static void fnic_fip_notify_timer(unsigned long data)
  357. {
  358. struct fnic *fnic = (struct fnic *)data;
  359. fnic_handle_fip_timer(fnic);
  360. }
  361. static void fnic_notify_timer_start(struct fnic *fnic)
  362. {
  363. switch (vnic_dev_get_intr_mode(fnic->vdev)) {
  364. case VNIC_DEV_INTR_MODE_MSI:
  365. /*
  366. * Schedule first timeout immediately. The driver is
  367. * initiatialized and ready to look for link up notification
  368. */
  369. mod_timer(&fnic->notify_timer, jiffies);
  370. break;
  371. default:
  372. /* Using intr for notification for INTx/MSI-X */
  373. break;
  374. };
  375. }
  376. static int fnic_dev_wait(struct vnic_dev *vdev,
  377. int (*start)(struct vnic_dev *, int),
  378. int (*finished)(struct vnic_dev *, int *),
  379. int arg)
  380. {
  381. unsigned long time;
  382. int done;
  383. int err;
  384. err = start(vdev, arg);
  385. if (err)
  386. return err;
  387. /* Wait for func to complete...2 seconds max */
  388. time = jiffies + (HZ * 2);
  389. do {
  390. err = finished(vdev, &done);
  391. if (err)
  392. return err;
  393. if (done)
  394. return 0;
  395. schedule_timeout_uninterruptible(HZ / 10);
  396. } while (time_after(time, jiffies));
  397. return -ETIMEDOUT;
  398. }
  399. static int fnic_cleanup(struct fnic *fnic)
  400. {
  401. unsigned int i;
  402. int err;
  403. vnic_dev_disable(fnic->vdev);
  404. for (i = 0; i < fnic->intr_count; i++)
  405. vnic_intr_mask(&fnic->intr[i]);
  406. for (i = 0; i < fnic->rq_count; i++) {
  407. err = vnic_rq_disable(&fnic->rq[i]);
  408. if (err)
  409. return err;
  410. }
  411. for (i = 0; i < fnic->raw_wq_count; i++) {
  412. err = vnic_wq_disable(&fnic->wq[i]);
  413. if (err)
  414. return err;
  415. }
  416. for (i = 0; i < fnic->wq_copy_count; i++) {
  417. err = vnic_wq_copy_disable(&fnic->wq_copy[i]);
  418. if (err)
  419. return err;
  420. }
  421. /* Clean up completed IOs and FCS frames */
  422. fnic_wq_copy_cmpl_handler(fnic, -1);
  423. fnic_wq_cmpl_handler(fnic, -1);
  424. fnic_rq_cmpl_handler(fnic, -1);
  425. /* Clean up the IOs and FCS frames that have not completed */
  426. for (i = 0; i < fnic->raw_wq_count; i++)
  427. vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf);
  428. for (i = 0; i < fnic->rq_count; i++)
  429. vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
  430. for (i = 0; i < fnic->wq_copy_count; i++)
  431. vnic_wq_copy_clean(&fnic->wq_copy[i],
  432. fnic_wq_copy_cleanup_handler);
  433. for (i = 0; i < fnic->cq_count; i++)
  434. vnic_cq_clean(&fnic->cq[i]);
  435. for (i = 0; i < fnic->intr_count; i++)
  436. vnic_intr_clean(&fnic->intr[i]);
  437. mempool_destroy(fnic->io_req_pool);
  438. for (i = 0; i < FNIC_SGL_NUM_CACHES; i++)
  439. mempool_destroy(fnic->io_sgl_pool[i]);
  440. return 0;
  441. }
  442. static void fnic_iounmap(struct fnic *fnic)
  443. {
  444. if (fnic->bar0.vaddr)
  445. iounmap(fnic->bar0.vaddr);
  446. }
  447. /**
  448. * fnic_get_mac() - get assigned data MAC address for FIP code.
  449. * @lport: local port.
  450. */
  451. static u8 *fnic_get_mac(struct fc_lport *lport)
  452. {
  453. struct fnic *fnic = lport_priv(lport);
  454. return fnic->data_src_addr;
  455. }
  456. static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id)
  457. {
  458. u16 old_vlan;
  459. old_vlan = vnic_dev_set_default_vlan(fnic->vdev, vlan_id);
  460. }
  461. static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  462. {
  463. struct Scsi_Host *host;
  464. struct fc_lport *lp;
  465. struct fnic *fnic;
  466. mempool_t *pool;
  467. int err;
  468. int i;
  469. unsigned long flags;
  470. /*
  471. * Allocate SCSI Host and set up association between host,
  472. * local port, and fnic
  473. */
  474. lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic));
  475. if (!lp) {
  476. printk(KERN_ERR PFX "Unable to alloc libfc local port\n");
  477. err = -ENOMEM;
  478. goto err_out;
  479. }
  480. host = lp->host;
  481. fnic = lport_priv(lp);
  482. fnic->lport = lp;
  483. fnic->ctlr.lp = lp;
  484. snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME,
  485. host->host_no);
  486. host->transportt = fnic_fc_transport;
  487. err = scsi_init_shared_tag_map(host, FNIC_MAX_IO_REQ);
  488. if (err) {
  489. shost_printk(KERN_ERR, fnic->lport->host,
  490. "Unable to alloc shared tag map\n");
  491. goto err_out_free_hba;
  492. }
  493. /* Setup PCI resources */
  494. pci_set_drvdata(pdev, fnic);
  495. fnic->pdev = pdev;
  496. err = pci_enable_device(pdev);
  497. if (err) {
  498. shost_printk(KERN_ERR, fnic->lport->host,
  499. "Cannot enable PCI device, aborting.\n");
  500. goto err_out_free_hba;
  501. }
  502. err = pci_request_regions(pdev, DRV_NAME);
  503. if (err) {
  504. shost_printk(KERN_ERR, fnic->lport->host,
  505. "Cannot enable PCI resources, aborting\n");
  506. goto err_out_disable_device;
  507. }
  508. pci_set_master(pdev);
  509. /* Query PCI controller on system for DMA addressing
  510. * limitation for the device. Try 40-bit first, and
  511. * fail to 32-bit.
  512. */
  513. err = pci_set_dma_mask(pdev, DMA_BIT_MASK(40));
  514. if (err) {
  515. err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
  516. if (err) {
  517. shost_printk(KERN_ERR, fnic->lport->host,
  518. "No usable DMA configuration "
  519. "aborting\n");
  520. goto err_out_release_regions;
  521. }
  522. err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  523. if (err) {
  524. shost_printk(KERN_ERR, fnic->lport->host,
  525. "Unable to obtain 32-bit DMA "
  526. "for consistent allocations, aborting.\n");
  527. goto err_out_release_regions;
  528. }
  529. } else {
  530. err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40));
  531. if (err) {
  532. shost_printk(KERN_ERR, fnic->lport->host,
  533. "Unable to obtain 40-bit DMA "
  534. "for consistent allocations, aborting.\n");
  535. goto err_out_release_regions;
  536. }
  537. }
  538. /* Map vNIC resources from BAR0 */
  539. if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
  540. shost_printk(KERN_ERR, fnic->lport->host,
  541. "BAR0 not memory-map'able, aborting.\n");
  542. err = -ENODEV;
  543. goto err_out_release_regions;
  544. }
  545. fnic->bar0.vaddr = pci_iomap(pdev, 0, 0);
  546. fnic->bar0.bus_addr = pci_resource_start(pdev, 0);
  547. fnic->bar0.len = pci_resource_len(pdev, 0);
  548. if (!fnic->bar0.vaddr) {
  549. shost_printk(KERN_ERR, fnic->lport->host,
  550. "Cannot memory-map BAR0 res hdr, "
  551. "aborting.\n");
  552. err = -ENODEV;
  553. goto err_out_release_regions;
  554. }
  555. fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0);
  556. if (!fnic->vdev) {
  557. shost_printk(KERN_ERR, fnic->lport->host,
  558. "vNIC registration failed, "
  559. "aborting.\n");
  560. err = -ENODEV;
  561. goto err_out_iounmap;
  562. }
  563. err = fnic_dev_wait(fnic->vdev, vnic_dev_open,
  564. vnic_dev_open_done, 0);
  565. if (err) {
  566. shost_printk(KERN_ERR, fnic->lport->host,
  567. "vNIC dev open failed, aborting.\n");
  568. goto err_out_vnic_unregister;
  569. }
  570. err = vnic_dev_init(fnic->vdev, 0);
  571. if (err) {
  572. shost_printk(KERN_ERR, fnic->lport->host,
  573. "vNIC dev init failed, aborting.\n");
  574. goto err_out_dev_close;
  575. }
  576. err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr);
  577. if (err) {
  578. shost_printk(KERN_ERR, fnic->lport->host,
  579. "vNIC get MAC addr failed \n");
  580. goto err_out_dev_close;
  581. }
  582. /* set data_src for point-to-point mode and to keep it non-zero */
  583. memcpy(fnic->data_src_addr, fnic->ctlr.ctl_src_addr, ETH_ALEN);
  584. /* Get vNIC configuration */
  585. err = fnic_get_vnic_config(fnic);
  586. if (err) {
  587. shost_printk(KERN_ERR, fnic->lport->host,
  588. "Get vNIC configuration failed, "
  589. "aborting.\n");
  590. goto err_out_dev_close;
  591. }
  592. host->max_lun = fnic->config.luns_per_tgt;
  593. host->max_id = FNIC_MAX_FCP_TARGET;
  594. host->max_cmd_len = FCOE_MAX_CMD_LEN;
  595. fnic_get_res_counts(fnic);
  596. err = fnic_set_intr_mode(fnic);
  597. if (err) {
  598. shost_printk(KERN_ERR, fnic->lport->host,
  599. "Failed to set intr mode, "
  600. "aborting.\n");
  601. goto err_out_dev_close;
  602. }
  603. err = fnic_alloc_vnic_resources(fnic);
  604. if (err) {
  605. shost_printk(KERN_ERR, fnic->lport->host,
  606. "Failed to alloc vNIC resources, "
  607. "aborting.\n");
  608. goto err_out_clear_intr;
  609. }
  610. /* initialize all fnic locks */
  611. spin_lock_init(&fnic->fnic_lock);
  612. for (i = 0; i < FNIC_WQ_MAX; i++)
  613. spin_lock_init(&fnic->wq_lock[i]);
  614. for (i = 0; i < FNIC_WQ_COPY_MAX; i++) {
  615. spin_lock_init(&fnic->wq_copy_lock[i]);
  616. fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK;
  617. fnic->fw_ack_recd[i] = 0;
  618. fnic->fw_ack_index[i] = -1;
  619. }
  620. for (i = 0; i < FNIC_IO_LOCKS; i++)
  621. spin_lock_init(&fnic->io_req_lock[i]);
  622. fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
  623. if (!fnic->io_req_pool)
  624. goto err_out_free_resources;
  625. pool = mempool_create_slab_pool(2, fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
  626. if (!pool)
  627. goto err_out_free_ioreq_pool;
  628. fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool;
  629. pool = mempool_create_slab_pool(2, fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
  630. if (!pool)
  631. goto err_out_free_dflt_pool;
  632. fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool;
  633. /* setup vlan config, hw inserts vlan header */
  634. fnic->vlan_hw_insert = 1;
  635. fnic->vlan_id = 0;
  636. /* Initialize the FIP fcoe_ctrl struct */
  637. fnic->ctlr.send = fnic_eth_send;
  638. fnic->ctlr.update_mac = fnic_update_mac;
  639. fnic->ctlr.get_src_addr = fnic_get_mac;
  640. if (fnic->config.flags & VFCF_FIP_CAPABLE) {
  641. shost_printk(KERN_INFO, fnic->lport->host,
  642. "firmware supports FIP\n");
  643. /* enable directed and multicast */
  644. vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0);
  645. vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS);
  646. vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr);
  647. fnic->set_vlan = fnic_set_vlan;
  648. fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO);
  649. setup_timer(&fnic->fip_timer, fnic_fip_notify_timer,
  650. (unsigned long)fnic);
  651. spin_lock_init(&fnic->vlans_lock);
  652. INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
  653. INIT_WORK(&fnic->event_work, fnic_handle_event);
  654. skb_queue_head_init(&fnic->fip_frame_queue);
  655. INIT_LIST_HEAD(&fnic->evlist);
  656. INIT_LIST_HEAD(&fnic->vlans);
  657. } else {
  658. shost_printk(KERN_INFO, fnic->lport->host,
  659. "firmware uses non-FIP mode\n");
  660. fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP);
  661. }
  662. fnic->state = FNIC_IN_FC_MODE;
  663. atomic_set(&fnic->in_flight, 0);
  664. fnic->state_flags = FNIC_FLAGS_NONE;
  665. /* Enable hardware stripping of vlan header on ingress */
  666. fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1);
  667. /* Setup notification buffer area */
  668. err = fnic_notify_set(fnic);
  669. if (err) {
  670. shost_printk(KERN_ERR, fnic->lport->host,
  671. "Failed to alloc notify buffer, aborting.\n");
  672. goto err_out_free_max_pool;
  673. }
  674. /* Setup notify timer when using MSI interrupts */
  675. if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
  676. setup_timer(&fnic->notify_timer,
  677. fnic_notify_timer, (unsigned long)fnic);
  678. /* allocate RQ buffers and post them to RQ*/
  679. for (i = 0; i < fnic->rq_count; i++) {
  680. err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame);
  681. if (err) {
  682. shost_printk(KERN_ERR, fnic->lport->host,
  683. "fnic_alloc_rq_frame can't alloc "
  684. "frame\n");
  685. goto err_out_free_rq_buf;
  686. }
  687. }
  688. /*
  689. * Initialization done with PCI system, hardware, firmware.
  690. * Add host to SCSI
  691. */
  692. err = scsi_add_host(lp->host, &pdev->dev);
  693. if (err) {
  694. shost_printk(KERN_ERR, fnic->lport->host,
  695. "fnic: scsi_add_host failed...exiting\n");
  696. goto err_out_free_rq_buf;
  697. }
  698. /* Start local port initiatialization */
  699. lp->link_up = 0;
  700. lp->max_retry_count = fnic->config.flogi_retries;
  701. lp->max_rport_retry_count = fnic->config.plogi_retries;
  702. lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS |
  703. FCP_SPPF_CONF_COMPL);
  704. if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR)
  705. lp->service_params |= FCP_SPPF_RETRY;
  706. lp->boot_time = jiffies;
  707. lp->e_d_tov = fnic->config.ed_tov;
  708. lp->r_a_tov = fnic->config.ra_tov;
  709. lp->link_supported_speeds = FC_PORTSPEED_10GBIT;
  710. fc_set_wwnn(lp, fnic->config.node_wwn);
  711. fc_set_wwpn(lp, fnic->config.port_wwn);
  712. fcoe_libfc_config(lp, &fnic->ctlr, &fnic_transport_template, 0);
  713. if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, FCPIO_HOST_EXCH_RANGE_START,
  714. FCPIO_HOST_EXCH_RANGE_END, NULL)) {
  715. err = -ENOMEM;
  716. goto err_out_remove_scsi_host;
  717. }
  718. fc_lport_init_stats(lp);
  719. fnic->stats_reset_time = jiffies;
  720. fc_lport_config(lp);
  721. if (fc_set_mfs(lp, fnic->config.maxdatafieldsize +
  722. sizeof(struct fc_frame_header))) {
  723. err = -EINVAL;
  724. goto err_out_free_exch_mgr;
  725. }
  726. fc_host_maxframe_size(lp->host) = lp->mfs;
  727. fc_host_dev_loss_tmo(lp->host) = fnic->config.port_down_timeout / 1000;
  728. sprintf(fc_host_symbolic_name(lp->host),
  729. DRV_NAME " v" DRV_VERSION " over %s", fnic->name);
  730. spin_lock_irqsave(&fnic_list_lock, flags);
  731. list_add_tail(&fnic->list, &fnic_list);
  732. spin_unlock_irqrestore(&fnic_list_lock, flags);
  733. INIT_WORK(&fnic->link_work, fnic_handle_link);
  734. INIT_WORK(&fnic->frame_work, fnic_handle_frame);
  735. skb_queue_head_init(&fnic->frame_queue);
  736. skb_queue_head_init(&fnic->tx_queue);
  737. /* Enable all queues */
  738. for (i = 0; i < fnic->raw_wq_count; i++)
  739. vnic_wq_enable(&fnic->wq[i]);
  740. for (i = 0; i < fnic->rq_count; i++)
  741. vnic_rq_enable(&fnic->rq[i]);
  742. for (i = 0; i < fnic->wq_copy_count; i++)
  743. vnic_wq_copy_enable(&fnic->wq_copy[i]);
  744. fc_fabric_login(lp);
  745. vnic_dev_enable(fnic->vdev);
  746. err = fnic_request_intr(fnic);
  747. if (err) {
  748. shost_printk(KERN_ERR, fnic->lport->host,
  749. "Unable to request irq.\n");
  750. goto err_out_free_exch_mgr;
  751. }
  752. for (i = 0; i < fnic->intr_count; i++)
  753. vnic_intr_unmask(&fnic->intr[i]);
  754. fnic_notify_timer_start(fnic);
  755. return 0;
  756. err_out_free_exch_mgr:
  757. fc_exch_mgr_free(lp);
  758. err_out_remove_scsi_host:
  759. fc_remove_host(lp->host);
  760. scsi_remove_host(lp->host);
  761. err_out_free_rq_buf:
  762. for (i = 0; i < fnic->rq_count; i++)
  763. vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
  764. vnic_dev_notify_unset(fnic->vdev);
  765. err_out_free_max_pool:
  766. mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]);
  767. err_out_free_dflt_pool:
  768. mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]);
  769. err_out_free_ioreq_pool:
  770. mempool_destroy(fnic->io_req_pool);
  771. err_out_free_resources:
  772. fnic_free_vnic_resources(fnic);
  773. err_out_clear_intr:
  774. fnic_clear_intr_mode(fnic);
  775. err_out_dev_close:
  776. vnic_dev_close(fnic->vdev);
  777. err_out_vnic_unregister:
  778. vnic_dev_unregister(fnic->vdev);
  779. err_out_iounmap:
  780. fnic_iounmap(fnic);
  781. err_out_release_regions:
  782. pci_release_regions(pdev);
  783. err_out_disable_device:
  784. pci_disable_device(pdev);
  785. err_out_free_hba:
  786. scsi_host_put(lp->host);
  787. err_out:
  788. return err;
  789. }
  790. static void fnic_remove(struct pci_dev *pdev)
  791. {
  792. struct fnic *fnic = pci_get_drvdata(pdev);
  793. struct fc_lport *lp = fnic->lport;
  794. unsigned long flags;
  795. /*
  796. * Mark state so that the workqueue thread stops forwarding
  797. * received frames and link events to the local port. ISR and
  798. * other threads that can queue work items will also stop
  799. * creating work items on the fnic workqueue
  800. */
  801. spin_lock_irqsave(&fnic->fnic_lock, flags);
  802. fnic->stop_rx_link_events = 1;
  803. spin_unlock_irqrestore(&fnic->fnic_lock, flags);
  804. if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
  805. del_timer_sync(&fnic->notify_timer);
  806. /*
  807. * Flush the fnic event queue. After this call, there should
  808. * be no event queued for this fnic device in the workqueue
  809. */
  810. flush_workqueue(fnic_event_queue);
  811. skb_queue_purge(&fnic->frame_queue);
  812. skb_queue_purge(&fnic->tx_queue);
  813. if (fnic->config.flags & VFCF_FIP_CAPABLE) {
  814. del_timer_sync(&fnic->fip_timer);
  815. skb_queue_purge(&fnic->fip_frame_queue);
  816. fnic_fcoe_reset_vlans(fnic);
  817. fnic_fcoe_evlist_free(fnic);
  818. }
  819. /*
  820. * Log off the fabric. This stops all remote ports, dns port,
  821. * logs off the fabric. This flushes all rport, disc, lport work
  822. * before returning
  823. */
  824. fc_fabric_logoff(fnic->lport);
  825. spin_lock_irqsave(&fnic->fnic_lock, flags);
  826. fnic->in_remove = 1;
  827. spin_unlock_irqrestore(&fnic->fnic_lock, flags);
  828. fcoe_ctlr_destroy(&fnic->ctlr);
  829. fc_lport_destroy(lp);
  830. /*
  831. * This stops the fnic device, masks all interrupts. Completed
  832. * CQ entries are drained. Posted WQ/RQ/Copy-WQ entries are
  833. * cleaned up
  834. */
  835. fnic_cleanup(fnic);
  836. BUG_ON(!skb_queue_empty(&fnic->frame_queue));
  837. BUG_ON(!skb_queue_empty(&fnic->tx_queue));
  838. spin_lock_irqsave(&fnic_list_lock, flags);
  839. list_del(&fnic->list);
  840. spin_unlock_irqrestore(&fnic_list_lock, flags);
  841. fc_remove_host(fnic->lport->host);
  842. scsi_remove_host(fnic->lport->host);
  843. fc_exch_mgr_free(fnic->lport);
  844. vnic_dev_notify_unset(fnic->vdev);
  845. fnic_free_intr(fnic);
  846. fnic_free_vnic_resources(fnic);
  847. fnic_clear_intr_mode(fnic);
  848. vnic_dev_close(fnic->vdev);
  849. vnic_dev_unregister(fnic->vdev);
  850. fnic_iounmap(fnic);
  851. pci_release_regions(pdev);
  852. pci_disable_device(pdev);
  853. pci_set_drvdata(pdev, NULL);
  854. scsi_host_put(lp->host);
  855. }
  856. static struct pci_driver fnic_driver = {
  857. .name = DRV_NAME,
  858. .id_table = fnic_id_table,
  859. .probe = fnic_probe,
  860. .remove = fnic_remove,
  861. };
  862. static int __init fnic_init_module(void)
  863. {
  864. size_t len;
  865. int err = 0;
  866. printk(KERN_INFO PFX "%s, ver %s\n", DRV_DESCRIPTION, DRV_VERSION);
  867. /* Allocate memory for trace buffer */
  868. err = fnic_trace_buf_init();
  869. if (err < 0) {
  870. printk(KERN_ERR PFX "Trace buffer initialization Failed "
  871. "Fnic Tracing utility is disabled\n");
  872. fnic_trace_free();
  873. }
  874. /* Create a cache for allocation of default size sgls */
  875. len = sizeof(struct fnic_dflt_sgl_list);
  876. fnic_sgl_cache[FNIC_SGL_CACHE_DFLT] = kmem_cache_create
  877. ("fnic_sgl_dflt", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
  878. SLAB_HWCACHE_ALIGN,
  879. NULL);
  880. if (!fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]) {
  881. printk(KERN_ERR PFX "failed to create fnic dflt sgl slab\n");
  882. err = -ENOMEM;
  883. goto err_create_fnic_sgl_slab_dflt;
  884. }
  885. /* Create a cache for allocation of max size sgls*/
  886. len = sizeof(struct fnic_sgl_list);
  887. fnic_sgl_cache[FNIC_SGL_CACHE_MAX] = kmem_cache_create
  888. ("fnic_sgl_max", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
  889. SLAB_HWCACHE_ALIGN,
  890. NULL);
  891. if (!fnic_sgl_cache[FNIC_SGL_CACHE_MAX]) {
  892. printk(KERN_ERR PFX "failed to create fnic max sgl slab\n");
  893. err = -ENOMEM;
  894. goto err_create_fnic_sgl_slab_max;
  895. }
  896. /* Create a cache of io_req structs for use via mempool */
  897. fnic_io_req_cache = kmem_cache_create("fnic_io_req",
  898. sizeof(struct fnic_io_req),
  899. 0, SLAB_HWCACHE_ALIGN, NULL);
  900. if (!fnic_io_req_cache) {
  901. printk(KERN_ERR PFX "failed to create fnic io_req slab\n");
  902. err = -ENOMEM;
  903. goto err_create_fnic_ioreq_slab;
  904. }
  905. fnic_event_queue = create_singlethread_workqueue("fnic_event_wq");
  906. if (!fnic_event_queue) {
  907. printk(KERN_ERR PFX "fnic work queue create failed\n");
  908. err = -ENOMEM;
  909. goto err_create_fnic_workq;
  910. }
  911. spin_lock_init(&fnic_list_lock);
  912. INIT_LIST_HEAD(&fnic_list);
  913. fnic_fip_queue = create_singlethread_workqueue("fnic_fip_q");
  914. if (!fnic_fip_queue) {
  915. printk(KERN_ERR PFX "fnic FIP work queue create failed\n");
  916. err = -ENOMEM;
  917. goto err_create_fip_workq;
  918. }
  919. fnic_fc_transport = fc_attach_transport(&fnic_fc_functions);
  920. if (!fnic_fc_transport) {
  921. printk(KERN_ERR PFX "fc_attach_transport error\n");
  922. err = -ENOMEM;
  923. goto err_fc_transport;
  924. }
  925. /* register the driver with PCI system */
  926. err = pci_register_driver(&fnic_driver);
  927. if (err < 0) {
  928. printk(KERN_ERR PFX "pci register error\n");
  929. goto err_pci_register;
  930. }
  931. return err;
  932. err_pci_register:
  933. fc_release_transport(fnic_fc_transport);
  934. err_fc_transport:
  935. destroy_workqueue(fnic_fip_queue);
  936. err_create_fip_workq:
  937. destroy_workqueue(fnic_event_queue);
  938. err_create_fnic_workq:
  939. kmem_cache_destroy(fnic_io_req_cache);
  940. err_create_fnic_ioreq_slab:
  941. kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
  942. err_create_fnic_sgl_slab_max:
  943. kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
  944. err_create_fnic_sgl_slab_dflt:
  945. fnic_trace_free();
  946. return err;
  947. }
  948. static void __exit fnic_cleanup_module(void)
  949. {
  950. pci_unregister_driver(&fnic_driver);
  951. destroy_workqueue(fnic_event_queue);
  952. if (fnic_fip_queue) {
  953. flush_workqueue(fnic_fip_queue);
  954. destroy_workqueue(fnic_fip_queue);
  955. }
  956. kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
  957. kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
  958. kmem_cache_destroy(fnic_io_req_cache);
  959. fc_release_transport(fnic_fc_transport);
  960. fnic_trace_free();
  961. }
  962. module_init(fnic_init_module);
  963. module_exit(fnic_cleanup_module);