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