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