1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 #include <linux/module.h>
5 #include <linux/mempool.h>
6 #include <linux/string.h>
7 #include <linux/slab.h>
8 #include <linux/errno.h>
9 #include <linux/init.h>
10 #include <linux/pci.h>
11 #include <linux/skbuff.h>
12 #include <linux/interrupt.h>
13 #include <linux/spinlock.h>
14 #include <linux/workqueue.h>
15 #include <scsi/scsi_host.h>
16 #include <scsi/scsi_tcq.h>
19 #include "snic_fwint.h"
21 #define PCI_DEVICE_ID_CISCO_SNIC 0x0046
23 /* Supported devices by snic module */
24 static struct pci_device_id snic_id_table[] = {
25 {PCI_DEVICE(0x1137, PCI_DEVICE_ID_CISCO_SNIC) },
26 { 0, } /* end of table */
29 unsigned int snic_log_level = 0x0;
30 module_param(snic_log_level, int, S_IRUGO|S_IWUSR);
31 MODULE_PARM_DESC(snic_log_level, "bitmask for snic logging levels");
33 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
34 unsigned int snic_trace_max_pages = 16;
35 module_param(snic_trace_max_pages, uint, S_IRUGO|S_IWUSR);
36 MODULE_PARM_DESC(snic_trace_max_pages,
37 "Total allocated memory pages for snic trace buffer");
40 unsigned int snic_max_qdepth = SNIC_DFLT_QUEUE_DEPTH;
41 module_param(snic_max_qdepth, uint, S_IRUGO | S_IWUSR);
42 MODULE_PARM_DESC(snic_max_qdepth, "Queue depth to report for each LUN");
45 * snic_slave_alloc : callback function to SCSI Mid Layer, called on
46 * scsi device initialization.
49 snic_slave_alloc(struct scsi_device *sdev)
51 struct snic_tgt *tgt = starget_to_tgt(scsi_target(sdev));
53 if (!tgt || snic_tgt_chkready(tgt))
60 * snic_slave_configure : callback function to SCSI Mid Layer, called on
61 * scsi device initialization.
64 snic_slave_configure(struct scsi_device *sdev)
66 struct snic *snic = shost_priv(sdev->host);
67 u32 qdepth = 0, max_ios = 0;
68 int tmo = SNIC_DFLT_CMD_TIMEOUT * HZ;
71 max_ios = snic_max_qdepth;
72 qdepth = min_t(u32, max_ios, SNIC_MAX_QUEUE_DEPTH);
73 scsi_change_queue_depth(sdev, qdepth);
75 if (snic->fwinfo.io_tmo > 1)
76 tmo = snic->fwinfo.io_tmo * HZ;
78 /* FW requires extended timeouts */
79 blk_queue_rq_timeout(sdev->request_queue, tmo);
85 snic_change_queue_depth(struct scsi_device *sdev, int qdepth)
87 struct snic *snic = shost_priv(sdev->host);
90 qsz = min_t(u32, qdepth, SNIC_MAX_QUEUE_DEPTH);
91 if (qsz < sdev->queue_depth)
92 atomic64_inc(&snic->s_stats.misc.qsz_rampdown);
93 else if (qsz > sdev->queue_depth)
94 atomic64_inc(&snic->s_stats.misc.qsz_rampup);
96 atomic64_set(&snic->s_stats.misc.last_qsz, sdev->queue_depth);
98 scsi_change_queue_depth(sdev, qsz);
100 return sdev->queue_depth;
103 static const struct scsi_host_template snic_host_template = {
104 .module = THIS_MODULE,
105 .name = SNIC_DRV_NAME,
106 .queuecommand = snic_queuecommand,
107 .eh_abort_handler = snic_abort_cmd,
108 .eh_device_reset_handler = snic_device_reset,
109 .eh_host_reset_handler = snic_host_reset,
110 .slave_alloc = snic_slave_alloc,
111 .slave_configure = snic_slave_configure,
112 .change_queue_depth = snic_change_queue_depth,
114 .cmd_per_lun = SNIC_DFLT_QUEUE_DEPTH,
115 .can_queue = SNIC_MAX_IO_REQ,
116 .sg_tablesize = SNIC_MAX_SG_DESC_CNT,
117 .max_sectors = 0x800,
118 .shost_groups = snic_host_groups,
119 .track_queue_depth = 1,
120 .cmd_size = sizeof(struct snic_internal_io_state),
121 .proc_name = "snic_scsi",
125 * snic_handle_link_event : Handles link events such as link up/down/error
128 snic_handle_link_event(struct snic *snic)
132 spin_lock_irqsave(&snic->snic_lock, flags);
133 if (snic->stop_link_events) {
134 spin_unlock_irqrestore(&snic->snic_lock, flags);
138 spin_unlock_irqrestore(&snic->snic_lock, flags);
140 queue_work(snic_glob->event_q, &snic->link_work);
141 } /* end of snic_handle_link_event */
144 * snic_notify_set : sets notification area
145 * This notification area is to receive events from fw
146 * Note: snic supports only MSIX interrupts, in which we can just call
147 * svnic_dev_notify_set directly
150 snic_notify_set(struct snic *snic)
153 enum vnic_dev_intr_mode intr_mode;
155 intr_mode = svnic_dev_get_intr_mode(snic->vdev);
157 if (intr_mode == VNIC_DEV_INTR_MODE_MSIX) {
158 ret = svnic_dev_notify_set(snic->vdev, SNIC_MSIX_ERR_NOTIFY);
160 SNIC_HOST_ERR(snic->shost,
161 "Interrupt mode should be setup before devcmd notify set %d\n",
167 } /* end of snic_notify_set */
170 * snic_dev_wait : polls vnic open status.
173 snic_dev_wait(struct vnic_dev *vdev,
174 int (*start)(struct vnic_dev *, int),
175 int (*finished)(struct vnic_dev *, int *),
182 ret = start(vdev, arg);
187 * Wait for func to complete...2 seconds max.
189 * Sometimes schedule_timeout_uninterruptible take long time
190 * to wakeup, which results skipping retry. The retry counter
191 * ensures to retry at least two times.
193 time = jiffies + (HZ * 2);
195 ret = finished(vdev, &done);
201 schedule_timeout_uninterruptible(HZ/10);
203 } while (time_after(time, jiffies) || (retry_cnt < 3));
206 } /* end of snic_dev_wait */
209 * snic_cleanup: called by snic_remove
210 * Stops the snic device, masks all interrupts, Completed CQ entries are
211 * drained. Posted WQ/RQ/Copy-WQ entries are cleanup
214 snic_cleanup(struct snic *snic)
219 svnic_dev_disable(snic->vdev);
220 for (i = 0; i < snic->intr_count; i++)
221 svnic_intr_mask(&snic->intr[i]);
223 for (i = 0; i < snic->wq_count; i++) {
224 ret = svnic_wq_disable(&snic->wq[i]);
229 /* Clean up completed IOs */
230 snic_fwcq_cmpl_handler(snic, -1);
232 snic_wq_cmpl_handler(snic, -1);
234 /* Clean up the IOs that have not completed */
235 for (i = 0; i < snic->wq_count; i++)
236 svnic_wq_clean(&snic->wq[i], snic_free_wq_buf);
238 for (i = 0; i < snic->cq_count; i++)
239 svnic_cq_clean(&snic->cq[i]);
241 for (i = 0; i < snic->intr_count; i++)
242 svnic_intr_clean(&snic->intr[i]);
244 /* Cleanup snic specific requests */
245 snic_free_all_untagged_reqs(snic);
247 /* Cleanup Pending SCSI commands */
248 snic_shutdown_scsi_cleanup(snic);
250 for (i = 0; i < SNIC_REQ_MAX_CACHES; i++)
251 mempool_destroy(snic->req_pool[i]);
254 } /* end of snic_cleanup */
258 snic_iounmap(struct snic *snic)
260 if (snic->bar0.vaddr)
261 iounmap(snic->bar0.vaddr);
265 * snic_vdev_open_done : polls for svnic_dev_open cmd completion.
268 snic_vdev_open_done(struct vnic_dev *vdev, int *done)
270 struct snic *snic = svnic_dev_priv(vdev);
275 ret = svnic_dev_open_done(vdev, done);
279 SNIC_HOST_INFO(snic->shost, "VNIC_DEV_OPEN Timedout.\n");
280 } while (nretries--);
283 } /* end of snic_vdev_open_done */
286 * snic_add_host : registers scsi host with ML
289 snic_add_host(struct Scsi_Host *shost, struct pci_dev *pdev)
293 ret = scsi_add_host(shost, &pdev->dev);
296 "snic: scsi_add_host failed. %d\n",
302 SNIC_BUG_ON(shost->work_q != NULL);
303 snprintf(shost->work_q_name, sizeof(shost->work_q_name), "scsi_wq_%d",
305 shost->work_q = create_singlethread_workqueue(shost->work_q_name);
306 if (!shost->work_q) {
307 SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
313 } /* end of snic_add_host */
316 snic_del_host(struct Scsi_Host *shost)
321 destroy_workqueue(shost->work_q);
322 shost->work_q = NULL;
323 scsi_remove_host(shost);
327 snic_get_state(struct snic *snic)
329 return atomic_read(&snic->state);
333 snic_set_state(struct snic *snic, enum snic_state state)
335 SNIC_HOST_INFO(snic->shost, "snic state change from %s to %s\n",
336 snic_state_to_str(snic_get_state(snic)),
337 snic_state_to_str(state));
339 atomic_set(&snic->state, state);
343 * snic_probe : Initialize the snic interface.
346 snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
348 struct Scsi_Host *shost;
355 /* Device Information */
356 SNIC_INFO("snic device %4x:%4x:%4x:%4x: ",
357 pdev->vendor, pdev->device, pdev->subsystem_vendor,
358 pdev->subsystem_device);
360 SNIC_INFO("snic device bus %x: slot %x: fn %x\n",
361 pdev->bus->number, PCI_SLOT(pdev->devfn),
362 PCI_FUNC(pdev->devfn));
365 * Allocate SCSI Host and setup association between host, and snic
367 shost = scsi_host_alloc(&snic_host_template, sizeof(struct snic));
369 SNIC_ERR("Unable to alloc scsi_host\n");
374 snic = shost_priv(shost);
377 snprintf(snic->name, sizeof(snic->name) - 1, "%s%d", SNIC_DRV_NAME,
380 SNIC_HOST_INFO(shost,
381 "snic%d = %p shost = %p device bus %x: slot %x: fn %x\n",
382 shost->host_no, snic, shost, pdev->bus->number,
383 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
384 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
385 /* Per snic debugfs init */
386 snic_stats_debugfs_init(snic);
389 /* Setup PCI Resources */
390 pci_set_drvdata(pdev, snic);
393 ret = pci_enable_device(pdev);
396 "Cannot enable PCI Resources, aborting : %d\n",
402 ret = pci_request_regions(pdev, SNIC_DRV_NAME);
405 "Cannot obtain PCI Resources, aborting : %d\n",
408 goto err_pci_disable;
411 pci_set_master(pdev);
414 * Query PCI Controller on system for DMA addressing
415 * limitation for the device. Try 43-bit first, and
418 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(43));
420 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
423 "No Usable DMA Configuration, aborting %d\n",
425 goto err_rel_regions;
429 /* Map vNIC resources from BAR0 */
430 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
431 SNIC_HOST_ERR(shost, "BAR0 not memory mappable aborting.\n");
434 goto err_rel_regions;
437 snic->bar0.vaddr = pci_iomap(pdev, 0, 0);
438 if (!snic->bar0.vaddr) {
440 "Cannot memory map BAR0 res hdr aborting.\n");
443 goto err_rel_regions;
446 snic->bar0.bus_addr = pci_resource_start(pdev, 0);
447 snic->bar0.len = pci_resource_len(pdev, 0);
448 SNIC_BUG_ON(snic->bar0.bus_addr == 0);
450 /* Devcmd2 Resource Allocation and Initialization */
451 snic->vdev = svnic_dev_alloc_discover(NULL, snic, pdev, &snic->bar0, 1);
453 SNIC_HOST_ERR(shost, "vNIC Resource Discovery Failed.\n");
459 ret = svnic_dev_cmd_init(snic->vdev, 0);
461 SNIC_HOST_INFO(shost, "Devcmd2 Init Failed. err = %d\n", ret);
466 ret = snic_dev_wait(snic->vdev, svnic_dev_open, snic_vdev_open_done, 0);
469 "vNIC dev open failed, aborting. %d\n",
475 ret = svnic_dev_init(snic->vdev, 0);
478 "vNIC dev init failed. aborting. %d\n",
484 /* Get vNIC information */
485 ret = snic_get_vnic_config(snic);
488 "Get vNIC configuration failed, aborting. %d\n",
494 /* Configure Maximum Outstanding IO reqs */
495 max_ios = snic->config.io_throttle_count;
496 if (max_ios != SNIC_UCSM_DFLT_THROTTLE_CNT_BLD)
497 shost->can_queue = min_t(u32, SNIC_MAX_IO_REQ,
498 max_t(u32, SNIC_MIN_IO_REQ, max_ios));
500 snic->max_tag_id = shost->can_queue;
502 shost->max_lun = snic->config.luns_per_tgt;
503 shost->max_id = SNIC_MAX_TARGET;
505 shost->max_cmd_len = MAX_COMMAND_SIZE; /*defined in scsi_cmnd.h*/
507 snic_get_res_counts(snic);
510 * Assumption: Only MSIx is supported
512 ret = snic_set_intr_mode(snic);
515 "Failed to set intr mode aborting. %d\n",
521 ret = snic_alloc_vnic_res(snic);
524 "Failed to alloc vNIC resources aborting. %d\n",
530 /* Initialize specific lists */
531 INIT_LIST_HEAD(&snic->list);
534 * spl_cmd_list for maintaining snic specific cmds
535 * such as EXCH_VER_REQ, REPORT_TARGETS etc
537 INIT_LIST_HEAD(&snic->spl_cmd_list);
538 spin_lock_init(&snic->spl_cmd_lock);
540 /* initialize all snic locks */
541 spin_lock_init(&snic->snic_lock);
543 for (i = 0; i < SNIC_WQ_MAX; i++)
544 spin_lock_init(&snic->wq_lock[i]);
546 for (i = 0; i < SNIC_IO_LOCKS; i++)
547 spin_lock_init(&snic->io_req_lock[i]);
549 pool = mempool_create_slab_pool(2,
550 snic_glob->req_cache[SNIC_REQ_CACHE_DFLT_SGL]);
552 SNIC_HOST_ERR(shost, "dflt sgl pool creation failed\n");
558 snic->req_pool[SNIC_REQ_CACHE_DFLT_SGL] = pool;
560 pool = mempool_create_slab_pool(2,
561 snic_glob->req_cache[SNIC_REQ_CACHE_MAX_SGL]);
563 SNIC_HOST_ERR(shost, "max sgl pool creation failed\n");
566 goto err_free_dflt_sgl_pool;
569 snic->req_pool[SNIC_REQ_CACHE_MAX_SGL] = pool;
571 pool = mempool_create_slab_pool(2,
572 snic_glob->req_cache[SNIC_REQ_TM_CACHE]);
574 SNIC_HOST_ERR(shost, "snic tmreq info pool creation failed.\n");
577 goto err_free_max_sgl_pool;
580 snic->req_pool[SNIC_REQ_TM_CACHE] = pool;
582 /* Initialize snic state */
583 atomic_set(&snic->state, SNIC_INIT);
585 atomic_set(&snic->ios_inflight, 0);
587 /* Setup notification buffer area */
588 ret = snic_notify_set(snic);
591 "Failed to alloc notify buffer aborting. %d\n",
594 goto err_free_tmreq_pool;
597 spin_lock_irqsave(&snic_glob->snic_list_lock, flags);
598 list_add_tail(&snic->list, &snic_glob->snic_list);
599 spin_unlock_irqrestore(&snic_glob->snic_list_lock, flags);
601 snic_disc_init(&snic->disc);
602 INIT_WORK(&snic->tgt_work, snic_handle_tgt_disc);
603 INIT_WORK(&snic->disc_work, snic_handle_disc);
604 INIT_WORK(&snic->link_work, snic_handle_link);
606 /* Enable all queues */
607 for (i = 0; i < snic->wq_count; i++)
608 svnic_wq_enable(&snic->wq[i]);
610 ret = svnic_dev_enable_wait(snic->vdev);
613 "vNIC dev enable failed w/ error %d\n",
616 goto err_vdev_enable;
619 ret = snic_request_intr(snic);
621 SNIC_HOST_ERR(shost, "Unable to request irq. %d\n", ret);
626 for (i = 0; i < snic->intr_count; i++)
627 svnic_intr_unmask(&snic->intr[i]);
629 /* Get snic params */
630 ret = snic_get_conf(snic);
633 "Failed to get snic io config from FW w err %d\n",
640 * Initialization done with PCI system, hardware, firmware.
643 ret = snic_add_host(shost, pdev);
646 "Adding scsi host Failed ... exiting. %d\n",
652 snic_set_state(snic, SNIC_ONLINE);
654 ret = snic_disc_start(snic);
656 SNIC_HOST_ERR(shost, "snic_probe:Discovery Failed w err = %d\n",
662 SNIC_HOST_INFO(shost, "SNIC Device Probe Successful.\n");
667 snic_free_all_untagged_reqs(snic);
669 for (i = 0; i < snic->intr_count; i++)
670 svnic_intr_mask(&snic->intr[i]);
672 snic_free_intr(snic);
675 svnic_dev_disable(snic->vdev);
678 svnic_dev_notify_unset(snic->vdev);
680 for (i = 0; i < snic->wq_count; i++) {
683 rc = svnic_wq_disable(&snic->wq[i]);
686 "WQ Disable Failed w/ err = %d\n", rc);
691 snic_del_host(snic->shost);
694 mempool_destroy(snic->req_pool[SNIC_REQ_TM_CACHE]);
696 err_free_max_sgl_pool:
697 mempool_destroy(snic->req_pool[SNIC_REQ_CACHE_MAX_SGL]);
699 err_free_dflt_sgl_pool:
700 mempool_destroy(snic->req_pool[SNIC_REQ_CACHE_DFLT_SGL]);
703 snic_free_vnic_res(snic);
706 snic_clear_intr_mode(snic);
709 svnic_dev_close(snic->vdev);
712 svnic_dev_unregister(snic->vdev);
718 pci_release_regions(pdev);
721 pci_disable_device(pdev);
724 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
725 snic_stats_debugfs_remove(snic);
727 scsi_host_put(shost);
728 pci_set_drvdata(pdev, NULL);
731 SNIC_INFO("sNIC device : bus %d: slot %d: fn %d Registration Failed.\n",
732 pdev->bus->number, PCI_SLOT(pdev->devfn),
733 PCI_FUNC(pdev->devfn));
736 } /* end of snic_probe */
740 * snic_remove : invoked on unbinding the interface to cleanup the
741 * resources allocated in snic_probe on initialization.
744 snic_remove(struct pci_dev *pdev)
746 struct snic *snic = pci_get_drvdata(pdev);
750 SNIC_INFO("sNIC dev: bus %d slot %d fn %d snic inst is null.\n",
751 pdev->bus->number, PCI_SLOT(pdev->devfn),
752 PCI_FUNC(pdev->devfn));
758 * Mark state so that the workqueue thread stops forwarding
759 * received frames and link events. ISR and other threads
760 * that can queue work items will also stop creating work
761 * items on the snic workqueue
763 snic_set_state(snic, SNIC_OFFLINE);
764 spin_lock_irqsave(&snic->snic_lock, flags);
765 snic->stop_link_events = 1;
766 spin_unlock_irqrestore(&snic->snic_lock, flags);
768 flush_workqueue(snic_glob->event_q);
769 snic_disc_term(snic);
771 spin_lock_irqsave(&snic->snic_lock, flags);
773 spin_unlock_irqrestore(&snic->snic_lock, flags);
776 * This stops the snic device, masks all interrupts, Completed
777 * CQ entries are drained. Posted WQ/RQ/Copy-WQ entries are
782 spin_lock_irqsave(&snic_glob->snic_list_lock, flags);
783 list_del(&snic->list);
784 spin_unlock_irqrestore(&snic_glob->snic_list_lock, flags);
786 snic_tgt_del_all(snic);
787 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
788 snic_stats_debugfs_remove(snic);
790 snic_del_host(snic->shost);
792 svnic_dev_notify_unset(snic->vdev);
793 snic_free_intr(snic);
794 snic_free_vnic_res(snic);
795 snic_clear_intr_mode(snic);
796 svnic_dev_close(snic->vdev);
797 svnic_dev_unregister(snic->vdev);
799 pci_release_regions(pdev);
800 pci_disable_device(pdev);
801 pci_set_drvdata(pdev, NULL);
803 /* this frees Scsi_Host and snic memory (continuous chunk) */
804 scsi_host_put(snic->shost);
805 } /* end of snic_remove */
808 struct snic_global *snic_glob;
811 * snic_global_data_init: Initialize SNIC Global Data
812 * Notes: All the global lists, variables should be part of global data
813 * this helps in debugging.
816 snic_global_data_init(void)
819 struct kmem_cache *cachep;
822 snic_glob = kzalloc(sizeof(*snic_glob), GFP_KERNEL);
825 SNIC_ERR("Failed to allocate Global Context.\n");
831 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
832 /* Debugfs related Initialization */
833 /* Create debugfs entries for snic */
836 /* Trace related Initialization */
837 /* Allocate memory for trace buffer */
838 ret = snic_trc_init();
840 SNIC_ERR("Trace buffer init failed, SNIC tracing disabled\n");
842 /* continue even if it fails */
846 INIT_LIST_HEAD(&snic_glob->snic_list);
847 spin_lock_init(&snic_glob->snic_list_lock);
849 /* Create a cache for allocation of snic_host_req+default size ESGLs */
850 len = sizeof(struct snic_req_info);
851 len += sizeof(struct snic_host_req) + sizeof(struct snic_dflt_sgl);
852 cachep = kmem_cache_create("snic_req_dfltsgl", len, SNIC_SG_DESC_ALIGN,
853 SLAB_HWCACHE_ALIGN, NULL);
855 SNIC_ERR("Failed to create snic default sgl slab\n");
858 goto err_dflt_req_slab;
860 snic_glob->req_cache[SNIC_REQ_CACHE_DFLT_SGL] = cachep;
862 /* Create a cache for allocation of max size Extended SGLs */
863 len = sizeof(struct snic_req_info);
864 len += sizeof(struct snic_host_req) + sizeof(struct snic_max_sgl);
865 cachep = kmem_cache_create("snic_req_maxsgl", len, SNIC_SG_DESC_ALIGN,
866 SLAB_HWCACHE_ALIGN, NULL);
868 SNIC_ERR("Failed to create snic max sgl slab\n");
871 goto err_max_req_slab;
873 snic_glob->req_cache[SNIC_REQ_CACHE_MAX_SGL] = cachep;
875 len = sizeof(struct snic_host_req);
876 cachep = kmem_cache_create("snic_req_maxsgl", len, SNIC_SG_DESC_ALIGN,
877 SLAB_HWCACHE_ALIGN, NULL);
879 SNIC_ERR("Failed to create snic tm req slab\n");
884 snic_glob->req_cache[SNIC_REQ_TM_CACHE] = cachep;
886 /* snic_event queue */
887 snic_glob->event_q = create_singlethread_workqueue("snic_event_wq");
888 if (!snic_glob->event_q) {
889 SNIC_ERR("snic event queue create failed\n");
898 kmem_cache_destroy(snic_glob->req_cache[SNIC_REQ_TM_CACHE]);
901 kmem_cache_destroy(snic_glob->req_cache[SNIC_REQ_CACHE_MAX_SGL]);
904 kmem_cache_destroy(snic_glob->req_cache[SNIC_REQ_CACHE_DFLT_SGL]);
907 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
916 } /* end of snic_glob_init */
919 * snic_global_data_cleanup : Frees SNIC Global Data
922 snic_global_data_cleanup(void)
924 SNIC_BUG_ON(snic_glob == NULL);
926 destroy_workqueue(snic_glob->event_q);
927 kmem_cache_destroy(snic_glob->req_cache[SNIC_REQ_TM_CACHE]);
928 kmem_cache_destroy(snic_glob->req_cache[SNIC_REQ_CACHE_MAX_SGL]);
929 kmem_cache_destroy(snic_glob->req_cache[SNIC_REQ_CACHE_DFLT_SGL]);
931 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
932 /* Freeing Trace Resources */
935 /* Freeing Debugfs Resources */
940 } /* end of snic_glob_cleanup */
942 static struct pci_driver snic_driver = {
943 .name = SNIC_DRV_NAME,
944 .id_table = snic_id_table,
946 .remove = snic_remove,
950 snic_init_module(void)
955 SNIC_INFO("SNIC Driver is supported only for x86_64 platforms!\n");
956 add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
959 SNIC_INFO("%s, ver %s\n", SNIC_DRV_DESCRIPTION, SNIC_DRV_VERSION);
961 ret = snic_global_data_init();
963 SNIC_ERR("Failed to Initialize Global Data.\n");
968 ret = pci_register_driver(&snic_driver);
970 SNIC_ERR("PCI driver register error\n");
978 snic_global_data_cleanup();
984 snic_cleanup_module(void)
986 pci_unregister_driver(&snic_driver);
987 snic_global_data_cleanup();
990 module_init(snic_init_module);
991 module_exit(snic_cleanup_module);
993 MODULE_LICENSE("GPL v2");
994 MODULE_DESCRIPTION(SNIC_DRV_DESCRIPTION);
995 MODULE_VERSION(SNIC_DRV_VERSION);
996 MODULE_DEVICE_TABLE(pci, snic_id_table);
997 MODULE_AUTHOR("Narsimhulu Musini <nmusini@cisco.com>, "
998 "Sesidhar Baddela <sebaddel@cisco.com>");