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