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