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