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