Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 3 | * All rights reserved |
| 4 | * www.brocade.com |
| 5 | * |
| 6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License (GPL) Version 2 as |
| 10 | * published by the Free Software Foundation |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | */ |
| 17 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 18 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 19 | * bfad.c Linux driver PCI interface module. |
| 20 | */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 22 | #include <linux/kthread.h> |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 23 | #include <linux/errno.h> |
| 24 | #include <linux/sched.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/fs.h> |
| 27 | #include <linux/pci.h> |
| 28 | #include <linux/firmware.h> |
| 29 | #include <asm/uaccess.h> |
| 30 | #include <asm/fcntl.h> |
| 31 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 32 | #include "bfad_drv.h" |
| 33 | #include "bfad_im.h" |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 34 | #include "bfa_fcs.h" |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 35 | #include "bfa_defs.h" |
| 36 | #include "bfa.h" |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 37 | |
| 38 | BFA_TRC_FILE(LDRV, BFAD); |
Jing Huang | 42b426e | 2010-03-19 11:07:09 -0700 | [diff] [blame] | 39 | DEFINE_MUTEX(bfad_mutex); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 40 | LIST_HEAD(bfad_list); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 41 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 42 | static int bfad_inst; |
| 43 | static int num_sgpgs_parm; |
| 44 | int supported_fc4s; |
| 45 | char *host_name, *os_name, *os_patch; |
| 46 | int num_rports, num_ios, num_tms; |
| 47 | int num_fcxps, num_ufbufs; |
| 48 | int reqq_size, rspq_size, num_sgpgs; |
| 49 | int rport_del_timeout = BFA_FCS_RPORT_DEF_DEL_TIMEOUT; |
| 50 | int bfa_lun_queue_depth = BFAD_LUN_QUEUE_DEPTH; |
| 51 | int bfa_io_max_sge = BFAD_IO_MAX_SGE; |
Jing Huang | 8816624 | 2010-12-09 17:11:53 -0800 | [diff] [blame] | 52 | int bfa_log_level = 3; /* WARNING log level */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 53 | int ioc_auto_recover = BFA_TRUE; |
| 54 | int bfa_linkup_delay = -1; |
| 55 | int fdmi_enable = BFA_TRUE; |
| 56 | int pcie_max_read_reqsz; |
Jing Huang | ab2a9ba | 2010-07-08 20:02:55 -0700 | [diff] [blame] | 57 | int bfa_debugfs_enable = 1; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 58 | int msix_disable_cb = 0, msix_disable_ct = 0; |
| 59 | |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 60 | /* Firmware releated */ |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 61 | u32 bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size; |
| 62 | u32 *bfi_image_cb, *bfi_image_ct, *bfi_image_ct2; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 63 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 64 | #define BFAD_FW_FILE_CB "cbfw.bin" |
| 65 | #define BFAD_FW_FILE_CT "ctfw.bin" |
| 66 | #define BFAD_FW_FILE_CT2 "ct2fw.bin" |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 67 | |
| 68 | static u32 *bfad_load_fwimg(struct pci_dev *pdev); |
| 69 | static void bfad_free_fwimg(void); |
| 70 | static void bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image, |
| 71 | u32 *bfi_image_size, char *fw_name); |
| 72 | |
Maggie | 52f94b6 | 2010-11-29 18:21:32 -0800 | [diff] [blame] | 73 | static const char *msix_name_ct[] = { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 74 | "ctrl", |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 75 | "cpe0", "cpe1", "cpe2", "cpe3", |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 76 | "rme0", "rme1", "rme2", "rme3" }; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 77 | |
Maggie | 52f94b6 | 2010-11-29 18:21:32 -0800 | [diff] [blame] | 78 | static const char *msix_name_cb[] = { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 79 | "cpe0", "cpe1", "cpe2", "cpe3", |
| 80 | "rme0", "rme1", "rme2", "rme3", |
| 81 | "eemc", "elpu0", "elpu1", "epss", "mlpu" }; |
| 82 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 83 | MODULE_FIRMWARE(BFAD_FW_FILE_CB); |
| 84 | MODULE_FIRMWARE(BFAD_FW_FILE_CT); |
| 85 | MODULE_FIRMWARE(BFAD_FW_FILE_CT2); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 86 | |
| 87 | module_param(os_name, charp, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 88 | MODULE_PARM_DESC(os_name, "OS name of the hba host machine"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 89 | module_param(os_patch, charp, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 90 | MODULE_PARM_DESC(os_patch, "OS patch level of the hba host machine"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 91 | module_param(host_name, charp, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 92 | MODULE_PARM_DESC(host_name, "Hostname of the hba host machine"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 93 | module_param(num_rports, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 94 | MODULE_PARM_DESC(num_rports, "Max number of rports supported per port " |
| 95 | "(physical/logical), default=1024"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 96 | module_param(num_ios, int, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 97 | MODULE_PARM_DESC(num_ios, "Max number of ioim requests, default=2000"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 98 | module_param(num_tms, int, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 99 | MODULE_PARM_DESC(num_tms, "Max number of task im requests, default=128"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 100 | module_param(num_fcxps, int, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 101 | MODULE_PARM_DESC(num_fcxps, "Max number of fcxp requests, default=64"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 102 | module_param(num_ufbufs, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 103 | MODULE_PARM_DESC(num_ufbufs, "Max number of unsolicited frame " |
| 104 | "buffers, default=64"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 105 | module_param(reqq_size, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 106 | MODULE_PARM_DESC(reqq_size, "Max number of request queue elements, " |
| 107 | "default=256"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 108 | module_param(rspq_size, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 109 | MODULE_PARM_DESC(rspq_size, "Max number of response queue elements, " |
| 110 | "default=64"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 111 | module_param(num_sgpgs, int, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 112 | MODULE_PARM_DESC(num_sgpgs, "Number of scatter/gather pages, default=2048"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 113 | module_param(rport_del_timeout, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 114 | MODULE_PARM_DESC(rport_del_timeout, "Rport delete timeout, default=90 secs, " |
| 115 | "Range[>0]"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 116 | module_param(bfa_lun_queue_depth, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 117 | MODULE_PARM_DESC(bfa_lun_queue_depth, "Lun queue depth, default=32, Range[>0]"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 118 | module_param(bfa_io_max_sge, int, S_IRUGO | S_IWUSR); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 119 | MODULE_PARM_DESC(bfa_io_max_sge, "Max io scatter/gather elements, default=255"); |
Jing Huang | 8816624 | 2010-12-09 17:11:53 -0800 | [diff] [blame] | 120 | module_param(bfa_log_level, int, S_IRUGO | S_IWUSR); |
| 121 | MODULE_PARM_DESC(bfa_log_level, "Driver log level, default=3, " |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 122 | "Range[Critical:1|Error:2|Warning:3|Info:4]"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 123 | module_param(ioc_auto_recover, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 124 | MODULE_PARM_DESC(ioc_auto_recover, "IOC auto recovery, default=1, " |
| 125 | "Range[off:0|on:1]"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 126 | module_param(bfa_linkup_delay, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 127 | MODULE_PARM_DESC(bfa_linkup_delay, "Link up delay, default=30 secs for " |
| 128 | "boot port. Otherwise 10 secs in RHEL4 & 0 for " |
| 129 | "[RHEL5, SLES10, ESX40] Range[>0]"); |
| 130 | module_param(msix_disable_cb, int, S_IRUGO | S_IWUSR); |
| 131 | MODULE_PARM_DESC(msix_disable_cb, "Disable Message Signaled Interrupts " |
| 132 | "for Brocade-415/425/815/825 cards, default=0, " |
| 133 | " Range[false:0|true:1]"); |
| 134 | module_param(msix_disable_ct, int, S_IRUGO | S_IWUSR); |
| 135 | MODULE_PARM_DESC(msix_disable_ct, "Disable Message Signaled Interrupts " |
| 136 | "if possible for Brocade-1010/1020/804/1007/902/1741 " |
| 137 | "cards, default=0, Range[false:0|true:1]"); |
Jing Huang | 604158ad | 2010-07-08 19:59:49 -0700 | [diff] [blame] | 138 | module_param(fdmi_enable, int, S_IRUGO | S_IWUSR); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 139 | MODULE_PARM_DESC(fdmi_enable, "Enables fdmi registration, default=1, " |
| 140 | "Range[false:0|true:1]"); |
| 141 | module_param(pcie_max_read_reqsz, int, S_IRUGO | S_IWUSR); |
| 142 | MODULE_PARM_DESC(pcie_max_read_reqsz, "PCIe max read request size, default=0 " |
| 143 | "(use system setting), Range[128|256|512|1024|2048|4096]"); |
Jing Huang | ab2a9ba | 2010-07-08 20:02:55 -0700 | [diff] [blame] | 144 | module_param(bfa_debugfs_enable, int, S_IRUGO | S_IWUSR); |
| 145 | MODULE_PARM_DESC(bfa_debugfs_enable, "Enables debugfs feature, default=1," |
| 146 | " Range[false:0|true:1]"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 147 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 148 | static void |
| 149 | bfad_sm_uninit(struct bfad_s *bfad, enum bfad_sm_event event); |
| 150 | static void |
| 151 | bfad_sm_created(struct bfad_s *bfad, enum bfad_sm_event event); |
| 152 | static void |
| 153 | bfad_sm_initializing(struct bfad_s *bfad, enum bfad_sm_event event); |
| 154 | static void |
| 155 | bfad_sm_operational(struct bfad_s *bfad, enum bfad_sm_event event); |
| 156 | static void |
| 157 | bfad_sm_stopping(struct bfad_s *bfad, enum bfad_sm_event event); |
| 158 | static void |
| 159 | bfad_sm_failed(struct bfad_s *bfad, enum bfad_sm_event event); |
| 160 | static void |
| 161 | bfad_sm_fcs_exit(struct bfad_s *bfad, enum bfad_sm_event event); |
| 162 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 163 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 164 | * Beginning state for the driver instance, awaiting the pci_probe event |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 165 | */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 166 | static void |
| 167 | bfad_sm_uninit(struct bfad_s *bfad, enum bfad_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 168 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 169 | bfa_trc(bfad, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 170 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 171 | switch (event) { |
| 172 | case BFAD_E_CREATE: |
| 173 | bfa_sm_set_state(bfad, bfad_sm_created); |
| 174 | bfad->bfad_tsk = kthread_create(bfad_worker, (void *) bfad, |
| 175 | "%s", "bfad_worker"); |
| 176 | if (IS_ERR(bfad->bfad_tsk)) { |
| 177 | printk(KERN_INFO "bfad[%d]: Kernel thread " |
| 178 | "creation failed!\n", bfad->inst_no); |
| 179 | bfa_sm_send_event(bfad, BFAD_E_KTHREAD_CREATE_FAILED); |
| 180 | } |
| 181 | bfa_sm_send_event(bfad, BFAD_E_INIT); |
| 182 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 183 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 184 | case BFAD_E_STOP: |
| 185 | /* Ignore stop; already in uninit */ |
| 186 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 187 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 188 | default: |
| 189 | bfa_sm_fault(bfad, event); |
| 190 | } |
| 191 | } |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 192 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 193 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 194 | * Driver Instance is created, awaiting event INIT to initialize the bfad |
| 195 | */ |
| 196 | static void |
| 197 | bfad_sm_created(struct bfad_s *bfad, enum bfad_sm_event event) |
| 198 | { |
| 199 | unsigned long flags; |
| 200 | |
| 201 | bfa_trc(bfad, event); |
| 202 | |
| 203 | switch (event) { |
| 204 | case BFAD_E_INIT: |
| 205 | bfa_sm_set_state(bfad, bfad_sm_initializing); |
| 206 | |
| 207 | init_completion(&bfad->comp); |
| 208 | |
| 209 | /* Enable Interrupt and wait bfa_init completion */ |
| 210 | if (bfad_setup_intr(bfad)) { |
| 211 | printk(KERN_WARNING "bfad%d: bfad_setup_intr failed\n", |
| 212 | bfad->inst_no); |
| 213 | bfa_sm_send_event(bfad, BFAD_E_INTR_INIT_FAILED); |
| 214 | break; |
| 215 | } |
| 216 | |
| 217 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 218 | bfa_iocfc_init(&bfad->bfa); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 219 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 220 | |
| 221 | /* Set up interrupt handler for each vectors */ |
| 222 | if ((bfad->bfad_flags & BFAD_MSIX_ON) && |
| 223 | bfad_install_msix_handler(bfad)) { |
| 224 | printk(KERN_WARNING "%s: install_msix failed, bfad%d\n", |
| 225 | __func__, bfad->inst_no); |
| 226 | } |
| 227 | |
| 228 | bfad_init_timer(bfad); |
| 229 | |
| 230 | wait_for_completion(&bfad->comp); |
| 231 | |
| 232 | if ((bfad->bfad_flags & BFAD_HAL_INIT_DONE)) { |
| 233 | bfa_sm_send_event(bfad, BFAD_E_INIT_SUCCESS); |
| 234 | } else { |
Krishna Gudipati | 7c38c05 | 2011-04-14 16:50:35 -0700 | [diff] [blame] | 235 | printk(KERN_WARNING |
| 236 | "bfa %s: bfa init failed\n", |
| 237 | bfad->pci_name); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 238 | bfad->bfad_flags |= BFAD_HAL_INIT_FAIL; |
| 239 | bfa_sm_send_event(bfad, BFAD_E_INIT_FAILED); |
| 240 | } |
| 241 | |
| 242 | break; |
| 243 | |
| 244 | case BFAD_E_KTHREAD_CREATE_FAILED: |
| 245 | bfa_sm_set_state(bfad, bfad_sm_uninit); |
| 246 | break; |
| 247 | |
| 248 | default: |
| 249 | bfa_sm_fault(bfad, event); |
| 250 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | static void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 254 | bfad_sm_initializing(struct bfad_s *bfad, enum bfad_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 255 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 256 | int retval; |
| 257 | unsigned long flags; |
| 258 | |
| 259 | bfa_trc(bfad, event); |
| 260 | |
| 261 | switch (event) { |
| 262 | case BFAD_E_INIT_SUCCESS: |
| 263 | kthread_stop(bfad->bfad_tsk); |
| 264 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 265 | bfad->bfad_tsk = NULL; |
| 266 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 267 | |
| 268 | retval = bfad_start_ops(bfad); |
| 269 | if (retval != BFA_STATUS_OK) |
| 270 | break; |
| 271 | bfa_sm_set_state(bfad, bfad_sm_operational); |
| 272 | break; |
| 273 | |
| 274 | case BFAD_E_INTR_INIT_FAILED: |
| 275 | bfa_sm_set_state(bfad, bfad_sm_uninit); |
| 276 | kthread_stop(bfad->bfad_tsk); |
| 277 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 278 | bfad->bfad_tsk = NULL; |
| 279 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 280 | break; |
| 281 | |
| 282 | case BFAD_E_INIT_FAILED: |
| 283 | bfa_sm_set_state(bfad, bfad_sm_failed); |
| 284 | break; |
| 285 | default: |
| 286 | bfa_sm_fault(bfad, event); |
| 287 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | static void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 291 | bfad_sm_failed(struct bfad_s *bfad, enum bfad_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 292 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 293 | int retval; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 294 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 295 | bfa_trc(bfad, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 296 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 297 | switch (event) { |
| 298 | case BFAD_E_INIT_SUCCESS: |
| 299 | retval = bfad_start_ops(bfad); |
| 300 | if (retval != BFA_STATUS_OK) |
| 301 | break; |
| 302 | bfa_sm_set_state(bfad, bfad_sm_operational); |
| 303 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 304 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 305 | case BFAD_E_STOP: |
| 306 | if (bfad->bfad_flags & BFAD_CFG_PPORT_DONE) |
| 307 | bfad_uncfg_pport(bfad); |
| 308 | if (bfad->bfad_flags & BFAD_FC4_PROBE_DONE) { |
| 309 | bfad_im_probe_undo(bfad); |
| 310 | bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE; |
| 311 | } |
| 312 | bfad_stop(bfad); |
| 313 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 314 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 315 | case BFAD_E_EXIT_COMP: |
| 316 | bfa_sm_set_state(bfad, bfad_sm_uninit); |
| 317 | bfad_remove_intr(bfad); |
| 318 | del_timer_sync(&bfad->hal_tmo); |
| 319 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 320 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 321 | default: |
| 322 | bfa_sm_fault(bfad, event); |
| 323 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 327 | bfad_sm_operational(struct bfad_s *bfad, enum bfad_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 328 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 329 | bfa_trc(bfad, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 330 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 331 | switch (event) { |
| 332 | case BFAD_E_STOP: |
| 333 | bfa_sm_set_state(bfad, bfad_sm_fcs_exit); |
| 334 | bfad_fcs_stop(bfad); |
| 335 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 336 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 337 | default: |
| 338 | bfa_sm_fault(bfad, event); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | static void |
| 343 | bfad_sm_fcs_exit(struct bfad_s *bfad, enum bfad_sm_event event) |
| 344 | { |
| 345 | bfa_trc(bfad, event); |
| 346 | |
| 347 | switch (event) { |
| 348 | case BFAD_E_FCS_EXIT_COMP: |
| 349 | bfa_sm_set_state(bfad, bfad_sm_stopping); |
| 350 | bfad_stop(bfad); |
| 351 | break; |
| 352 | |
| 353 | default: |
| 354 | bfa_sm_fault(bfad, event); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | static void |
| 359 | bfad_sm_stopping(struct bfad_s *bfad, enum bfad_sm_event event) |
| 360 | { |
| 361 | bfa_trc(bfad, event); |
| 362 | |
| 363 | switch (event) { |
| 364 | case BFAD_E_EXIT_COMP: |
| 365 | bfa_sm_set_state(bfad, bfad_sm_uninit); |
| 366 | bfad_remove_intr(bfad); |
| 367 | del_timer_sync(&bfad->hal_tmo); |
| 368 | bfad_im_probe_undo(bfad); |
| 369 | bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE; |
| 370 | bfad_uncfg_pport(bfad); |
| 371 | break; |
| 372 | |
| 373 | default: |
| 374 | bfa_sm_fault(bfad, event); |
| 375 | break; |
| 376 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 377 | } |
| 378 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 379 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 380 | * BFA callbacks |
| 381 | */ |
| 382 | void |
| 383 | bfad_hcb_comp(void *arg, bfa_status_t status) |
| 384 | { |
| 385 | struct bfad_hal_comp *fcomp = (struct bfad_hal_comp *)arg; |
| 386 | |
| 387 | fcomp->status = status; |
| 388 | complete(&fcomp->comp); |
| 389 | } |
| 390 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 391 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 392 | * bfa_init callback |
| 393 | */ |
| 394 | void |
| 395 | bfa_cb_init(void *drv, bfa_status_t init_status) |
| 396 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 397 | struct bfad_s *bfad = drv; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 398 | |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 399 | if (init_status == BFA_STATUS_OK) { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 400 | bfad->bfad_flags |= BFAD_HAL_INIT_DONE; |
| 401 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 402 | /* |
| 403 | * If BFAD_HAL_INIT_FAIL flag is set: |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 404 | * Wake up the kernel thread to start |
| 405 | * the bfad operations after HAL init done |
| 406 | */ |
| 407 | if ((bfad->bfad_flags & BFAD_HAL_INIT_FAIL)) { |
| 408 | bfad->bfad_flags &= ~BFAD_HAL_INIT_FAIL; |
| 409 | wake_up_process(bfad->bfad_tsk); |
| 410 | } |
| 411 | } |
| 412 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 413 | complete(&bfad->comp); |
| 414 | } |
| 415 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 416 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 417 | * BFA_FCS callbacks |
| 418 | */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 419 | struct bfad_port_s * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 420 | bfa_fcb_lport_new(struct bfad_s *bfad, struct bfa_fcs_lport_s *port, |
| 421 | enum bfa_lport_role roles, struct bfad_vf_s *vf_drv, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 422 | struct bfad_vport_s *vp_drv) |
| 423 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 424 | bfa_status_t rc; |
| 425 | struct bfad_port_s *port_drv; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 426 | |
| 427 | if (!vp_drv && !vf_drv) { |
| 428 | port_drv = &bfad->pport; |
| 429 | port_drv->pvb_type = BFAD_PORT_PHYS_BASE; |
| 430 | } else if (!vp_drv && vf_drv) { |
| 431 | port_drv = &vf_drv->base_port; |
| 432 | port_drv->pvb_type = BFAD_PORT_VF_BASE; |
| 433 | } else if (vp_drv && !vf_drv) { |
| 434 | port_drv = &vp_drv->drv_port; |
| 435 | port_drv->pvb_type = BFAD_PORT_PHYS_VPORT; |
| 436 | } else { |
| 437 | port_drv = &vp_drv->drv_port; |
| 438 | port_drv->pvb_type = BFAD_PORT_VF_VPORT; |
| 439 | } |
| 440 | |
| 441 | port_drv->fcs_port = port; |
| 442 | port_drv->roles = roles; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 443 | |
| 444 | if (roles & BFA_LPORT_ROLE_FCP_IM) { |
| 445 | rc = bfad_im_port_new(bfad, port_drv); |
| 446 | if (rc != BFA_STATUS_OK) { |
| 447 | bfad_im_port_delete(bfad, port_drv); |
| 448 | port_drv = NULL; |
| 449 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | return port_drv; |
| 453 | } |
| 454 | |
| 455 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 456 | bfa_fcb_lport_delete(struct bfad_s *bfad, enum bfa_lport_role roles, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 457 | struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv) |
| 458 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 459 | struct bfad_port_s *port_drv; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 460 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 461 | /* this will be only called from rmmod context */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 462 | if (vp_drv && !vp_drv->comp_del) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 463 | port_drv = (vp_drv) ? (&(vp_drv)->drv_port) : |
| 464 | ((vf_drv) ? (&(vf_drv)->base_port) : |
| 465 | (&(bfad)->pport)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 466 | bfa_trc(bfad, roles); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 467 | if (roles & BFA_LPORT_ROLE_FCP_IM) |
| 468 | bfad_im_port_delete(bfad, port_drv); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 469 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 470 | } |
| 471 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 472 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 473 | * FCS RPORT alloc callback, after successful PLOGI by FCS |
| 474 | */ |
| 475 | bfa_status_t |
| 476 | bfa_fcb_rport_alloc(struct bfad_s *bfad, struct bfa_fcs_rport_s **rport, |
| 477 | struct bfad_rport_s **rport_drv) |
| 478 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 479 | bfa_status_t rc = BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 480 | |
| 481 | *rport_drv = kzalloc(sizeof(struct bfad_rport_s), GFP_ATOMIC); |
| 482 | if (*rport_drv == NULL) { |
| 483 | rc = BFA_STATUS_ENOMEM; |
| 484 | goto ext; |
| 485 | } |
| 486 | |
| 487 | *rport = &(*rport_drv)->fcs_rport; |
| 488 | |
| 489 | ext: |
| 490 | return rc; |
| 491 | } |
| 492 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 493 | /* |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 494 | * FCS PBC VPORT Create |
| 495 | */ |
| 496 | void |
| 497 | bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s pbc_vport) |
| 498 | { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 499 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 500 | struct bfa_lport_cfg_s port_cfg = {0}; |
| 501 | struct bfad_vport_s *vport; |
| 502 | int rc; |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 503 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 504 | vport = kzalloc(sizeof(struct bfad_vport_s), GFP_KERNEL); |
| 505 | if (!vport) { |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 506 | bfa_trc(bfad, 0); |
| 507 | return; |
| 508 | } |
| 509 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 510 | vport->drv_port.bfad = bfad; |
| 511 | port_cfg.roles = BFA_LPORT_ROLE_FCP_IM; |
| 512 | port_cfg.pwwn = pbc_vport.vp_pwwn; |
| 513 | port_cfg.nwwn = pbc_vport.vp_nwwn; |
| 514 | port_cfg.preboot_vp = BFA_TRUE; |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 515 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 516 | rc = bfa_fcs_pbc_vport_create(&vport->fcs_vport, &bfad->bfa_fcs, 0, |
| 517 | &port_cfg, vport); |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 518 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 519 | if (rc != BFA_STATUS_OK) { |
| 520 | bfa_trc(bfad, 0); |
| 521 | return; |
| 522 | } |
| 523 | |
| 524 | list_add_tail(&vport->list_entry, &bfad->pbc_vport_list); |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 525 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 526 | |
| 527 | void |
| 528 | bfad_hal_mem_release(struct bfad_s *bfad) |
| 529 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 530 | int i; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 531 | struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; |
| 532 | struct bfa_mem_elem_s *meminfo_elem; |
| 533 | |
| 534 | for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { |
| 535 | meminfo_elem = &hal_meminfo->meminfo[i]; |
| 536 | if (meminfo_elem->kva != NULL) { |
| 537 | switch (meminfo_elem->mem_type) { |
| 538 | case BFA_MEM_TYPE_KVA: |
| 539 | vfree(meminfo_elem->kva); |
| 540 | break; |
| 541 | case BFA_MEM_TYPE_DMA: |
| 542 | dma_free_coherent(&bfad->pcidev->dev, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 543 | meminfo_elem->mem_len, |
| 544 | meminfo_elem->kva, |
| 545 | (dma_addr_t) meminfo_elem->dma); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 546 | break; |
| 547 | default: |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 548 | WARN_ON(1); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 549 | break; |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | memset(hal_meminfo, 0, sizeof(struct bfa_meminfo_s)); |
| 555 | } |
| 556 | |
| 557 | void |
| 558 | bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg) |
| 559 | { |
| 560 | if (num_rports > 0) |
| 561 | bfa_cfg->fwcfg.num_rports = num_rports; |
| 562 | if (num_ios > 0) |
| 563 | bfa_cfg->fwcfg.num_ioim_reqs = num_ios; |
| 564 | if (num_tms > 0) |
| 565 | bfa_cfg->fwcfg.num_tskim_reqs = num_tms; |
| 566 | if (num_fcxps > 0) |
| 567 | bfa_cfg->fwcfg.num_fcxp_reqs = num_fcxps; |
| 568 | if (num_ufbufs > 0) |
| 569 | bfa_cfg->fwcfg.num_uf_bufs = num_ufbufs; |
| 570 | if (reqq_size > 0) |
| 571 | bfa_cfg->drvcfg.num_reqq_elems = reqq_size; |
| 572 | if (rspq_size > 0) |
| 573 | bfa_cfg->drvcfg.num_rspq_elems = rspq_size; |
| 574 | if (num_sgpgs > 0) |
| 575 | bfa_cfg->drvcfg.num_sgpgs = num_sgpgs; |
| 576 | |
| 577 | /* |
| 578 | * populate the hal values back to the driver for sysfs use. |
| 579 | * otherwise, the default values will be shown as 0 in sysfs |
| 580 | */ |
| 581 | num_rports = bfa_cfg->fwcfg.num_rports; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 582 | num_ios = bfa_cfg->fwcfg.num_ioim_reqs; |
| 583 | num_tms = bfa_cfg->fwcfg.num_tskim_reqs; |
| 584 | num_fcxps = bfa_cfg->fwcfg.num_fcxp_reqs; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 585 | num_ufbufs = bfa_cfg->fwcfg.num_uf_bufs; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 586 | reqq_size = bfa_cfg->drvcfg.num_reqq_elems; |
| 587 | rspq_size = bfa_cfg->drvcfg.num_rspq_elems; |
| 588 | num_sgpgs = bfa_cfg->drvcfg.num_sgpgs; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | bfa_status_t |
| 592 | bfad_hal_mem_alloc(struct bfad_s *bfad) |
| 593 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 594 | int i; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 595 | struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; |
| 596 | struct bfa_mem_elem_s *meminfo_elem; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 597 | dma_addr_t phys_addr; |
| 598 | void *kva; |
| 599 | bfa_status_t rc = BFA_STATUS_OK; |
| 600 | int retry_count = 0; |
| 601 | int reset_value = 1; |
| 602 | int min_num_sgpgs = 512; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 603 | |
| 604 | bfa_cfg_get_default(&bfad->ioc_cfg); |
| 605 | |
| 606 | retry: |
| 607 | bfad_update_hal_cfg(&bfad->ioc_cfg); |
| 608 | bfad->cfg_data.ioc_queue_depth = bfad->ioc_cfg.fwcfg.num_ioim_reqs; |
| 609 | bfa_cfg_get_meminfo(&bfad->ioc_cfg, hal_meminfo); |
| 610 | |
| 611 | for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { |
| 612 | meminfo_elem = &hal_meminfo->meminfo[i]; |
| 613 | switch (meminfo_elem->mem_type) { |
| 614 | case BFA_MEM_TYPE_KVA: |
| 615 | kva = vmalloc(meminfo_elem->mem_len); |
| 616 | if (kva == NULL) { |
| 617 | bfad_hal_mem_release(bfad); |
| 618 | rc = BFA_STATUS_ENOMEM; |
| 619 | goto ext; |
| 620 | } |
| 621 | memset(kva, 0, meminfo_elem->mem_len); |
| 622 | meminfo_elem->kva = kva; |
| 623 | break; |
| 624 | case BFA_MEM_TYPE_DMA: |
| 625 | kva = dma_alloc_coherent(&bfad->pcidev->dev, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 626 | meminfo_elem->mem_len, &phys_addr, GFP_KERNEL); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 627 | if (kva == NULL) { |
| 628 | bfad_hal_mem_release(bfad); |
| 629 | /* |
| 630 | * If we cannot allocate with default |
| 631 | * num_sgpages try with half the value. |
| 632 | */ |
| 633 | if (num_sgpgs > min_num_sgpgs) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 634 | printk(KERN_INFO |
| 635 | "bfad[%d]: memory allocation failed" |
| 636 | " with num_sgpgs: %d\n", |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 637 | bfad->inst_no, num_sgpgs); |
| 638 | nextLowerInt(&num_sgpgs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 639 | printk(KERN_INFO |
| 640 | "bfad[%d]: trying to allocate memory" |
| 641 | " with num_sgpgs: %d\n", |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 642 | bfad->inst_no, num_sgpgs); |
| 643 | retry_count++; |
| 644 | goto retry; |
| 645 | } else { |
| 646 | if (num_sgpgs_parm > 0) |
| 647 | num_sgpgs = num_sgpgs_parm; |
| 648 | else { |
| 649 | reset_value = |
| 650 | (1 << retry_count); |
| 651 | num_sgpgs *= reset_value; |
| 652 | } |
| 653 | rc = BFA_STATUS_ENOMEM; |
| 654 | goto ext; |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | if (num_sgpgs_parm > 0) |
| 659 | num_sgpgs = num_sgpgs_parm; |
| 660 | else { |
| 661 | reset_value = (1 << retry_count); |
| 662 | num_sgpgs *= reset_value; |
| 663 | } |
| 664 | |
| 665 | memset(kva, 0, meminfo_elem->mem_len); |
| 666 | meminfo_elem->kva = kva; |
| 667 | meminfo_elem->dma = phys_addr; |
| 668 | break; |
| 669 | default: |
| 670 | break; |
| 671 | |
| 672 | } |
| 673 | } |
| 674 | ext: |
| 675 | return rc; |
| 676 | } |
| 677 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 678 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 679 | * Create a vport under a vf. |
| 680 | */ |
| 681 | bfa_status_t |
| 682 | bfad_vport_create(struct bfad_s *bfad, u16 vf_id, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 683 | struct bfa_lport_cfg_s *port_cfg, struct device *dev) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 684 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 685 | struct bfad_vport_s *vport; |
| 686 | int rc = BFA_STATUS_OK; |
| 687 | unsigned long flags; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 688 | struct completion fcomp; |
| 689 | |
| 690 | vport = kzalloc(sizeof(struct bfad_vport_s), GFP_KERNEL); |
| 691 | if (!vport) { |
| 692 | rc = BFA_STATUS_ENOMEM; |
| 693 | goto ext; |
| 694 | } |
| 695 | |
| 696 | vport->drv_port.bfad = bfad; |
| 697 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 698 | rc = bfa_fcs_vport_create(&vport->fcs_vport, &bfad->bfa_fcs, vf_id, |
| 699 | port_cfg, vport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 700 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 701 | |
| 702 | if (rc != BFA_STATUS_OK) |
| 703 | goto ext_free_vport; |
| 704 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 705 | if (port_cfg->roles & BFA_LPORT_ROLE_FCP_IM) { |
Jing Huang | b504293 | 2010-03-19 11:05:39 -0700 | [diff] [blame] | 706 | rc = bfad_im_scsi_host_alloc(bfad, vport->drv_port.im_port, |
| 707 | dev); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 708 | if (rc != BFA_STATUS_OK) |
| 709 | goto ext_free_fcs_vport; |
| 710 | } |
| 711 | |
| 712 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 713 | bfa_fcs_vport_start(&vport->fcs_vport); |
| 714 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 715 | |
| 716 | return BFA_STATUS_OK; |
| 717 | |
| 718 | ext_free_fcs_vport: |
| 719 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 720 | vport->comp_del = &fcomp; |
| 721 | init_completion(vport->comp_del); |
| 722 | bfa_fcs_vport_delete(&vport->fcs_vport); |
| 723 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 724 | wait_for_completion(vport->comp_del); |
| 725 | ext_free_vport: |
| 726 | kfree(vport); |
| 727 | ext: |
| 728 | return rc; |
| 729 | } |
| 730 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 731 | void |
| 732 | bfad_bfa_tmo(unsigned long data) |
| 733 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 734 | struct bfad_s *bfad = (struct bfad_s *) data; |
| 735 | unsigned long flags; |
| 736 | struct list_head doneq; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 737 | |
| 738 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 739 | |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 740 | bfa_timer_beat(&bfad->bfa.timer_mod); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 741 | |
| 742 | bfa_comp_deq(&bfad->bfa, &doneq); |
| 743 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 744 | |
| 745 | if (!list_empty(&doneq)) { |
| 746 | bfa_comp_process(&bfad->bfa, &doneq); |
| 747 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 748 | bfa_comp_free(&bfad->bfa, &doneq); |
| 749 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 750 | } |
| 751 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 752 | mod_timer(&bfad->hal_tmo, |
| 753 | jiffies + msecs_to_jiffies(BFA_TIMER_FREQ)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | void |
| 757 | bfad_init_timer(struct bfad_s *bfad) |
| 758 | { |
| 759 | init_timer(&bfad->hal_tmo); |
| 760 | bfad->hal_tmo.function = bfad_bfa_tmo; |
| 761 | bfad->hal_tmo.data = (unsigned long)bfad; |
| 762 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 763 | mod_timer(&bfad->hal_tmo, |
| 764 | jiffies + msecs_to_jiffies(BFA_TIMER_FREQ)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | int |
| 768 | bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) |
| 769 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 770 | int rc = -ENODEV; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 771 | |
| 772 | if (pci_enable_device(pdev)) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 773 | printk(KERN_ERR "pci_enable_device fail %p\n", pdev); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 774 | goto out; |
| 775 | } |
| 776 | |
| 777 | if (pci_request_regions(pdev, BFAD_DRIVER_NAME)) |
| 778 | goto out_disable_device; |
| 779 | |
| 780 | pci_set_master(pdev); |
| 781 | |
| 782 | |
| 783 | if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) |
| 784 | if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 785 | printk(KERN_ERR "pci_set_dma_mask fail %p\n", pdev); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 786 | goto out_release_region; |
| 787 | } |
| 788 | |
Jing Huang | b3522f0 | 2010-03-19 11:06:44 -0700 | [diff] [blame] | 789 | bfad->pci_bar0_kva = pci_iomap(pdev, 0, pci_resource_len(pdev, 0)); |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 790 | bfad->pci_bar2_kva = pci_iomap(pdev, 2, pci_resource_len(pdev, 2)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 791 | |
| 792 | if (bfad->pci_bar0_kva == NULL) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 793 | printk(KERN_ERR "Fail to map bar0\n"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 794 | goto out_release_region; |
| 795 | } |
| 796 | |
| 797 | bfad->hal_pcidev.pci_slot = PCI_SLOT(pdev->devfn); |
| 798 | bfad->hal_pcidev.pci_func = PCI_FUNC(pdev->devfn); |
| 799 | bfad->hal_pcidev.pci_bar_kva = bfad->pci_bar0_kva; |
| 800 | bfad->hal_pcidev.device_id = pdev->device; |
| 801 | bfad->pci_name = pci_name(pdev); |
| 802 | |
| 803 | bfad->pci_attr.vendor_id = pdev->vendor; |
| 804 | bfad->pci_attr.device_id = pdev->device; |
| 805 | bfad->pci_attr.ssid = pdev->subsystem_device; |
| 806 | bfad->pci_attr.ssvid = pdev->subsystem_vendor; |
| 807 | bfad->pci_attr.pcifn = PCI_FUNC(pdev->devfn); |
| 808 | |
| 809 | bfad->pcidev = pdev; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 810 | |
| 811 | /* Adjust PCIe Maximum Read Request Size */ |
| 812 | if (pcie_max_read_reqsz > 0) { |
| 813 | int pcie_cap_reg; |
| 814 | u16 pcie_dev_ctl; |
| 815 | u16 mask = 0xffff; |
| 816 | |
| 817 | switch (pcie_max_read_reqsz) { |
| 818 | case 128: |
| 819 | mask = 0x0; |
| 820 | break; |
| 821 | case 256: |
| 822 | mask = 0x1000; |
| 823 | break; |
| 824 | case 512: |
| 825 | mask = 0x2000; |
| 826 | break; |
| 827 | case 1024: |
| 828 | mask = 0x3000; |
| 829 | break; |
| 830 | case 2048: |
| 831 | mask = 0x4000; |
| 832 | break; |
| 833 | case 4096: |
| 834 | mask = 0x5000; |
| 835 | break; |
| 836 | default: |
| 837 | break; |
| 838 | } |
| 839 | |
| 840 | pcie_cap_reg = pci_find_capability(pdev, PCI_CAP_ID_EXP); |
| 841 | if (mask != 0xffff && pcie_cap_reg) { |
| 842 | pcie_cap_reg += 0x08; |
| 843 | pci_read_config_word(pdev, pcie_cap_reg, &pcie_dev_ctl); |
| 844 | if ((pcie_dev_ctl & 0x7000) != mask) { |
| 845 | printk(KERN_WARNING "BFA[%s]: " |
| 846 | "pcie_max_read_request_size is %d, " |
| 847 | "reset to %d\n", bfad->pci_name, |
| 848 | (1 << ((pcie_dev_ctl & 0x7000) >> 12)) << 7, |
| 849 | pcie_max_read_reqsz); |
| 850 | |
| 851 | pcie_dev_ctl &= ~0x7000; |
| 852 | pci_write_config_word(pdev, pcie_cap_reg, |
| 853 | pcie_dev_ctl | mask); |
| 854 | } |
| 855 | } |
| 856 | } |
| 857 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 858 | return 0; |
| 859 | |
| 860 | out_release_region: |
| 861 | pci_release_regions(pdev); |
| 862 | out_disable_device: |
| 863 | pci_disable_device(pdev); |
| 864 | out: |
| 865 | return rc; |
| 866 | } |
| 867 | |
| 868 | void |
| 869 | bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad) |
| 870 | { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 871 | pci_iounmap(pdev, bfad->pci_bar0_kva); |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 872 | pci_iounmap(pdev, bfad->pci_bar2_kva); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 873 | pci_release_regions(pdev); |
| 874 | pci_disable_device(pdev); |
| 875 | pci_set_drvdata(pdev, NULL); |
| 876 | } |
| 877 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 878 | bfa_status_t |
| 879 | bfad_drv_init(struct bfad_s *bfad) |
| 880 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 881 | bfa_status_t rc; |
| 882 | unsigned long flags; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 883 | |
| 884 | bfad->cfg_data.rport_del_timeout = rport_del_timeout; |
| 885 | bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth; |
| 886 | bfad->cfg_data.io_max_sge = bfa_io_max_sge; |
| 887 | bfad->cfg_data.binding_method = FCP_PWWN_BINDING; |
| 888 | |
| 889 | rc = bfad_hal_mem_alloc(bfad); |
| 890 | if (rc != BFA_STATUS_OK) { |
| 891 | printk(KERN_WARNING "bfad%d bfad_hal_mem_alloc failure\n", |
| 892 | bfad->inst_no); |
| 893 | printk(KERN_WARNING |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 894 | "Not enough memory to attach all Brocade HBA ports, %s", |
| 895 | "System may need more memory.\n"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 896 | goto out_hal_mem_alloc_failure; |
| 897 | } |
| 898 | |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 899 | bfad->bfa.trcmod = bfad->trcmod; |
| 900 | bfad->bfa.plog = &bfad->plog_buf; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 901 | bfa_plog_init(&bfad->plog_buf); |
| 902 | bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START, |
| 903 | 0, "Driver Attach"); |
| 904 | |
| 905 | bfa_attach(&bfad->bfa, bfad, &bfad->ioc_cfg, &bfad->meminfo, |
| 906 | &bfad->hal_pcidev); |
| 907 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 908 | /* FCS INIT */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 909 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 910 | bfad->bfa_fcs.trcmod = bfad->trcmod; |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 911 | bfa_fcs_attach(&bfad->bfa_fcs, &bfad->bfa, bfad, BFA_FALSE); |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 912 | bfad->bfa_fcs.fdmi_enabled = fdmi_enable; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 913 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 914 | |
| 915 | bfad->bfad_flags |= BFAD_DRV_INIT_DONE; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 916 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 917 | return BFA_STATUS_OK; |
| 918 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 919 | out_hal_mem_alloc_failure: |
| 920 | return BFA_STATUS_FAILED; |
| 921 | } |
| 922 | |
| 923 | void |
| 924 | bfad_drv_uninit(struct bfad_s *bfad) |
| 925 | { |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 926 | unsigned long flags; |
| 927 | |
| 928 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 929 | init_completion(&bfad->comp); |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 930 | bfa_iocfc_stop(&bfad->bfa); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 931 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 932 | wait_for_completion(&bfad->comp); |
| 933 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 934 | del_timer_sync(&bfad->hal_tmo); |
| 935 | bfa_isr_disable(&bfad->bfa); |
| 936 | bfa_detach(&bfad->bfa); |
| 937 | bfad_remove_intr(bfad); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 938 | bfad_hal_mem_release(bfad); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 939 | |
| 940 | bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | void |
| 944 | bfad_drv_start(struct bfad_s *bfad) |
| 945 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 946 | unsigned long flags; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 947 | |
| 948 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 949 | bfa_iocfc_start(&bfad->bfa); |
| 950 | bfa_fcs_fabric_modstart(&bfad->bfa_fcs); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 951 | bfad->bfad_flags |= BFAD_HAL_START_DONE; |
| 952 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 953 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 954 | if (bfad->im) |
| 955 | flush_workqueue(bfad->im->drv_workq); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 959 | bfad_fcs_stop(struct bfad_s *bfad) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 960 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 961 | unsigned long flags; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 962 | |
| 963 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 964 | init_completion(&bfad->comp); |
| 965 | bfad->pport.flags |= BFAD_PORT_DELETE; |
| 966 | bfa_fcs_exit(&bfad->bfa_fcs); |
| 967 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 968 | wait_for_completion(&bfad->comp); |
| 969 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 970 | bfa_sm_send_event(bfad, BFAD_E_FCS_EXIT_COMP); |
| 971 | } |
| 972 | |
| 973 | void |
| 974 | bfad_stop(struct bfad_s *bfad) |
| 975 | { |
| 976 | unsigned long flags; |
| 977 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 978 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 979 | init_completion(&bfad->comp); |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 980 | bfa_iocfc_stop(&bfad->bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 981 | bfad->bfad_flags &= ~BFAD_HAL_START_DONE; |
| 982 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 983 | wait_for_completion(&bfad->comp); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 984 | |
| 985 | bfa_sm_send_event(bfad, BFAD_E_EXIT_COMP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | bfa_status_t |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 989 | bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 990 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 991 | int rc = BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 992 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 993 | /* Allocate scsi_host for the physical port */ |
| 994 | if ((supported_fc4s & BFA_LPORT_ROLE_FCP_IM) && |
| 995 | (role & BFA_LPORT_ROLE_FCP_IM)) { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 996 | if (bfad->pport.im_port == NULL) { |
| 997 | rc = BFA_STATUS_FAILED; |
| 998 | goto out; |
| 999 | } |
| 1000 | |
Jing Huang | b504293 | 2010-03-19 11:05:39 -0700 | [diff] [blame] | 1001 | rc = bfad_im_scsi_host_alloc(bfad, bfad->pport.im_port, |
| 1002 | &bfad->pcidev->dev); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1003 | if (rc != BFA_STATUS_OK) |
| 1004 | goto out; |
| 1005 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1006 | bfad->pport.roles |= BFA_LPORT_ROLE_FCP_IM; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | bfad->bfad_flags |= BFAD_CFG_PPORT_DONE; |
| 1010 | |
| 1011 | out: |
| 1012 | return rc; |
| 1013 | } |
| 1014 | |
| 1015 | void |
| 1016 | bfad_uncfg_pport(struct bfad_s *bfad) |
| 1017 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1018 | if ((supported_fc4s & BFA_LPORT_ROLE_FCP_IM) && |
| 1019 | (bfad->pport.roles & BFA_LPORT_ROLE_FCP_IM)) { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1020 | bfad_im_scsi_host_free(bfad, bfad->pport.im_port); |
| 1021 | bfad_im_port_clean(bfad->pport.im_port); |
| 1022 | kfree(bfad->pport.im_port); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1023 | bfad->pport.roles &= ~BFA_LPORT_ROLE_FCP_IM; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | bfad->bfad_flags &= ~BFAD_CFG_PPORT_DONE; |
| 1027 | } |
| 1028 | |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1029 | bfa_status_t |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1030 | bfad_start_ops(struct bfad_s *bfad) { |
| 1031 | |
| 1032 | int retval; |
| 1033 | unsigned long flags; |
| 1034 | struct bfad_vport_s *vport, *vport_new; |
| 1035 | struct bfa_fcs_driver_info_s driver_info; |
| 1036 | |
| 1037 | /* Fill the driver_info info to fcs*/ |
| 1038 | memset(&driver_info, 0, sizeof(driver_info)); |
| 1039 | strncpy(driver_info.version, BFAD_DRIVER_VERSION, |
| 1040 | sizeof(driver_info.version) - 1); |
| 1041 | if (host_name) |
| 1042 | strncpy(driver_info.host_machine_name, host_name, |
| 1043 | sizeof(driver_info.host_machine_name) - 1); |
| 1044 | if (os_name) |
| 1045 | strncpy(driver_info.host_os_name, os_name, |
| 1046 | sizeof(driver_info.host_os_name) - 1); |
| 1047 | if (os_patch) |
| 1048 | strncpy(driver_info.host_os_patch, os_patch, |
| 1049 | sizeof(driver_info.host_os_patch) - 1); |
| 1050 | |
| 1051 | strncpy(driver_info.os_device_name, bfad->pci_name, |
| 1052 | sizeof(driver_info.os_device_name - 1)); |
| 1053 | |
| 1054 | /* FCS INIT */ |
| 1055 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1056 | bfa_fcs_driver_info_init(&bfad->bfa_fcs, &driver_info); |
| 1057 | bfa_fcs_init(&bfad->bfa_fcs); |
| 1058 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1059 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1060 | retval = bfad_cfg_pport(bfad, BFA_LPORT_ROLE_FCP_IM); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1061 | if (retval != BFA_STATUS_OK) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1062 | if (bfa_sm_cmp_state(bfad, bfad_sm_initializing)) |
| 1063 | bfa_sm_set_state(bfad, bfad_sm_failed); |
| 1064 | bfad_stop(bfad); |
| 1065 | return BFA_STATUS_FAILED; |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1066 | } |
| 1067 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1068 | /* BFAD level FC4 IM specific resource allocation */ |
| 1069 | retval = bfad_im_probe(bfad); |
| 1070 | if (retval != BFA_STATUS_OK) { |
| 1071 | printk(KERN_WARNING "bfad_im_probe failed\n"); |
| 1072 | if (bfa_sm_cmp_state(bfad, bfad_sm_initializing)) |
| 1073 | bfa_sm_set_state(bfad, bfad_sm_failed); |
| 1074 | bfad_im_probe_undo(bfad); |
| 1075 | bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE; |
| 1076 | bfad_uncfg_pport(bfad); |
| 1077 | bfad_stop(bfad); |
| 1078 | return BFA_STATUS_FAILED; |
| 1079 | } else |
| 1080 | bfad->bfad_flags |= BFAD_FC4_PROBE_DONE; |
| 1081 | |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1082 | bfad_drv_start(bfad); |
| 1083 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1084 | /* Complete pbc vport create */ |
| 1085 | list_for_each_entry_safe(vport, vport_new, &bfad->pbc_vport_list, |
| 1086 | list_entry) { |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 1087 | struct fc_vport_identifiers vid; |
| 1088 | struct fc_vport *fc_vport; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1089 | char pwwn_buf[BFA_STRING_32]; |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 1090 | |
| 1091 | memset(&vid, 0, sizeof(vid)); |
| 1092 | vid.roles = FC_PORT_ROLE_FCP_INITIATOR; |
| 1093 | vid.vport_type = FC_PORTTYPE_NPIV; |
| 1094 | vid.disable = false; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1095 | vid.node_name = wwn_to_u64((u8 *) |
| 1096 | (&((vport->fcs_vport).lport.port_cfg.nwwn))); |
| 1097 | vid.port_name = wwn_to_u64((u8 *) |
| 1098 | (&((vport->fcs_vport).lport.port_cfg.pwwn))); |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 1099 | fc_vport = fc_vport_create(bfad->pport.im_port->shost, 0, &vid); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1100 | if (!fc_vport) { |
| 1101 | wwn2str(pwwn_buf, vid.port_name); |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 1102 | printk(KERN_WARNING "bfad%d: failed to create pbc vport" |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1103 | " %s\n", bfad->inst_no, pwwn_buf); |
| 1104 | } |
| 1105 | list_del(&vport->list_entry); |
| 1106 | kfree(vport); |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1109 | /* |
| 1110 | * If bfa_linkup_delay is set to -1 default; try to retrive the |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 1111 | * value using the bfad_get_linkup_delay(); else use the |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1112 | * passed in module param value as the bfa_linkup_delay. |
| 1113 | */ |
| 1114 | if (bfa_linkup_delay < 0) { |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 1115 | bfa_linkup_delay = bfad_get_linkup_delay(bfad); |
| 1116 | bfad_rport_online_wait(bfad); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1117 | bfa_linkup_delay = -1; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1118 | } else |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 1119 | bfad_rport_online_wait(bfad); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1120 | |
Jing Huang | 8816624 | 2010-12-09 17:11:53 -0800 | [diff] [blame] | 1121 | BFA_LOG(KERN_INFO, bfad, bfa_log_level, "bfa device claimed\n"); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1122 | |
| 1123 | return BFA_STATUS_OK; |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | int |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 1127 | bfad_worker(void *ptr) |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1128 | { |
| 1129 | struct bfad_s *bfad; |
| 1130 | unsigned long flags; |
| 1131 | |
| 1132 | bfad = (struct bfad_s *)ptr; |
| 1133 | |
| 1134 | while (!kthread_should_stop()) { |
| 1135 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1136 | /* Send event BFAD_E_INIT_SUCCESS */ |
| 1137 | bfa_sm_send_event(bfad, BFAD_E_INIT_SUCCESS); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1138 | |
| 1139 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1140 | bfad->bfad_tsk = NULL; |
| 1141 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 1142 | |
| 1143 | break; |
| 1144 | } |
| 1145 | |
| 1146 | return 0; |
| 1147 | } |
| 1148 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1149 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1150 | * BFA driver interrupt functions |
| 1151 | */ |
| 1152 | irqreturn_t |
| 1153 | bfad_intx(int irq, void *dev_id) |
| 1154 | { |
| 1155 | struct bfad_s *bfad = dev_id; |
| 1156 | struct list_head doneq; |
| 1157 | unsigned long flags; |
| 1158 | bfa_boolean_t rc; |
| 1159 | |
| 1160 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1161 | rc = bfa_intx(&bfad->bfa); |
| 1162 | if (!rc) { |
| 1163 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 1164 | return IRQ_NONE; |
| 1165 | } |
| 1166 | |
| 1167 | bfa_comp_deq(&bfad->bfa, &doneq); |
| 1168 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 1169 | |
| 1170 | if (!list_empty(&doneq)) { |
| 1171 | bfa_comp_process(&bfad->bfa, &doneq); |
| 1172 | |
| 1173 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1174 | bfa_comp_free(&bfad->bfa, &doneq); |
| 1175 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | return IRQ_HANDLED; |
| 1179 | |
| 1180 | } |
| 1181 | |
| 1182 | static irqreturn_t |
| 1183 | bfad_msix(int irq, void *dev_id) |
| 1184 | { |
| 1185 | struct bfad_msix_s *vec = dev_id; |
| 1186 | struct bfad_s *bfad = vec->bfad; |
| 1187 | struct list_head doneq; |
| 1188 | unsigned long flags; |
| 1189 | |
| 1190 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1191 | |
| 1192 | bfa_msix(&bfad->bfa, vec->msix.entry); |
| 1193 | bfa_comp_deq(&bfad->bfa, &doneq); |
| 1194 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 1195 | |
| 1196 | if (!list_empty(&doneq)) { |
| 1197 | bfa_comp_process(&bfad->bfa, &doneq); |
| 1198 | |
| 1199 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1200 | bfa_comp_free(&bfad->bfa, &doneq); |
| 1201 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 1202 | } |
| 1203 | |
| 1204 | return IRQ_HANDLED; |
| 1205 | } |
| 1206 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1207 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1208 | * Initialize the MSIX entry table. |
| 1209 | */ |
| 1210 | static void |
| 1211 | bfad_init_msix_entry(struct bfad_s *bfad, struct msix_entry *msix_entries, |
| 1212 | int mask, int max_bit) |
| 1213 | { |
| 1214 | int i; |
| 1215 | int match = 0x00000001; |
| 1216 | |
| 1217 | for (i = 0, bfad->nvec = 0; i < MAX_MSIX_ENTRY; i++) { |
| 1218 | if (mask & match) { |
| 1219 | bfad->msix_tab[bfad->nvec].msix.entry = i; |
| 1220 | bfad->msix_tab[bfad->nvec].bfad = bfad; |
| 1221 | msix_entries[bfad->nvec].entry = i; |
| 1222 | bfad->nvec++; |
| 1223 | } |
| 1224 | |
| 1225 | match <<= 1; |
| 1226 | } |
| 1227 | |
| 1228 | } |
| 1229 | |
| 1230 | int |
| 1231 | bfad_install_msix_handler(struct bfad_s *bfad) |
| 1232 | { |
| 1233 | int i, error = 0; |
| 1234 | |
| 1235 | for (i = 0; i < bfad->nvec; i++) { |
| 1236 | sprintf(bfad->msix_tab[i].name, "bfa-%s-%s", |
| 1237 | bfad->pci_name, |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1238 | ((bfa_asic_id_cb(bfad->hal_pcidev.device_id)) ? |
| 1239 | msix_name_cb[i] : msix_name_ct[i])); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1240 | |
| 1241 | error = request_irq(bfad->msix_tab[i].msix.vector, |
| 1242 | (irq_handler_t) bfad_msix, 0, |
| 1243 | bfad->msix_tab[i].name, &bfad->msix_tab[i]); |
| 1244 | bfa_trc(bfad, i); |
| 1245 | bfa_trc(bfad, bfad->msix_tab[i].msix.vector); |
| 1246 | if (error) { |
| 1247 | int j; |
| 1248 | |
| 1249 | for (j = 0; j < i; j++) |
| 1250 | free_irq(bfad->msix_tab[j].msix.vector, |
| 1251 | &bfad->msix_tab[j]); |
| 1252 | |
| 1253 | return 1; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | return 0; |
| 1258 | } |
| 1259 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1260 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1261 | * Setup MSIX based interrupt. |
| 1262 | */ |
| 1263 | int |
| 1264 | bfad_setup_intr(struct bfad_s *bfad) |
| 1265 | { |
| 1266 | int error = 0; |
| 1267 | u32 mask = 0, i, num_bit = 0, max_bit = 0; |
| 1268 | struct msix_entry msix_entries[MAX_MSIX_ENTRY]; |
| 1269 | struct pci_dev *pdev = bfad->pcidev; |
| 1270 | |
| 1271 | /* Call BFA to get the msix map for this PCI function. */ |
| 1272 | bfa_msix_getvecs(&bfad->bfa, &mask, &num_bit, &max_bit); |
| 1273 | |
| 1274 | /* Set up the msix entry table */ |
| 1275 | bfad_init_msix_entry(bfad, msix_entries, mask, max_bit); |
| 1276 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1277 | if ((bfa_asic_id_ctc(pdev->device) && !msix_disable_ct) || |
| 1278 | (bfa_asic_id_cb(pdev->device) && !msix_disable_cb)) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1279 | |
| 1280 | error = pci_enable_msix(bfad->pcidev, msix_entries, bfad->nvec); |
| 1281 | if (error) { |
| 1282 | /* |
| 1283 | * Only error number of vector is available. |
| 1284 | * We don't have a mechanism to map multiple |
| 1285 | * interrupts into one vector, so even if we |
| 1286 | * can try to request less vectors, we don't |
| 1287 | * know how to associate interrupt events to |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1288 | * vectors. Linux doesn't duplicate vectors |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1289 | * in the MSIX table for this case. |
| 1290 | */ |
| 1291 | |
| 1292 | printk(KERN_WARNING "bfad%d: " |
| 1293 | "pci_enable_msix failed (%d)," |
| 1294 | " use line based.\n", bfad->inst_no, error); |
| 1295 | |
| 1296 | goto line_based; |
| 1297 | } |
| 1298 | |
| 1299 | /* Save the vectors */ |
| 1300 | for (i = 0; i < bfad->nvec; i++) { |
| 1301 | bfa_trc(bfad, msix_entries[i].vector); |
| 1302 | bfad->msix_tab[i].msix.vector = msix_entries[i].vector; |
| 1303 | } |
| 1304 | |
| 1305 | bfa_msix_init(&bfad->bfa, bfad->nvec); |
| 1306 | |
| 1307 | bfad->bfad_flags |= BFAD_MSIX_ON; |
| 1308 | |
| 1309 | return error; |
| 1310 | } |
| 1311 | |
| 1312 | line_based: |
| 1313 | error = 0; |
| 1314 | if (request_irq |
| 1315 | (bfad->pcidev->irq, (irq_handler_t) bfad_intx, BFAD_IRQ_FLAGS, |
| 1316 | BFAD_DRIVER_NAME, bfad) != 0) { |
| 1317 | /* Enable interrupt handler failed */ |
| 1318 | return 1; |
| 1319 | } |
| 1320 | |
| 1321 | return error; |
| 1322 | } |
| 1323 | |
| 1324 | void |
| 1325 | bfad_remove_intr(struct bfad_s *bfad) |
| 1326 | { |
| 1327 | int i; |
| 1328 | |
| 1329 | if (bfad->bfad_flags & BFAD_MSIX_ON) { |
| 1330 | for (i = 0; i < bfad->nvec; i++) |
| 1331 | free_irq(bfad->msix_tab[i].msix.vector, |
| 1332 | &bfad->msix_tab[i]); |
| 1333 | |
| 1334 | pci_disable_msix(bfad->pcidev); |
| 1335 | bfad->bfad_flags &= ~BFAD_MSIX_ON; |
| 1336 | } else { |
| 1337 | free_irq(bfad->pcidev->irq, bfad); |
| 1338 | } |
| 1339 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1340 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1341 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1342 | * PCI probe entry. |
| 1343 | */ |
| 1344 | int |
| 1345 | bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) |
| 1346 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1347 | struct bfad_s *bfad; |
| 1348 | int error = -ENODEV, retval; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1349 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1350 | /* For single port cards - only claim function 0 */ |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1351 | if ((pdev->device == BFA_PCI_DEVICE_ID_FC_8G1P || |
| 1352 | pdev->device == BFA_PCI_DEVICE_ID_CT2) && |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1353 | (PCI_FUNC(pdev->devfn) != 0)) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1354 | return -ENODEV; |
| 1355 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1356 | bfad = kzalloc(sizeof(struct bfad_s), GFP_KERNEL); |
| 1357 | if (!bfad) { |
| 1358 | error = -ENOMEM; |
| 1359 | goto out; |
| 1360 | } |
| 1361 | |
| 1362 | bfad->trcmod = kzalloc(sizeof(struct bfa_trc_mod_s), GFP_KERNEL); |
| 1363 | if (!bfad->trcmod) { |
| 1364 | printk(KERN_WARNING "Error alloc trace buffer!\n"); |
| 1365 | error = -ENOMEM; |
| 1366 | goto out_alloc_trace_failure; |
| 1367 | } |
| 1368 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1369 | /* TRACE INIT */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1370 | bfa_trc_init(bfad->trcmod); |
| 1371 | bfa_trc(bfad, bfad_inst); |
| 1372 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1373 | if (!(bfad_load_fwimg(pdev))) { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1374 | kfree(bfad->trcmod); |
| 1375 | goto out_alloc_trace_failure; |
| 1376 | } |
| 1377 | |
| 1378 | retval = bfad_pci_init(pdev, bfad); |
| 1379 | if (retval) { |
| 1380 | printk(KERN_WARNING "bfad_pci_init failure!\n"); |
| 1381 | error = retval; |
| 1382 | goto out_pci_init_failure; |
| 1383 | } |
| 1384 | |
| 1385 | mutex_lock(&bfad_mutex); |
| 1386 | bfad->inst_no = bfad_inst++; |
| 1387 | list_add_tail(&bfad->list_entry, &bfad_list); |
| 1388 | mutex_unlock(&bfad_mutex); |
| 1389 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1390 | /* Initializing the state machine: State set to uninit */ |
| 1391 | bfa_sm_set_state(bfad, bfad_sm_uninit); |
| 1392 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1393 | spin_lock_init(&bfad->bfad_lock); |
| 1394 | pci_set_drvdata(pdev, bfad); |
| 1395 | |
| 1396 | bfad->ref_count = 0; |
| 1397 | bfad->pport.bfad = bfad; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1398 | INIT_LIST_HEAD(&bfad->pbc_vport_list); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1399 | |
Krishna Gudipati | 7c38c05 | 2011-04-14 16:50:35 -0700 | [diff] [blame] | 1400 | /* Setup the debugfs node for this bfad */ |
| 1401 | if (bfa_debugfs_enable) |
| 1402 | bfad_debugfs_init(&bfad->pport); |
| 1403 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1404 | retval = bfad_drv_init(bfad); |
| 1405 | if (retval != BFA_STATUS_OK) |
| 1406 | goto out_drv_init_failure; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1407 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1408 | bfa_sm_send_event(bfad, BFAD_E_CREATE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1409 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1410 | if (bfa_sm_cmp_state(bfad, bfad_sm_uninit)) |
| 1411 | goto out_bfad_sm_failure; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1412 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1413 | return 0; |
| 1414 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1415 | out_bfad_sm_failure: |
| 1416 | bfa_detach(&bfad->bfa); |
| 1417 | bfad_hal_mem_release(bfad); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1418 | out_drv_init_failure: |
Krishna Gudipati | 7c38c05 | 2011-04-14 16:50:35 -0700 | [diff] [blame] | 1419 | /* Remove the debugfs node for this bfad */ |
| 1420 | kfree(bfad->regdata); |
| 1421 | bfad_debugfs_exit(&bfad->pport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1422 | mutex_lock(&bfad_mutex); |
| 1423 | bfad_inst--; |
| 1424 | list_del(&bfad->list_entry); |
| 1425 | mutex_unlock(&bfad_mutex); |
| 1426 | bfad_pci_uninit(pdev, bfad); |
| 1427 | out_pci_init_failure: |
| 1428 | kfree(bfad->trcmod); |
| 1429 | out_alloc_trace_failure: |
| 1430 | kfree(bfad); |
| 1431 | out: |
| 1432 | return error; |
| 1433 | } |
| 1434 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1435 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1436 | * PCI remove entry. |
| 1437 | */ |
| 1438 | void |
| 1439 | bfad_pci_remove(struct pci_dev *pdev) |
| 1440 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1441 | struct bfad_s *bfad = pci_get_drvdata(pdev); |
| 1442 | unsigned long flags; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1443 | |
| 1444 | bfa_trc(bfad, bfad->inst_no); |
| 1445 | |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1446 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1447 | if (bfad->bfad_tsk != NULL) { |
| 1448 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
Krishna Gudipati | e671432 | 2010-03-03 17:44:02 -0800 | [diff] [blame] | 1449 | kthread_stop(bfad->bfad_tsk); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1450 | } else { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1451 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1452 | } |
| 1453 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1454 | /* Send Event BFAD_E_STOP */ |
| 1455 | bfa_sm_send_event(bfad, BFAD_E_STOP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1456 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1457 | /* Driver detach and dealloc mem */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1458 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
| 1459 | bfa_detach(&bfad->bfa); |
| 1460 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
| 1461 | bfad_hal_mem_release(bfad); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1462 | |
Krishna Gudipati | 7c38c05 | 2011-04-14 16:50:35 -0700 | [diff] [blame] | 1463 | /* Remove the debugfs node for this bfad */ |
| 1464 | kfree(bfad->regdata); |
| 1465 | bfad_debugfs_exit(&bfad->pport); |
| 1466 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1467 | /* Cleaning the BFAD instance */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1468 | mutex_lock(&bfad_mutex); |
| 1469 | bfad_inst--; |
| 1470 | list_del(&bfad->list_entry); |
| 1471 | mutex_unlock(&bfad_mutex); |
| 1472 | bfad_pci_uninit(pdev, bfad); |
| 1473 | |
| 1474 | kfree(bfad->trcmod); |
| 1475 | kfree(bfad); |
| 1476 | } |
| 1477 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1478 | struct pci_device_id bfad_id_table[] = { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1479 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1480 | .vendor = BFA_PCI_VENDOR_ID_BROCADE, |
| 1481 | .device = BFA_PCI_DEVICE_ID_FC_8G2P, |
| 1482 | .subvendor = PCI_ANY_ID, |
| 1483 | .subdevice = PCI_ANY_ID, |
| 1484 | }, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1485 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1486 | .vendor = BFA_PCI_VENDOR_ID_BROCADE, |
| 1487 | .device = BFA_PCI_DEVICE_ID_FC_8G1P, |
| 1488 | .subvendor = PCI_ANY_ID, |
| 1489 | .subdevice = PCI_ANY_ID, |
| 1490 | }, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1491 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1492 | .vendor = BFA_PCI_VENDOR_ID_BROCADE, |
| 1493 | .device = BFA_PCI_DEVICE_ID_CT, |
| 1494 | .subvendor = PCI_ANY_ID, |
| 1495 | .subdevice = PCI_ANY_ID, |
| 1496 | .class = (PCI_CLASS_SERIAL_FIBER << 8), |
| 1497 | .class_mask = ~0, |
| 1498 | }, |
Jing Huang | 293f82d | 2010-07-08 19:45:20 -0700 | [diff] [blame] | 1499 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1500 | .vendor = BFA_PCI_VENDOR_ID_BROCADE, |
| 1501 | .device = BFA_PCI_DEVICE_ID_CT_FC, |
| 1502 | .subvendor = PCI_ANY_ID, |
| 1503 | .subdevice = PCI_ANY_ID, |
| 1504 | .class = (PCI_CLASS_SERIAL_FIBER << 8), |
| 1505 | .class_mask = ~0, |
Jing Huang | 293f82d | 2010-07-08 19:45:20 -0700 | [diff] [blame] | 1506 | }, |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1507 | { |
| 1508 | .vendor = BFA_PCI_VENDOR_ID_BROCADE, |
| 1509 | .device = BFA_PCI_DEVICE_ID_CT2, |
| 1510 | .subvendor = PCI_ANY_ID, |
| 1511 | .subdevice = PCI_ANY_ID, |
| 1512 | .class = (PCI_CLASS_SERIAL_FIBER << 8), |
| 1513 | .class_mask = ~0, |
| 1514 | }, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1515 | |
| 1516 | {0, 0}, |
| 1517 | }; |
| 1518 | |
| 1519 | MODULE_DEVICE_TABLE(pci, bfad_id_table); |
| 1520 | |
| 1521 | static struct pci_driver bfad_pci_driver = { |
| 1522 | .name = BFAD_DRIVER_NAME, |
| 1523 | .id_table = bfad_id_table, |
| 1524 | .probe = bfad_pci_probe, |
| 1525 | .remove = __devexit_p(bfad_pci_remove), |
| 1526 | }; |
| 1527 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1528 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1529 | * Driver module init. |
| 1530 | */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1531 | static int __init |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1532 | bfad_init(void) |
| 1533 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1534 | int error = 0; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1535 | |
| 1536 | printk(KERN_INFO "Brocade BFA FC/FCOE SCSI driver - version: %s\n", |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1537 | BFAD_DRIVER_VERSION); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1538 | |
| 1539 | if (num_sgpgs > 0) |
| 1540 | num_sgpgs_parm = num_sgpgs; |
| 1541 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1542 | error = bfad_im_module_init(); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1543 | if (error) { |
| 1544 | error = -ENOMEM; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1545 | printk(KERN_WARNING "bfad_im_module_init failure\n"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1546 | goto ext; |
| 1547 | } |
| 1548 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1549 | if (strcmp(FCPI_NAME, " fcpim") == 0) |
| 1550 | supported_fc4s |= BFA_LPORT_ROLE_FCP_IM; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1551 | |
Maggie Zhang | f7f7381 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 1552 | bfa_auto_recover = ioc_auto_recover; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1553 | bfa_fcs_rport_set_del_timeout(rport_del_timeout); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1554 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1555 | error = pci_register_driver(&bfad_pci_driver); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1556 | if (error) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1557 | printk(KERN_WARNING "pci_register_driver failure\n"); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1558 | goto ext; |
| 1559 | } |
| 1560 | |
| 1561 | return 0; |
| 1562 | |
| 1563 | ext: |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1564 | bfad_im_module_exit(); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1565 | return error; |
| 1566 | } |
| 1567 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1568 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1569 | * Driver module exit. |
| 1570 | */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1571 | static void __exit |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1572 | bfad_exit(void) |
| 1573 | { |
| 1574 | pci_unregister_driver(&bfad_pci_driver); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1575 | bfad_im_module_exit(); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1576 | bfad_free_fwimg(); |
| 1577 | } |
| 1578 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1579 | /* Firmware handling */ |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1580 | static void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1581 | bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image, |
| 1582 | u32 *bfi_image_size, char *fw_name) |
| 1583 | { |
| 1584 | const struct firmware *fw; |
| 1585 | |
| 1586 | if (request_firmware(&fw, fw_name, &pdev->dev)) { |
| 1587 | printk(KERN_ALERT "Can't locate firmware %s\n", fw_name); |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1588 | *bfi_image = NULL; |
| 1589 | goto out; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1590 | } |
| 1591 | |
| 1592 | *bfi_image = vmalloc(fw->size); |
| 1593 | if (NULL == *bfi_image) { |
| 1594 | printk(KERN_ALERT "Fail to allocate buffer for fw image " |
| 1595 | "size=%x!\n", (u32) fw->size); |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1596 | goto out; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1597 | } |
| 1598 | |
| 1599 | memcpy(*bfi_image, fw->data, fw->size); |
| 1600 | *bfi_image_size = fw->size/sizeof(u32); |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1601 | out: |
| 1602 | release_firmware(fw); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1603 | } |
| 1604 | |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1605 | static u32 * |
| 1606 | bfad_load_fwimg(struct pci_dev *pdev) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1607 | { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1608 | if (pdev->device == BFA_PCI_DEVICE_ID_CT2) { |
| 1609 | if (bfi_image_ct2_size == 0) |
| 1610 | bfad_read_firmware(pdev, &bfi_image_ct2, |
| 1611 | &bfi_image_ct2_size, BFAD_FW_FILE_CT2); |
| 1612 | return bfi_image_ct2; |
| 1613 | } else if (bfa_asic_id_ct(pdev->device)) { |
| 1614 | if (bfi_image_ct_size == 0) |
| 1615 | bfad_read_firmware(pdev, &bfi_image_ct, |
| 1616 | &bfi_image_ct_size, BFAD_FW_FILE_CT); |
| 1617 | return bfi_image_ct; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1618 | } else { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1619 | if (bfi_image_cb_size == 0) |
| 1620 | bfad_read_firmware(pdev, &bfi_image_cb, |
| 1621 | &bfi_image_cb_size, BFAD_FW_FILE_CB); |
| 1622 | return bfi_image_cb; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1623 | } |
| 1624 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1625 | |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1626 | static void |
| 1627 | bfad_free_fwimg(void) |
| 1628 | { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame^] | 1629 | if (bfi_image_ct2_size && bfi_image_ct2) |
| 1630 | vfree(bfi_image_ct2); |
| 1631 | if (bfi_image_ct_size && bfi_image_ct) |
| 1632 | vfree(bfi_image_ct); |
| 1633 | if (bfi_image_cb_size && bfi_image_cb) |
| 1634 | vfree(bfi_image_cb); |
Jing Huang | 61338a0 | 2011-04-13 11:44:03 -0700 | [diff] [blame] | 1635 | } |
| 1636 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1637 | module_init(bfad_init); |
| 1638 | module_exit(bfad_exit); |
| 1639 | MODULE_LICENSE("GPL"); |
| 1640 | MODULE_DESCRIPTION("Brocade Fibre Channel HBA Driver" BFAD_PROTO_NAME); |
| 1641 | MODULE_AUTHOR("Brocade Communications Systems, Inc."); |
| 1642 | MODULE_VERSION(BFAD_DRIVER_VERSION); |