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