| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | 9413aff | 2007-04-25 09:53:35 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 8 | * * |
| 9 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 10 | * modify it under the terms of version 2 of the GNU General * |
| 11 | * Public License as published by the Free Software Foundation. * |
| 12 | * This program is distributed in the hope that it will be useful. * |
| 13 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 14 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 16 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 17 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 18 | * more details, a copy of which can be found in the file COPYING * |
| 19 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 20 | *******************************************************************/ |
| 21 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | #include <linux/ctype.h> |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 23 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 24 | #include <linux/pci.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 27 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 28 | #include <scsi/scsi_device.h> |
| 29 | #include <scsi/scsi_host.h> |
| 30 | #include <scsi/scsi_tcq.h> |
| 31 | #include <scsi/scsi_transport_fc.h> |
| 32 | |
| 33 | #include "lpfc_hw.h" |
| 34 | #include "lpfc_sli.h" |
| 35 | #include "lpfc_disc.h" |
| 36 | #include "lpfc_scsi.h" |
| 37 | #include "lpfc.h" |
| 38 | #include "lpfc_logmsg.h" |
| 39 | #include "lpfc_version.h" |
| 40 | #include "lpfc_compat.h" |
| 41 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 42 | #include "lpfc_vport.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 43 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 44 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 45 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 46 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 47 | |
| 48 | static void |
| 49 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 50 | { |
| 51 | int i, j; |
| 52 | for (i = 0; i < 8; i++) { |
| 53 | j = (incr & 0xf); |
| 54 | if (j <= 9) |
| 55 | hdw[7 - i] = 0x30 + j; |
| 56 | else |
| 57 | hdw[7 - i] = 0x61 + j - 10; |
| 58 | incr = (incr >> 4); |
| 59 | } |
| 60 | hdw[8] = 0; |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | static ssize_t |
| 65 | lpfc_drvr_version_show(struct class_device *cdev, char *buf) |
| 66 | { |
| 67 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 68 | } |
| 69 | |
| 70 | static ssize_t |
| 71 | management_version_show(struct class_device *cdev, char *buf) |
| 72 | { |
| 73 | return snprintf(buf, PAGE_SIZE, DFC_API_VERSION "\n"); |
| 74 | } |
| 75 | |
| 76 | static ssize_t |
| 77 | lpfc_info_show(struct class_device *cdev, char *buf) |
| 78 | { |
| 79 | struct Scsi_Host *host = class_to_shost(cdev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 80 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 81 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 82 | } |
| 83 | |
| 84 | static ssize_t |
| 85 | lpfc_serialnum_show(struct class_device *cdev, char *buf) |
| 86 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 87 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 88 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 89 | struct lpfc_hba *phba = vport->phba; |
| 90 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 91 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 92 | } |
| 93 | |
| 94 | static ssize_t |
| 95 | lpfc_modeldesc_show(struct class_device *cdev, char *buf) |
| 96 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 97 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 98 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 99 | struct lpfc_hba *phba = vport->phba; |
| 100 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 101 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 102 | } |
| 103 | |
| 104 | static ssize_t |
| 105 | lpfc_modelname_show(struct class_device *cdev, char *buf) |
| 106 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 107 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 108 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 109 | struct lpfc_hba *phba = vport->phba; |
| 110 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 111 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 112 | } |
| 113 | |
| 114 | static ssize_t |
| 115 | lpfc_programtype_show(struct class_device *cdev, char *buf) |
| 116 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 117 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 118 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 119 | struct lpfc_hba *phba = vport->phba; |
| 120 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 121 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 122 | } |
| 123 | |
| 124 | static ssize_t |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 125 | lpfc_vportnum_show(struct class_device *cdev, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 126 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 127 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 128 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 129 | struct lpfc_hba *phba = vport->phba; |
| 130 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 131 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 132 | } |
| 133 | |
| 134 | static ssize_t |
| 135 | lpfc_fwrev_show(struct class_device *cdev, char *buf) |
| 136 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 137 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 138 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 139 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 140 | char fwrev[32]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 141 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 142 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 143 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | static ssize_t |
| 147 | lpfc_hdw_show(struct class_device *cdev, char *buf) |
| 148 | { |
| 149 | char hdw[9]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 150 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 151 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 152 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 153 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 154 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 155 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 156 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 157 | } |
| 158 | static ssize_t |
| 159 | lpfc_option_rom_version_show(struct class_device *cdev, char *buf) |
| 160 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 161 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 162 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 163 | struct lpfc_hba *phba = vport->phba; |
| 164 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 165 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 166 | } |
| 167 | static ssize_t |
| 168 | lpfc_state_show(struct class_device *cdev, char *buf) |
| 169 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 170 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 171 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 172 | struct lpfc_hba *phba = vport->phba; |
| 173 | int len = 0; |
| 174 | |
| 175 | switch (phba->link_state) { |
| 176 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 177 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 178 | case LPFC_INIT_START: |
| 179 | case LPFC_INIT_MBX_CMDS: |
| 180 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 181 | case LPFC_HBA_ERROR: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 182 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 183 | break; |
| 184 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 185 | case LPFC_CLEAR_LA: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 186 | case LPFC_HBA_READY: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 187 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - \n"); |
| 188 | |
| 189 | switch (vport->port_state) { |
| 190 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 191 | "initializing\n"); |
| 192 | break; |
| 193 | case LPFC_LOCAL_CFG_LINK: |
| 194 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 195 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 196 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 197 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 198 | case LPFC_FLOGI: |
| 199 | case LPFC_FABRIC_CFG_LINK: |
| 200 | case LPFC_NS_REG: |
| 201 | case LPFC_NS_QRY: |
| 202 | case LPFC_BUILD_DISC_LIST: |
| 203 | case LPFC_DISC_AUTH: |
| 204 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 205 | "Discovery\n"); |
| 206 | break; |
| 207 | case LPFC_VPORT_READY: |
| 208 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 209 | break; |
| 210 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 211 | case LPFC_VPORT_FAILED: |
| 212 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 213 | break; |
| 214 | |
| 215 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 216 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 217 | "Unknown\n"); |
| 218 | break; |
| 219 | } |
| 220 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 221 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 222 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 223 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 224 | " Public Loop\n"); |
| 225 | else |
| 226 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 227 | " Private Loop\n"); |
| 228 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 229 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 230 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 231 | " Fabric\n"); |
| 232 | else |
| 233 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 234 | " Point-2-Point\n"); |
| 235 | } |
| 236 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 237 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 238 | return len; |
| 239 | } |
| 240 | |
| 241 | static ssize_t |
| 242 | lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf) |
| 243 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 244 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 245 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 246 | |
| 247 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 248 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 252 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 253 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 254 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 255 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 256 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 257 | LPFC_MBOXQ_t *pmboxq; |
| 258 | int mbxstatus = MBXERR_ERROR; |
| 259 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 260 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
| 261 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) || |
| 262 | (vport->port_state != LPFC_VPORT_READY)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 263 | return -EPERM; |
| 264 | |
| 265 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 266 | |
| 267 | if (!pmboxq) |
| 268 | return -ENOMEM; |
| 269 | |
| 270 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 271 | pmboxq->mb.mbxCommand = MBX_DOWN_LINK; |
| 272 | pmboxq->mb.mbxOwner = OWN_HOST; |
| 273 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 274 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 275 | |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 276 | if ((mbxstatus == MBX_SUCCESS) && (pmboxq->mb.mbxStatus == 0)) { |
| 277 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 278 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 279 | phba->cfg_link_speed); |
| 280 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 281 | phba->fc_ratov * 2); |
| 282 | } |
| 283 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 284 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 285 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 286 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 287 | |
| 288 | if (mbxstatus == MBXERR_ERROR) |
| 289 | return -EIO; |
| 290 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 291 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 292 | } |
| 293 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 294 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 295 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 296 | { |
| 297 | struct completion online_compl; |
| 298 | struct lpfc_sli_ring *pring; |
| 299 | struct lpfc_sli *psli; |
| 300 | int status = 0; |
| 301 | int cnt = 0; |
| 302 | int i; |
| 303 | |
| 304 | init_completion(&online_compl); |
| 305 | lpfc_workq_post_event(phba, &status, &online_compl, |
| 306 | LPFC_EVT_OFFLINE_PREP); |
| 307 | wait_for_completion(&online_compl); |
| 308 | |
| 309 | if (status != 0) |
| 310 | return -EIO; |
| 311 | |
| 312 | psli = &phba->sli; |
| 313 | |
| 314 | for (i = 0; i < psli->num_rings; i++) { |
| 315 | pring = &psli->ring[i]; |
| 316 | /* The linkdown event takes 30 seconds to timeout. */ |
| 317 | while (pring->txcmplq_cnt) { |
| 318 | msleep(10); |
| 319 | if (cnt++ > 3000) { |
| 320 | lpfc_printf_log(phba, |
| 321 | KERN_WARNING, LOG_INIT, |
| 322 | "%d:0466 Outstanding IO when " |
| 323 | "bringing Adapter offline\n", |
| 324 | phba->brd_no); |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | init_completion(&online_compl); |
| 331 | lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 332 | wait_for_completion(&online_compl); |
| 333 | |
| 334 | if (status != 0) |
| 335 | return -EIO; |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | static int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 341 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 342 | { |
| 343 | struct completion online_compl; |
| 344 | int status = 0; |
| 345 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 346 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 347 | |
| 348 | if (status != 0) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 349 | return status; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 350 | |
| 351 | init_completion(&online_compl); |
| 352 | lpfc_workq_post_event(phba, &status, &online_compl, |
| 353 | LPFC_EVT_ONLINE); |
| 354 | wait_for_completion(&online_compl); |
| 355 | |
| 356 | if (status != 0) |
| 357 | return -EIO; |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | static ssize_t |
| 363 | lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count) |
| 364 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 365 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 366 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 367 | struct lpfc_hba *phba = vport->phba; |
| 368 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 369 | int status = -EINVAL; |
| 370 | |
| 371 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
| 372 | status = lpfc_selective_reset(phba); |
| 373 | |
| 374 | if (status == 0) |
| 375 | return strlen(buf); |
| 376 | else |
| 377 | return status; |
| 378 | } |
| 379 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 380 | static ssize_t |
| 381 | lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) |
| 382 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 383 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 384 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 385 | struct lpfc_hba *phba = vport->phba; |
| 386 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 387 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 388 | } |
| 389 | |
| 390 | static ssize_t |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 391 | lpfc_board_mode_show(struct class_device *cdev, char *buf) |
| 392 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 393 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 394 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 395 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 396 | char * state; |
| 397 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 398 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 399 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 400 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 401 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 402 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 403 | state = "offline"; |
| 404 | else |
| 405 | state = "online"; |
| 406 | |
| 407 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 408 | } |
| 409 | |
| 410 | static ssize_t |
| 411 | lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count) |
| 412 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 413 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 414 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 415 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 416 | struct completion online_compl; |
| 417 | int status=0; |
| 418 | |
| 419 | init_completion(&online_compl); |
| 420 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 421 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 422 | lpfc_workq_post_event(phba, &status, &online_compl, |
| 423 | LPFC_EVT_ONLINE); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 424 | wait_for_completion(&online_compl); |
| 425 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 426 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 427 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 428 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
| 429 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
| 430 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 431 | else |
| 432 | return -EINVAL; |
| 433 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 434 | if (!status) |
| 435 | return strlen(buf); |
| 436 | else |
| 437 | return -EIO; |
| 438 | } |
| 439 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 440 | int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 441 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 442 | uint32_t *mxri, uint32_t *axri, |
| 443 | uint32_t *mrpi, uint32_t *arpi, |
| 444 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 445 | { |
| 446 | struct lpfc_sli *psli = &phba->sli; |
| 447 | LPFC_MBOXQ_t *pmboxq; |
| 448 | MAILBOX_t *pmb; |
| 449 | int rc = 0; |
| 450 | |
| 451 | /* |
| 452 | * prevent udev from issuing mailbox commands until the port is |
| 453 | * configured. |
| 454 | */ |
| 455 | if (phba->link_state < LPFC_LINK_DOWN || |
| 456 | !phba->mbox_mem_pool || |
| 457 | (phba->sli.sli_flag & LPFC_SLI2_ACTIVE) == 0) |
| 458 | return 0; |
| 459 | |
| 460 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 461 | return 0; |
| 462 | |
| 463 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 464 | if (!pmboxq) |
| 465 | return 0; |
| 466 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 467 | |
| 468 | pmb = &pmboxq->mb; |
| 469 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 470 | pmb->mbxOwner = OWN_HOST; |
| 471 | pmboxq->context1 = NULL; |
| 472 | |
| 473 | if ((phba->pport->fc_flag & FC_OFFLINE_MODE) || |
| 474 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) |
| 475 | rc = MBX_NOT_FINISHED; |
| 476 | else |
| 477 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 478 | |
| 479 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 480 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 481 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | if (mrpi) |
| 486 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 487 | if (arpi) |
| 488 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 489 | if (mxri) |
| 490 | *mxri = pmb->un.varRdConfig.max_xri; |
| 491 | if (axri) |
| 492 | *axri = pmb->un.varRdConfig.avail_xri; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 493 | if (mvpi) |
| 494 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 495 | if (avpi) |
| 496 | *avpi = pmb->un.varRdConfig.avail_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 497 | |
| 498 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 499 | return 1; |
| 500 | } |
| 501 | |
| 502 | static ssize_t |
| 503 | lpfc_max_rpi_show(struct class_device *cdev, char *buf) |
| 504 | { |
| 505 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 506 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 507 | struct lpfc_hba *phba = vport->phba; |
| 508 | uint32_t cnt; |
| 509 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 510 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 511 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 512 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 513 | } |
| 514 | |
| 515 | static ssize_t |
| 516 | lpfc_used_rpi_show(struct class_device *cdev, char *buf) |
| 517 | { |
| 518 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 519 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 520 | struct lpfc_hba *phba = vport->phba; |
| 521 | uint32_t cnt, acnt; |
| 522 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 523 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 524 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 525 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 526 | } |
| 527 | |
| 528 | static ssize_t |
| 529 | lpfc_max_xri_show(struct class_device *cdev, char *buf) |
| 530 | { |
| 531 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 532 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 533 | struct lpfc_hba *phba = vport->phba; |
| 534 | uint32_t cnt; |
| 535 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 536 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 537 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 538 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 539 | } |
| 540 | |
| 541 | static ssize_t |
| 542 | lpfc_used_xri_show(struct class_device *cdev, char *buf) |
| 543 | { |
| 544 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 545 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 546 | struct lpfc_hba *phba = vport->phba; |
| 547 | uint32_t cnt, acnt; |
| 548 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 549 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 550 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 551 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 552 | } |
| 553 | |
| 554 | static ssize_t |
| 555 | lpfc_max_vpi_show(struct class_device *cdev, char *buf) |
| 556 | { |
| 557 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 558 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 559 | struct lpfc_hba *phba = vport->phba; |
| 560 | uint32_t cnt; |
| 561 | |
| 562 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 563 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 564 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 565 | } |
| 566 | |
| 567 | static ssize_t |
| 568 | lpfc_used_vpi_show(struct class_device *cdev, char *buf) |
| 569 | { |
| 570 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 571 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 572 | struct lpfc_hba *phba = vport->phba; |
| 573 | uint32_t cnt, acnt; |
| 574 | |
| 575 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 576 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 577 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 578 | } |
| 579 | |
| 580 | static ssize_t |
| 581 | lpfc_npiv_info_show(struct class_device *cdev, char *buf) |
| 582 | { |
| 583 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 584 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 585 | struct lpfc_hba *phba = vport->phba; |
| 586 | |
| 587 | if (!(phba->max_vpi)) |
| 588 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 589 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 590 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 591 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 592 | } |
| 593 | |
| 594 | static ssize_t |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 595 | lpfc_poll_show(struct class_device *cdev, char *buf) |
| 596 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 597 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 598 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 599 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 600 | |
| 601 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 602 | } |
| 603 | |
| 604 | static ssize_t |
| 605 | lpfc_poll_store(struct class_device *cdev, const char *buf, |
| 606 | size_t count) |
| 607 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 608 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 609 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 610 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 611 | uint32_t creg_val; |
| 612 | uint32_t old_val; |
| 613 | int val=0; |
| 614 | |
| 615 | if (!isdigit(buf[0])) |
| 616 | return -EINVAL; |
| 617 | |
| 618 | if (sscanf(buf, "%i", &val) != 1) |
| 619 | return -EINVAL; |
| 620 | |
| 621 | if ((val & 0x3) != val) |
| 622 | return -EINVAL; |
| 623 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 624 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 625 | |
| 626 | old_val = phba->cfg_poll; |
| 627 | |
| 628 | if (val & ENABLE_FCP_RING_POLLING) { |
| 629 | if ((val & DISABLE_FCP_RING_INT) && |
| 630 | !(old_val & DISABLE_FCP_RING_INT)) { |
| 631 | creg_val = readl(phba->HCregaddr); |
| 632 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 633 | writel(creg_val, phba->HCregaddr); |
| 634 | readl(phba->HCregaddr); /* flush */ |
| 635 | |
| 636 | lpfc_poll_start_timer(phba); |
| 637 | } |
| 638 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 639 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 640 | return -EINVAL; |
| 641 | } |
| 642 | |
| 643 | if (!(val & DISABLE_FCP_RING_INT) && |
| 644 | (old_val & DISABLE_FCP_RING_INT)) |
| 645 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 646 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 647 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 648 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 649 | creg_val = readl(phba->HCregaddr); |
| 650 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 651 | writel(creg_val, phba->HCregaddr); |
| 652 | readl(phba->HCregaddr); /* flush */ |
| 653 | } |
| 654 | |
| 655 | phba->cfg_poll = val; |
| 656 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 657 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 658 | |
| 659 | return strlen(buf); |
| 660 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 661 | |
| 662 | #define lpfc_param_show(attr) \ |
| 663 | static ssize_t \ |
| 664 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ |
| 665 | { \ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 666 | struct Scsi_Host *shost = class_to_shost(cdev);\ |
| 667 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 668 | struct lpfc_hba *phba = vport->phba;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 669 | int val = 0;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 670 | val = phba->cfg_##attr;\ |
| 671 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 672 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 673 | } |
| 674 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 675 | #define lpfc_param_hex_show(attr) \ |
| 676 | static ssize_t \ |
| 677 | lpfc_##attr##_show(struct class_device *cdev, char *buf) \ |
| 678 | { \ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 679 | struct Scsi_Host *shost = class_to_shost(cdev);\ |
| 680 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 681 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 682 | int val = 0;\ |
| 683 | val = phba->cfg_##attr;\ |
| 684 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 685 | phba->cfg_##attr);\ |
| 686 | } |
| 687 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 688 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 689 | static int \ |
| 690 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ |
| 691 | { \ |
| 692 | if (val >= minval && val <= maxval) {\ |
| 693 | phba->cfg_##attr = val;\ |
| 694 | return 0;\ |
| 695 | }\ |
| 696 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 697 | "%d:0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 698 | "allowed range is ["#minval", "#maxval"]\n", \ |
| 699 | phba->brd_no, val); \ |
| 700 | phba->cfg_##attr = default;\ |
| 701 | return -EINVAL;\ |
| 702 | } |
| 703 | |
| 704 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 705 | static int \ |
| 706 | lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ |
| 707 | { \ |
| 708 | if (val >= minval && val <= maxval) {\ |
| 709 | phba->cfg_##attr = val;\ |
| 710 | return 0;\ |
| 711 | }\ |
| 712 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 713 | "%d:0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 714 | "allowed range is ["#minval", "#maxval"]\n", \ |
| 715 | phba->brd_no, val); \ |
| 716 | return -EINVAL;\ |
| 717 | } |
| 718 | |
| 719 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 720 | static ssize_t \ |
| 721 | lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ |
| 722 | { \ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 723 | struct Scsi_Host *shost = class_to_shost(cdev);\ |
| 724 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 725 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 726 | int val=0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 727 | if (!isdigit(buf[0]))\ |
| 728 | return -EINVAL;\ |
| 729 | if (sscanf(buf, "%i", &val) != 1)\ |
| 730 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 731 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 732 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 733 | else \ |
| 734 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 735 | } |
| 736 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 737 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
| 738 | static int lpfc_##name = defval;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 739 | module_param(lpfc_##name, int, 0);\ |
| 740 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 741 | lpfc_param_init(name, defval, minval, maxval) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 742 | |
| 743 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ |
| 744 | static int lpfc_##name = defval;\ |
| 745 | module_param(lpfc_##name, int, 0);\ |
| 746 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 747 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 748 | lpfc_param_init(name, defval, minval, maxval)\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 749 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| 750 | |
| 751 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
| 752 | static int lpfc_##name = defval;\ |
| 753 | module_param(lpfc_##name, int, 0);\ |
| 754 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 755 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 756 | lpfc_param_init(name, defval, minval, maxval)\ |
| 757 | lpfc_param_set(name, defval, minval, maxval)\ |
| 758 | lpfc_param_store(name)\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 759 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 760 | lpfc_##name##_show, lpfc_##name##_store) |
| 761 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 762 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
| 763 | static int lpfc_##name = defval;\ |
| 764 | module_param(lpfc_##name, int, 0);\ |
| 765 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 766 | lpfc_param_hex_show(name)\ |
| 767 | lpfc_param_init(name, defval, minval, maxval)\ |
| 768 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| 769 | |
| 770 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
| 771 | static int lpfc_##name = defval;\ |
| 772 | module_param(lpfc_##name, int, 0);\ |
| 773 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 774 | lpfc_param_hex_show(name)\ |
| 775 | lpfc_param_init(name, defval, minval, maxval)\ |
| 776 | lpfc_param_set(name, defval, minval, maxval)\ |
| 777 | lpfc_param_store(name)\ |
| 778 | static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 779 | lpfc_##name##_show, lpfc_##name##_store) |
| 780 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 781 | static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 782 | static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 783 | static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 784 | static CLASS_DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 785 | static CLASS_DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 786 | static CLASS_DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 787 | static CLASS_DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 788 | static CLASS_DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
| 789 | static CLASS_DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL); |
| 790 | static CLASS_DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 791 | lpfc_option_rom_version_show, NULL); |
| 792 | static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 793 | lpfc_num_discovered_ports_show, NULL); |
| 794 | static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 795 | static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, |
| 796 | NULL); |
| 797 | static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show, |
| 798 | NULL); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 799 | static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 800 | lpfc_board_mode_show, lpfc_board_mode_store); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 801 | static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 802 | static CLASS_DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 803 | static CLASS_DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 804 | static CLASS_DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 805 | static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 806 | static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 807 | static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 808 | static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 809 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 810 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 811 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 812 | |
| 813 | static ssize_t |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 814 | lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 815 | size_t count) |
| 816 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 817 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 818 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 819 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 820 | unsigned int cnt = count; |
| 821 | |
| 822 | /* |
| 823 | * We're doing a simple sanity check for soft_wwpn setting. |
| 824 | * We require that the user write a specific key to enable |
| 825 | * the soft_wwpn attribute to be settable. Once the attribute |
| 826 | * is written, the enable key resets. If further updates are |
| 827 | * desired, the key must be written again to re-enable the |
| 828 | * attribute. |
| 829 | * |
| 830 | * The "key" is not secret - it is a hardcoded string shown |
| 831 | * here. The intent is to protect against the random user or |
| 832 | * application that is just writing attributes. |
| 833 | */ |
| 834 | |
| 835 | /* count may include a LF at end of string */ |
| 836 | if (buf[cnt-1] == '\n') |
| 837 | cnt--; |
| 838 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 839 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 840 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 841 | return -EINVAL; |
| 842 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 843 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 844 | return count; |
| 845 | } |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 846 | static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 847 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 848 | |
| 849 | static ssize_t |
| 850 | lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) |
| 851 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 852 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 853 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 854 | struct lpfc_hba *phba = vport->phba; |
| 855 | |
Randy Dunlap | afc071e | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 856 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 857 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | |
| 861 | static ssize_t |
| 862 | lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) |
| 863 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 864 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 865 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 866 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 867 | struct completion online_compl; |
| 868 | int stat1=0, stat2=0; |
| 869 | unsigned int i, j, cnt=count; |
| 870 | u8 wwpn[8]; |
| 871 | |
| 872 | /* count may include a LF at end of string */ |
| 873 | if (buf[cnt-1] == '\n') |
| 874 | cnt--; |
| 875 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 876 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 877 | ((cnt == 17) && (*buf++ != 'x')) || |
| 878 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 879 | return -EINVAL; |
| 880 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 881 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 882 | |
| 883 | memset(wwpn, 0, sizeof(wwpn)); |
| 884 | |
| 885 | /* Validate and store the new name */ |
| 886 | for (i=0, j=0; i < 16; i++) { |
| 887 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 888 | j = ((j << 4) | ((*buf++ -'a') + 10)); |
| 889 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 890 | j = ((j << 4) | ((*buf++ -'A') + 10)); |
| 891 | else if ((*buf >= '0') && (*buf <= '9')) |
| 892 | j = ((j << 4) | (*buf++ -'0')); |
| 893 | else |
| 894 | return -EINVAL; |
| 895 | if (i % 2) { |
| 896 | wwpn[i/2] = j & 0xff; |
| 897 | j = 0; |
| 898 | } |
| 899 | } |
| 900 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 901 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 902 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 903 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 904 | |
| 905 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 906 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 907 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 908 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 909 | if (stat1) |
| 910 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 911 | "%d:0463 lpfc_soft_wwpn attribute set failed to reinit " |
| 912 | "adapter - %d\n", phba->brd_no, stat1); |
| 913 | |
| 914 | init_completion(&online_compl); |
| 915 | lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE); |
| 916 | wait_for_completion(&online_compl); |
| 917 | if (stat2) |
| 918 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 919 | "%d:0464 lpfc_soft_wwpn attribute set failed to reinit " |
| 920 | "adapter - %d\n", phba->brd_no, stat2); |
| 921 | |
| 922 | return (stat1 || stat2) ? -EIO : count; |
| 923 | } |
| 924 | static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ |
| 925 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
| 926 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 927 | static ssize_t |
| 928 | lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) |
| 929 | { |
| 930 | struct Scsi_Host *host = class_to_shost(cdev); |
| 931 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; |
| 932 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 933 | (unsigned long long)phba->cfg_soft_wwnn); |
| 934 | } |
| 935 | |
| 936 | |
| 937 | static ssize_t |
| 938 | lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) |
| 939 | { |
| 940 | struct Scsi_Host *host = class_to_shost(cdev); |
| 941 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; |
| 942 | unsigned int i, j, cnt=count; |
| 943 | u8 wwnn[8]; |
| 944 | |
| 945 | /* count may include a LF at end of string */ |
| 946 | if (buf[cnt-1] == '\n') |
| 947 | cnt--; |
| 948 | |
| 949 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
| 950 | ((cnt == 17) && (*buf++ != 'x')) || |
| 951 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 952 | return -EINVAL; |
| 953 | |
| 954 | /* |
| 955 | * Allow wwnn to be set many times, as long as the enable is set. |
| 956 | * However, once the wwpn is set, everything locks. |
| 957 | */ |
| 958 | |
| 959 | memset(wwnn, 0, sizeof(wwnn)); |
| 960 | |
| 961 | /* Validate and store the new name */ |
| 962 | for (i=0, j=0; i < 16; i++) { |
| 963 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 964 | j = ((j << 4) | ((*buf++ -'a') + 10)); |
| 965 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 966 | j = ((j << 4) | ((*buf++ -'A') + 10)); |
| 967 | else if ((*buf >= '0') && (*buf <= '9')) |
| 968 | j = ((j << 4) | (*buf++ -'0')); |
| 969 | else |
| 970 | return -EINVAL; |
| 971 | if (i % 2) { |
| 972 | wwnn[i/2] = j & 0xff; |
| 973 | j = 0; |
| 974 | } |
| 975 | } |
| 976 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 977 | |
| 978 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 979 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 980 | "setting of the soft_wwpn\n", phba->brd_no); |
| 981 | |
| 982 | return count; |
| 983 | } |
| 984 | static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ |
| 985 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
| 986 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 987 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 988 | static int lpfc_poll = 0; |
| 989 | module_param(lpfc_poll, int, 0); |
| 990 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 991 | " 0 - none," |
| 992 | " 1 - poll with interrupts enabled" |
| 993 | " 3 - poll and disable FCP ring interrupts"); |
| 994 | |
| 995 | static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 996 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 997 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 998 | int lpfc_sli_mode = 0; |
| 999 | module_param(lpfc_sli_mode, int, 0); |
| 1000 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" |
| 1001 | " 0 - auto (SLI-3 if supported)," |
| 1002 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 1003 | " 3 - select SLI-3"); |
| 1004 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1005 | LPFC_ATTR_R(npiv_enable, 0, 0, 1, "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1006 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1007 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1008 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 1009 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 1010 | */ |
| 1011 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 1012 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 1013 | module_param(lpfc_nodev_tmo, int, 0); |
| 1014 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 1015 | "Seconds driver will hold I/O waiting " |
| 1016 | "for a device to come back"); |
| 1017 | static ssize_t |
| 1018 | lpfc_nodev_tmo_show(struct class_device *cdev, char *buf) |
| 1019 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1020 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 1021 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1022 | struct lpfc_hba *phba = vport->phba; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1023 | int val = 0; |
| 1024 | val = phba->cfg_devloss_tmo; |
| 1025 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 1026 | phba->cfg_devloss_tmo); |
| 1027 | } |
| 1028 | |
| 1029 | static int |
| 1030 | lpfc_nodev_tmo_init(struct lpfc_hba *phba, int val) |
| 1031 | { |
| 1032 | static int warned; |
| 1033 | if (phba->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 1034 | phba->cfg_nodev_tmo = phba->cfg_devloss_tmo; |
| 1035 | if (!warned && val != LPFC_DEF_DEVLOSS_TMO) { |
| 1036 | warned = 1; |
| 1037 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1038 | "%d:0402 Ignoring nodev_tmo module " |
| 1039 | "parameter because devloss_tmo is" |
| 1040 | " set.\n", |
| 1041 | phba->brd_no); |
| 1042 | } |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
| 1046 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
| 1047 | phba->cfg_nodev_tmo = val; |
| 1048 | phba->cfg_devloss_tmo = val; |
| 1049 | return 0; |
| 1050 | } |
| 1051 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1052 | "%d:0400 lpfc_nodev_tmo attribute cannot be set to %d, " |
| 1053 | "allowed range is [%d, %d]\n", |
| 1054 | phba->brd_no, val, |
| 1055 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
| 1056 | phba->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 1057 | return -EINVAL; |
| 1058 | } |
| 1059 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1060 | static void |
| 1061 | lpfc_update_rport_devloss_tmo(struct lpfc_hba *phba) |
| 1062 | { |
| 1063 | struct lpfc_vport *vport; |
| 1064 | struct Scsi_Host *shost; |
| 1065 | struct lpfc_nodelist *ndlp; |
| 1066 | |
| 1067 | list_for_each_entry(vport, &phba->port_list, listentry) { |
| 1068 | shost = lpfc_shost_from_vport(vport); |
| 1069 | spin_lock_irq(shost->host_lock); |
| 1070 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
| 1071 | if (ndlp->rport) |
| 1072 | ndlp->rport->dev_loss_tmo = |
| 1073 | phba->cfg_devloss_tmo; |
| 1074 | spin_unlock_irq(shost->host_lock); |
| 1075 | } |
| 1076 | } |
| 1077 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1078 | static int |
| 1079 | lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val) |
| 1080 | { |
| 1081 | if (phba->dev_loss_tmo_changed || |
| 1082 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
| 1083 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1084 | "%d:0401 Ignoring change to nodev_tmo " |
| 1085 | "because devloss_tmo is set.\n", |
| 1086 | phba->brd_no); |
| 1087 | return 0; |
| 1088 | } |
| 1089 | |
| 1090 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
| 1091 | phba->cfg_nodev_tmo = val; |
| 1092 | phba->cfg_devloss_tmo = val; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1093 | lpfc_update_rport_devloss_tmo(phba); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1098 | "%d:0403 lpfc_nodev_tmo attribute cannot be set to %d, " |
| 1099 | "allowed range is [%d, %d]\n", |
| 1100 | phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO, |
| 1101 | LPFC_MAX_DEVLOSS_TMO); |
| 1102 | return -EINVAL; |
| 1103 | } |
| 1104 | |
| 1105 | lpfc_param_store(nodev_tmo) |
| 1106 | |
| 1107 | static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 1108 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
| 1109 | |
| 1110 | /* |
| 1111 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 1112 | # disappear until the timer expires. Value range is [0,255]. Default |
| 1113 | # value is 30. |
| 1114 | */ |
| 1115 | module_param(lpfc_devloss_tmo, int, 0); |
| 1116 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 1117 | "Seconds driver will hold I/O waiting " |
| 1118 | "for a device to come back"); |
| 1119 | lpfc_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 1120 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 1121 | lpfc_param_show(devloss_tmo) |
| 1122 | static int |
| 1123 | lpfc_devloss_tmo_set(struct lpfc_hba *phba, int val) |
| 1124 | { |
| 1125 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
| 1126 | phba->cfg_nodev_tmo = val; |
| 1127 | phba->cfg_devloss_tmo = val; |
| 1128 | phba->dev_loss_tmo_changed = 1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1129 | lpfc_update_rport_devloss_tmo(phba); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1130 | return 0; |
| 1131 | } |
| 1132 | |
| 1133 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1134 | "%d:0404 lpfc_devloss_tmo attribute cannot be set to" |
| 1135 | " %d, allowed range is [%d, %d]\n", |
| 1136 | phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO, |
| 1137 | LPFC_MAX_DEVLOSS_TMO); |
| 1138 | return -EINVAL; |
| 1139 | } |
| 1140 | |
| 1141 | lpfc_param_store(devloss_tmo) |
| 1142 | static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 1143 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
| 1144 | |
| 1145 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1146 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 1147 | # deluged with LOTS of information. |
| 1148 | # You can set a bit mask to record specific types of verbose messages: |
| 1149 | # |
| 1150 | # LOG_ELS 0x1 ELS events |
| 1151 | # LOG_DISCOVERY 0x2 Link discovery events |
| 1152 | # LOG_MBOX 0x4 Mailbox events |
| 1153 | # LOG_INIT 0x8 Initialization events |
| 1154 | # LOG_LINK_EVENT 0x10 Link events |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1155 | # LOG_FCP 0x40 FCP traffic history |
| 1156 | # LOG_NODE 0x80 Node table events |
| 1157 | # LOG_MISC 0x400 Miscellaneous events |
| 1158 | # LOG_SLI 0x800 SLI events |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 1159 | # LOG_FCP_ERROR 0x1000 Only log FCP errors |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1160 | # LOG_LIBDFC 0x2000 LIBDFC events |
| 1161 | # LOG_ALL_MSG 0xffff LOG all messages |
| 1162 | */ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1163 | LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1164 | |
| 1165 | /* |
| 1166 | # lun_queue_depth: This parameter is used to limit the number of outstanding |
| 1167 | # commands per FCP LUN. Value range is [1,128]. Default value is 30. |
| 1168 | */ |
| 1169 | LPFC_ATTR_R(lun_queue_depth, 30, 1, 128, |
| 1170 | "Max number of FCP commands we can queue to a specific LUN"); |
| 1171 | |
| 1172 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 1173 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 1174 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 1175 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 1176 | # then maximum number of exchanges supported by the HBA is used to determine |
| 1177 | # the hba_queue_depth. |
| 1178 | */ |
| 1179 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 1180 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 1181 | |
| 1182 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1183 | # peer_port_login: This parameter allows/prevents logins |
| 1184 | # between peer ports hosted on the same physical port. |
| 1185 | # When this parameter is set 0 peer ports of same physical port |
| 1186 | # are not allowed to login to each other. |
| 1187 | # When this parameter is set 1 peer ports of same physical port |
| 1188 | # are allowed to login to each other. |
| 1189 | # Default value of this parameter is 0. |
| 1190 | */ |
| 1191 | LPFC_ATTR_R(peer_port_login, 0, 0, 1, |
| 1192 | "Allow peer ports on the same physical port to login to each " |
| 1193 | "other."); |
| 1194 | |
| 1195 | /* |
| 1196 | # vport_restrict_login: This parameter allows/prevents logins |
| 1197 | # between Virtual Ports and remote initiators. |
| 1198 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 1199 | # other initiators and will attempt to PLOGI all remote ports. |
| 1200 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 1201 | # remote ports and will not attempt to PLOGI to other initiators. |
| 1202 | # This parameter does not restrict to the physical port. |
| 1203 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 1204 | # Default value of this parameter is 1. |
| 1205 | */ |
| 1206 | LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1, |
| 1207 | "Restrict virtual ports login to remote initiators."); |
| 1208 | |
| 1209 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1210 | # Some disk devices have a "select ID" or "select Target" capability. |
| 1211 | # From a protocol standpoint "select ID" usually means select the |
| 1212 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 1213 | # annex" which contains a table that maps a "select ID" (a number |
| 1214 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 1215 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 1216 | # ALPA. |
| 1217 | # |
| 1218 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 1219 | # cause the lpfc driver to use an inverted table, effectively |
| 1220 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 1221 | # |
| 1222 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 1223 | # and will not work across a fabric. Also this parameter will take |
| 1224 | # effect only in the case when ALPA map is not available.) |
| 1225 | */ |
| 1226 | LPFC_ATTR_R(scan_down, 1, 0, 1, |
| 1227 | "Start scanning for devices from highest ALPA to lowest"); |
| 1228 | |
| 1229 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1230 | # lpfc_topology: link topology for init link |
| 1231 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 1232 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1233 | # 0x02 = attempt point-to-point mode only |
| 1234 | # 0x04 = attempt loop mode only |
| 1235 | # 0x06 = attempt point-to-point mode then loop |
| 1236 | # Set point-to-point mode if you want to run as an N_Port. |
| 1237 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 1238 | # Default value is 0. |
| 1239 | */ |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 1240 | LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1241 | |
| 1242 | /* |
| 1243 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 1244 | # connection. |
| 1245 | # 0 = auto select (default) |
| 1246 | # 1 = 1 Gigabaud |
| 1247 | # 2 = 2 Gigabaud |
| 1248 | # 4 = 4 Gigabaud |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1249 | # 8 = 8 Gigabaud |
| 1250 | # Value range is [0,8]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1251 | */ |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1252 | LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1253 | |
| 1254 | /* |
| 1255 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 1256 | # Value range is [2,3]. Default value is 3. |
| 1257 | */ |
| 1258 | LPFC_ATTR_R(fcp_class, 3, 2, 3, |
| 1259 | "Select Fibre Channel class of service for FCP sequences"); |
| 1260 | |
| 1261 | /* |
| 1262 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 1263 | # is [0,1]. Default value is 0. |
| 1264 | */ |
| 1265 | LPFC_ATTR_RW(use_adisc, 0, 0, 1, |
| 1266 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| 1267 | |
| 1268 | /* |
| 1269 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 1270 | # range is [0,1]. Default value is 0. |
| 1271 | */ |
| 1272 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 1273 | |
| 1274 | /* |
| 1275 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 1276 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1277 | # value [0,63]. cr_count can take value [1,255]. Default value of cr_delay |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1278 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 1279 | # cr_delay is set to 0. |
| 1280 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 1281 | LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1282 | "interrupt response is generated"); |
| 1283 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 1284 | LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1285 | "interrupt response is generated"); |
| 1286 | |
| 1287 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 1288 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 1289 | # cmd/rsp IOCB entries across. |
| 1290 | # Value range is [1,2]. Default value is 1. |
| 1291 | */ |
| 1292 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 1293 | "SLI rings to spread IOCB entries across"); |
| 1294 | |
| 1295 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 1296 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 1297 | # identifies what rctl value to configure the additional ring for. |
| 1298 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 1299 | */ |
| 1300 | LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1, |
| 1301 | 255, "Identifies RCTL for additional ring configuration"); |
| 1302 | |
| 1303 | /* |
| 1304 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 1305 | # identifies what type value to configure the additional ring for. |
| 1306 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 1307 | */ |
| 1308 | LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1, |
| 1309 | 255, "Identifies TYPE for additional ring configuration"); |
| 1310 | |
| 1311 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1312 | # lpfc_fdmi_on: controls FDMI support. |
| 1313 | # 0 = no FDMI support |
| 1314 | # 1 = support FDMI without attribute of hostname |
| 1315 | # 2 = support FDMI with attribute of hostname |
| 1316 | # Value range [0,2]. Default value is 0. |
| 1317 | */ |
| 1318 | LPFC_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); |
| 1319 | |
| 1320 | /* |
| 1321 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 1322 | # discovery). Value range is [1,64]. Default value = 32. |
| 1323 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 1324 | LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1325 | "during discovery"); |
| 1326 | |
| 1327 | /* |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 1328 | # lpfc_max_luns: maximum allowed LUN. |
| 1329 | # Value range is [0,65535]. Default value is 255. |
| 1330 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1331 | */ |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 1332 | LPFC_ATTR_R(max_luns, 255, 0, 65535, |
| 1333 | "Maximum allowed LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1334 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1335 | /* |
| 1336 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 1337 | # Value range is [1,255], default value is 10. |
| 1338 | */ |
| 1339 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 1340 | "Milliseconds driver will wait between polling FCP ring"); |
| 1341 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 1342 | /* |
| 1343 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 1344 | # support this feature |
| 1345 | # 0 = MSI disabled (default) |
| 1346 | # 1 = MSI enabled |
| 1347 | # Value range is [0,1]. Default value is 0. |
| 1348 | */ |
| 1349 | LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible"); |
| 1350 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1351 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1352 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1353 | struct class_device_attribute *lpfc_hba_attrs[] = { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1354 | &class_device_attr_info, |
| 1355 | &class_device_attr_serialnum, |
| 1356 | &class_device_attr_modeldesc, |
| 1357 | &class_device_attr_modelname, |
| 1358 | &class_device_attr_programtype, |
| 1359 | &class_device_attr_portnum, |
| 1360 | &class_device_attr_fwrev, |
| 1361 | &class_device_attr_hdw, |
| 1362 | &class_device_attr_option_rom_version, |
| 1363 | &class_device_attr_state, |
| 1364 | &class_device_attr_num_discovered_ports, |
| 1365 | &class_device_attr_lpfc_drvr_version, |
| 1366 | &class_device_attr_lpfc_log_verbose, |
| 1367 | &class_device_attr_lpfc_lun_queue_depth, |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 1368 | &class_device_attr_lpfc_hba_queue_depth, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1369 | &class_device_attr_lpfc_peer_port_login, |
| 1370 | &class_device_attr_lpfc_vport_restrict_login, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1371 | &class_device_attr_lpfc_nodev_tmo, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1372 | &class_device_attr_lpfc_devloss_tmo, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1373 | &class_device_attr_lpfc_fcp_class, |
| 1374 | &class_device_attr_lpfc_use_adisc, |
| 1375 | &class_device_attr_lpfc_ack0, |
| 1376 | &class_device_attr_lpfc_topology, |
| 1377 | &class_device_attr_lpfc_scan_down, |
| 1378 | &class_device_attr_lpfc_link_speed, |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1379 | &class_device_attr_lpfc_cr_delay, |
| 1380 | &class_device_attr_lpfc_cr_count, |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 1381 | &class_device_attr_lpfc_multi_ring_support, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 1382 | &class_device_attr_lpfc_multi_ring_rctl, |
| 1383 | &class_device_attr_lpfc_multi_ring_type, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1384 | &class_device_attr_lpfc_fdmi_on, |
| 1385 | &class_device_attr_lpfc_max_luns, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1386 | &class_device_attr_lpfc_npiv_enable, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1387 | &class_device_attr_nport_evt_cnt, |
| 1388 | &class_device_attr_management_version, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1389 | &class_device_attr_board_mode, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1390 | &class_device_attr_max_vpi, |
| 1391 | &class_device_attr_used_vpi, |
| 1392 | &class_device_attr_max_rpi, |
| 1393 | &class_device_attr_used_rpi, |
| 1394 | &class_device_attr_max_xri, |
| 1395 | &class_device_attr_used_xri, |
| 1396 | &class_device_attr_npiv_info, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1397 | &class_device_attr_issue_reset, |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1398 | &class_device_attr_lpfc_poll, |
| 1399 | &class_device_attr_lpfc_poll_tmo, |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 1400 | &class_device_attr_lpfc_use_msi, |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1401 | &class_device_attr_lpfc_soft_wwnn, |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1402 | &class_device_attr_lpfc_soft_wwpn, |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1403 | &class_device_attr_lpfc_soft_wwn_enable, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1404 | NULL, |
| 1405 | }; |
| 1406 | |
| 1407 | static ssize_t |
| 1408 | sysfs_ctlreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) |
| 1409 | { |
| 1410 | size_t buf_off; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1411 | struct class_device *cdev = container_of(kobj, struct class_device, |
| 1412 | kobj); |
| 1413 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 1414 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1415 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1416 | |
| 1417 | if ((off + count) > FF_REG_AREA_SIZE) |
| 1418 | return -ERANGE; |
| 1419 | |
| 1420 | if (count == 0) return 0; |
| 1421 | |
| 1422 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 1423 | return -EINVAL; |
| 1424 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1425 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1426 | return -EPERM; |
| 1427 | } |
| 1428 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1429 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1430 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) |
| 1431 | writel(*((uint32_t *)(buf + buf_off)), |
| 1432 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 1433 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1434 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1435 | |
| 1436 | return count; |
| 1437 | } |
| 1438 | |
| 1439 | static ssize_t |
| 1440 | sysfs_ctlreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) |
| 1441 | { |
| 1442 | size_t buf_off; |
| 1443 | uint32_t * tmp_ptr; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1444 | struct class_device *cdev = container_of(kobj, struct class_device, |
| 1445 | kobj); |
| 1446 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 1447 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1448 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1449 | |
| 1450 | if (off > FF_REG_AREA_SIZE) |
| 1451 | return -ERANGE; |
| 1452 | |
| 1453 | if ((off + count) > FF_REG_AREA_SIZE) |
| 1454 | count = FF_REG_AREA_SIZE - off; |
| 1455 | |
| 1456 | if (count == 0) return 0; |
| 1457 | |
| 1458 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 1459 | return -EINVAL; |
| 1460 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1461 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1462 | |
| 1463 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 1464 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 1465 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 1466 | } |
| 1467 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1468 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1469 | |
| 1470 | return count; |
| 1471 | } |
| 1472 | |
| 1473 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 1474 | .attr = { |
| 1475 | .name = "ctlreg", |
| 1476 | .mode = S_IRUSR | S_IWUSR, |
| 1477 | .owner = THIS_MODULE, |
| 1478 | }, |
| 1479 | .size = 256, |
| 1480 | .read = sysfs_ctlreg_read, |
| 1481 | .write = sysfs_ctlreg_write, |
| 1482 | }; |
| 1483 | |
| 1484 | |
| 1485 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1486 | sysfs_mbox_idle(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1487 | { |
| 1488 | phba->sysfs_mbox.state = SMBOX_IDLE; |
| 1489 | phba->sysfs_mbox.offset = 0; |
| 1490 | |
| 1491 | if (phba->sysfs_mbox.mbox) { |
| 1492 | mempool_free(phba->sysfs_mbox.mbox, |
| 1493 | phba->mbox_mem_pool); |
| 1494 | phba->sysfs_mbox.mbox = NULL; |
| 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | static ssize_t |
| 1499 | sysfs_mbox_write(struct kobject *kobj, char *buf, loff_t off, size_t count) |
| 1500 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1501 | struct class_device *cdev = container_of(kobj, struct class_device, |
| 1502 | kobj); |
| 1503 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 1504 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1505 | struct lpfc_hba *phba = vport->phba; |
| 1506 | struct lpfcMboxq *mbox = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1507 | |
| 1508 | if ((count + off) > MAILBOX_CMD_SIZE) |
| 1509 | return -ERANGE; |
| 1510 | |
| 1511 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 1512 | return -EINVAL; |
| 1513 | |
| 1514 | if (count == 0) |
| 1515 | return 0; |
| 1516 | |
| 1517 | if (off == 0) { |
| 1518 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1519 | if (!mbox) |
| 1520 | return -ENOMEM; |
James Smart | fc6c12b | 2006-03-07 15:04:19 -0500 | [diff] [blame] | 1521 | memset(mbox, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1522 | } |
| 1523 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1524 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1525 | |
| 1526 | if (off == 0) { |
| 1527 | if (phba->sysfs_mbox.mbox) |
| 1528 | mempool_free(mbox, phba->mbox_mem_pool); |
| 1529 | else |
| 1530 | phba->sysfs_mbox.mbox = mbox; |
| 1531 | phba->sysfs_mbox.state = SMBOX_WRITING; |
| 1532 | } else { |
| 1533 | if (phba->sysfs_mbox.state != SMBOX_WRITING || |
| 1534 | phba->sysfs_mbox.offset != off || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1535 | phba->sysfs_mbox.mbox == NULL) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1536 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1537 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 1538 | return -EAGAIN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | memcpy((uint8_t *) & phba->sysfs_mbox.mbox->mb + off, |
| 1543 | buf, count); |
| 1544 | |
| 1545 | phba->sysfs_mbox.offset = off + count; |
| 1546 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1547 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1548 | |
| 1549 | return count; |
| 1550 | } |
| 1551 | |
| 1552 | static ssize_t |
| 1553 | sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count) |
| 1554 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1555 | struct class_device *cdev = container_of(kobj, struct class_device, |
| 1556 | kobj); |
| 1557 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 1558 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1559 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1560 | int rc; |
| 1561 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1562 | if (off > MAILBOX_CMD_SIZE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1563 | return -ERANGE; |
| 1564 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1565 | if ((count + off) > MAILBOX_CMD_SIZE) |
| 1566 | count = MAILBOX_CMD_SIZE - off; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1567 | |
| 1568 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 1569 | return -EINVAL; |
| 1570 | |
| 1571 | if (off && count == 0) |
| 1572 | return 0; |
| 1573 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1574 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1575 | |
| 1576 | if (off == 0 && |
| 1577 | phba->sysfs_mbox.state == SMBOX_WRITING && |
| 1578 | phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) { |
| 1579 | |
| 1580 | switch (phba->sysfs_mbox.mbox->mb.mbxCommand) { |
| 1581 | /* Offline only */ |
| 1582 | case MBX_WRITE_NV: |
| 1583 | case MBX_INIT_LINK: |
| 1584 | case MBX_DOWN_LINK: |
| 1585 | case MBX_CONFIG_LINK: |
| 1586 | case MBX_CONFIG_RING: |
| 1587 | case MBX_RESET_RING: |
| 1588 | case MBX_UNREG_LOGIN: |
| 1589 | case MBX_CLEAR_LA: |
| 1590 | case MBX_DUMP_CONTEXT: |
| 1591 | case MBX_RUN_DIAGS: |
| 1592 | case MBX_RESTART: |
| 1593 | case MBX_FLASH_WR_ULA: |
| 1594 | case MBX_SET_MASK: |
| 1595 | case MBX_SET_SLIM: |
| 1596 | case MBX_SET_DEBUG: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1597 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1598 | printk(KERN_WARNING "mbox_read:Command 0x%x " |
| 1599 | "is illegal in on-line state\n", |
| 1600 | phba->sysfs_mbox.mbox->mb.mbxCommand); |
| 1601 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1602 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1603 | return -EPERM; |
| 1604 | } |
| 1605 | case MBX_LOAD_SM: |
| 1606 | case MBX_READ_NV: |
| 1607 | case MBX_READ_CONFIG: |
| 1608 | case MBX_READ_RCONFIG: |
| 1609 | case MBX_READ_STATUS: |
| 1610 | case MBX_READ_XRI: |
| 1611 | case MBX_READ_REV: |
| 1612 | case MBX_READ_LNK_STAT: |
| 1613 | case MBX_DUMP_MEMORY: |
| 1614 | case MBX_DOWN_LOAD: |
| 1615 | case MBX_UPDATE_CFG: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1616 | case MBX_KILL_BOARD: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1617 | case MBX_LOAD_AREA: |
| 1618 | case MBX_LOAD_EXP_ROM: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1619 | case MBX_BEACON: |
| 1620 | case MBX_DEL_LD_ENTRY: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1621 | break; |
| 1622 | case MBX_READ_SPARM64: |
| 1623 | case MBX_READ_LA: |
| 1624 | case MBX_READ_LA64: |
| 1625 | case MBX_REG_LOGIN: |
| 1626 | case MBX_REG_LOGIN64: |
| 1627 | case MBX_CONFIG_PORT: |
| 1628 | case MBX_RUN_BIU_DIAG: |
| 1629 | printk(KERN_WARNING "mbox_read: Illegal Command 0x%x\n", |
| 1630 | phba->sysfs_mbox.mbox->mb.mbxCommand); |
| 1631 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1632 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1633 | return -EPERM; |
| 1634 | default: |
| 1635 | printk(KERN_WARNING "mbox_read: Unknown Command 0x%x\n", |
| 1636 | phba->sysfs_mbox.mbox->mb.mbxCommand); |
| 1637 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1638 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1639 | return -EPERM; |
| 1640 | } |
| 1641 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1642 | phba->sysfs_mbox.mbox->vport = vport; |
| 1643 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1644 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1645 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1646 | spin_unlock_irq(&phba->hbalock); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1647 | return -EAGAIN; |
| 1648 | } |
| 1649 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1650 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1651 | (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE))){ |
| 1652 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1653 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1654 | rc = lpfc_sli_issue_mbox (phba, |
| 1655 | phba->sysfs_mbox.mbox, |
| 1656 | MBX_POLL); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1657 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1658 | |
| 1659 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1660 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1661 | rc = lpfc_sli_issue_mbox_wait (phba, |
| 1662 | phba->sysfs_mbox.mbox, |
James Smart | a309a6b | 2006-08-01 07:33:43 -0400 | [diff] [blame] | 1663 | lpfc_mbox_tmo_val(phba, |
| 1664 | phba->sysfs_mbox.mbox->mb.mbxCommand) * HZ); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1665 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1666 | } |
| 1667 | |
| 1668 | if (rc != MBX_SUCCESS) { |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1669 | if (rc == MBX_TIMEOUT) { |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1670 | phba->sysfs_mbox.mbox = NULL; |
| 1671 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1672 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1673 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 1674 | return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1675 | } |
| 1676 | phba->sysfs_mbox.state = SMBOX_READING; |
| 1677 | } |
| 1678 | else if (phba->sysfs_mbox.offset != off || |
| 1679 | phba->sysfs_mbox.state != SMBOX_READING) { |
| 1680 | printk(KERN_WARNING "mbox_read: Bad State\n"); |
| 1681 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1682 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 1683 | return -EAGAIN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1684 | } |
| 1685 | |
| 1686 | memcpy(buf, (uint8_t *) & phba->sysfs_mbox.mbox->mb + off, count); |
| 1687 | |
| 1688 | phba->sysfs_mbox.offset = off + count; |
| 1689 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1690 | if (phba->sysfs_mbox.offset == MAILBOX_CMD_SIZE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1691 | sysfs_mbox_idle(phba); |
| 1692 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1693 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1694 | |
| 1695 | return count; |
| 1696 | } |
| 1697 | |
| 1698 | static struct bin_attribute sysfs_mbox_attr = { |
| 1699 | .attr = { |
| 1700 | .name = "mbox", |
| 1701 | .mode = S_IRUSR | S_IWUSR, |
| 1702 | .owner = THIS_MODULE, |
| 1703 | }, |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1704 | .size = MAILBOX_CMD_SIZE, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1705 | .read = sysfs_mbox_read, |
| 1706 | .write = sysfs_mbox_write, |
| 1707 | }; |
| 1708 | |
| 1709 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1710 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1711 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1712 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1713 | int error; |
| 1714 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1715 | error = sysfs_create_bin_file(&shost->shost_classdev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1716 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1717 | if (error) |
| 1718 | goto out; |
| 1719 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1720 | error = sysfs_create_bin_file(&shost->shost_classdev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1721 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1722 | if (error) |
| 1723 | goto out_remove_ctlreg_attr; |
| 1724 | |
| 1725 | return 0; |
| 1726 | out_remove_ctlreg_attr: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1727 | sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1728 | out: |
| 1729 | return error; |
| 1730 | } |
| 1731 | |
| 1732 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1733 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1734 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1735 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1736 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1737 | sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_mbox_attr); |
| 1738 | sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1739 | } |
| 1740 | |
| 1741 | |
| 1742 | /* |
| 1743 | * Dynamic FC Host Attributes Support |
| 1744 | */ |
| 1745 | |
| 1746 | static void |
| 1747 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 1748 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1749 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1750 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1751 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1752 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1753 | } |
| 1754 | |
| 1755 | static void |
| 1756 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 1757 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1758 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1759 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1760 | |
| 1761 | spin_lock_irq(shost->host_lock); |
| 1762 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1763 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 1764 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 1765 | } else if (lpfc_is_link_up(phba)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1766 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1767 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1768 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 1769 | else |
| 1770 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 1771 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1772 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1773 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 1774 | else |
| 1775 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 1776 | } |
| 1777 | } else |
| 1778 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 1779 | |
| 1780 | spin_unlock_irq(shost->host_lock); |
| 1781 | } |
| 1782 | |
| 1783 | static void |
| 1784 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 1785 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1786 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1787 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1788 | |
| 1789 | spin_lock_irq(shost->host_lock); |
| 1790 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1791 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1792 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 1793 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1794 | switch (phba->link_state) { |
| 1795 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1796 | case LPFC_LINK_DOWN: |
| 1797 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 1798 | break; |
| 1799 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1800 | case LPFC_CLEAR_LA: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1801 | case LPFC_HBA_READY: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1802 | /* Links up, beyond this port_type reports state */ |
| 1803 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
| 1804 | break; |
| 1805 | case LPFC_HBA_ERROR: |
| 1806 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 1807 | break; |
| 1808 | default: |
| 1809 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 1810 | break; |
| 1811 | } |
| 1812 | } |
| 1813 | |
| 1814 | spin_unlock_irq(shost->host_lock); |
| 1815 | } |
| 1816 | |
| 1817 | static void |
| 1818 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 1819 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1820 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1821 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1822 | |
| 1823 | spin_lock_irq(shost->host_lock); |
| 1824 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1825 | if (lpfc_is_link_up(phba)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1826 | switch(phba->fc_linkspeed) { |
| 1827 | case LA_1GHZ_LINK: |
| 1828 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| 1829 | break; |
| 1830 | case LA_2GHZ_LINK: |
| 1831 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| 1832 | break; |
| 1833 | case LA_4GHZ_LINK: |
| 1834 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| 1835 | break; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1836 | case LA_8GHZ_LINK: |
| 1837 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
| 1838 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1839 | default: |
| 1840 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| 1841 | break; |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | spin_unlock_irq(shost->host_lock); |
| 1846 | } |
| 1847 | |
| 1848 | static void |
| 1849 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 1850 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1851 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1852 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 1853 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1854 | |
| 1855 | spin_lock_irq(shost->host_lock); |
| 1856 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1857 | if ((vport->fc_flag & FC_FABRIC) || |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1858 | ((phba->fc_topology == TOPOLOGY_LOOP) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1859 | (vport->fc_flag & FC_PUBLIC_LOOP))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 1860 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1861 | else |
| 1862 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1863 | node_name = wwn_to_u64(vport->fc_nodename.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1864 | |
| 1865 | spin_unlock_irq(shost->host_lock); |
| 1866 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 1867 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1868 | } |
| 1869 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1870 | static struct fc_host_statistics * |
| 1871 | lpfc_get_stats(struct Scsi_Host *shost) |
| 1872 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1873 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1874 | struct lpfc_hba *phba = vport->phba; |
| 1875 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 1876 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1877 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1878 | LPFC_MBOXQ_t *pmboxq; |
| 1879 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1880 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1881 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1882 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1883 | /* |
| 1884 | * prevent udev from issuing mailbox commands until the port is |
| 1885 | * configured. |
| 1886 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1887 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1888 | !phba->mbox_mem_pool || |
| 1889 | (phba->sli.sli_flag & LPFC_SLI2_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1890 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1891 | |
| 1892 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1893 | return NULL; |
| 1894 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1895 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1896 | if (!pmboxq) |
| 1897 | return NULL; |
| 1898 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1899 | |
| 1900 | pmb = &pmboxq->mb; |
| 1901 | pmb->mbxCommand = MBX_READ_STATUS; |
| 1902 | pmb->mbxOwner = OWN_HOST; |
| 1903 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1904 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1905 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1906 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1907 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1908 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1909 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1910 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1911 | |
| 1912 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1913 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1914 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1915 | return NULL; |
| 1916 | } |
| 1917 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 1918 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 1919 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1920 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
| 1921 | hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); |
| 1922 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
| 1923 | hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256); |
| 1924 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1925 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1926 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 1927 | pmb->mbxOwner = OWN_HOST; |
| 1928 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1929 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1930 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1931 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1932 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1933 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1934 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1935 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1936 | |
| 1937 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 1938 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1939 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1940 | return NULL; |
| 1941 | } |
| 1942 | |
| 1943 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 1944 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 1945 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 1946 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 1947 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 1948 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 1949 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 1950 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1951 | hs->link_failure_count -= lso->link_failure_count; |
| 1952 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 1953 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 1954 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 1955 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 1956 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 1957 | hs->error_frames -= lso->error_frames; |
| 1958 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1959 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
| 1960 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1961 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1962 | hs->nos_count = -1; |
| 1963 | } else { |
| 1964 | hs->lip_count = -1; |
| 1965 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1966 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1967 | } |
| 1968 | |
| 1969 | hs->dumped_frames = -1; |
| 1970 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1971 | seconds = get_seconds(); |
| 1972 | if (seconds < psli->stats_start) |
| 1973 | hs->seconds_since_last_reset = seconds + |
| 1974 | ((unsigned long)-1 - psli->stats_start); |
| 1975 | else |
| 1976 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1977 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 1978 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1979 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1980 | return hs; |
| 1981 | } |
| 1982 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1983 | static void |
| 1984 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 1985 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1986 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1987 | struct lpfc_hba *phba = vport->phba; |
| 1988 | struct lpfc_sli *psli = &phba->sli; |
| 1989 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1990 | LPFC_MBOXQ_t *pmboxq; |
| 1991 | MAILBOX_t *pmb; |
| 1992 | int rc = 0; |
| 1993 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1994 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1995 | return; |
| 1996 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 1997 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1998 | if (!pmboxq) |
| 1999 | return; |
| 2000 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 2001 | |
| 2002 | pmb = &pmboxq->mb; |
| 2003 | pmb->mbxCommand = MBX_READ_STATUS; |
| 2004 | pmb->mbxOwner = OWN_HOST; |
| 2005 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 2006 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2007 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2008 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2009 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2010 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) |
| 2011 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 2012 | else |
| 2013 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 2014 | |
| 2015 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 2016 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2017 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 2018 | return; |
| 2019 | } |
| 2020 | |
| 2021 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 2022 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 2023 | pmb->mbxOwner = OWN_HOST; |
| 2024 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2025 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2026 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2027 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2028 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) |
| 2029 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 2030 | else |
| 2031 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 2032 | |
| 2033 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 2034 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2035 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 2036 | return; |
| 2037 | } |
| 2038 | |
| 2039 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 2040 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 2041 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 2042 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 2043 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 2044 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 2045 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
| 2046 | lso->link_events = (phba->fc_eventTag >> 1); |
| 2047 | |
| 2048 | psli->stats_start = get_seconds(); |
| 2049 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 2050 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 2051 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2052 | return; |
| 2053 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2054 | |
| 2055 | /* |
| 2056 | * The LPFC driver treats linkdown handling as target loss events so there |
| 2057 | * are no sysfs handlers for link_down_tmo. |
| 2058 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2059 | |
| 2060 | static struct lpfc_nodelist * |
| 2061 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2062 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2063 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 2064 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2065 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2066 | |
| 2067 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2068 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2069 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2070 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
| 2071 | starget->id == ndlp->nlp_sid) { |
| 2072 | spin_unlock_irq(shost->host_lock); |
| 2073 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2074 | } |
| 2075 | } |
| 2076 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2077 | return NULL; |
| 2078 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2079 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2080 | static void |
| 2081 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 2082 | { |
| 2083 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 2084 | |
| 2085 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | } |
| 2087 | |
| 2088 | static void |
| 2089 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 2090 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2091 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2092 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2093 | fc_starget_node_name(starget) = |
| 2094 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2095 | } |
| 2096 | |
| 2097 | static void |
| 2098 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 2099 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2100 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2101 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 2102 | fc_starget_port_name(starget) = |
| 2103 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2104 | } |
| 2105 | |
| 2106 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2107 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 2108 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2109 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2110 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2111 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2112 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2113 | } |
| 2114 | |
| 2115 | |
| 2116 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 2117 | static ssize_t \ |
| 2118 | lpfc_show_rport_##field (struct class_device *cdev, char *buf) \ |
| 2119 | { \ |
| 2120 | struct fc_rport *rport = transport_class_to_rport(cdev); \ |
| 2121 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 2122 | return snprintf(buf, sz, format_string, \ |
| 2123 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 2124 | } |
| 2125 | |
| 2126 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 2127 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 2128 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 2129 | |
| 2130 | |
| 2131 | struct fc_function_template lpfc_transport_functions = { |
| 2132 | /* fixed attributes the driver supports */ |
| 2133 | .show_host_node_name = 1, |
| 2134 | .show_host_port_name = 1, |
| 2135 | .show_host_supported_classes = 1, |
| 2136 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2137 | .show_host_supported_speeds = 1, |
| 2138 | .show_host_maxframe_size = 1, |
| 2139 | |
| 2140 | /* dynamic attributes the driver supports */ |
| 2141 | .get_host_port_id = lpfc_get_host_port_id, |
| 2142 | .show_host_port_id = 1, |
| 2143 | |
| 2144 | .get_host_port_type = lpfc_get_host_port_type, |
| 2145 | .show_host_port_type = 1, |
| 2146 | |
| 2147 | .get_host_port_state = lpfc_get_host_port_state, |
| 2148 | .show_host_port_state = 1, |
| 2149 | |
| 2150 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 2151 | .show_host_active_fc4s = 1, |
| 2152 | |
| 2153 | .get_host_speed = lpfc_get_host_speed, |
| 2154 | .show_host_speed = 1, |
| 2155 | |
| 2156 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 2157 | .show_host_fabric_name = 1, |
| 2158 | |
| 2159 | /* |
| 2160 | * The LPFC driver treats linkdown handling as target loss events |
| 2161 | * so there are no sysfs handlers for link_down_tmo. |
| 2162 | */ |
| 2163 | |
| 2164 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 2165 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2166 | |
| 2167 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 2168 | .show_rport_maxframe_size = 1, |
| 2169 | .show_rport_supported_classes = 1, |
| 2170 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2171 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 2172 | .show_rport_dev_loss_tmo = 1, |
| 2173 | |
| 2174 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 2175 | .show_starget_port_id = 1, |
| 2176 | |
| 2177 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 2178 | .show_starget_node_name = 1, |
| 2179 | |
| 2180 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 2181 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 2182 | |
| 2183 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2184 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 2185 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2186 | |
| 2187 | .vport_create = lpfc_vport_create, |
| 2188 | .vport_delete = lpfc_vport_delete, |
| 2189 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
| 2190 | }; |
| 2191 | |
| 2192 | struct fc_function_template lpfc_vport_transport_functions = { |
| 2193 | /* fixed attributes the driver supports */ |
| 2194 | .show_host_node_name = 1, |
| 2195 | .show_host_port_name = 1, |
| 2196 | .show_host_supported_classes = 1, |
| 2197 | .show_host_supported_fc4s = 1, |
| 2198 | .show_host_supported_speeds = 1, |
| 2199 | .show_host_maxframe_size = 1, |
| 2200 | |
| 2201 | /* dynamic attributes the driver supports */ |
| 2202 | .get_host_port_id = lpfc_get_host_port_id, |
| 2203 | .show_host_port_id = 1, |
| 2204 | |
| 2205 | .get_host_port_type = lpfc_get_host_port_type, |
| 2206 | .show_host_port_type = 1, |
| 2207 | |
| 2208 | .get_host_port_state = lpfc_get_host_port_state, |
| 2209 | .show_host_port_state = 1, |
| 2210 | |
| 2211 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 2212 | .show_host_active_fc4s = 1, |
| 2213 | |
| 2214 | .get_host_speed = lpfc_get_host_speed, |
| 2215 | .show_host_speed = 1, |
| 2216 | |
| 2217 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 2218 | .show_host_fabric_name = 1, |
| 2219 | |
| 2220 | /* |
| 2221 | * The LPFC driver treats linkdown handling as target loss events |
| 2222 | * so there are no sysfs handlers for link_down_tmo. |
| 2223 | */ |
| 2224 | |
| 2225 | .get_fc_host_stats = lpfc_get_stats, |
| 2226 | .reset_fc_host_stats = lpfc_reset_stats, |
| 2227 | |
| 2228 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 2229 | .show_rport_maxframe_size = 1, |
| 2230 | .show_rport_supported_classes = 1, |
| 2231 | |
| 2232 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 2233 | .show_rport_dev_loss_tmo = 1, |
| 2234 | |
| 2235 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 2236 | .show_starget_port_id = 1, |
| 2237 | |
| 2238 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 2239 | .show_starget_node_name = 1, |
| 2240 | |
| 2241 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 2242 | .show_starget_port_name = 1, |
| 2243 | |
| 2244 | .issue_fc_host_lip = lpfc_issue_lip, |
| 2245 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 2246 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 2247 | |
| 2248 | .vport_disable = lpfc_vport_disable, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2249 | }; |
| 2250 | |
| 2251 | void |
| 2252 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 2253 | { |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2254 | lpfc_log_verbose_init(phba, lpfc_log_verbose); |
| 2255 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 2256 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 2257 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 2258 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 2259 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2260 | lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth); |
| 2261 | lpfc_fcp_class_init(phba, lpfc_fcp_class); |
| 2262 | lpfc_use_adisc_init(phba, lpfc_use_adisc); |
| 2263 | lpfc_ack0_init(phba, lpfc_ack0); |
| 2264 | lpfc_topology_init(phba, lpfc_topology); |
| 2265 | lpfc_scan_down_init(phba, lpfc_scan_down); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2266 | lpfc_link_speed_init(phba, lpfc_link_speed); |
| 2267 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 2268 | lpfc_discovery_threads_init(phba, lpfc_discovery_threads); |
| 2269 | lpfc_max_luns_init(phba, lpfc_max_luns); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2270 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2271 | lpfc_peer_port_login_init(phba, lpfc_peer_port_login); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 2272 | lpfc_npiv_enable_init(phba, lpfc_npiv_enable); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2273 | lpfc_vport_restrict_login_init(phba, lpfc_vport_restrict_login); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 2274 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2275 | lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo); |
| 2276 | lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2277 | phba->cfg_poll = lpfc_poll; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2278 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2279 | phba->cfg_soft_wwpn = 0L; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2280 | |
| 2281 | /* |
| 2282 | * The total number of segments is the configuration value plus 2 |
| 2283 | * since the IOCB need a command and response bde. |
| 2284 | */ |
| 2285 | phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2; |
| 2286 | |
| 2287 | /* |
| 2288 | * Since the sg_tablesize is module parameter, the sg_dma_buf_size |
| 2289 | * used to create the sg_dma_buf_pool must be dynamically calculated |
| 2290 | */ |
| 2291 | phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + |
| 2292 | sizeof(struct fcp_rsp) + |
| 2293 | (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64)); |
| 2294 | |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 2295 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2296 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 2297 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2298 | return; |
| 2299 | } |