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