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