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