| 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 | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4 | * Copyright (C) 2004-2011 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> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 26 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 27 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 28 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 29 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 30 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 31 | #include <scsi/scsi_device.h> |
| 32 | #include <scsi/scsi_host.h> |
| 33 | #include <scsi/scsi_tcq.h> |
| 34 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 35 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 36 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 37 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 38 | #include "lpfc_hw.h" |
| 39 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 40 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 41 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 42 | #include "lpfc_disc.h" |
| 43 | #include "lpfc_scsi.h" |
| 44 | #include "lpfc.h" |
| 45 | #include "lpfc_logmsg.h" |
| 46 | #include "lpfc_version.h" |
| 47 | #include "lpfc_compat.h" |
| 48 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 49 | #include "lpfc_vport.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 50 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 51 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 52 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 53 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 54 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 55 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 56 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 57 | * @incr: integer to convert. |
| 58 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 59 | * |
| 60 | * Description: |
| 61 | * JEDEC Joint Electron Device Engineering Council. |
| 62 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 63 | * character string. The string is then terminated with a NULL in byte 9. |
| 64 | * Hex 0-9 becomes ascii '0' to '9'. |
| 65 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 66 | * |
| 67 | * Notes: |
| 68 | * Coded for 32 bit integers only. |
| 69 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 70 | static void |
| 71 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 72 | { |
| 73 | int i, j; |
| 74 | for (i = 0; i < 8; i++) { |
| 75 | j = (incr & 0xf); |
| 76 | if (j <= 9) |
| 77 | hdw[7 - i] = 0x30 + j; |
| 78 | else |
| 79 | hdw[7 - i] = 0x61 + j - 10; |
| 80 | incr = (incr >> 4); |
| 81 | } |
| 82 | hdw[8] = 0; |
| 83 | return; |
| 84 | } |
| 85 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 86 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 87 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 88 | * @dev: class unused variable. |
| 89 | * @attr: device attribute, not used. |
| 90 | * @buf: on return contains the module description text. |
| 91 | * |
| 92 | * Returns: size of formatted string. |
| 93 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 94 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 95 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 96 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 97 | { |
| 98 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 99 | } |
| 100 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 101 | /** |
| 102 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 103 | * @dev: class unused variable. |
| 104 | * @attr: device attribute, not used. |
| 105 | * @buf: on return contains the module description text. |
| 106 | * |
| 107 | * Returns: size of formatted string. |
| 108 | **/ |
| 109 | static ssize_t |
| 110 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 111 | char *buf) |
| 112 | { |
| 113 | struct Scsi_Host *shost = class_to_shost(dev); |
| 114 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 115 | struct lpfc_hba *phba = vport->phba; |
| 116 | |
| 117 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 118 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 119 | else |
| 120 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 121 | } |
| 122 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 123 | static ssize_t |
| 124 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 125 | char *buf) |
| 126 | { |
| 127 | struct Scsi_Host *shost = class_to_shost(dev); |
| 128 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 129 | struct lpfc_hba *phba = vport->phba; |
| 130 | |
| 131 | if (phba->cfg_enable_bg) |
| 132 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 133 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 134 | else |
| 135 | return snprintf(buf, PAGE_SIZE, |
| 136 | "BlockGuard Not Supported\n"); |
| 137 | else |
| 138 | return snprintf(buf, PAGE_SIZE, |
| 139 | "BlockGuard Disabled\n"); |
| 140 | } |
| 141 | |
| 142 | static ssize_t |
| 143 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 144 | char *buf) |
| 145 | { |
| 146 | struct Scsi_Host *shost = class_to_shost(dev); |
| 147 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 148 | struct lpfc_hba *phba = vport->phba; |
| 149 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 150 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 151 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | static ssize_t |
| 155 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 156 | char *buf) |
| 157 | { |
| 158 | struct Scsi_Host *shost = class_to_shost(dev); |
| 159 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 160 | struct lpfc_hba *phba = vport->phba; |
| 161 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 162 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 163 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | static ssize_t |
| 167 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 168 | char *buf) |
| 169 | { |
| 170 | struct Scsi_Host *shost = class_to_shost(dev); |
| 171 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 172 | struct lpfc_hba *phba = vport->phba; |
| 173 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 174 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 175 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 176 | } |
| 177 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 178 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 179 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 180 | * @dev: class converted to a Scsi_host structure. |
| 181 | * @attr: device attribute, not used. |
| 182 | * @buf: on return contains the formatted text from lpfc_info(). |
| 183 | * |
| 184 | * Returns: size of formatted string. |
| 185 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 186 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 187 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 188 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 189 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 190 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 191 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 192 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 193 | } |
| 194 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 195 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 196 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 197 | * @dev: class converted to a Scsi_host structure. |
| 198 | * @attr: device attribute, not used. |
| 199 | * @buf: on return contains the formatted text serial number. |
| 200 | * |
| 201 | * Returns: size of formatted string. |
| 202 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 203 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 204 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 205 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 206 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 207 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 208 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 209 | struct lpfc_hba *phba = vport->phba; |
| 210 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 211 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 212 | } |
| 213 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 214 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 215 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 216 | * @dev: class converted to a Scsi_host structure. |
| 217 | * @attr: device attribute, not used. |
| 218 | * @buf: on return contains the formatted support level. |
| 219 | * |
| 220 | * Description: |
| 221 | * Returns a number indicating the temperature sensor level currently |
| 222 | * supported, zero or one in ascii. |
| 223 | * |
| 224 | * Returns: size of formatted string. |
| 225 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 226 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 227 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 228 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 229 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 230 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 231 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 232 | struct lpfc_hba *phba = vport->phba; |
| 233 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 234 | } |
| 235 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 236 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 237 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 238 | * @dev: class converted to a Scsi_host structure. |
| 239 | * @attr: device attribute, not used. |
| 240 | * @buf: on return contains the scsi vpd model description. |
| 241 | * |
| 242 | * Returns: size of formatted string. |
| 243 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 244 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 245 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 246 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 247 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 248 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 249 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 250 | struct lpfc_hba *phba = vport->phba; |
| 251 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 252 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 253 | } |
| 254 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 255 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 256 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 257 | * @dev: class converted to a Scsi_host structure. |
| 258 | * @attr: device attribute, not used. |
| 259 | * @buf: on return contains the scsi vpd model name. |
| 260 | * |
| 261 | * Returns: size of formatted string. |
| 262 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 263 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 264 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 265 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 266 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 267 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 268 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 269 | struct lpfc_hba *phba = vport->phba; |
| 270 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 271 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 272 | } |
| 273 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 274 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 275 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 276 | * @dev: class converted to a Scsi_host structure. |
| 277 | * @attr: device attribute, not used. |
| 278 | * @buf: on return contains the scsi vpd program type. |
| 279 | * |
| 280 | * Returns: size of formatted string. |
| 281 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 282 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 283 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 284 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 285 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 286 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 287 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 288 | struct lpfc_hba *phba = vport->phba; |
| 289 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 290 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 291 | } |
| 292 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 293 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 294 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 295 | * @dev: class converted to a Scsi_host structure. |
| 296 | * @attr: device attribute, not used. |
| 297 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 298 | * |
| 299 | * Returns: size of formatted string. |
| 300 | **/ |
| 301 | static ssize_t |
| 302 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 303 | { |
| 304 | struct Scsi_Host *shost = class_to_shost(dev); |
| 305 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 306 | struct lpfc_hba *phba = vport->phba; |
| 307 | |
| 308 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 309 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 310 | } |
| 311 | |
| 312 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 313 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 314 | * @dev: class converted to a Scsi_host structure. |
| 315 | * @attr: device attribute, not used. |
| 316 | * @buf: on return contains scsi vpd program type. |
| 317 | * |
| 318 | * Returns: size of formatted string. |
| 319 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 320 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 321 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 322 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 323 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 324 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 325 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 326 | struct lpfc_hba *phba = vport->phba; |
| 327 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 328 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 329 | } |
| 330 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 331 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 332 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 333 | * @dev: class converted to a Scsi_host structure. |
| 334 | * @attr: device attribute, not used. |
| 335 | * @buf: on return contains the scsi vpd program type. |
| 336 | * |
| 337 | * Returns: size of formatted string. |
| 338 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 339 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 340 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 341 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 342 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 343 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 344 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 345 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 346 | char fwrev[32]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 347 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 348 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 349 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 350 | } |
| 351 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 352 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 353 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 354 | * @dev: class converted to a Scsi_host structure. |
| 355 | * @attr: device attribute, not used. |
| 356 | * @buf: on return contains the scsi vpd program type. |
| 357 | * |
| 358 | * Returns: size of formatted string. |
| 359 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 360 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 361 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 362 | { |
| 363 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 364 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 365 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 366 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 367 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 368 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 369 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 370 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 371 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 372 | |
| 373 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 374 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 375 | * @dev: class converted to a Scsi_host structure. |
| 376 | * @attr: device attribute, not used. |
| 377 | * @buf: on return contains the ROM and FCode ascii strings. |
| 378 | * |
| 379 | * Returns: size of formatted string. |
| 380 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 381 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 382 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 383 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 384 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 385 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 386 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 387 | struct lpfc_hba *phba = vport->phba; |
| 388 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 389 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 390 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 391 | |
| 392 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 393 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 394 | * @dev: class converted to a Scsi_host structure. |
| 395 | * @attr: device attribute, not used. |
| 396 | * @buf: on return contains text describing the state of the link. |
| 397 | * |
| 398 | * Notes: |
| 399 | * The switch statement has no default so zero will be returned. |
| 400 | * |
| 401 | * Returns: size of formatted string. |
| 402 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 403 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 404 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 405 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 406 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 407 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 408 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 409 | struct lpfc_hba *phba = vport->phba; |
| 410 | int len = 0; |
| 411 | |
| 412 | switch (phba->link_state) { |
| 413 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 414 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 415 | case LPFC_INIT_START: |
| 416 | case LPFC_INIT_MBX_CMDS: |
| 417 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 418 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 419 | if (phba->hba_flag & LINK_DISABLED) |
| 420 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 421 | "Link Down - User disabled\n"); |
| 422 | else |
| 423 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 424 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 425 | break; |
| 426 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 427 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 428 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 429 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 430 | |
| 431 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 432 | case LPFC_LOCAL_CFG_LINK: |
| 433 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 434 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 435 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 436 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 437 | case LPFC_FLOGI: |
| 438 | case LPFC_FABRIC_CFG_LINK: |
| 439 | case LPFC_NS_REG: |
| 440 | case LPFC_NS_QRY: |
| 441 | case LPFC_BUILD_DISC_LIST: |
| 442 | case LPFC_DISC_AUTH: |
| 443 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 444 | "Discovery\n"); |
| 445 | break; |
| 446 | case LPFC_VPORT_READY: |
| 447 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 448 | break; |
| 449 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 450 | case LPFC_VPORT_FAILED: |
| 451 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 452 | break; |
| 453 | |
| 454 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 455 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 456 | "Unknown\n"); |
| 457 | break; |
| 458 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 459 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 460 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 461 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 462 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 463 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 464 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 465 | " Public Loop\n"); |
| 466 | else |
| 467 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 468 | " Private Loop\n"); |
| 469 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 470 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 471 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 472 | " Fabric\n"); |
| 473 | else |
| 474 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 475 | " Point-2-Point\n"); |
| 476 | } |
| 477 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 478 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 479 | return len; |
| 480 | } |
| 481 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 482 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 483 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 484 | * @dev: class device that is converted into a Scsi_host. |
| 485 | * @attr: device attribute, not used. |
| 486 | * @buf: one or more lpfc_polling_flags values. |
| 487 | * @count: not used. |
| 488 | * |
| 489 | * Returns: |
| 490 | * -EINVAL if the buffer is not "up" or "down" |
| 491 | * return from link state change function if non-zero |
| 492 | * length of the buf on success |
| 493 | **/ |
| 494 | static ssize_t |
| 495 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 496 | const char *buf, size_t count) |
| 497 | { |
| 498 | struct Scsi_Host *shost = class_to_shost(dev); |
| 499 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 500 | struct lpfc_hba *phba = vport->phba; |
| 501 | |
| 502 | int status = -EINVAL; |
| 503 | |
| 504 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 505 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 506 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 507 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 508 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 509 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 510 | |
| 511 | if (status == 0) |
| 512 | return strlen(buf); |
| 513 | else |
| 514 | return status; |
| 515 | } |
| 516 | |
| 517 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 518 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 519 | * @dev: class device that is converted into a Scsi_host. |
| 520 | * @attr: device attribute, not used. |
| 521 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 522 | * |
| 523 | * Description: |
| 524 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 525 | * vport counts. |
| 526 | * |
| 527 | * Returns: size of formatted string. |
| 528 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 529 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 530 | lpfc_num_discovered_ports_show(struct device *dev, |
| 531 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 532 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 533 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 534 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 535 | |
| 536 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 537 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 538 | } |
| 539 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 540 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 541 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 542 | * @shost: Scsi_Host pointer. |
| 543 | * |
| 544 | * Description: |
| 545 | * Bring the link down gracefully then re-init the link. The firmware will |
| 546 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 547 | * |
| 548 | * Returns: |
| 549 | * -EPERM port offline or management commands are being blocked |
| 550 | * -ENOMEM cannot allocate memory for the mailbox command |
| 551 | * -EIO error sending the mailbox command |
| 552 | * zero for success |
| 553 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 554 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 555 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 556 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 557 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 558 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 559 | LPFC_MBOXQ_t *pmboxq; |
| 560 | int mbxstatus = MBXERR_ERROR; |
| 561 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 562 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 563 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 564 | return -EPERM; |
| 565 | |
| 566 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 567 | |
| 568 | if (!pmboxq) |
| 569 | return -ENOMEM; |
| 570 | |
| 571 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 572 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 573 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 574 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 575 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 576 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 577 | if ((mbxstatus == MBX_SUCCESS) && |
| 578 | (pmboxq->u.mb.mbxStatus == 0 || |
| 579 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 580 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 581 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 582 | phba->cfg_link_speed); |
| 583 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 584 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 585 | if ((mbxstatus == MBX_SUCCESS) && |
| 586 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 587 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 588 | "2859 SLI authentication is required " |
| 589 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 590 | } |
| 591 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 592 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 593 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 594 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 595 | |
| 596 | if (mbxstatus == MBXERR_ERROR) |
| 597 | return -EIO; |
| 598 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 599 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 600 | } |
| 601 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 602 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 603 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 604 | * @phba: lpfc_hba pointer. |
| 605 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 606 | * |
| 607 | * Notes: |
| 608 | * Assumes any error from lpfc_do_offline() will be negative. |
| 609 | * Can wait up to 5 seconds for the port ring buffers count |
| 610 | * to reach zero, prints a warning if it is not zero and continues. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 611 | * lpfc_workq_post_event() returns a non-zero return code if call fails. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 612 | * |
| 613 | * Returns: |
| 614 | * -EIO error posting the event |
| 615 | * zero for success |
| 616 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 617 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 618 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 619 | { |
| 620 | struct completion online_compl; |
| 621 | struct lpfc_sli_ring *pring; |
| 622 | struct lpfc_sli *psli; |
| 623 | int status = 0; |
| 624 | int cnt = 0; |
| 625 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 626 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 627 | |
| 628 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 629 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 630 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 631 | if (rc == 0) |
| 632 | return -ENOMEM; |
| 633 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 634 | wait_for_completion(&online_compl); |
| 635 | |
| 636 | if (status != 0) |
| 637 | return -EIO; |
| 638 | |
| 639 | psli = &phba->sli; |
| 640 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 641 | /* Wait a little for things to settle down, but not |
| 642 | * long enough for dev loss timeout to expire. |
| 643 | */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 644 | for (i = 0; i < psli->num_rings; i++) { |
| 645 | pring = &psli->ring[i]; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 646 | while (pring->txcmplq_cnt) { |
| 647 | msleep(10); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 648 | if (cnt++ > 500) { /* 5 secs */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 649 | lpfc_printf_log(phba, |
| 650 | KERN_WARNING, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 651 | "0466 Outstanding IO when " |
| 652 | "bringing Adapter offline\n"); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 653 | break; |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 659 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 660 | if (rc == 0) |
| 661 | return -ENOMEM; |
| 662 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 663 | wait_for_completion(&online_compl); |
| 664 | |
| 665 | if (status != 0) |
| 666 | return -EIO; |
| 667 | |
| 668 | return 0; |
| 669 | } |
| 670 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 671 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 672 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 673 | * @phba: lpfc_hba pointer. |
| 674 | * |
| 675 | * Description: |
| 676 | * If the port is configured to allow a reset then the hba is brought |
| 677 | * offline then online. |
| 678 | * |
| 679 | * Notes: |
| 680 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 681 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 682 | * |
| 683 | * Returns: |
| 684 | * lpfc_do_offline() return code if not zero |
| 685 | * -EIO reset not configured or error posting the event |
| 686 | * zero for success |
| 687 | **/ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 688 | static int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 689 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 690 | { |
| 691 | struct completion online_compl; |
| 692 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 693 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 694 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 695 | if (!phba->cfg_enable_hba_reset) |
| 696 | return -EIO; |
| 697 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 698 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 699 | |
| 700 | if (status != 0) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 701 | return status; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 702 | |
| 703 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 704 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 705 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 706 | if (rc == 0) |
| 707 | return -ENOMEM; |
| 708 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 709 | wait_for_completion(&online_compl); |
| 710 | |
| 711 | if (status != 0) |
| 712 | return -EIO; |
| 713 | |
| 714 | return 0; |
| 715 | } |
| 716 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 717 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 718 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 719 | * @dev: class device that is converted into a Scsi_host. |
| 720 | * @attr: device attribute, not used. |
| 721 | * @buf: containing the string "selective". |
| 722 | * @count: unused variable. |
| 723 | * |
| 724 | * Description: |
| 725 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 726 | * is called to perform the reset. |
| 727 | * |
| 728 | * Notes: |
| 729 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 730 | * If lpfc_selective_reset() returns zero then the length of the buffer |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 731 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 732 | * |
| 733 | * Returns: |
| 734 | * -EINVAL if the buffer does not contain the string "selective" |
| 735 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 736 | * return value of lpfc_selective_reset() if the call fails |
| 737 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 738 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 739 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 740 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 741 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 742 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 743 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 744 | struct lpfc_hba *phba = vport->phba; |
| 745 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 746 | int status = -EINVAL; |
| 747 | |
| 748 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
| 749 | status = lpfc_selective_reset(phba); |
| 750 | |
| 751 | if (status == 0) |
| 752 | return strlen(buf); |
| 753 | else |
| 754 | return status; |
| 755 | } |
| 756 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 757 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 758 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 759 | * @dev: class device that is converted into a Scsi_host. |
| 760 | * @attr: device attribute, not used. |
| 761 | * @buf: on return contains the ascii number of nport events. |
| 762 | * |
| 763 | * Returns: size of formatted string. |
| 764 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 765 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 766 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 767 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 768 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 769 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 770 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 771 | struct lpfc_hba *phba = vport->phba; |
| 772 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 773 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 774 | } |
| 775 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 776 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 777 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 778 | * @dev: class device that is converted into a Scsi_host. |
| 779 | * @attr: device attribute, not used. |
| 780 | * @buf: on return contains the state of the adapter. |
| 781 | * |
| 782 | * Returns: size of formatted string. |
| 783 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 784 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 785 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 786 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 787 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 788 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 789 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 790 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 791 | char * state; |
| 792 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 793 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 794 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 795 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 796 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 797 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 798 | state = "offline"; |
| 799 | else |
| 800 | state = "online"; |
| 801 | |
| 802 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 803 | } |
| 804 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 805 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 806 | * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 807 | * @dev: class device that is converted into a Scsi_host. |
| 808 | * @attr: device attribute, not used. |
| 809 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 810 | * @count: unused variable. |
| 811 | * |
| 812 | * Returns: |
| 813 | * -EACCES if enable hba reset not enabled |
| 814 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 815 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 816 | * buf length greater than zero indicates success |
| 817 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 818 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 819 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 820 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 821 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 822 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 823 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 824 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 825 | struct completion online_compl; |
| 826 | int status=0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 827 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 828 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 829 | if (!phba->cfg_enable_hba_reset) |
| 830 | return -EACCES; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 831 | init_completion(&online_compl); |
| 832 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 833 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 834 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 835 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 836 | if (rc == 0) |
| 837 | return -ENOMEM; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 838 | wait_for_completion(&online_compl); |
| 839 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 840 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 841 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 842 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 843 | return -EINVAL; |
| 844 | else |
| 845 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 846 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 847 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 848 | return -EINVAL; |
| 849 | else |
| 850 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 851 | else |
| 852 | return -EINVAL; |
| 853 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 854 | if (!status) |
| 855 | return strlen(buf); |
| 856 | else |
| 857 | return -EIO; |
| 858 | } |
| 859 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 860 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 861 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 862 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 863 | * @mxri: max xri count. |
| 864 | * @axri: available xri count. |
| 865 | * @mrpi: max rpi count. |
| 866 | * @arpi: available rpi count. |
| 867 | * @mvpi: max vpi count. |
| 868 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 869 | * |
| 870 | * Description: |
| 871 | * If an integer pointer for an count is not null then the value for the |
| 872 | * count is returned. |
| 873 | * |
| 874 | * Returns: |
| 875 | * zero on error |
| 876 | * one for success |
| 877 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 878 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 879 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 880 | uint32_t *mxri, uint32_t *axri, |
| 881 | uint32_t *mrpi, uint32_t *arpi, |
| 882 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 883 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 884 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 885 | LPFC_MBOXQ_t *pmboxq; |
| 886 | MAILBOX_t *pmb; |
| 887 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 888 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 889 | |
| 890 | /* |
| 891 | * prevent udev from issuing mailbox commands until the port is |
| 892 | * configured. |
| 893 | */ |
| 894 | if (phba->link_state < LPFC_LINK_DOWN || |
| 895 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 896 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 897 | return 0; |
| 898 | |
| 899 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 900 | return 0; |
| 901 | |
| 902 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 903 | if (!pmboxq) |
| 904 | return 0; |
| 905 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 906 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 907 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 908 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 909 | pmb->mbxOwner = OWN_HOST; |
| 910 | pmboxq->context1 = NULL; |
| 911 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 912 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 913 | rc = MBX_NOT_FINISHED; |
| 914 | else |
| 915 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 916 | |
| 917 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 918 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 919 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 920 | return 0; |
| 921 | } |
| 922 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 923 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 924 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 925 | if (mrpi) |
| 926 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 927 | if (arpi) |
| 928 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 929 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 930 | if (mxri) |
| 931 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 932 | if (axri) |
| 933 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 934 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 935 | |
| 936 | /* Account for differences with SLI-3. Get vpi count from |
| 937 | * mailbox data and subtract one for max vpi value. |
| 938 | */ |
| 939 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 940 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 941 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 942 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 943 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 944 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 945 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 946 | } else { |
| 947 | if (mrpi) |
| 948 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 949 | if (arpi) |
| 950 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 951 | if (mxri) |
| 952 | *mxri = pmb->un.varRdConfig.max_xri; |
| 953 | if (axri) |
| 954 | *axri = pmb->un.varRdConfig.avail_xri; |
| 955 | if (mvpi) |
| 956 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 957 | if (avpi) |
| 958 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 959 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 960 | |
| 961 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 962 | return 1; |
| 963 | } |
| 964 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 965 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 966 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 967 | * @dev: class device that is converted into a Scsi_host. |
| 968 | * @attr: device attribute, not used. |
| 969 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 970 | * |
| 971 | * Description: |
| 972 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 973 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 974 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 975 | * must check for "Unknown" in the buffer to detect a failure. |
| 976 | * |
| 977 | * Returns: size of formatted string. |
| 978 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 979 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 980 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 981 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 982 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 983 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 984 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 985 | struct lpfc_hba *phba = vport->phba; |
| 986 | uint32_t cnt; |
| 987 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 988 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 989 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 990 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 991 | } |
| 992 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 993 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 994 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 995 | * @dev: class device that is converted into a Scsi_host. |
| 996 | * @attr: device attribute, not used. |
| 997 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 998 | * |
| 999 | * Description: |
| 1000 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1001 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1002 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1003 | * must check for "Unknown" in the buffer to detect a failure. |
| 1004 | * |
| 1005 | * Returns: size of formatted string. |
| 1006 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1007 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1008 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1009 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1010 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1011 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1012 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1013 | struct lpfc_hba *phba = vport->phba; |
| 1014 | uint32_t cnt, acnt; |
| 1015 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1016 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1017 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1018 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1019 | } |
| 1020 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1021 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1022 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1023 | * @dev: class device that is converted into a Scsi_host. |
| 1024 | * @attr: device attribute, not used. |
| 1025 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1026 | * |
| 1027 | * Description: |
| 1028 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1029 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1030 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1031 | * must check for "Unknown" in the buffer to detect a failure. |
| 1032 | * |
| 1033 | * Returns: size of formatted string. |
| 1034 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1035 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1036 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1037 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1038 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1039 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1040 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1041 | struct lpfc_hba *phba = vport->phba; |
| 1042 | uint32_t cnt; |
| 1043 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1044 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1045 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1046 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1047 | } |
| 1048 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1049 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1050 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1051 | * @dev: class device that is converted into a Scsi_host. |
| 1052 | * @attr: device attribute, not used. |
| 1053 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1054 | * |
| 1055 | * Description: |
| 1056 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1057 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1058 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1059 | * must check for "Unknown" in the buffer to detect a failure. |
| 1060 | * |
| 1061 | * Returns: size of formatted string. |
| 1062 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1063 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1064 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1065 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1066 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1067 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1068 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1069 | struct lpfc_hba *phba = vport->phba; |
| 1070 | uint32_t cnt, acnt; |
| 1071 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1072 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1073 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1074 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1075 | } |
| 1076 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1077 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1078 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1079 | * @dev: class device that is converted into a Scsi_host. |
| 1080 | * @attr: device attribute, not used. |
| 1081 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1082 | * |
| 1083 | * Description: |
| 1084 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1085 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1086 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1087 | * must check for "Unknown" in the buffer to detect a failure. |
| 1088 | * |
| 1089 | * Returns: size of formatted string. |
| 1090 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1091 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1092 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1093 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1094 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1095 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1096 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1097 | struct lpfc_hba *phba = vport->phba; |
| 1098 | uint32_t cnt; |
| 1099 | |
| 1100 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1101 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1102 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1103 | } |
| 1104 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1105 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1106 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1107 | * @dev: class device that is converted into a Scsi_host. |
| 1108 | * @attr: device attribute, not used. |
| 1109 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1110 | * |
| 1111 | * Description: |
| 1112 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1113 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1114 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1115 | * must check for "Unknown" in the buffer to detect a failure. |
| 1116 | * |
| 1117 | * Returns: size of formatted string. |
| 1118 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1119 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1120 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1121 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1122 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1123 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1124 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1125 | struct lpfc_hba *phba = vport->phba; |
| 1126 | uint32_t cnt, acnt; |
| 1127 | |
| 1128 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1129 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1130 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1131 | } |
| 1132 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1133 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1134 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1135 | * @dev: class device that is converted into a Scsi_host. |
| 1136 | * @attr: device attribute, not used. |
| 1137 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1138 | * |
| 1139 | * Description: |
| 1140 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1141 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1142 | * the id of the vport. |
| 1143 | * |
| 1144 | * Returns: size of formatted string. |
| 1145 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1146 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1147 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1148 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1149 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1150 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1151 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1152 | struct lpfc_hba *phba = vport->phba; |
| 1153 | |
| 1154 | if (!(phba->max_vpi)) |
| 1155 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1156 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1157 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1158 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1159 | } |
| 1160 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1161 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1162 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1163 | * @dev: class device that is converted into a Scsi_host. |
| 1164 | * @attr: device attribute, not used. |
| 1165 | * @buf: on return contains the cfg_poll in hex. |
| 1166 | * |
| 1167 | * Notes: |
| 1168 | * cfg_poll should be a lpfc_polling_flags type. |
| 1169 | * |
| 1170 | * Returns: size of formatted string. |
| 1171 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1172 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1173 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1174 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1175 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1176 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1177 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1178 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1179 | |
| 1180 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1181 | } |
| 1182 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1183 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1184 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1185 | * @dev: class device that is converted into a Scsi_host. |
| 1186 | * @attr: device attribute, not used. |
| 1187 | * @buf: one or more lpfc_polling_flags values. |
| 1188 | * @count: not used. |
| 1189 | * |
| 1190 | * Notes: |
| 1191 | * buf contents converted to integer and checked for a valid value. |
| 1192 | * |
| 1193 | * Returns: |
| 1194 | * -EINVAL if the buffer connot be converted or is out of range |
| 1195 | * length of the buf on success |
| 1196 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1197 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1198 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1199 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1200 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1201 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1202 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1203 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1204 | uint32_t creg_val; |
| 1205 | uint32_t old_val; |
| 1206 | int val=0; |
| 1207 | |
| 1208 | if (!isdigit(buf[0])) |
| 1209 | return -EINVAL; |
| 1210 | |
| 1211 | if (sscanf(buf, "%i", &val) != 1) |
| 1212 | return -EINVAL; |
| 1213 | |
| 1214 | if ((val & 0x3) != val) |
| 1215 | return -EINVAL; |
| 1216 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1217 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1218 | val = 0; |
| 1219 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1220 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1221 | |
| 1222 | old_val = phba->cfg_poll; |
| 1223 | |
| 1224 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1225 | if ((val & DISABLE_FCP_RING_INT) && |
| 1226 | !(old_val & DISABLE_FCP_RING_INT)) { |
| 1227 | creg_val = readl(phba->HCregaddr); |
| 1228 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1229 | writel(creg_val, phba->HCregaddr); |
| 1230 | readl(phba->HCregaddr); /* flush */ |
| 1231 | |
| 1232 | lpfc_poll_start_timer(phba); |
| 1233 | } |
| 1234 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1235 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1236 | return -EINVAL; |
| 1237 | } |
| 1238 | |
| 1239 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1240 | (old_val & DISABLE_FCP_RING_INT)) |
| 1241 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1242 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1243 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1244 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1245 | creg_val = readl(phba->HCregaddr); |
| 1246 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1247 | writel(creg_val, phba->HCregaddr); |
| 1248 | readl(phba->HCregaddr); /* flush */ |
| 1249 | } |
| 1250 | |
| 1251 | phba->cfg_poll = val; |
| 1252 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1253 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1254 | |
| 1255 | return strlen(buf); |
| 1256 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1257 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1258 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1259 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1260 | * @dev: class unused variable. |
| 1261 | * @attr: device attribute, not used. |
| 1262 | * @buf: on return contains the module description text. |
| 1263 | * |
| 1264 | * Returns: size of formatted string. |
| 1265 | **/ |
| 1266 | static ssize_t |
| 1267 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1268 | char *buf) |
| 1269 | { |
| 1270 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1271 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1272 | struct lpfc_hba *phba = vport->phba; |
| 1273 | |
| 1274 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1275 | } |
| 1276 | |
| 1277 | /** |
| 1278 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1279 | * @dev: class unused variable. |
| 1280 | * @attr: device attribute, not used. |
| 1281 | * @buf: on return contains the module description text. |
| 1282 | * |
| 1283 | * Returns: size of formatted string. |
| 1284 | **/ |
| 1285 | static ssize_t |
| 1286 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1287 | char *buf) |
| 1288 | { |
| 1289 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1290 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1291 | struct lpfc_hba *phba = vport->phba; |
| 1292 | |
| 1293 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1294 | } |
| 1295 | |
| 1296 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1297 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1298 | * @dev: class converted to a Scsi_host structure. |
| 1299 | * @attr: device attribute, not used. |
| 1300 | * @buf: on return contains the formatted text. |
| 1301 | * |
| 1302 | * Returns: size of formatted string. |
| 1303 | **/ |
| 1304 | static ssize_t |
| 1305 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1306 | char *buf) |
| 1307 | { |
| 1308 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1309 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1310 | struct lpfc_hba *phba = vport->phba; |
| 1311 | |
| 1312 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1313 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1314 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1315 | "" : "Not "); |
| 1316 | } |
| 1317 | |
| 1318 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1319 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1320 | * |
| 1321 | * Description: |
| 1322 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1323 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1324 | * |
| 1325 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1326 | * @dev: class device that is converted into a Scsi_host. |
| 1327 | * @attr: device attribute, not used. |
| 1328 | * @buf: on return contains the attribute value in decimal. |
| 1329 | * |
| 1330 | * Returns: size of formatted string. |
| 1331 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1332 | #define lpfc_param_show(attr) \ |
| 1333 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1334 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1335 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1336 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1337 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1338 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1339 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1340 | uint val = 0;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1341 | val = phba->cfg_##attr;\ |
| 1342 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1343 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1344 | } |
| 1345 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1346 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1347 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1348 | * |
| 1349 | * Description: |
| 1350 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1351 | * into a function with the name lpfc_hba_queue_depth_show |
| 1352 | * |
| 1353 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1354 | * @dev: class device that is converted into a Scsi_host. |
| 1355 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1356 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1357 | * |
| 1358 | * Returns: size of formatted string. |
| 1359 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1360 | #define lpfc_param_hex_show(attr) \ |
| 1361 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1362 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1363 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1364 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1365 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1366 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1367 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1368 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1369 | val = phba->cfg_##attr;\ |
| 1370 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1371 | phba->cfg_##attr);\ |
| 1372 | } |
| 1373 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1374 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1375 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1376 | * |
| 1377 | * Description: |
| 1378 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1379 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1380 | * takes a default argument, a minimum and maximum argument. |
| 1381 | * |
| 1382 | * lpfc_##attr##_init: Initializes an attribute. |
| 1383 | * @phba: pointer the the adapter structure. |
| 1384 | * @val: integer attribute value. |
| 1385 | * |
| 1386 | * Validates the min and max values then sets the adapter config field |
| 1387 | * accordingly, or uses the default if out of range and prints an error message. |
| 1388 | * |
| 1389 | * Returns: |
| 1390 | * zero on success |
| 1391 | * -EINVAL if default used |
| 1392 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1393 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1394 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1395 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1396 | { \ |
| 1397 | if (val >= minval && val <= maxval) {\ |
| 1398 | phba->cfg_##attr = val;\ |
| 1399 | return 0;\ |
| 1400 | }\ |
| 1401 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1402 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1403 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1404 | phba->cfg_##attr = default;\ |
| 1405 | return -EINVAL;\ |
| 1406 | } |
| 1407 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1408 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1409 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1410 | * |
| 1411 | * Description: |
| 1412 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1413 | * into a function with the name lpfc_hba_queue_depth_set |
| 1414 | * |
| 1415 | * lpfc_##attr##_set: Sets an attribute value. |
| 1416 | * @phba: pointer the the adapter structure. |
| 1417 | * @val: integer attribute value. |
| 1418 | * |
| 1419 | * Description: |
| 1420 | * Validates the min and max values then sets the |
| 1421 | * adapter config field if in the valid range. prints error message |
| 1422 | * and does not set the parameter if invalid. |
| 1423 | * |
| 1424 | * Returns: |
| 1425 | * zero on success |
| 1426 | * -EINVAL if val is invalid |
| 1427 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1428 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1429 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1430 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1431 | { \ |
| 1432 | if (val >= minval && val <= maxval) {\ |
| 1433 | phba->cfg_##attr = val;\ |
| 1434 | return 0;\ |
| 1435 | }\ |
| 1436 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1437 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1438 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1439 | return -EINVAL;\ |
| 1440 | } |
| 1441 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1442 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1443 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1444 | * |
| 1445 | * Description: |
| 1446 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1447 | * into a function with the name lpfc_hba_queue_depth_store. |
| 1448 | * |
| 1449 | * lpfc_##attr##_store: Set an sttribute value. |
| 1450 | * @dev: class device that is converted into a Scsi_host. |
| 1451 | * @attr: device attribute, not used. |
| 1452 | * @buf: contains the attribute value in ascii. |
| 1453 | * @count: not used. |
| 1454 | * |
| 1455 | * Description: |
| 1456 | * Convert the ascii text number to an integer, then |
| 1457 | * use the lpfc_##attr##_set function to set the value. |
| 1458 | * |
| 1459 | * Returns: |
| 1460 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1461 | * length of buffer upon success. |
| 1462 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1463 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1464 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1465 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1466 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1467 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1468 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1469 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1470 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1471 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1472 | if (!isdigit(buf[0]))\ |
| 1473 | return -EINVAL;\ |
| 1474 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1475 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1476 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 1477 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1478 | else \ |
| 1479 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1480 | } |
| 1481 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1482 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1483 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1484 | * |
| 1485 | * Description: |
| 1486 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1487 | * into a function with the name lpfc_hba_queue_depth_show |
| 1488 | * |
| 1489 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 1490 | * @dev: class device that is converted into a Scsi_host. |
| 1491 | * @attr: device attribute, not used. |
| 1492 | * @buf: on return contains the attribute value in decimal. |
| 1493 | * |
| 1494 | * Returns: length of formatted string. |
| 1495 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1496 | #define lpfc_vport_param_show(attr) \ |
| 1497 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1498 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1499 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1500 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1501 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1502 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1503 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1504 | val = vport->cfg_##attr;\ |
| 1505 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 1506 | } |
| 1507 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1508 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1509 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1510 | * |
| 1511 | * Description: |
| 1512 | * Macro that given an attr e.g. |
| 1513 | * hba_queue_depth expands into a function with the name |
| 1514 | * lpfc_hba_queue_depth_show |
| 1515 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1516 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1517 | * @dev: class device that is converted into a Scsi_host. |
| 1518 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1519 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1520 | * |
| 1521 | * Returns: length of formatted string. |
| 1522 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1523 | #define lpfc_vport_param_hex_show(attr) \ |
| 1524 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1525 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1526 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1527 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1528 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1529 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1530 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1531 | val = vport->cfg_##attr;\ |
| 1532 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 1533 | } |
| 1534 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1535 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1536 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1537 | * |
| 1538 | * Description: |
| 1539 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1540 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1541 | * takes a default argument, a minimum and maximum argument. |
| 1542 | * |
| 1543 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 1544 | * adapter config field accordingly, or uses the default if out of range |
| 1545 | * and prints an error message. |
| 1546 | * @phba: pointer the the adapter structure. |
| 1547 | * @val: integer attribute value. |
| 1548 | * |
| 1549 | * Returns: |
| 1550 | * zero on success |
| 1551 | * -EINVAL if default used |
| 1552 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1553 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 1554 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1555 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1556 | { \ |
| 1557 | if (val >= minval && val <= maxval) {\ |
| 1558 | vport->cfg_##attr = val;\ |
| 1559 | return 0;\ |
| 1560 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1561 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1562 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1563 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1564 | vport->cfg_##attr = default;\ |
| 1565 | return -EINVAL;\ |
| 1566 | } |
| 1567 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1568 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1569 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1570 | * |
| 1571 | * Description: |
| 1572 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1573 | * into a function with the name lpfc_hba_queue_depth_set |
| 1574 | * |
| 1575 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 1576 | * adapter config field if in the valid range. prints error message |
| 1577 | * and does not set the parameter if invalid. |
| 1578 | * @phba: pointer the the adapter structure. |
| 1579 | * @val: integer attribute value. |
| 1580 | * |
| 1581 | * Returns: |
| 1582 | * zero on success |
| 1583 | * -EINVAL if val is invalid |
| 1584 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1585 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 1586 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1587 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1588 | { \ |
| 1589 | if (val >= minval && val <= maxval) {\ |
| 1590 | vport->cfg_##attr = val;\ |
| 1591 | return 0;\ |
| 1592 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1593 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1594 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1595 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1596 | return -EINVAL;\ |
| 1597 | } |
| 1598 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1599 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1600 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1601 | * |
| 1602 | * Description: |
| 1603 | * Macro that given an attr e.g. hba_queue_depth |
| 1604 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 1605 | * |
| 1606 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 1607 | * use the lpfc_##attr##_set function to set the value. |
| 1608 | * @cdev: class device that is converted into a Scsi_host. |
| 1609 | * @buf: contains the attribute value in decimal. |
| 1610 | * @count: not used. |
| 1611 | * |
| 1612 | * Returns: |
| 1613 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1614 | * length of buffer upon success. |
| 1615 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1616 | #define lpfc_vport_param_store(attr) \ |
| 1617 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1618 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1619 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1620 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1621 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1622 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1623 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1624 | if (!isdigit(buf[0]))\ |
| 1625 | return -EINVAL;\ |
| 1626 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1627 | return -EINVAL;\ |
| 1628 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 1629 | return strlen(buf);\ |
| 1630 | else \ |
| 1631 | return -EINVAL;\ |
| 1632 | } |
| 1633 | |
| 1634 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1635 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1636 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1637 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1638 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1639 | lpfc_param_init(name, defval, minval, maxval) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1640 | |
| 1641 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1642 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1643 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1644 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1645 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1646 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1647 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1648 | |
| 1649 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1650 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1651 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1652 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1653 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1654 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1655 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1656 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1657 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1658 | lpfc_##name##_show, lpfc_##name##_store) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1659 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1660 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1661 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1662 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1663 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1664 | lpfc_param_hex_show(name)\ |
| 1665 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1666 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1667 | |
| 1668 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1669 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1670 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1671 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1672 | lpfc_param_hex_show(name)\ |
| 1673 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1674 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1675 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1676 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1677 | lpfc_##name##_show, lpfc_##name##_store) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1678 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1679 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1680 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1681 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1682 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1683 | lpfc_vport_param_init(name, defval, minval, maxval) |
| 1684 | |
| 1685 | #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1686 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1687 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1688 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1689 | lpfc_vport_param_show(name)\ |
| 1690 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1691 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1692 | |
| 1693 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1694 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1695 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1696 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1697 | lpfc_vport_param_show(name)\ |
| 1698 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 1699 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 1700 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1701 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1702 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1703 | |
| 1704 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1705 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1706 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1707 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1708 | lpfc_vport_param_hex_show(name)\ |
| 1709 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1710 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1711 | |
| 1712 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1713 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1714 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1715 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1716 | lpfc_vport_param_hex_show(name)\ |
| 1717 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 1718 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 1719 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1720 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1721 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1722 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 1723 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 1724 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 1725 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 1726 | static DEVICE_ATTR(bg_reftag_err, S_IRUGO, lpfc_bg_reftag_err_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1727 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 1728 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 1729 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 1730 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 1731 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 1732 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 1733 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 1734 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1735 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 1736 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1737 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 1738 | lpfc_option_rom_version_show, NULL); |
| 1739 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 1740 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 1741 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1742 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 1743 | static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1744 | static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1745 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 1746 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 1747 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 1748 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 1749 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 1750 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 1751 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 1752 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 1753 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 1754 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 1755 | static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1756 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 1757 | static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1758 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1759 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1760 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1761 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1762 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1763 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1764 | * @dev: class device that is converted into a Scsi_host. |
| 1765 | * @attr: device attribute, not used. |
| 1766 | * @buf: containing the string lpfc_soft_wwn_key. |
| 1767 | * @count: must be size of lpfc_soft_wwn_key. |
| 1768 | * |
| 1769 | * Returns: |
| 1770 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 1771 | * length of buf indicates success |
| 1772 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1773 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1774 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 1775 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1776 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1777 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1778 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1779 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1780 | unsigned int cnt = count; |
| 1781 | |
| 1782 | /* |
| 1783 | * We're doing a simple sanity check for soft_wwpn setting. |
| 1784 | * We require that the user write a specific key to enable |
| 1785 | * the soft_wwpn attribute to be settable. Once the attribute |
| 1786 | * is written, the enable key resets. If further updates are |
| 1787 | * desired, the key must be written again to re-enable the |
| 1788 | * attribute. |
| 1789 | * |
| 1790 | * The "key" is not secret - it is a hardcoded string shown |
| 1791 | * here. The intent is to protect against the random user or |
| 1792 | * application that is just writing attributes. |
| 1793 | */ |
| 1794 | |
| 1795 | /* count may include a LF at end of string */ |
| 1796 | if (buf[cnt-1] == '\n') |
| 1797 | cnt--; |
| 1798 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1799 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 1800 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1801 | return -EINVAL; |
| 1802 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1803 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1804 | return count; |
| 1805 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1806 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 1807 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1808 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1809 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1810 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1811 | * @dev: class device that is converted into a Scsi_host. |
| 1812 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1813 | * @buf: on return contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1814 | * |
| 1815 | * Returns: size of formatted string. |
| 1816 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1817 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1818 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 1819 | char *buf) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1820 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1821 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1822 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1823 | struct lpfc_hba *phba = vport->phba; |
| 1824 | |
Randy Dunlap | afc071e6 | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 1825 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 1826 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1827 | } |
| 1828 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1829 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1830 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1831 | * @dev class device that is converted into a Scsi_host. |
| 1832 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1833 | * @buf: contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1834 | * @count: number of wwpn bytes in buf |
| 1835 | * |
| 1836 | * Returns: |
| 1837 | * -EACCES hba reset not enabled, adapter over temp |
| 1838 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 1839 | * -EIO error taking adapter offline or online |
| 1840 | * value of count on success |
| 1841 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1842 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1843 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 1844 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1845 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1846 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1847 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1848 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1849 | struct completion online_compl; |
| 1850 | int stat1=0, stat2=0; |
| 1851 | unsigned int i, j, cnt=count; |
| 1852 | u8 wwpn[8]; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1853 | int rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1854 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1855 | if (!phba->cfg_enable_hba_reset) |
| 1856 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 1857 | spin_lock_irq(&phba->hbalock); |
| 1858 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 1859 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1860 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 1861 | } |
| 1862 | spin_unlock_irq(&phba->hbalock); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1863 | /* count may include a LF at end of string */ |
| 1864 | if (buf[cnt-1] == '\n') |
| 1865 | cnt--; |
| 1866 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1867 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1868 | ((cnt == 17) && (*buf++ != 'x')) || |
| 1869 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 1870 | return -EINVAL; |
| 1871 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1872 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1873 | |
| 1874 | memset(wwpn, 0, sizeof(wwpn)); |
| 1875 | |
| 1876 | /* Validate and store the new name */ |
| 1877 | for (i=0, j=0; i < 16; i++) { |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 1878 | int value; |
| 1879 | |
| 1880 | value = hex_to_bin(*buf++); |
| 1881 | if (value >= 0) |
| 1882 | j = (j << 4) | value; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1883 | else |
| 1884 | return -EINVAL; |
| 1885 | if (i % 2) { |
| 1886 | wwpn[i/2] = j & 0xff; |
| 1887 | j = 0; |
| 1888 | } |
| 1889 | } |
| 1890 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1891 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1892 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1893 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1894 | |
| 1895 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 1896 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 1897 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1898 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1899 | if (stat1) |
| 1900 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1901 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 1902 | "reinit adapter - %d\n", stat1); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1903 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1904 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 1905 | LPFC_EVT_ONLINE); |
| 1906 | if (rc == 0) |
| 1907 | return -ENOMEM; |
| 1908 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1909 | wait_for_completion(&online_compl); |
| 1910 | if (stat2) |
| 1911 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1912 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 1913 | "reinit adapter - %d\n", stat2); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1914 | return (stat1 || stat2) ? -EIO : count; |
| 1915 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1916 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ |
| 1917 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1918 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1919 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1920 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1921 | * @dev: class device that is converted into a Scsi_host. |
| 1922 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1923 | * @buf: on return contains the wwnn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1924 | * |
| 1925 | * Returns: size of formatted string. |
| 1926 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1927 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1928 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 1929 | char *buf) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1930 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1931 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1932 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1933 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 1934 | (unsigned long long)phba->cfg_soft_wwnn); |
| 1935 | } |
| 1936 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1937 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1938 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1939 | * @cdev: class device that is converted into a Scsi_host. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1940 | * @buf: contains the ww node name in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1941 | * @count: number of wwnn bytes in buf. |
| 1942 | * |
| 1943 | * Returns: |
| 1944 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 1945 | * value of count on success |
| 1946 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1947 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1948 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 1949 | const char *buf, size_t count) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1950 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1951 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1952 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1953 | unsigned int i, j, cnt=count; |
| 1954 | u8 wwnn[8]; |
| 1955 | |
| 1956 | /* count may include a LF at end of string */ |
| 1957 | if (buf[cnt-1] == '\n') |
| 1958 | cnt--; |
| 1959 | |
| 1960 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
| 1961 | ((cnt == 17) && (*buf++ != 'x')) || |
| 1962 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 1963 | return -EINVAL; |
| 1964 | |
| 1965 | /* |
| 1966 | * Allow wwnn to be set many times, as long as the enable is set. |
| 1967 | * However, once the wwpn is set, everything locks. |
| 1968 | */ |
| 1969 | |
| 1970 | memset(wwnn, 0, sizeof(wwnn)); |
| 1971 | |
| 1972 | /* Validate and store the new name */ |
| 1973 | for (i=0, j=0; i < 16; i++) { |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 1974 | int value; |
| 1975 | |
| 1976 | value = hex_to_bin(*buf++); |
| 1977 | if (value >= 0) |
| 1978 | j = (j << 4) | value; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1979 | else |
| 1980 | return -EINVAL; |
| 1981 | if (i % 2) { |
| 1982 | wwnn[i/2] = j & 0xff; |
| 1983 | j = 0; |
| 1984 | } |
| 1985 | } |
| 1986 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 1987 | |
| 1988 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 1989 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 1990 | "setting of the soft_wwpn\n", phba->brd_no); |
| 1991 | |
| 1992 | return count; |
| 1993 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1994 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ |
| 1995 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1996 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1997 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1998 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 1999 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2000 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 2001 | " 0 - none," |
| 2002 | " 1 - poll with interrupts enabled" |
| 2003 | " 3 - poll and disable FCP ring interrupts"); |
| 2004 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2005 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 2006 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2007 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2008 | int lpfc_sli_mode = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2009 | module_param(lpfc_sli_mode, int, S_IRUGO); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2010 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" |
| 2011 | " 0 - auto (SLI-3 if supported)," |
| 2012 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 2013 | " 3 - select SLI-3"); |
| 2014 | |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2015 | int lpfc_enable_npiv = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2016 | module_param(lpfc_enable_npiv, int, S_IRUGO); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 2017 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); |
| 2018 | lpfc_param_show(enable_npiv); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 2019 | lpfc_param_init(enable_npiv, 1, 0, 1); |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2020 | static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, lpfc_enable_npiv_show, NULL); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2021 | |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2022 | int lpfc_enable_rrq; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2023 | module_param(lpfc_enable_rrq, int, S_IRUGO); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2024 | MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality"); |
| 2025 | lpfc_param_show(enable_rrq); |
| 2026 | lpfc_param_init(enable_rrq, 0, 0, 1); |
| 2027 | static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL); |
| 2028 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2029 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2030 | # lpfc_suppress_link_up: Bring link up at initialization |
| 2031 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 2032 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 2033 | # 0x2 = never bring up link |
| 2034 | # Default value is 0. |
| 2035 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2036 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 2037 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 2038 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2039 | /* |
| 2040 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 2041 | # 1 - (1024) |
| 2042 | # 2 - (2048) |
| 2043 | # 3 - (3072) |
| 2044 | # 4 - (4096) |
| 2045 | # 5 - (5120) |
| 2046 | */ |
| 2047 | static ssize_t |
| 2048 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2049 | { |
| 2050 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2051 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2052 | |
| 2053 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 2054 | } |
| 2055 | |
| 2056 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 2057 | lpfc_iocb_hw_show, NULL); |
| 2058 | static ssize_t |
| 2059 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2060 | { |
| 2061 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2062 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2063 | |
| 2064 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2065 | phba->sli.ring[LPFC_ELS_RING].txq_max); |
| 2066 | } |
| 2067 | |
| 2068 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 2069 | lpfc_txq_hw_show, NULL); |
| 2070 | static ssize_t |
| 2071 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 2072 | char *buf) |
| 2073 | { |
| 2074 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2075 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2076 | |
| 2077 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2078 | phba->sli.ring[LPFC_ELS_RING].txcmplq_max); |
| 2079 | } |
| 2080 | |
| 2081 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 2082 | lpfc_txcmplq_hw_show, NULL); |
| 2083 | |
| 2084 | int lpfc_iocb_cnt = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2085 | module_param(lpfc_iocb_cnt, int, S_IRUGO); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2086 | MODULE_PARM_DESC(lpfc_iocb_cnt, |
| 2087 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
| 2088 | lpfc_param_show(iocb_cnt); |
| 2089 | lpfc_param_init(iocb_cnt, 2, 1, 5); |
| 2090 | static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO, |
| 2091 | lpfc_iocb_cnt_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2092 | |
| 2093 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2094 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 2095 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 2096 | */ |
| 2097 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2098 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2099 | module_param(lpfc_nodev_tmo, int, 0); |
| 2100 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 2101 | "Seconds driver will hold I/O waiting " |
| 2102 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2103 | |
| 2104 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2105 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2106 | * @dev: class converted to a Scsi_host structure. |
| 2107 | * @attr: device attribute, not used. |
| 2108 | * @buf: on return contains the dev loss timeout in decimal. |
| 2109 | * |
| 2110 | * Returns: size of formatted string. |
| 2111 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2112 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2113 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 2114 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2115 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2116 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2117 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2118 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2119 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2120 | } |
| 2121 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2122 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2123 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2124 | * @vport: lpfc vport structure pointer. |
| 2125 | * @val: contains the nodev timeout value. |
| 2126 | * |
| 2127 | * Description: |
| 2128 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 2129 | * a kernel error message is printed and zero is returned. |
| 2130 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2131 | * Otherwise nodev tmo is set to the default value. |
| 2132 | * |
| 2133 | * Returns: |
| 2134 | * zero if already set or if val is in range |
| 2135 | * -EINVAL val out of range |
| 2136 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2137 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2138 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2139 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2140 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 2141 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 2142 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2143 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2144 | "0407 Ignoring nodev_tmo module " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2145 | "parameter because devloss_tmo is " |
| 2146 | "set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2147 | return 0; |
| 2148 | } |
| 2149 | |
| 2150 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2151 | vport->cfg_nodev_tmo = val; |
| 2152 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2153 | return 0; |
| 2154 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2155 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2156 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 2157 | " %d, allowed range is [%d, %d]\n", |
| 2158 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2159 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2160 | return -EINVAL; |
| 2161 | } |
| 2162 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2163 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2164 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2165 | * @vport: lpfc vport structure pointer. |
| 2166 | * |
| 2167 | * Description: |
| 2168 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 2169 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2170 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2171 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2172 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2173 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2174 | struct lpfc_nodelist *ndlp; |
| 2175 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2176 | shost = lpfc_shost_from_vport(vport); |
| 2177 | spin_lock_irq(shost->host_lock); |
| 2178 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2179 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2180 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 2181 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2182 | } |
| 2183 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2184 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2185 | * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2186 | * @vport: lpfc vport structure pointer. |
| 2187 | * @val: contains the tmo value. |
| 2188 | * |
| 2189 | * Description: |
| 2190 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 2191 | * then a kernel error message is printed and zero is returned. |
| 2192 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2193 | * Otherwise nodev tmo is set to the default value. |
| 2194 | * |
| 2195 | * Returns: |
| 2196 | * zero if already set or if val is in range |
| 2197 | * -EINVAL val out of range |
| 2198 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2199 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2200 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2201 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2202 | if (vport->dev_loss_tmo_changed || |
| 2203 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2204 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2205 | "0401 Ignoring change to nodev_tmo " |
| 2206 | "because devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2207 | return 0; |
| 2208 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2209 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2210 | vport->cfg_nodev_tmo = val; |
| 2211 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2212 | /* |
| 2213 | * For compat: set the fc_host dev loss so new rports |
| 2214 | * will get the value. |
| 2215 | */ |
| 2216 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2217 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2218 | return 0; |
| 2219 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2220 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2221 | "0403 lpfc_nodev_tmo attribute cannot be set to" |
| 2222 | "%d, allowed range is [%d, %d]\n", |
| 2223 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2224 | return -EINVAL; |
| 2225 | } |
| 2226 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2227 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2228 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2229 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 2230 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2231 | |
| 2232 | /* |
| 2233 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 2234 | # disappear until the timer expires. Value range is [0,255]. Default |
| 2235 | # value is 30. |
| 2236 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2237 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2238 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 2239 | "Seconds driver will hold I/O waiting " |
| 2240 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2241 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 2242 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 2243 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2244 | |
| 2245 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2246 | * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2247 | * @vport: lpfc vport structure pointer. |
| 2248 | * @val: contains the tmo value. |
| 2249 | * |
| 2250 | * Description: |
| 2251 | * If val is in a valid range then set the vport nodev tmo, |
| 2252 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 2253 | * Else a kernel error message is printed. |
| 2254 | * |
| 2255 | * Returns: |
| 2256 | * zero if val is in range |
| 2257 | * -EINVAL val out of range |
| 2258 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2259 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2260 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2261 | { |
| 2262 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2263 | vport->cfg_nodev_tmo = val; |
| 2264 | vport->cfg_devloss_tmo = val; |
| 2265 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2266 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2267 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2268 | return 0; |
| 2269 | } |
| 2270 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2271 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2272 | "0404 lpfc_devloss_tmo attribute cannot be set to" |
| 2273 | " %d, allowed range is [%d, %d]\n", |
| 2274 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2275 | return -EINVAL; |
| 2276 | } |
| 2277 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2278 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2279 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 2280 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2281 | |
| 2282 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2283 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 2284 | # deluged with LOTS of information. |
| 2285 | # You can set a bit mask to record specific types of verbose messages: |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2286 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2287 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2288 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2289 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2290 | |
| 2291 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 2292 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 2293 | # objects that have been registered with the nameserver after login. |
| 2294 | */ |
| 2295 | LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1, |
| 2296 | "Deregister nameserver objects before LOGO"); |
| 2297 | |
| 2298 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2299 | # lun_queue_depth: This parameter is used to limit the number of outstanding |
| 2300 | # commands per FCP LUN. Value range is [1,128]. Default value is 30. |
| 2301 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2302 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 128, |
| 2303 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2304 | |
| 2305 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 2306 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 2307 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 2308 | */ |
| 2309 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
| 2310 | "Max number of FCP commands we can queue to a specific target port"); |
| 2311 | |
| 2312 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 2313 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 2314 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 2315 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 2316 | # then maximum number of exchanges supported by the HBA is used to determine |
| 2317 | # the hba_queue_depth. |
| 2318 | */ |
| 2319 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 2320 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 2321 | |
| 2322 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2323 | # peer_port_login: This parameter allows/prevents logins |
| 2324 | # between peer ports hosted on the same physical port. |
| 2325 | # When this parameter is set 0 peer ports of same physical port |
| 2326 | # are not allowed to login to each other. |
| 2327 | # When this parameter is set 1 peer ports of same physical port |
| 2328 | # are allowed to login to each other. |
| 2329 | # Default value of this parameter is 0. |
| 2330 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2331 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 2332 | "Allow peer ports on the same physical port to login to each " |
| 2333 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2334 | |
| 2335 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2336 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2337 | # between Virtual Ports and remote initiators. |
| 2338 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 2339 | # other initiators and will attempt to PLOGI all remote ports. |
| 2340 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 2341 | # remote ports and will not attempt to PLOGI to other initiators. |
| 2342 | # This parameter does not restrict to the physical port. |
| 2343 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 2344 | # Default value of this parameter is 1. |
| 2345 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2346 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2347 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2348 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 2349 | "Restrict virtual ports login to remote initiators."); |
| 2350 | lpfc_vport_param_show(restrict_login); |
| 2351 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2352 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2353 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2354 | * @vport: lpfc vport structure pointer. |
| 2355 | * @val: contains the restrict login value. |
| 2356 | * |
| 2357 | * Description: |
| 2358 | * If val is not in a valid range then log a kernel error message and set |
| 2359 | * the vport restrict login to one. |
| 2360 | * If the port type is physical clear the restrict login flag and return. |
| 2361 | * Else set the restrict login flag to val. |
| 2362 | * |
| 2363 | * Returns: |
| 2364 | * zero if val is in range |
| 2365 | * -EINVAL val out of range |
| 2366 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2367 | static int |
| 2368 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 2369 | { |
| 2370 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2371 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2372 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2373 | "be set to %d, allowed range is [0, 1]\n", |
| 2374 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2375 | vport->cfg_restrict_login = 1; |
| 2376 | return -EINVAL; |
| 2377 | } |
| 2378 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 2379 | vport->cfg_restrict_login = 0; |
| 2380 | return 0; |
| 2381 | } |
| 2382 | vport->cfg_restrict_login = val; |
| 2383 | return 0; |
| 2384 | } |
| 2385 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2386 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2387 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2388 | * @vport: lpfc vport structure pointer. |
| 2389 | * @val: contains the restrict login value. |
| 2390 | * |
| 2391 | * Description: |
| 2392 | * If val is not in a valid range then log a kernel error message and set |
| 2393 | * the vport restrict login to one. |
| 2394 | * If the port type is physical and the val is not zero log a kernel |
| 2395 | * error message, clear the restrict login flag and return zero. |
| 2396 | * Else set the restrict login flag to val. |
| 2397 | * |
| 2398 | * Returns: |
| 2399 | * zero if val is in range |
| 2400 | * -EINVAL val out of range |
| 2401 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2402 | static int |
| 2403 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 2404 | { |
| 2405 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2406 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2407 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2408 | "be set to %d, allowed range is [0, 1]\n", |
| 2409 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2410 | vport->cfg_restrict_login = 1; |
| 2411 | return -EINVAL; |
| 2412 | } |
| 2413 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2414 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2415 | "0468 lpfc_restrict_login must be 0 for " |
| 2416 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2417 | vport->cfg_restrict_login = 0; |
| 2418 | return 0; |
| 2419 | } |
| 2420 | vport->cfg_restrict_login = val; |
| 2421 | return 0; |
| 2422 | } |
| 2423 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2424 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 2425 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2426 | |
| 2427 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2428 | # Some disk devices have a "select ID" or "select Target" capability. |
| 2429 | # From a protocol standpoint "select ID" usually means select the |
| 2430 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 2431 | # annex" which contains a table that maps a "select ID" (a number |
| 2432 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 2433 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 2434 | # ALPA. |
| 2435 | # |
| 2436 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 2437 | # cause the lpfc driver to use an inverted table, effectively |
| 2438 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 2439 | # |
| 2440 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 2441 | # and will not work across a fabric. Also this parameter will take |
| 2442 | # effect only in the case when ALPA map is not available.) |
| 2443 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2444 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 2445 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2446 | |
| 2447 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2448 | # lpfc_topology: link topology for init link |
| 2449 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 2450 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2451 | # 0x02 = attempt point-to-point mode only |
| 2452 | # 0x04 = attempt loop mode only |
| 2453 | # 0x06 = attempt point-to-point mode then loop |
| 2454 | # Set point-to-point mode if you want to run as an N_Port. |
| 2455 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 2456 | # Default value is 0. |
| 2457 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2458 | |
| 2459 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2460 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2461 | * @phba: lpfc_hba pointer. |
| 2462 | * @val: topology value. |
| 2463 | * |
| 2464 | * Description: |
| 2465 | * If val is in a valid range then set the adapter's topology field and |
| 2466 | * issue a lip; if the lip fails reset the topology to the old value. |
| 2467 | * |
| 2468 | * If the value is not in range log a kernel error message and return an error. |
| 2469 | * |
| 2470 | * Returns: |
| 2471 | * zero if val is in range and lip okay |
| 2472 | * non-zero return value from lpfc_issue_lip() |
| 2473 | * -EINVAL val out of range |
| 2474 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2475 | static ssize_t |
| 2476 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 2477 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2478 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2479 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2480 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2481 | struct lpfc_hba *phba = vport->phba; |
| 2482 | int val = 0; |
| 2483 | int nolip = 0; |
| 2484 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2485 | int err; |
| 2486 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2487 | |
| 2488 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 2489 | nolip = 1; |
| 2490 | val_buf = &buf[strlen("nolip ")]; |
| 2491 | } |
| 2492 | |
| 2493 | if (!isdigit(val_buf[0])) |
| 2494 | return -EINVAL; |
| 2495 | if (sscanf(val_buf, "%i", &val) != 1) |
| 2496 | return -EINVAL; |
| 2497 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2498 | if (val >= 0 && val <= 6) { |
| 2499 | prev_val = phba->cfg_topology; |
| 2500 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2501 | if (nolip) |
| 2502 | return strlen(buf); |
| 2503 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2504 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2505 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2506 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2507 | return -EINVAL; |
| 2508 | } else |
| 2509 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2510 | } |
| 2511 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2512 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 2513 | "allowed range is [0, 6]\n", |
| 2514 | phba->brd_no, val); |
| 2515 | return -EINVAL; |
| 2516 | } |
| 2517 | static int lpfc_topology = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2518 | module_param(lpfc_topology, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2519 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
| 2520 | lpfc_param_show(topology) |
| 2521 | lpfc_param_init(topology, 0, 0, 6) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2522 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2523 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2524 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 2525 | /** |
| 2526 | * lpfc_static_vport_show: Read callback function for |
| 2527 | * lpfc_static_vport sysfs file. |
| 2528 | * @dev: Pointer to class device object. |
| 2529 | * @attr: device attribute structure. |
| 2530 | * @buf: Data buffer. |
| 2531 | * |
| 2532 | * This function is the read call back function for |
| 2533 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 2534 | * sysfs file report the mageability of the vport. |
| 2535 | **/ |
| 2536 | static ssize_t |
| 2537 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 2538 | char *buf) |
| 2539 | { |
| 2540 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2541 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2542 | if (vport->vport_flag & STATIC_VPORT) |
| 2543 | sprintf(buf, "1\n"); |
| 2544 | else |
| 2545 | sprintf(buf, "0\n"); |
| 2546 | |
| 2547 | return strlen(buf); |
| 2548 | } |
| 2549 | |
| 2550 | /* |
| 2551 | * Sysfs attribute to control the statistical data collection. |
| 2552 | */ |
| 2553 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 2554 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2555 | |
| 2556 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2557 | * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2558 | * @dev: Pointer to class device. |
| 2559 | * @buf: Data buffer. |
| 2560 | * @count: Size of the data buffer. |
| 2561 | * |
| 2562 | * This function get called when an user write to the lpfc_stat_data_ctrl |
| 2563 | * sysfs file. This function parse the command written to the sysfs file |
| 2564 | * and take appropriate action. These commands are used for controlling |
| 2565 | * driver statistical data collection. |
| 2566 | * Following are the command this function handles. |
| 2567 | * |
| 2568 | * setbucket <bucket_type> <base> <step> |
| 2569 | * = Set the latency buckets. |
| 2570 | * destroybucket = destroy all the buckets. |
| 2571 | * start = start data collection |
| 2572 | * stop = stop data collection |
| 2573 | * reset = reset the collected data |
| 2574 | **/ |
| 2575 | static ssize_t |
| 2576 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 2577 | const char *buf, size_t count) |
| 2578 | { |
| 2579 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2580 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2581 | struct lpfc_hba *phba = vport->phba; |
| 2582 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 2583 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 2584 | unsigned long i; |
| 2585 | char *str_ptr, *token; |
| 2586 | struct lpfc_vport **vports; |
| 2587 | struct Scsi_Host *v_shost; |
| 2588 | char *bucket_type_str, *base_str, *step_str; |
| 2589 | unsigned long base, step, bucket_type; |
| 2590 | |
| 2591 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2592 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2593 | return -EINVAL; |
| 2594 | |
| 2595 | strcpy(bucket_data, buf); |
| 2596 | str_ptr = &bucket_data[0]; |
| 2597 | /* Ignore this token - this is command token */ |
| 2598 | token = strsep(&str_ptr, "\t "); |
| 2599 | if (!token) |
| 2600 | return -EINVAL; |
| 2601 | |
| 2602 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 2603 | if (!bucket_type_str) |
| 2604 | return -EINVAL; |
| 2605 | |
| 2606 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 2607 | bucket_type = LPFC_LINEAR_BUCKET; |
| 2608 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 2609 | bucket_type = LPFC_POWER2_BUCKET; |
| 2610 | else |
| 2611 | return -EINVAL; |
| 2612 | |
| 2613 | base_str = strsep(&str_ptr, "\t "); |
| 2614 | if (!base_str) |
| 2615 | return -EINVAL; |
| 2616 | base = simple_strtoul(base_str, NULL, 0); |
| 2617 | |
| 2618 | step_str = strsep(&str_ptr, "\t "); |
| 2619 | if (!step_str) |
| 2620 | return -EINVAL; |
| 2621 | step = simple_strtoul(step_str, NULL, 0); |
| 2622 | if (!step) |
| 2623 | return -EINVAL; |
| 2624 | |
| 2625 | /* Block the data collection for every vport */ |
| 2626 | vports = lpfc_create_vport_work_array(phba); |
| 2627 | if (vports == NULL) |
| 2628 | return -ENOMEM; |
| 2629 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2630 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2631 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 2632 | spin_lock_irq(v_shost->host_lock); |
| 2633 | /* Block and reset data collection */ |
| 2634 | vports[i]->stat_data_blocked = 1; |
| 2635 | if (vports[i]->stat_data_enabled) |
| 2636 | lpfc_vport_reset_stat_data(vports[i]); |
| 2637 | spin_unlock_irq(v_shost->host_lock); |
| 2638 | } |
| 2639 | |
| 2640 | /* Set the bucket attributes */ |
| 2641 | phba->bucket_type = bucket_type; |
| 2642 | phba->bucket_base = base; |
| 2643 | phba->bucket_step = step; |
| 2644 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2645 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2646 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 2647 | |
| 2648 | /* Unblock data collection */ |
| 2649 | spin_lock_irq(v_shost->host_lock); |
| 2650 | vports[i]->stat_data_blocked = 0; |
| 2651 | spin_unlock_irq(v_shost->host_lock); |
| 2652 | } |
| 2653 | lpfc_destroy_vport_work_array(phba, vports); |
| 2654 | return strlen(buf); |
| 2655 | } |
| 2656 | |
| 2657 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 2658 | vports = lpfc_create_vport_work_array(phba); |
| 2659 | if (vports == NULL) |
| 2660 | return -ENOMEM; |
| 2661 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2662 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2663 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 2664 | spin_lock_irq(shost->host_lock); |
| 2665 | vports[i]->stat_data_blocked = 1; |
| 2666 | lpfc_free_bucket(vport); |
| 2667 | vport->stat_data_enabled = 0; |
| 2668 | vports[i]->stat_data_blocked = 0; |
| 2669 | spin_unlock_irq(shost->host_lock); |
| 2670 | } |
| 2671 | lpfc_destroy_vport_work_array(phba, vports); |
| 2672 | phba->bucket_type = LPFC_NO_BUCKET; |
| 2673 | phba->bucket_base = 0; |
| 2674 | phba->bucket_step = 0; |
| 2675 | return strlen(buf); |
| 2676 | } |
| 2677 | |
| 2678 | if (!strncmp(buf, "start", strlen("start"))) { |
| 2679 | /* If no buckets configured return error */ |
| 2680 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 2681 | return -EINVAL; |
| 2682 | spin_lock_irq(shost->host_lock); |
| 2683 | if (vport->stat_data_enabled) { |
| 2684 | spin_unlock_irq(shost->host_lock); |
| 2685 | return strlen(buf); |
| 2686 | } |
| 2687 | lpfc_alloc_bucket(vport); |
| 2688 | vport->stat_data_enabled = 1; |
| 2689 | spin_unlock_irq(shost->host_lock); |
| 2690 | return strlen(buf); |
| 2691 | } |
| 2692 | |
| 2693 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 2694 | spin_lock_irq(shost->host_lock); |
| 2695 | if (vport->stat_data_enabled == 0) { |
| 2696 | spin_unlock_irq(shost->host_lock); |
| 2697 | return strlen(buf); |
| 2698 | } |
| 2699 | lpfc_free_bucket(vport); |
| 2700 | vport->stat_data_enabled = 0; |
| 2701 | spin_unlock_irq(shost->host_lock); |
| 2702 | return strlen(buf); |
| 2703 | } |
| 2704 | |
| 2705 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 2706 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 2707 | || !vport->stat_data_enabled) |
| 2708 | return strlen(buf); |
| 2709 | spin_lock_irq(shost->host_lock); |
| 2710 | vport->stat_data_blocked = 1; |
| 2711 | lpfc_vport_reset_stat_data(vport); |
| 2712 | vport->stat_data_blocked = 0; |
| 2713 | spin_unlock_irq(shost->host_lock); |
| 2714 | return strlen(buf); |
| 2715 | } |
| 2716 | return -EINVAL; |
| 2717 | } |
| 2718 | |
| 2719 | |
| 2720 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2721 | * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2722 | * @dev: Pointer to class device object. |
| 2723 | * @buf: Data buffer. |
| 2724 | * |
| 2725 | * This function is the read call back function for |
| 2726 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 2727 | * current statistical data collection state. |
| 2728 | **/ |
| 2729 | static ssize_t |
| 2730 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 2731 | char *buf) |
| 2732 | { |
| 2733 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2734 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2735 | struct lpfc_hba *phba = vport->phba; |
| 2736 | int index = 0; |
| 2737 | int i; |
| 2738 | char *bucket_type; |
| 2739 | unsigned long bucket_value; |
| 2740 | |
| 2741 | switch (phba->bucket_type) { |
| 2742 | case LPFC_LINEAR_BUCKET: |
| 2743 | bucket_type = "linear"; |
| 2744 | break; |
| 2745 | case LPFC_POWER2_BUCKET: |
| 2746 | bucket_type = "power2"; |
| 2747 | break; |
| 2748 | default: |
| 2749 | bucket_type = "No Bucket"; |
| 2750 | break; |
| 2751 | } |
| 2752 | |
| 2753 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 2754 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 2755 | " Bucket step :%d\nLatency Ranges :", |
| 2756 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 2757 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 2758 | index = strlen(buf); |
| 2759 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 2760 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 2761 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 2762 | bucket_value = phba->bucket_base + |
| 2763 | phba->bucket_step * i; |
| 2764 | else |
| 2765 | bucket_value = phba->bucket_base + |
| 2766 | (1 << i) * phba->bucket_step; |
| 2767 | |
| 2768 | if (index + 10 > PAGE_SIZE) |
| 2769 | break; |
| 2770 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 2771 | index = strlen(buf); |
| 2772 | } |
| 2773 | } |
| 2774 | sprintf(&buf[index], "\n"); |
| 2775 | return strlen(buf); |
| 2776 | } |
| 2777 | |
| 2778 | /* |
| 2779 | * Sysfs attribute to control the statistical data collection. |
| 2780 | */ |
| 2781 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 2782 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 2783 | |
| 2784 | /* |
| 2785 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 2786 | */ |
| 2787 | |
| 2788 | /* |
| 2789 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 2790 | * for each target. |
| 2791 | */ |
| 2792 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 2793 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 2794 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 2795 | |
| 2796 | |
| 2797 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2798 | * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2799 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2800 | * @kobj: Pointer to the kernel object |
| 2801 | * @bin_attr: Attribute object |
| 2802 | * @buff: Buffer pointer |
| 2803 | * @off: File offset |
| 2804 | * @count: Buffer size |
| 2805 | * |
| 2806 | * This function is the read call back function for lpfc_drvr_stat_data |
| 2807 | * sysfs file. This function export the statistical data to user |
| 2808 | * applications. |
| 2809 | **/ |
| 2810 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2811 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 2812 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2813 | char *buf, loff_t off, size_t count) |
| 2814 | { |
| 2815 | struct device *dev = container_of(kobj, struct device, |
| 2816 | kobj); |
| 2817 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2818 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2819 | struct lpfc_hba *phba = vport->phba; |
| 2820 | int i = 0, index = 0; |
| 2821 | unsigned long nport_index; |
| 2822 | struct lpfc_nodelist *ndlp = NULL; |
| 2823 | nport_index = (unsigned long)off / |
| 2824 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 2825 | |
| 2826 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 2827 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 2828 | return 0; |
| 2829 | |
| 2830 | spin_lock_irq(shost->host_lock); |
| 2831 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 2832 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 2833 | continue; |
| 2834 | |
| 2835 | if (nport_index > 0) { |
| 2836 | nport_index--; |
| 2837 | continue; |
| 2838 | } |
| 2839 | |
| 2840 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 2841 | > count) |
| 2842 | break; |
| 2843 | |
| 2844 | if (!ndlp->lat_data) |
| 2845 | continue; |
| 2846 | |
| 2847 | /* Print the WWN */ |
| 2848 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 2849 | ndlp->nlp_portname.u.wwn[0], |
| 2850 | ndlp->nlp_portname.u.wwn[1], |
| 2851 | ndlp->nlp_portname.u.wwn[2], |
| 2852 | ndlp->nlp_portname.u.wwn[3], |
| 2853 | ndlp->nlp_portname.u.wwn[4], |
| 2854 | ndlp->nlp_portname.u.wwn[5], |
| 2855 | ndlp->nlp_portname.u.wwn[6], |
| 2856 | ndlp->nlp_portname.u.wwn[7]); |
| 2857 | |
| 2858 | index = strlen(buf); |
| 2859 | |
| 2860 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 2861 | sprintf(&buf[index], "%010u,", |
| 2862 | ndlp->lat_data[i].cmd_count); |
| 2863 | index = strlen(buf); |
| 2864 | } |
| 2865 | sprintf(&buf[index], "\n"); |
| 2866 | index = strlen(buf); |
| 2867 | } |
| 2868 | spin_unlock_irq(shost->host_lock); |
| 2869 | return index; |
| 2870 | } |
| 2871 | |
| 2872 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 2873 | .attr = { |
| 2874 | .name = "lpfc_drvr_stat_data", |
| 2875 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2876 | }, |
| 2877 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 2878 | .read = sysfs_drvr_stat_data_read, |
| 2879 | .write = NULL, |
| 2880 | }; |
| 2881 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2882 | /* |
| 2883 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 2884 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2885 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2886 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2887 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2888 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2889 | * @phba: lpfc_hba pointer. |
| 2890 | * @val: link speed value. |
| 2891 | * |
| 2892 | * Description: |
| 2893 | * If val is in a valid range then set the adapter's link speed field and |
| 2894 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 2895 | * |
| 2896 | * Notes: |
| 2897 | * If the value is not in range log a kernel error message and return an error. |
| 2898 | * |
| 2899 | * Returns: |
| 2900 | * zero if val is in range and lip okay. |
| 2901 | * non-zero return value from lpfc_issue_lip() |
| 2902 | * -EINVAL val out of range |
| 2903 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2904 | static ssize_t |
| 2905 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 2906 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2907 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2908 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2909 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2910 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2911 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2912 | int nolip = 0; |
| 2913 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2914 | int err; |
| 2915 | uint32_t prev_val; |
| 2916 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2917 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 2918 | nolip = 1; |
| 2919 | val_buf = &buf[strlen("nolip ")]; |
| 2920 | } |
| 2921 | |
| 2922 | if (!isdigit(val_buf[0])) |
| 2923 | return -EINVAL; |
| 2924 | if (sscanf(val_buf, "%i", &val) != 1) |
| 2925 | return -EINVAL; |
| 2926 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2927 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 2928 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 2929 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 2930 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 2931 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
| 2932 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb))) { |
| 2933 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2934 | "2879 lpfc_link_speed attribute cannot be set " |
| 2935 | "to %d. Speed is not supported by this port.\n", |
| 2936 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2937 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2938 | } |
| 2939 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 2940 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2941 | prev_val = phba->cfg_link_speed; |
| 2942 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2943 | if (nolip) |
| 2944 | return strlen(buf); |
| 2945 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2946 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2947 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2948 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2949 | return -EINVAL; |
| 2950 | } else |
| 2951 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2952 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2953 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2954 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 2955 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2956 | return -EINVAL; |
| 2957 | } |
| 2958 | |
| 2959 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 2960 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2961 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 2962 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2963 | |
| 2964 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2965 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2966 | * @phba: lpfc_hba pointer. |
| 2967 | * @val: link speed value. |
| 2968 | * |
| 2969 | * Description: |
| 2970 | * If val is in a valid range then set the adapter's link speed field. |
| 2971 | * |
| 2972 | * Notes: |
| 2973 | * If the value is not in range log a kernel error message, clear the link |
| 2974 | * speed and return an error. |
| 2975 | * |
| 2976 | * Returns: |
| 2977 | * zero if val saved. |
| 2978 | * -EINVAL val out of range |
| 2979 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2980 | static int |
| 2981 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 2982 | { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2983 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 2984 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2985 | phba->cfg_link_speed = val; |
| 2986 | return 0; |
| 2987 | } |
| 2988 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2989 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2990 | "be set to %d, allowed values are " |
| 2991 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2992 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2993 | return -EINVAL; |
| 2994 | } |
| 2995 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2996 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2997 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2998 | |
| 2999 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3000 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 3001 | # 0 = aer disabled or not supported |
| 3002 | # 1 = aer supported and enabled (default) |
| 3003 | # Value range is [0,1]. Default value is 1. |
| 3004 | */ |
| 3005 | |
| 3006 | /** |
| 3007 | * lpfc_aer_support_store - Set the adapter for aer support |
| 3008 | * |
| 3009 | * @dev: class device that is converted into a Scsi_host. |
| 3010 | * @attr: device attribute, not used. |
| 3011 | * @buf: containing the string "selective". |
| 3012 | * @count: unused variable. |
| 3013 | * |
| 3014 | * Description: |
| 3015 | * If the val is 1 and currently the device's AER capability was not |
| 3016 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 3017 | * enable the device's AER capability. If the helper routine enabling |
| 3018 | * AER returns success, update the device's cfg_aer_support flag to |
| 3019 | * indicate AER is supported by the device; otherwise, if the device |
| 3020 | * AER capability is already enabled to support AER, then do nothing. |
| 3021 | * |
| 3022 | * If the val is 0 and currently the device's AER support was enabled, |
| 3023 | * invoke the kernel's disable AER helper routine. After that, update |
| 3024 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 3025 | * by the device; otherwise, if the device AER capability is already |
| 3026 | * disabled from supporting AER, then do nothing. |
| 3027 | * |
| 3028 | * Returns: |
| 3029 | * length of the buf on success if val is in range the intended mode |
| 3030 | * is supported. |
| 3031 | * -EINVAL if val out of range or intended mode is not supported. |
| 3032 | **/ |
| 3033 | static ssize_t |
| 3034 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 3035 | const char *buf, size_t count) |
| 3036 | { |
| 3037 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3038 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 3039 | struct lpfc_hba *phba = vport->phba; |
| 3040 | int val = 0, rc = -EINVAL; |
| 3041 | |
| 3042 | if (!isdigit(buf[0])) |
| 3043 | return -EINVAL; |
| 3044 | if (sscanf(buf, "%i", &val) != 1) |
| 3045 | return -EINVAL; |
| 3046 | |
| 3047 | switch (val) { |
| 3048 | case 0: |
| 3049 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 3050 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 3051 | if (!rc) { |
| 3052 | spin_lock_irq(&phba->hbalock); |
| 3053 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 3054 | spin_unlock_irq(&phba->hbalock); |
| 3055 | phba->cfg_aer_support = 0; |
| 3056 | rc = strlen(buf); |
| 3057 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3058 | rc = -EPERM; |
| 3059 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3060 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3061 | rc = strlen(buf); |
| 3062 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3063 | break; |
| 3064 | case 1: |
| 3065 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 3066 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 3067 | if (!rc) { |
| 3068 | spin_lock_irq(&phba->hbalock); |
| 3069 | phba->hba_flag |= HBA_AER_ENABLED; |
| 3070 | spin_unlock_irq(&phba->hbalock); |
| 3071 | phba->cfg_aer_support = 1; |
| 3072 | rc = strlen(buf); |
| 3073 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3074 | rc = -EPERM; |
| 3075 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3076 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3077 | rc = strlen(buf); |
| 3078 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3079 | break; |
| 3080 | default: |
| 3081 | rc = -EINVAL; |
| 3082 | break; |
| 3083 | } |
| 3084 | return rc; |
| 3085 | } |
| 3086 | |
| 3087 | static int lpfc_aer_support = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 3088 | module_param(lpfc_aer_support, int, S_IRUGO); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3089 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); |
| 3090 | lpfc_param_show(aer_support) |
| 3091 | |
| 3092 | /** |
| 3093 | * lpfc_aer_support_init - Set the initial adapters aer support flag |
| 3094 | * @phba: lpfc_hba pointer. |
| 3095 | * @val: link speed value. |
| 3096 | * |
| 3097 | * Description: |
| 3098 | * If val is in a valid range [0,1], then set the adapter's initial |
| 3099 | * cfg_aer_support field. It will be up to the driver's probe_one |
| 3100 | * routine to determine whether the device's AER support can be set |
| 3101 | * or not. |
| 3102 | * |
| 3103 | * Notes: |
| 3104 | * If the value is not in range log a kernel error message, and |
| 3105 | * choose the default value of setting AER support and return. |
| 3106 | * |
| 3107 | * Returns: |
| 3108 | * zero if val saved. |
| 3109 | * -EINVAL val out of range |
| 3110 | **/ |
| 3111 | static int |
| 3112 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) |
| 3113 | { |
| 3114 | if (val == 0 || val == 1) { |
| 3115 | phba->cfg_aer_support = val; |
| 3116 | return 0; |
| 3117 | } |
| 3118 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3119 | "2712 lpfc_aer_support attribute value %d out " |
| 3120 | "of range, allowed values are 0|1, setting it " |
| 3121 | "to default value of 1\n", val); |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3122 | /* By default, try to enable AER on a device */ |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3123 | phba->cfg_aer_support = 1; |
| 3124 | return -EINVAL; |
| 3125 | } |
| 3126 | |
| 3127 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 3128 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 3129 | |
| 3130 | /** |
| 3131 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 3132 | * @dev: class device that is converted into a Scsi_host. |
| 3133 | * @attr: device attribute, not used. |
| 3134 | * @buf: containing the string "selective". |
| 3135 | * @count: unused variable. |
| 3136 | * |
| 3137 | * Description: |
| 3138 | * If the @buf contains 1 and the device currently has the AER support |
| 3139 | * enabled, then invokes the kernel AER helper routine |
| 3140 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 3141 | * error status register. |
| 3142 | * |
| 3143 | * Notes: |
| 3144 | * |
| 3145 | * Returns: |
| 3146 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 3147 | * enabled with the AER support. |
| 3148 | **/ |
| 3149 | static ssize_t |
| 3150 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 3151 | const char *buf, size_t count) |
| 3152 | { |
| 3153 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3154 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3155 | struct lpfc_hba *phba = vport->phba; |
| 3156 | int val, rc = -1; |
| 3157 | |
| 3158 | if (!isdigit(buf[0])) |
| 3159 | return -EINVAL; |
| 3160 | if (sscanf(buf, "%i", &val) != 1) |
| 3161 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3162 | if (val != 1) |
| 3163 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3164 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3165 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3166 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 3167 | |
| 3168 | if (rc == 0) |
| 3169 | return strlen(buf); |
| 3170 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3171 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3172 | } |
| 3173 | |
| 3174 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 3175 | lpfc_aer_cleanup_state); |
| 3176 | |
| 3177 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3178 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 3179 | # Value range is [2,3]. Default value is 3. |
| 3180 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3181 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 3182 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3183 | |
| 3184 | /* |
| 3185 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 3186 | # is [0,1]. Default value is 0. |
| 3187 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3188 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 3189 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3190 | |
| 3191 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3192 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 3193 | # depth. Default value is 0. When the value of this parameter is zero the |
| 3194 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 3195 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 3196 | # to limit the I/O completion time to the parameter value. |
| 3197 | # The value is set in milliseconds. |
| 3198 | */ |
| 3199 | static int lpfc_max_scsicmpl_time; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 3200 | module_param(lpfc_max_scsicmpl_time, int, S_IRUGO); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3201 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, |
| 3202 | "Use command completion time to control queue depth"); |
| 3203 | lpfc_vport_param_show(max_scsicmpl_time); |
| 3204 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); |
| 3205 | static int |
| 3206 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 3207 | { |
| 3208 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3209 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 3210 | |
| 3211 | if (val == vport->cfg_max_scsicmpl_time) |
| 3212 | return 0; |
| 3213 | if ((val < 0) || (val > 60000)) |
| 3214 | return -EINVAL; |
| 3215 | vport->cfg_max_scsicmpl_time = val; |
| 3216 | |
| 3217 | spin_lock_irq(shost->host_lock); |
| 3218 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 3219 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3220 | continue; |
| 3221 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 3222 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3223 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3224 | } |
| 3225 | spin_unlock_irq(shost->host_lock); |
| 3226 | return 0; |
| 3227 | } |
| 3228 | lpfc_vport_param_store(max_scsicmpl_time); |
| 3229 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 3230 | lpfc_max_scsicmpl_time_show, |
| 3231 | lpfc_max_scsicmpl_time_store); |
| 3232 | |
| 3233 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3234 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 3235 | # range is [0,1]. Default value is 0. |
| 3236 | */ |
| 3237 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 3238 | |
| 3239 | /* |
| 3240 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 3241 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3242 | # 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] | 3243 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 3244 | # cr_delay is set to 0. |
| 3245 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 3246 | 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] | 3247 | "interrupt response is generated"); |
| 3248 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 3249 | 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] | 3250 | "interrupt response is generated"); |
| 3251 | |
| 3252 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 3253 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 3254 | # cmd/rsp IOCB entries across. |
| 3255 | # Value range is [1,2]. Default value is 1. |
| 3256 | */ |
| 3257 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 3258 | "SLI rings to spread IOCB entries across"); |
| 3259 | |
| 3260 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 3261 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 3262 | # identifies what rctl value to configure the additional ring for. |
| 3263 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 3264 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 3265 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 3266 | 255, "Identifies RCTL for additional ring configuration"); |
| 3267 | |
| 3268 | /* |
| 3269 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 3270 | # identifies what type value to configure the additional ring for. |
| 3271 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 3272 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 3273 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 3274 | 255, "Identifies TYPE for additional ring configuration"); |
| 3275 | |
| 3276 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3277 | # lpfc_fdmi_on: controls FDMI support. |
| 3278 | # 0 = no FDMI support |
| 3279 | # 1 = support FDMI without attribute of hostname |
| 3280 | # 2 = support FDMI with attribute of hostname |
| 3281 | # Value range [0,2]. Default value is 0. |
| 3282 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3283 | LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3284 | |
| 3285 | /* |
| 3286 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 3287 | # discovery). Value range is [1,64]. Default value = 32. |
| 3288 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3289 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3290 | "during discovery"); |
| 3291 | |
| 3292 | /* |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 3293 | # lpfc_max_luns: maximum allowed LUN. |
| 3294 | # Value range is [0,65535]. Default value is 255. |
| 3295 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3296 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3297 | LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3298 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3299 | /* |
| 3300 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 3301 | # Value range is [1,255], default value is 10. |
| 3302 | */ |
| 3303 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 3304 | "Milliseconds driver will wait between polling FCP ring"); |
| 3305 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3306 | /* |
| 3307 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 3308 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 3309 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3310 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 3311 | # 2 = MSI-X enabled (default) |
| 3312 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3313 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 3314 | LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or " |
James Smart | db2378e | 2008-02-08 18:49:51 -0500 | [diff] [blame] | 3315 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3316 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3317 | /* |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 3318 | # lpfc_fcp_imax: Set the maximum number of fast-path FCP interrupts per second |
| 3319 | # |
| 3320 | # Value range is [636,651042]. Default value is 10000. |
| 3321 | */ |
| 3322 | LPFC_ATTR_R(fcp_imax, LPFC_FP_DEF_IMAX, LPFC_MIM_IMAX, LPFC_DMULT_CONST, |
| 3323 | "Set the maximum number of fast-path FCP interrupts per second"); |
| 3324 | |
| 3325 | /* |
| 3326 | # lpfc_fcp_wq_count: Set the number of fast-path FCP work queues |
| 3327 | # |
| 3328 | # Value range is [1,31]. Default value is 4. |
| 3329 | */ |
| 3330 | LPFC_ATTR_R(fcp_wq_count, LPFC_FP_WQN_DEF, LPFC_FP_WQN_MIN, LPFC_FP_WQN_MAX, |
| 3331 | "Set the number of fast-path FCP work queues, if possible"); |
| 3332 | |
| 3333 | /* |
| 3334 | # lpfc_fcp_eq_count: Set the number of fast-path FCP event queues |
| 3335 | # |
| 3336 | # Value range is [1,7]. Default value is 1. |
| 3337 | */ |
| 3338 | LPFC_ATTR_R(fcp_eq_count, LPFC_FP_EQN_DEF, LPFC_FP_EQN_MIN, LPFC_FP_EQN_MAX, |
| 3339 | "Set the number of fast-path FCP event queues, if possible"); |
| 3340 | |
| 3341 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3342 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 3343 | # 0 = HBA resets disabled |
| 3344 | # 1 = HBA resets enabled (default) |
| 3345 | # Value range is [0,1]. Default value is 1. |
| 3346 | */ |
| 3347 | LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver."); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3348 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3349 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 3350 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3351 | # 0 = HBA Heartbeat disabled |
| 3352 | # 1 = HBA Heartbeat enabled (default) |
| 3353 | # Value range is [0,1]. Default value is 1. |
| 3354 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 3355 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3356 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3357 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3358 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 3359 | # 0 = BlockGuard disabled (default) |
| 3360 | # 1 = BlockGuard enabled |
| 3361 | # Value range is [0,1]. Default value is 0. |
| 3362 | */ |
| 3363 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 3364 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 3365 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3366 | # lpfc_prot_mask: i |
| 3367 | # - Bit mask of host protection capabilities used to register with the |
| 3368 | # SCSI mid-layer |
| 3369 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 3370 | # - Allows you to ultimately specify which profiles to use |
| 3371 | # - Default will result in registering capabilities for all profiles. |
| 3372 | # |
| 3373 | */ |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 3374 | unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3375 | |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 3376 | module_param(lpfc_prot_mask, uint, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3377 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); |
| 3378 | |
| 3379 | /* |
| 3380 | # lpfc_prot_guard: i |
| 3381 | # - Bit mask of protection guard types to register with the SCSI mid-layer |
| 3382 | # - Guard types are currently either 1) IP checksum 2) T10-DIF CRC |
| 3383 | # - Allows you to ultimately specify which profiles to use |
| 3384 | # - Default will result in registering capabilities for all guard types |
| 3385 | # |
| 3386 | */ |
| 3387 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 3388 | module_param(lpfc_prot_guard, byte, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3389 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); |
| 3390 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 3391 | /* |
| 3392 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 3393 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 3394 | * This parameter can have value 0 or 1. |
| 3395 | * When this parameter is set to 0, no delay is added to the initial |
| 3396 | * discovery. |
| 3397 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 3398 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 3399 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 3400 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 3401 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 3402 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 3403 | * Default value is 0. |
| 3404 | */ |
| 3405 | int lpfc_delay_discovery; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 3406 | module_param(lpfc_delay_discovery, int, S_IRUGO); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 3407 | MODULE_PARM_DESC(lpfc_delay_discovery, |
| 3408 | "Delay NPort discovery when Clean Address bit is cleared. " |
| 3409 | "Allowed values: 0,1."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3410 | |
| 3411 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3412 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3413 | * This value can be set to values between 64 and 256. The default value is |
| 3414 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 3415 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
| 3416 | */ |
| 3417 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 3418 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 3419 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3420 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_PROT_SG_SEG_CNT, |
| 3421 | LPFC_DEFAULT_PROT_SG_SEG_CNT, LPFC_MAX_PROT_SG_SEG_CNT, |
| 3422 | "Max Protection Scatter Gather Segment Count"); |
| 3423 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3424 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3425 | &dev_attr_bg_info, |
| 3426 | &dev_attr_bg_guard_err, |
| 3427 | &dev_attr_bg_apptag_err, |
| 3428 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3429 | &dev_attr_info, |
| 3430 | &dev_attr_serialnum, |
| 3431 | &dev_attr_modeldesc, |
| 3432 | &dev_attr_modelname, |
| 3433 | &dev_attr_programtype, |
| 3434 | &dev_attr_portnum, |
| 3435 | &dev_attr_fwrev, |
| 3436 | &dev_attr_hdw, |
| 3437 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 3438 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3439 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 3440 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3441 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 3442 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3443 | &dev_attr_lpfc_temp_sensor, |
| 3444 | &dev_attr_lpfc_log_verbose, |
| 3445 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3446 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3447 | &dev_attr_lpfc_hba_queue_depth, |
| 3448 | &dev_attr_lpfc_peer_port_login, |
| 3449 | &dev_attr_lpfc_nodev_tmo, |
| 3450 | &dev_attr_lpfc_devloss_tmo, |
| 3451 | &dev_attr_lpfc_fcp_class, |
| 3452 | &dev_attr_lpfc_use_adisc, |
| 3453 | &dev_attr_lpfc_ack0, |
| 3454 | &dev_attr_lpfc_topology, |
| 3455 | &dev_attr_lpfc_scan_down, |
| 3456 | &dev_attr_lpfc_link_speed, |
| 3457 | &dev_attr_lpfc_cr_delay, |
| 3458 | &dev_attr_lpfc_cr_count, |
| 3459 | &dev_attr_lpfc_multi_ring_support, |
| 3460 | &dev_attr_lpfc_multi_ring_rctl, |
| 3461 | &dev_attr_lpfc_multi_ring_type, |
| 3462 | &dev_attr_lpfc_fdmi_on, |
| 3463 | &dev_attr_lpfc_max_luns, |
| 3464 | &dev_attr_lpfc_enable_npiv, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3465 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3466 | &dev_attr_nport_evt_cnt, |
| 3467 | &dev_attr_board_mode, |
| 3468 | &dev_attr_max_vpi, |
| 3469 | &dev_attr_used_vpi, |
| 3470 | &dev_attr_max_rpi, |
| 3471 | &dev_attr_used_rpi, |
| 3472 | &dev_attr_max_xri, |
| 3473 | &dev_attr_used_xri, |
| 3474 | &dev_attr_npiv_info, |
| 3475 | &dev_attr_issue_reset, |
| 3476 | &dev_attr_lpfc_poll, |
| 3477 | &dev_attr_lpfc_poll_tmo, |
| 3478 | &dev_attr_lpfc_use_msi, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 3479 | &dev_attr_lpfc_fcp_imax, |
| 3480 | &dev_attr_lpfc_fcp_wq_count, |
| 3481 | &dev_attr_lpfc_fcp_eq_count, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3482 | &dev_attr_lpfc_enable_bg, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3483 | &dev_attr_lpfc_soft_wwnn, |
| 3484 | &dev_attr_lpfc_soft_wwpn, |
| 3485 | &dev_attr_lpfc_soft_wwn_enable, |
| 3486 | &dev_attr_lpfc_enable_hba_reset, |
| 3487 | &dev_attr_lpfc_enable_hba_heartbeat, |
| 3488 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3489 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3490 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3491 | &dev_attr_lpfc_prot_sg_seg_cnt, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3492 | &dev_attr_lpfc_aer_support, |
| 3493 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3494 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3495 | &dev_attr_lpfc_iocb_cnt, |
| 3496 | &dev_attr_iocb_hw, |
| 3497 | &dev_attr_txq_hw, |
| 3498 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 3499 | &dev_attr_lpfc_fips_level, |
| 3500 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 3501 | &dev_attr_lpfc_dss, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3502 | NULL, |
| 3503 | }; |
| 3504 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3505 | struct device_attribute *lpfc_vport_attrs[] = { |
| 3506 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 3507 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3508 | &dev_attr_num_discovered_ports, |
| 3509 | &dev_attr_lpfc_drvr_version, |
| 3510 | &dev_attr_lpfc_log_verbose, |
| 3511 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3512 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3513 | &dev_attr_lpfc_nodev_tmo, |
| 3514 | &dev_attr_lpfc_devloss_tmo, |
| 3515 | &dev_attr_lpfc_hba_queue_depth, |
| 3516 | &dev_attr_lpfc_peer_port_login, |
| 3517 | &dev_attr_lpfc_restrict_login, |
| 3518 | &dev_attr_lpfc_fcp_class, |
| 3519 | &dev_attr_lpfc_use_adisc, |
| 3520 | &dev_attr_lpfc_fdmi_on, |
| 3521 | &dev_attr_lpfc_max_luns, |
| 3522 | &dev_attr_nport_evt_cnt, |
| 3523 | &dev_attr_npiv_info, |
| 3524 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3525 | &dev_attr_lpfc_max_scsicmpl_time, |
| 3526 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3527 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 3528 | &dev_attr_lpfc_fips_level, |
| 3529 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3530 | NULL, |
| 3531 | }; |
| 3532 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3533 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3534 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3535 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3536 | * @kobj: kernel kobject that contains the kernel class device. |
| 3537 | * @bin_attr: kernel attributes passed to us. |
| 3538 | * @buf: contains the data to be written to the adapter IOREG space. |
| 3539 | * @off: offset into buffer to beginning of data. |
| 3540 | * @count: bytes to transfer. |
| 3541 | * |
| 3542 | * Description: |
| 3543 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 3544 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 3545 | * |
| 3546 | * Returns: |
| 3547 | * -ERANGE off and count combo out of range |
| 3548 | * -EINVAL off, count or buff address invalid |
| 3549 | * -EPERM adapter is offline |
| 3550 | * value of count, buf contents written |
| 3551 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3552 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3553 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 3554 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3555 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3556 | { |
| 3557 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3558 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3559 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3560 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3561 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3562 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 3563 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 3564 | return -EPERM; |
| 3565 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3566 | if ((off + count) > FF_REG_AREA_SIZE) |
| 3567 | return -ERANGE; |
| 3568 | |
| 3569 | if (count == 0) return 0; |
| 3570 | |
| 3571 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3572 | return -EINVAL; |
| 3573 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3574 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3575 | return -EPERM; |
| 3576 | } |
| 3577 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3578 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3579 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) |
| 3580 | writel(*((uint32_t *)(buf + buf_off)), |
| 3581 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 3582 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3583 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3584 | |
| 3585 | return count; |
| 3586 | } |
| 3587 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3588 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3589 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3590 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3591 | * @kobj: kernel kobject that contains the kernel class device. |
| 3592 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 3593 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3594 | * @off: offset into buffer to beginning of data. |
| 3595 | * @count: bytes to transfer. |
| 3596 | * |
| 3597 | * Description: |
| 3598 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 3599 | * Uses the adapter io control registers to read data into buf. |
| 3600 | * |
| 3601 | * Returns: |
| 3602 | * -ERANGE off and count combo out of range |
| 3603 | * -EINVAL off, count or buff address invalid |
| 3604 | * value of count, buf contents read |
| 3605 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3606 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3607 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 3608 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3609 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3610 | { |
| 3611 | size_t buf_off; |
| 3612 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3613 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3614 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3615 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3616 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3617 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 3618 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 3619 | return -EPERM; |
| 3620 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3621 | if (off > FF_REG_AREA_SIZE) |
| 3622 | return -ERANGE; |
| 3623 | |
| 3624 | if ((off + count) > FF_REG_AREA_SIZE) |
| 3625 | count = FF_REG_AREA_SIZE - off; |
| 3626 | |
| 3627 | if (count == 0) return 0; |
| 3628 | |
| 3629 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3630 | return -EINVAL; |
| 3631 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3632 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3633 | |
| 3634 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 3635 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 3636 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 3637 | } |
| 3638 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3639 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3640 | |
| 3641 | return count; |
| 3642 | } |
| 3643 | |
| 3644 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 3645 | .attr = { |
| 3646 | .name = "ctlreg", |
| 3647 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3648 | }, |
| 3649 | .size = 256, |
| 3650 | .read = sysfs_ctlreg_read, |
| 3651 | .write = sysfs_ctlreg_write, |
| 3652 | }; |
| 3653 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3654 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3655 | * sysfs_mbox_idle - frees the sysfs mailbox |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3656 | * @phba: lpfc_hba pointer |
| 3657 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3658 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3659 | sysfs_mbox_idle(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3660 | { |
| 3661 | phba->sysfs_mbox.state = SMBOX_IDLE; |
| 3662 | phba->sysfs_mbox.offset = 0; |
| 3663 | |
| 3664 | if (phba->sysfs_mbox.mbox) { |
| 3665 | mempool_free(phba->sysfs_mbox.mbox, |
| 3666 | phba->mbox_mem_pool); |
| 3667 | phba->sysfs_mbox.mbox = NULL; |
| 3668 | } |
| 3669 | } |
| 3670 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3671 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3672 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3673 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3674 | * @kobj: kernel kobject that contains the kernel class device. |
| 3675 | * @bin_attr: kernel attributes passed to us. |
| 3676 | * @buf: contains the data to be written to sysfs mbox. |
| 3677 | * @off: offset into buffer to beginning of data. |
| 3678 | * @count: bytes to transfer. |
| 3679 | * |
| 3680 | * Description: |
| 3681 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. |
| 3682 | * Uses the sysfs mbox to send buf contents to the adapter. |
| 3683 | * |
| 3684 | * Returns: |
| 3685 | * -ERANGE off and count combo out of range |
| 3686 | * -EINVAL off, count or buff address invalid |
| 3687 | * zero if count is zero |
| 3688 | * -EPERM adapter is offline |
| 3689 | * -ENOMEM failed to allocate memory for the mail box |
| 3690 | * -EAGAIN offset, state or mbox is NULL |
| 3691 | * count number of bytes transferred |
| 3692 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3693 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3694 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 3695 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3696 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3697 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3698 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3699 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3700 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3701 | struct lpfc_hba *phba = vport->phba; |
| 3702 | struct lpfcMboxq *mbox = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3703 | |
| 3704 | if ((count + off) > MAILBOX_CMD_SIZE) |
| 3705 | return -ERANGE; |
| 3706 | |
| 3707 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3708 | return -EINVAL; |
| 3709 | |
| 3710 | if (count == 0) |
| 3711 | return 0; |
| 3712 | |
| 3713 | if (off == 0) { |
| 3714 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 3715 | if (!mbox) |
| 3716 | return -ENOMEM; |
James Smart | fc6c12b | 2006-03-07 15:04:19 -0500 | [diff] [blame] | 3717 | memset(mbox, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3718 | } |
| 3719 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3720 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3721 | |
| 3722 | if (off == 0) { |
| 3723 | if (phba->sysfs_mbox.mbox) |
| 3724 | mempool_free(mbox, phba->mbox_mem_pool); |
| 3725 | else |
| 3726 | phba->sysfs_mbox.mbox = mbox; |
| 3727 | phba->sysfs_mbox.state = SMBOX_WRITING; |
| 3728 | } else { |
| 3729 | if (phba->sysfs_mbox.state != SMBOX_WRITING || |
| 3730 | phba->sysfs_mbox.offset != off || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3731 | phba->sysfs_mbox.mbox == NULL) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3732 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3733 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 3734 | return -EAGAIN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3735 | } |
| 3736 | } |
| 3737 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3738 | memcpy((uint8_t *) &phba->sysfs_mbox.mbox->u.mb + off, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3739 | buf, count); |
| 3740 | |
| 3741 | phba->sysfs_mbox.offset = off + count; |
| 3742 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3743 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3744 | |
| 3745 | return count; |
| 3746 | } |
| 3747 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3748 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3749 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3750 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3751 | * @kobj: kernel kobject that contains the kernel class device. |
| 3752 | * @bin_attr: kernel attributes passed to us. |
| 3753 | * @buf: contains the data to be read from sysfs mbox. |
| 3754 | * @off: offset into buffer to beginning of data. |
| 3755 | * @count: bytes to transfer. |
| 3756 | * |
| 3757 | * Description: |
| 3758 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. |
| 3759 | * Uses the sysfs mbox to receive data from to the adapter. |
| 3760 | * |
| 3761 | * Returns: |
| 3762 | * -ERANGE off greater than mailbox command size |
| 3763 | * -EINVAL off, count or buff address invalid |
| 3764 | * zero if off and count are zero |
| 3765 | * -EACCES adapter over temp |
| 3766 | * -EPERM garbage can value to catch a multitude of errors |
| 3767 | * -EAGAIN management IO not permitted, state or off error |
| 3768 | * -ETIME mailbox timeout |
| 3769 | * -ENODEV mailbox error |
| 3770 | * count number of bytes transferred |
| 3771 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3772 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3773 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 3774 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3775 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3776 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3777 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3778 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3779 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3780 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3781 | int rc; |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3782 | MAILBOX_t *pmb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3783 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3784 | if (off > MAILBOX_CMD_SIZE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3785 | return -ERANGE; |
| 3786 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3787 | if ((count + off) > MAILBOX_CMD_SIZE) |
| 3788 | count = MAILBOX_CMD_SIZE - off; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3789 | |
| 3790 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3791 | return -EINVAL; |
| 3792 | |
| 3793 | if (off && count == 0) |
| 3794 | return 0; |
| 3795 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3796 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3797 | |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 3798 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 3799 | sysfs_mbox_idle(phba); |
| 3800 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3801 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 3802 | } |
| 3803 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3804 | if (off == 0 && |
| 3805 | phba->sysfs_mbox.state == SMBOX_WRITING && |
| 3806 | phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3807 | pmb = &phba->sysfs_mbox.mbox->u.mb; |
| 3808 | switch (pmb->mbxCommand) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3809 | /* Offline only */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3810 | case MBX_INIT_LINK: |
| 3811 | case MBX_DOWN_LINK: |
| 3812 | case MBX_CONFIG_LINK: |
| 3813 | case MBX_CONFIG_RING: |
| 3814 | case MBX_RESET_RING: |
| 3815 | case MBX_UNREG_LOGIN: |
| 3816 | case MBX_CLEAR_LA: |
| 3817 | case MBX_DUMP_CONTEXT: |
| 3818 | case MBX_RUN_DIAGS: |
| 3819 | case MBX_RESTART: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3820 | case MBX_SET_MASK: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3821 | case MBX_SET_DEBUG: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3822 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3823 | printk(KERN_WARNING "mbox_read:Command 0x%x " |
| 3824 | "is illegal in on-line state\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3825 | pmb->mbxCommand); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3826 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3827 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3828 | return -EPERM; |
| 3829 | } |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3830 | case MBX_WRITE_NV: |
| 3831 | case MBX_WRITE_VPARMS: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3832 | case MBX_LOAD_SM: |
| 3833 | case MBX_READ_NV: |
| 3834 | case MBX_READ_CONFIG: |
| 3835 | case MBX_READ_RCONFIG: |
| 3836 | case MBX_READ_STATUS: |
| 3837 | case MBX_READ_XRI: |
| 3838 | case MBX_READ_REV: |
| 3839 | case MBX_READ_LNK_STAT: |
| 3840 | case MBX_DUMP_MEMORY: |
| 3841 | case MBX_DOWN_LOAD: |
| 3842 | case MBX_UPDATE_CFG: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 3843 | case MBX_KILL_BOARD: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3844 | case MBX_LOAD_AREA: |
| 3845 | case MBX_LOAD_EXP_ROM: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 3846 | case MBX_BEACON: |
| 3847 | case MBX_DEL_LD_ENTRY: |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3848 | case MBX_SET_VARIABLE: |
| 3849 | case MBX_WRITE_WWN: |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 3850 | case MBX_PORT_CAPABILITIES: |
| 3851 | case MBX_PORT_IOV_CONTROL: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3852 | break; |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 3853 | case MBX_SECURITY_MGMT: |
| 3854 | case MBX_AUTH_PORT: |
James Smart | 5989b8d | 2010-10-22 11:06:56 -0400 | [diff] [blame] | 3855 | if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) { |
| 3856 | printk(KERN_WARNING "mbox_read:Command 0x%x " |
| 3857 | "is not permitted\n", pmb->mbxCommand); |
| 3858 | sysfs_mbox_idle(phba); |
| 3859 | spin_unlock_irq(&phba->hbalock); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 3860 | return -EPERM; |
James Smart | 5989b8d | 2010-10-22 11:06:56 -0400 | [diff] [blame] | 3861 | } |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 3862 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3863 | case MBX_READ_SPARM64: |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3864 | case MBX_READ_TOPOLOGY: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3865 | case MBX_REG_LOGIN: |
| 3866 | case MBX_REG_LOGIN64: |
| 3867 | case MBX_CONFIG_PORT: |
| 3868 | case MBX_RUN_BIU_DIAG: |
| 3869 | printk(KERN_WARNING "mbox_read: Illegal Command 0x%x\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3870 | pmb->mbxCommand); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3871 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3872 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3873 | return -EPERM; |
| 3874 | default: |
| 3875 | printk(KERN_WARNING "mbox_read: Unknown Command 0x%x\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3876 | pmb->mbxCommand); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3877 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3878 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3879 | return -EPERM; |
| 3880 | } |
| 3881 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3882 | /* If HBA encountered an error attention, allow only DUMP |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 3883 | * or RESTART mailbox commands until the HBA is restarted. |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3884 | */ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3885 | if (phba->pport->stopped && |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3886 | pmb->mbxCommand != MBX_DUMP_MEMORY && |
| 3887 | pmb->mbxCommand != MBX_RESTART && |
| 3888 | pmb->mbxCommand != MBX_WRITE_VPARMS && |
| 3889 | pmb->mbxCommand != MBX_WRITE_WWN) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3890 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, |
| 3891 | "1259 mbox: Issued mailbox cmd " |
| 3892 | "0x%x while in stopped state.\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3893 | pmb->mbxCommand); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3894 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3895 | phba->sysfs_mbox.mbox->vport = vport; |
| 3896 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3897 | /* Don't allow mailbox commands to be sent when blocked |
| 3898 | * or when in the middle of discovery |
| 3899 | */ |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 3900 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 3901 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3902 | spin_unlock_irq(&phba->hbalock); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 3903 | return -EAGAIN; |
| 3904 | } |
| 3905 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3906 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3907 | (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3908 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3909 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3910 | rc = lpfc_sli_issue_mbox (phba, |
| 3911 | phba->sysfs_mbox.mbox, |
| 3912 | MBX_POLL); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3913 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3914 | |
| 3915 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3916 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3917 | rc = lpfc_sli_issue_mbox_wait (phba, |
| 3918 | phba->sysfs_mbox.mbox, |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3919 | lpfc_mbox_tmo_val(phba, pmb->mbxCommand) * HZ); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3920 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3921 | } |
| 3922 | |
| 3923 | if (rc != MBX_SUCCESS) { |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3924 | if (rc == MBX_TIMEOUT) { |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3925 | phba->sysfs_mbox.mbox = NULL; |
| 3926 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3927 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3928 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 3929 | return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3930 | } |
| 3931 | phba->sysfs_mbox.state = SMBOX_READING; |
| 3932 | } |
| 3933 | else if (phba->sysfs_mbox.offset != off || |
| 3934 | phba->sysfs_mbox.state != SMBOX_READING) { |
| 3935 | printk(KERN_WARNING "mbox_read: Bad State\n"); |
| 3936 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3937 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 3938 | return -EAGAIN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3939 | } |
| 3940 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3941 | memcpy(buf, (uint8_t *) &pmb + off, count); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3942 | |
| 3943 | phba->sysfs_mbox.offset = off + count; |
| 3944 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3945 | if (phba->sysfs_mbox.offset == MAILBOX_CMD_SIZE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3946 | sysfs_mbox_idle(phba); |
| 3947 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3948 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3949 | |
| 3950 | return count; |
| 3951 | } |
| 3952 | |
| 3953 | static struct bin_attribute sysfs_mbox_attr = { |
| 3954 | .attr = { |
| 3955 | .name = "mbox", |
| 3956 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3957 | }, |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3958 | .size = MAILBOX_CMD_SIZE, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3959 | .read = sysfs_mbox_read, |
| 3960 | .write = sysfs_mbox_write, |
| 3961 | }; |
| 3962 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3963 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3964 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3965 | * @vport: address of lpfc vport structure. |
| 3966 | * |
| 3967 | * Return codes: |
| 3968 | * zero on success |
| 3969 | * error return code from sysfs_create_bin_file() |
| 3970 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3971 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3972 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3973 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3974 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3975 | int error; |
| 3976 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3977 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 3978 | &sysfs_drvr_stat_data_attr); |
| 3979 | |
| 3980 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 3981 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 3982 | goto out; |
| 3983 | |
| 3984 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3985 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3986 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 3987 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3988 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3989 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3990 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3991 | if (error) |
| 3992 | goto out_remove_ctlreg_attr; |
| 3993 | |
| 3994 | return 0; |
| 3995 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3996 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 3997 | out_remove_stat_attr: |
| 3998 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 3999 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4000 | out: |
| 4001 | return error; |
| 4002 | } |
| 4003 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4004 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4005 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4006 | * @vport: address of lpfc vport structure. |
| 4007 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4008 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4009 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4010 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4011 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4012 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 4013 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4014 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 4015 | if (vport->port_type == LPFC_NPIV_PORT) |
| 4016 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4017 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 4018 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4019 | } |
| 4020 | |
| 4021 | |
| 4022 | /* |
| 4023 | * Dynamic FC Host Attributes Support |
| 4024 | */ |
| 4025 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4026 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4027 | * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4028 | * @shost: kernel scsi host pointer. |
| 4029 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4030 | static void |
| 4031 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 4032 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4033 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4034 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4035 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4036 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4037 | } |
| 4038 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4039 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4040 | * lpfc_get_host_port_type - Set the value of the scsi host port type |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4041 | * @shost: kernel scsi host pointer. |
| 4042 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4043 | static void |
| 4044 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 4045 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4046 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4047 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4048 | |
| 4049 | spin_lock_irq(shost->host_lock); |
| 4050 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4051 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 4052 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 4053 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4054 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4055 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4056 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 4057 | else |
| 4058 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 4059 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4060 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4061 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 4062 | else |
| 4063 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 4064 | } |
| 4065 | } else |
| 4066 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 4067 | |
| 4068 | spin_unlock_irq(shost->host_lock); |
| 4069 | } |
| 4070 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4071 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4072 | * lpfc_get_host_port_state - Set the value of the scsi host port state |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4073 | * @shost: kernel scsi host pointer. |
| 4074 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4075 | static void |
| 4076 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 4077 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4078 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4079 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4080 | |
| 4081 | spin_lock_irq(shost->host_lock); |
| 4082 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4083 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4084 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 4085 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4086 | switch (phba->link_state) { |
| 4087 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4088 | case LPFC_LINK_DOWN: |
| 4089 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 4090 | break; |
| 4091 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4092 | case LPFC_CLEAR_LA: |
| 4093 | case LPFC_HBA_READY: |
| 4094 | /* Links up, beyond this port_type reports state */ |
| 4095 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
| 4096 | break; |
| 4097 | case LPFC_HBA_ERROR: |
| 4098 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 4099 | break; |
| 4100 | default: |
| 4101 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 4102 | break; |
| 4103 | } |
| 4104 | } |
| 4105 | |
| 4106 | spin_unlock_irq(shost->host_lock); |
| 4107 | } |
| 4108 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4109 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4110 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4111 | * @shost: kernel scsi host pointer. |
| 4112 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4113 | static void |
| 4114 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 4115 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4116 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4117 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4118 | |
| 4119 | spin_lock_irq(shost->host_lock); |
| 4120 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4121 | if (lpfc_is_link_up(phba)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4122 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4123 | case LPFC_LINK_SPEED_1GHZ: |
| 4124 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4125 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4126 | case LPFC_LINK_SPEED_2GHZ: |
| 4127 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4128 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4129 | case LPFC_LINK_SPEED_4GHZ: |
| 4130 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4131 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4132 | case LPFC_LINK_SPEED_8GHZ: |
| 4133 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 4134 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4135 | case LPFC_LINK_SPEED_10GHZ: |
| 4136 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4137 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4138 | case LPFC_LINK_SPEED_16GHZ: |
| 4139 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 4140 | break; |
| 4141 | default: |
| 4142 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4143 | break; |
| 4144 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4145 | } else |
| 4146 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4147 | |
| 4148 | spin_unlock_irq(shost->host_lock); |
| 4149 | } |
| 4150 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4151 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4152 | * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4153 | * @shost: kernel scsi host pointer. |
| 4154 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4155 | static void |
| 4156 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 4157 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4158 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4159 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 4160 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4161 | |
| 4162 | spin_lock_irq(shost->host_lock); |
| 4163 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4164 | if ((vport->fc_flag & FC_FABRIC) || |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4165 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4166 | (vport->fc_flag & FC_PUBLIC_LOOP))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 4167 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4168 | else |
| 4169 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4170 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4171 | |
| 4172 | spin_unlock_irq(shost->host_lock); |
| 4173 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 4174 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4175 | } |
| 4176 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4177 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4178 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4179 | * @shost: kernel scsi host pointer. |
| 4180 | * |
| 4181 | * Notes: |
| 4182 | * NULL on error for link down, no mbox pool, sli2 active, |
| 4183 | * management not allowed, memory allocation error, or mbox error. |
| 4184 | * |
| 4185 | * Returns: |
| 4186 | * NULL for error |
| 4187 | * address of the adapter host statistics |
| 4188 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4189 | static struct fc_host_statistics * |
| 4190 | lpfc_get_stats(struct Scsi_Host *shost) |
| 4191 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4192 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4193 | struct lpfc_hba *phba = vport->phba; |
| 4194 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 4195 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4196 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4197 | LPFC_MBOXQ_t *pmboxq; |
| 4198 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4199 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4200 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4201 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4202 | /* |
| 4203 | * prevent udev from issuing mailbox commands until the port is |
| 4204 | * configured. |
| 4205 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4206 | if (phba->link_state < LPFC_LINK_DOWN || |
| 4207 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4208 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4209 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4210 | |
| 4211 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 4212 | return NULL; |
| 4213 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4214 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 4215 | if (!pmboxq) |
| 4216 | return NULL; |
| 4217 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 4218 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4219 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4220 | pmb->mbxCommand = MBX_READ_STATUS; |
| 4221 | pmb->mbxOwner = OWN_HOST; |
| 4222 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4223 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4224 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 4225 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4226 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4227 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4228 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4229 | |
| 4230 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4231 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4232 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4233 | return NULL; |
| 4234 | } |
| 4235 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 4236 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 4237 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4238 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
| 4239 | hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); |
| 4240 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
| 4241 | hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256); |
| 4242 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4243 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4244 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 4245 | pmb->mbxOwner = OWN_HOST; |
| 4246 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4247 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4248 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 4249 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4250 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4251 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4252 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4253 | |
| 4254 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4255 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4256 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4257 | return NULL; |
| 4258 | } |
| 4259 | |
| 4260 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 4261 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 4262 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 4263 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 4264 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 4265 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 4266 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 4267 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4268 | hs->link_failure_count -= lso->link_failure_count; |
| 4269 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 4270 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 4271 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 4272 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 4273 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 4274 | hs->error_frames -= lso->error_frames; |
| 4275 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4276 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 4277 | hs->lip_count = -1; |
| 4278 | hs->nos_count = (phba->link_events >> 1); |
| 4279 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4280 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4281 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4282 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4283 | hs->nos_count = -1; |
| 4284 | } else { |
| 4285 | hs->lip_count = -1; |
| 4286 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4287 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4288 | } |
| 4289 | |
| 4290 | hs->dumped_frames = -1; |
| 4291 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4292 | seconds = get_seconds(); |
| 4293 | if (seconds < psli->stats_start) |
| 4294 | hs->seconds_since_last_reset = seconds + |
| 4295 | ((unsigned long)-1 - psli->stats_start); |
| 4296 | else |
| 4297 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4298 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 4299 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 4300 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4301 | return hs; |
| 4302 | } |
| 4303 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4304 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4305 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4306 | * @shost: kernel scsi host pointer. |
| 4307 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4308 | static void |
| 4309 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 4310 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4311 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4312 | struct lpfc_hba *phba = vport->phba; |
| 4313 | struct lpfc_sli *psli = &phba->sli; |
| 4314 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4315 | LPFC_MBOXQ_t *pmboxq; |
| 4316 | MAILBOX_t *pmb; |
| 4317 | int rc = 0; |
| 4318 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4319 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 4320 | return; |
| 4321 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4322 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 4323 | if (!pmboxq) |
| 4324 | return; |
| 4325 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 4326 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4327 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4328 | pmb->mbxCommand = MBX_READ_STATUS; |
| 4329 | pmb->mbxOwner = OWN_HOST; |
| 4330 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 4331 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4332 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4333 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4334 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4335 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4336 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 4337 | else |
| 4338 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4339 | |
| 4340 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4341 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4342 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 4343 | return; |
| 4344 | } |
| 4345 | |
| 4346 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 4347 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 4348 | pmb->mbxOwner = OWN_HOST; |
| 4349 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4350 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4351 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4352 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4353 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4354 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 4355 | else |
| 4356 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4357 | |
| 4358 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4359 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4360 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 4361 | return; |
| 4362 | } |
| 4363 | |
| 4364 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 4365 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 4366 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 4367 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 4368 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 4369 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 4370 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4371 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 4372 | lso->link_events = (phba->link_events >> 1); |
| 4373 | else |
| 4374 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4375 | |
| 4376 | psli->stats_start = get_seconds(); |
| 4377 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 4378 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 4379 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4380 | return; |
| 4381 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4382 | |
| 4383 | /* |
| 4384 | * The LPFC driver treats linkdown handling as target loss events so there |
| 4385 | * are no sysfs handlers for link_down_tmo. |
| 4386 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4387 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4388 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4389 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4390 | * @starget: kernel scsi target pointer. |
| 4391 | * |
| 4392 | * Returns: |
| 4393 | * address of the node list if found |
| 4394 | * NULL target not found |
| 4395 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4396 | static struct lpfc_nodelist * |
| 4397 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4398 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4399 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 4400 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4401 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4402 | |
| 4403 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4404 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4405 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4406 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 4407 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4408 | starget->id == ndlp->nlp_sid) { |
| 4409 | spin_unlock_irq(shost->host_lock); |
| 4410 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4411 | } |
| 4412 | } |
| 4413 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4414 | return NULL; |
| 4415 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4416 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4417 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4418 | * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1 |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4419 | * @starget: kernel scsi target pointer. |
| 4420 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4421 | static void |
| 4422 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 4423 | { |
| 4424 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 4425 | |
| 4426 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4427 | } |
| 4428 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4429 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4430 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4431 | * @starget: kernel scsi target pointer. |
| 4432 | * |
| 4433 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 4434 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4435 | static void |
| 4436 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 4437 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4438 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4439 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4440 | fc_starget_node_name(starget) = |
| 4441 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4442 | } |
| 4443 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4444 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4445 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4446 | * @starget: kernel scsi target pointer. |
| 4447 | * |
| 4448 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 4449 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4450 | static void |
| 4451 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 4452 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4453 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4454 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4455 | fc_starget_port_name(starget) = |
| 4456 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4457 | } |
| 4458 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4459 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4460 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4461 | * @rport: fc rport address. |
| 4462 | * @timeout: new value for dev loss tmo. |
| 4463 | * |
| 4464 | * Description: |
| 4465 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 4466 | * dev_loss_tmo to one. |
| 4467 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4468 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4469 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 4470 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4471 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 4472 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4473 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 4474 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4475 | } |
| 4476 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4477 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4478 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4479 | * |
| 4480 | * Description: |
| 4481 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 4482 | * |
| 4483 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 4484 | * @cdev: class converted to an fc_rport. |
| 4485 | * @buf: on return contains the target_field or zero. |
| 4486 | * |
| 4487 | * Returns: size of formatted string. |
| 4488 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4489 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 4490 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4491 | lpfc_show_rport_##field (struct device *dev, \ |
| 4492 | struct device_attribute *attr, \ |
| 4493 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4494 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4495 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4496 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 4497 | return snprintf(buf, sz, format_string, \ |
| 4498 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 4499 | } |
| 4500 | |
| 4501 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 4502 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 4503 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 4504 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4505 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4506 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4507 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 4508 | * |
| 4509 | * Description: |
| 4510 | * This function is called by the transport after the @fc_vport's symbolic name |
| 4511 | * has been changed. This function re-registers the symbolic name with the |
| 4512 | * switch to propogate the change into the fabric if the vport is active. |
| 4513 | **/ |
| 4514 | static void |
| 4515 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 4516 | { |
| 4517 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 4518 | |
| 4519 | if (vport->port_state == LPFC_VPORT_READY) |
| 4520 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 4521 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4522 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4523 | /** |
| 4524 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 4525 | * @phba: Pointer to lpfc_hba struct. |
| 4526 | * |
| 4527 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 4528 | * module lpfc_log_verbose into the @phba cfg_log_verbose for use with |
| 4529 | * log messsage according to the module's lpfc_log_verbose parameter setting |
| 4530 | * before hba port or vport created. |
| 4531 | **/ |
| 4532 | static void |
| 4533 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 4534 | { |
| 4535 | phba->cfg_log_verbose = verbose; |
| 4536 | } |
| 4537 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4538 | struct fc_function_template lpfc_transport_functions = { |
| 4539 | /* fixed attributes the driver supports */ |
| 4540 | .show_host_node_name = 1, |
| 4541 | .show_host_port_name = 1, |
| 4542 | .show_host_supported_classes = 1, |
| 4543 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4544 | .show_host_supported_speeds = 1, |
| 4545 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4546 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4547 | |
| 4548 | /* dynamic attributes the driver supports */ |
| 4549 | .get_host_port_id = lpfc_get_host_port_id, |
| 4550 | .show_host_port_id = 1, |
| 4551 | |
| 4552 | .get_host_port_type = lpfc_get_host_port_type, |
| 4553 | .show_host_port_type = 1, |
| 4554 | |
| 4555 | .get_host_port_state = lpfc_get_host_port_state, |
| 4556 | .show_host_port_state = 1, |
| 4557 | |
| 4558 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 4559 | .show_host_active_fc4s = 1, |
| 4560 | |
| 4561 | .get_host_speed = lpfc_get_host_speed, |
| 4562 | .show_host_speed = 1, |
| 4563 | |
| 4564 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 4565 | .show_host_fabric_name = 1, |
| 4566 | |
| 4567 | /* |
| 4568 | * The LPFC driver treats linkdown handling as target loss events |
| 4569 | * so there are no sysfs handlers for link_down_tmo. |
| 4570 | */ |
| 4571 | |
| 4572 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4573 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4574 | |
| 4575 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 4576 | .show_rport_maxframe_size = 1, |
| 4577 | .show_rport_supported_classes = 1, |
| 4578 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4579 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 4580 | .show_rport_dev_loss_tmo = 1, |
| 4581 | |
| 4582 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 4583 | .show_starget_port_id = 1, |
| 4584 | |
| 4585 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 4586 | .show_starget_node_name = 1, |
| 4587 | |
| 4588 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 4589 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 4590 | |
| 4591 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 4592 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 4593 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4594 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4595 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4596 | |
| 4597 | .vport_disable = lpfc_vport_disable, |
| 4598 | |
| 4599 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 4600 | |
| 4601 | .bsg_request = lpfc_bsg_request, |
| 4602 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4603 | }; |
| 4604 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 4605 | struct fc_function_template lpfc_vport_transport_functions = { |
| 4606 | /* fixed attributes the driver supports */ |
| 4607 | .show_host_node_name = 1, |
| 4608 | .show_host_port_name = 1, |
| 4609 | .show_host_supported_classes = 1, |
| 4610 | .show_host_supported_fc4s = 1, |
| 4611 | .show_host_supported_speeds = 1, |
| 4612 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4613 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 4614 | |
| 4615 | /* dynamic attributes the driver supports */ |
| 4616 | .get_host_port_id = lpfc_get_host_port_id, |
| 4617 | .show_host_port_id = 1, |
| 4618 | |
| 4619 | .get_host_port_type = lpfc_get_host_port_type, |
| 4620 | .show_host_port_type = 1, |
| 4621 | |
| 4622 | .get_host_port_state = lpfc_get_host_port_state, |
| 4623 | .show_host_port_state = 1, |
| 4624 | |
| 4625 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 4626 | .show_host_active_fc4s = 1, |
| 4627 | |
| 4628 | .get_host_speed = lpfc_get_host_speed, |
| 4629 | .show_host_speed = 1, |
| 4630 | |
| 4631 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 4632 | .show_host_fabric_name = 1, |
| 4633 | |
| 4634 | /* |
| 4635 | * The LPFC driver treats linkdown handling as target loss events |
| 4636 | * so there are no sysfs handlers for link_down_tmo. |
| 4637 | */ |
| 4638 | |
| 4639 | .get_fc_host_stats = lpfc_get_stats, |
| 4640 | .reset_fc_host_stats = lpfc_reset_stats, |
| 4641 | |
| 4642 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 4643 | .show_rport_maxframe_size = 1, |
| 4644 | .show_rport_supported_classes = 1, |
| 4645 | |
| 4646 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 4647 | .show_rport_dev_loss_tmo = 1, |
| 4648 | |
| 4649 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 4650 | .show_starget_port_id = 1, |
| 4651 | |
| 4652 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 4653 | .show_starget_node_name = 1, |
| 4654 | |
| 4655 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 4656 | .show_starget_port_name = 1, |
| 4657 | |
| 4658 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 4659 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 4660 | |
| 4661 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4662 | |
| 4663 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 4664 | }; |
| 4665 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4666 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4667 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4668 | * @phba: lpfc_hba pointer. |
| 4669 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4670 | void |
| 4671 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 4672 | { |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 4673 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 4674 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4675 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4676 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 4677 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 4678 | lpfc_ack0_init(phba, lpfc_ack0); |
| 4679 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 4680 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4681 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 4682 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4683 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4684 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 4685 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
| 4686 | lpfc_fcp_wq_count_init(phba, lpfc_fcp_wq_count); |
| 4687 | lpfc_fcp_eq_count_init(phba, lpfc_fcp_eq_count); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4688 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 4689 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4690 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 4691 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 4692 | phba->cfg_poll = 0; |
| 4693 | else |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4694 | phba->cfg_poll = lpfc_poll; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 4695 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 4696 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4697 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4698 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4699 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4700 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4701 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 4702 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 4703 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame^] | 4704 | phba->cfg_enable_dss = 1; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4705 | return; |
| 4706 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 4707 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4708 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4709 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4710 | * @vport: lpfc_vport pointer. |
| 4711 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4712 | void |
| 4713 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 4714 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4715 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4716 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4717 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4718 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 4719 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 4720 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 4721 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 4722 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 4723 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4724 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4725 | lpfc_fdmi_on_init(vport, lpfc_fdmi_on); |
| 4726 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 4727 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 4728 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 4729 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4730 | return; |
| 4731 | } |