| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2013 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 8 | * * |
| 9 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 10 | * modify it under the terms of version 2 of the GNU General * |
| 11 | * Public License as published by the Free Software Foundation. * |
| 12 | * This program is distributed in the hope that it will be useful. * |
| 13 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 14 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 16 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 17 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 18 | * more details, a copy of which can be found in the file COPYING * |
| 19 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 20 | *******************************************************************/ |
| 21 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | #include <linux/ctype.h> |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 23 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 24 | #include <linux/pci.h> |
| 25 | #include <linux/interrupt.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 26 | #include <linux/module.h> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 27 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 29 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 30 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 31 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 32 | #include <scsi/scsi_device.h> |
| 33 | #include <scsi/scsi_host.h> |
| 34 | #include <scsi/scsi_tcq.h> |
| 35 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 36 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 37 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 38 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 39 | #include "lpfc_hw.h" |
| 40 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 41 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 42 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 43 | #include "lpfc_disc.h" |
| 44 | #include "lpfc_scsi.h" |
| 45 | #include "lpfc.h" |
| 46 | #include "lpfc_logmsg.h" |
| 47 | #include "lpfc_version.h" |
| 48 | #include "lpfc_compat.h" |
| 49 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 50 | #include "lpfc_vport.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 51 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 52 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 53 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 54 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 55 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 56 | /* |
| 57 | * Write key size should be multiple of 4. If write key is changed |
| 58 | * make sure that library write key is also changed. |
| 59 | */ |
| 60 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 61 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 62 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 63 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 64 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 65 | * @incr: integer to convert. |
| 66 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 67 | * |
| 68 | * Description: |
| 69 | * JEDEC Joint Electron Device Engineering Council. |
| 70 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 71 | * character string. The string is then terminated with a NULL in byte 9. |
| 72 | * Hex 0-9 becomes ascii '0' to '9'. |
| 73 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 74 | * |
| 75 | * Notes: |
| 76 | * Coded for 32 bit integers only. |
| 77 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 78 | static void |
| 79 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 80 | { |
| 81 | int i, j; |
| 82 | for (i = 0; i < 8; i++) { |
| 83 | j = (incr & 0xf); |
| 84 | if (j <= 9) |
| 85 | hdw[7 - i] = 0x30 + j; |
| 86 | else |
| 87 | hdw[7 - i] = 0x61 + j - 10; |
| 88 | incr = (incr >> 4); |
| 89 | } |
| 90 | hdw[8] = 0; |
| 91 | return; |
| 92 | } |
| 93 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 94 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 95 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 96 | * @dev: class unused variable. |
| 97 | * @attr: device attribute, not used. |
| 98 | * @buf: on return contains the module description text. |
| 99 | * |
| 100 | * Returns: size of formatted string. |
| 101 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 102 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 103 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 104 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 105 | { |
| 106 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 107 | } |
| 108 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 109 | /** |
| 110 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 111 | * @dev: class unused variable. |
| 112 | * @attr: device attribute, not used. |
| 113 | * @buf: on return contains the module description text. |
| 114 | * |
| 115 | * Returns: size of formatted string. |
| 116 | **/ |
| 117 | static ssize_t |
| 118 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 119 | char *buf) |
| 120 | { |
| 121 | struct Scsi_Host *shost = class_to_shost(dev); |
| 122 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 123 | struct lpfc_hba *phba = vport->phba; |
| 124 | |
| 125 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 126 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 127 | else |
| 128 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 129 | } |
| 130 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 131 | static ssize_t |
| 132 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 133 | char *buf) |
| 134 | { |
| 135 | struct Scsi_Host *shost = class_to_shost(dev); |
| 136 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 137 | struct lpfc_hba *phba = vport->phba; |
| 138 | |
| 139 | if (phba->cfg_enable_bg) |
| 140 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 141 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 142 | else |
| 143 | return snprintf(buf, PAGE_SIZE, |
| 144 | "BlockGuard Not Supported\n"); |
| 145 | else |
| 146 | return snprintf(buf, PAGE_SIZE, |
| 147 | "BlockGuard Disabled\n"); |
| 148 | } |
| 149 | |
| 150 | static ssize_t |
| 151 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 152 | char *buf) |
| 153 | { |
| 154 | struct Scsi_Host *shost = class_to_shost(dev); |
| 155 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 156 | struct lpfc_hba *phba = vport->phba; |
| 157 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 158 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 159 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static ssize_t |
| 163 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 164 | char *buf) |
| 165 | { |
| 166 | struct Scsi_Host *shost = class_to_shost(dev); |
| 167 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 168 | struct lpfc_hba *phba = vport->phba; |
| 169 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 170 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 171 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | static ssize_t |
| 175 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 176 | char *buf) |
| 177 | { |
| 178 | struct Scsi_Host *shost = class_to_shost(dev); |
| 179 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 180 | struct lpfc_hba *phba = vport->phba; |
| 181 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 182 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 183 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 184 | } |
| 185 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 186 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 187 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 188 | * @dev: class converted to a Scsi_host structure. |
| 189 | * @attr: device attribute, not used. |
| 190 | * @buf: on return contains the formatted text from lpfc_info(). |
| 191 | * |
| 192 | * Returns: size of formatted string. |
| 193 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 194 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 195 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 196 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 197 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 198 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 199 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 200 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 201 | } |
| 202 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 203 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 204 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 205 | * @dev: class converted to a Scsi_host structure. |
| 206 | * @attr: device attribute, not used. |
| 207 | * @buf: on return contains the formatted text serial number. |
| 208 | * |
| 209 | * Returns: size of formatted string. |
| 210 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 211 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 212 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 213 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 214 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 215 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 216 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 217 | struct lpfc_hba *phba = vport->phba; |
| 218 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 219 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 220 | } |
| 221 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 222 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 223 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 224 | * @dev: class converted to a Scsi_host structure. |
| 225 | * @attr: device attribute, not used. |
| 226 | * @buf: on return contains the formatted support level. |
| 227 | * |
| 228 | * Description: |
| 229 | * Returns a number indicating the temperature sensor level currently |
| 230 | * supported, zero or one in ascii. |
| 231 | * |
| 232 | * Returns: size of formatted string. |
| 233 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 234 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 235 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 236 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 237 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 238 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 239 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 240 | struct lpfc_hba *phba = vport->phba; |
| 241 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 242 | } |
| 243 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 244 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 245 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 246 | * @dev: class converted to a Scsi_host structure. |
| 247 | * @attr: device attribute, not used. |
| 248 | * @buf: on return contains the scsi vpd model description. |
| 249 | * |
| 250 | * Returns: size of formatted string. |
| 251 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 252 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 253 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 254 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 255 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 256 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 257 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 258 | struct lpfc_hba *phba = vport->phba; |
| 259 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 260 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 261 | } |
| 262 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 263 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 264 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 265 | * @dev: class converted to a Scsi_host structure. |
| 266 | * @attr: device attribute, not used. |
| 267 | * @buf: on return contains the scsi vpd model name. |
| 268 | * |
| 269 | * Returns: size of formatted string. |
| 270 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 271 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 272 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 273 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 274 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 275 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 276 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 277 | struct lpfc_hba *phba = vport->phba; |
| 278 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 279 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 280 | } |
| 281 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 282 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 283 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 284 | * @dev: class converted to a Scsi_host structure. |
| 285 | * @attr: device attribute, not used. |
| 286 | * @buf: on return contains the scsi vpd program type. |
| 287 | * |
| 288 | * Returns: size of formatted string. |
| 289 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 290 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 291 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 292 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 293 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 294 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 295 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 296 | struct lpfc_hba *phba = vport->phba; |
| 297 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 298 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 299 | } |
| 300 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 301 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 302 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 303 | * @dev: class converted to a Scsi_host structure. |
| 304 | * @attr: device attribute, not used. |
| 305 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 306 | * |
| 307 | * Returns: size of formatted string. |
| 308 | **/ |
| 309 | static ssize_t |
| 310 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 311 | { |
| 312 | struct Scsi_Host *shost = class_to_shost(dev); |
| 313 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 314 | struct lpfc_hba *phba = vport->phba; |
| 315 | |
| 316 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 317 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 318 | } |
| 319 | |
| 320 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 321 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 322 | * @dev: class converted to a Scsi_host structure. |
| 323 | * @attr: device attribute, not used. |
| 324 | * @buf: on return contains scsi vpd program type. |
| 325 | * |
| 326 | * Returns: size of formatted string. |
| 327 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 328 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 329 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 330 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 331 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 332 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 333 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 334 | struct lpfc_hba *phba = vport->phba; |
| 335 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 336 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 337 | } |
| 338 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 339 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 340 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 341 | * @dev: class converted to a Scsi_host structure. |
| 342 | * @attr: device attribute, not used. |
| 343 | * @buf: on return contains the scsi vpd program type. |
| 344 | * |
| 345 | * Returns: size of formatted string. |
| 346 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 347 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 348 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 349 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 350 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 351 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 352 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 353 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 354 | uint32_t if_type; |
| 355 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 356 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 357 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 358 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 359 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 360 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 361 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 362 | |
| 363 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 364 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 365 | fwrev, phba->sli_rev); |
| 366 | else |
| 367 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 368 | fwrev, phba->sli_rev, if_type, sli_family); |
| 369 | |
| 370 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 371 | } |
| 372 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 373 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 374 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 375 | * @dev: class converted to a Scsi_host structure. |
| 376 | * @attr: device attribute, not used. |
| 377 | * @buf: on return contains the scsi vpd program type. |
| 378 | * |
| 379 | * Returns: size of formatted string. |
| 380 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 381 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 382 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 383 | { |
| 384 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 385 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 386 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 387 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 388 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 389 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 390 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 391 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 392 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 393 | |
| 394 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 395 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 396 | * @dev: class converted to a Scsi_host structure. |
| 397 | * @attr: device attribute, not used. |
| 398 | * @buf: on return contains the ROM and FCode ascii strings. |
| 399 | * |
| 400 | * Returns: size of formatted string. |
| 401 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 402 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 403 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 404 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 405 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 406 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 407 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 408 | struct lpfc_hba *phba = vport->phba; |
| 409 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 410 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 411 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 412 | |
| 413 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 414 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 415 | * @dev: class converted to a Scsi_host structure. |
| 416 | * @attr: device attribute, not used. |
| 417 | * @buf: on return contains text describing the state of the link. |
| 418 | * |
| 419 | * Notes: |
| 420 | * The switch statement has no default so zero will be returned. |
| 421 | * |
| 422 | * Returns: size of formatted string. |
| 423 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 424 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 425 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 426 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 427 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 428 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 429 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 430 | struct lpfc_hba *phba = vport->phba; |
| 431 | int len = 0; |
| 432 | |
| 433 | switch (phba->link_state) { |
| 434 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 435 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 436 | case LPFC_INIT_START: |
| 437 | case LPFC_INIT_MBX_CMDS: |
| 438 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 439 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 440 | if (phba->hba_flag & LINK_DISABLED) |
| 441 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 442 | "Link Down - User disabled\n"); |
| 443 | else |
| 444 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 445 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 446 | break; |
| 447 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 448 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 449 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 450 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 451 | |
| 452 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 453 | case LPFC_LOCAL_CFG_LINK: |
| 454 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 455 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 456 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 457 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 458 | case LPFC_FLOGI: |
| 459 | case LPFC_FABRIC_CFG_LINK: |
| 460 | case LPFC_NS_REG: |
| 461 | case LPFC_NS_QRY: |
| 462 | case LPFC_BUILD_DISC_LIST: |
| 463 | case LPFC_DISC_AUTH: |
| 464 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 465 | "Discovery\n"); |
| 466 | break; |
| 467 | case LPFC_VPORT_READY: |
| 468 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 469 | break; |
| 470 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 471 | case LPFC_VPORT_FAILED: |
| 472 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 473 | break; |
| 474 | |
| 475 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 476 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 477 | "Unknown\n"); |
| 478 | break; |
| 479 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 480 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 481 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 482 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 483 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 484 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 485 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 486 | " Public Loop\n"); |
| 487 | else |
| 488 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 489 | " Private Loop\n"); |
| 490 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 491 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 492 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 493 | " Fabric\n"); |
| 494 | else |
| 495 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 496 | " Point-2-Point\n"); |
| 497 | } |
| 498 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 499 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 500 | return len; |
| 501 | } |
| 502 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 503 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 504 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 505 | * @dev: class unused variable. |
| 506 | * @attr: device attribute, not used. |
| 507 | * @buf: on return contains the module description text. |
| 508 | * |
| 509 | * Returns: size of formatted string. |
| 510 | **/ |
| 511 | static ssize_t |
| 512 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 513 | char *buf) |
| 514 | { |
| 515 | struct Scsi_Host *shost = class_to_shost(dev); |
| 516 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 517 | struct lpfc_hba *phba = vport->phba; |
| 518 | |
| 519 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 520 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 521 | |
| 522 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 523 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 524 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 525 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 526 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 527 | } |
| 528 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 529 | } |
| 530 | |
| 531 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 532 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 533 | * (OAS) is supported. |
| 534 | * @dev: class unused variable. |
| 535 | * @attr: device attribute, not used. |
| 536 | * @buf: on return contains the module description text. |
| 537 | * |
| 538 | * Returns: size of formatted string. |
| 539 | **/ |
| 540 | static ssize_t |
| 541 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 542 | char *buf) |
| 543 | { |
| 544 | struct Scsi_Host *shost = class_to_shost(dev); |
| 545 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 546 | struct lpfc_hba *phba = vport->phba; |
| 547 | |
| 548 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 549 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 550 | } |
| 551 | |
| 552 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 553 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 554 | * @dev: class device that is converted into a Scsi_host. |
| 555 | * @attr: device attribute, not used. |
| 556 | * @buf: one or more lpfc_polling_flags values. |
| 557 | * @count: not used. |
| 558 | * |
| 559 | * Returns: |
| 560 | * -EINVAL if the buffer is not "up" or "down" |
| 561 | * return from link state change function if non-zero |
| 562 | * length of the buf on success |
| 563 | **/ |
| 564 | static ssize_t |
| 565 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 566 | const char *buf, size_t count) |
| 567 | { |
| 568 | struct Scsi_Host *shost = class_to_shost(dev); |
| 569 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 570 | struct lpfc_hba *phba = vport->phba; |
| 571 | |
| 572 | int status = -EINVAL; |
| 573 | |
| 574 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 575 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 576 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 577 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 578 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 579 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 580 | |
| 581 | if (status == 0) |
| 582 | return strlen(buf); |
| 583 | else |
| 584 | return status; |
| 585 | } |
| 586 | |
| 587 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 588 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 589 | * @dev: class device that is converted into a Scsi_host. |
| 590 | * @attr: device attribute, not used. |
| 591 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 592 | * |
| 593 | * Description: |
| 594 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 595 | * vport counts. |
| 596 | * |
| 597 | * Returns: size of formatted string. |
| 598 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 599 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 600 | lpfc_num_discovered_ports_show(struct device *dev, |
| 601 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 602 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 603 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 604 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 605 | |
| 606 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 607 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 608 | } |
| 609 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 610 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 611 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 612 | * @shost: Scsi_Host pointer. |
| 613 | * |
| 614 | * Description: |
| 615 | * Bring the link down gracefully then re-init the link. The firmware will |
| 616 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 617 | * |
| 618 | * Returns: |
| 619 | * -EPERM port offline or management commands are being blocked |
| 620 | * -ENOMEM cannot allocate memory for the mailbox command |
| 621 | * -EIO error sending the mailbox command |
| 622 | * zero for success |
| 623 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 624 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 625 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 626 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 627 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 628 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 629 | LPFC_MBOXQ_t *pmboxq; |
| 630 | int mbxstatus = MBXERR_ERROR; |
| 631 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 632 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 633 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 634 | return -EPERM; |
| 635 | |
| 636 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 637 | |
| 638 | if (!pmboxq) |
| 639 | return -ENOMEM; |
| 640 | |
| 641 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 642 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 643 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 644 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 645 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 646 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 647 | if ((mbxstatus == MBX_SUCCESS) && |
| 648 | (pmboxq->u.mb.mbxStatus == 0 || |
| 649 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 650 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 651 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 652 | phba->cfg_link_speed); |
| 653 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 654 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 655 | if ((mbxstatus == MBX_SUCCESS) && |
| 656 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 657 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 658 | "2859 SLI authentication is required " |
| 659 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 660 | } |
| 661 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 662 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 663 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 664 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 665 | |
| 666 | if (mbxstatus == MBXERR_ERROR) |
| 667 | return -EIO; |
| 668 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 669 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | } |
| 671 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 672 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 673 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 674 | * @phba: lpfc_hba pointer. |
| 675 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 676 | * |
| 677 | * Notes: |
| 678 | * Assumes any error from lpfc_do_offline() will be negative. |
| 679 | * Can wait up to 5 seconds for the port ring buffers count |
| 680 | * 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] | 681 | * 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] | 682 | * |
| 683 | * Returns: |
| 684 | * -EIO error posting the event |
| 685 | * zero for success |
| 686 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 687 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 688 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 689 | { |
| 690 | struct completion online_compl; |
| 691 | struct lpfc_sli_ring *pring; |
| 692 | struct lpfc_sli *psli; |
| 693 | int status = 0; |
| 694 | int cnt = 0; |
| 695 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 696 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 697 | |
| 698 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 699 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 700 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 701 | if (rc == 0) |
| 702 | return -ENOMEM; |
| 703 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 704 | wait_for_completion(&online_compl); |
| 705 | |
| 706 | if (status != 0) |
| 707 | return -EIO; |
| 708 | |
| 709 | psli = &phba->sli; |
| 710 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 711 | /* Wait a little for things to settle down, but not |
| 712 | * long enough for dev loss timeout to expire. |
| 713 | */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 714 | for (i = 0; i < psli->num_rings; i++) { |
| 715 | pring = &psli->ring[i]; |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 716 | while (!list_empty(&pring->txcmplq)) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 717 | msleep(10); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 718 | if (cnt++ > 500) { /* 5 secs */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 719 | lpfc_printf_log(phba, |
| 720 | KERN_WARNING, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 721 | "0466 Outstanding IO when " |
| 722 | "bringing Adapter offline\n"); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 723 | break; |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 729 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 730 | if (rc == 0) |
| 731 | return -ENOMEM; |
| 732 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 733 | wait_for_completion(&online_compl); |
| 734 | |
| 735 | if (status != 0) |
| 736 | return -EIO; |
| 737 | |
| 738 | return 0; |
| 739 | } |
| 740 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 741 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 742 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 743 | * @phba: lpfc_hba pointer. |
| 744 | * |
| 745 | * Description: |
| 746 | * If the port is configured to allow a reset then the hba is brought |
| 747 | * offline then online. |
| 748 | * |
| 749 | * Notes: |
| 750 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 751 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 752 | * |
| 753 | * Returns: |
| 754 | * lpfc_do_offline() return code if not zero |
| 755 | * -EIO reset not configured or error posting the event |
| 756 | * zero for success |
| 757 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 758 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 759 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 760 | { |
| 761 | struct completion online_compl; |
| 762 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 763 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 764 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 765 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 766 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 767 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 768 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 769 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 770 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 771 | if (status != 0) |
| 772 | return status; |
| 773 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 774 | |
| 775 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 776 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 777 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 778 | if (rc == 0) |
| 779 | return -ENOMEM; |
| 780 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 781 | wait_for_completion(&online_compl); |
| 782 | |
| 783 | if (status != 0) |
| 784 | return -EIO; |
| 785 | |
| 786 | return 0; |
| 787 | } |
| 788 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 789 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 790 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 791 | * @dev: class device that is converted into a Scsi_host. |
| 792 | * @attr: device attribute, not used. |
| 793 | * @buf: containing the string "selective". |
| 794 | * @count: unused variable. |
| 795 | * |
| 796 | * Description: |
| 797 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 798 | * is called to perform the reset. |
| 799 | * |
| 800 | * Notes: |
| 801 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 802 | * 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] | 803 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 804 | * |
| 805 | * Returns: |
| 806 | * -EINVAL if the buffer does not contain the string "selective" |
| 807 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 808 | * return value of lpfc_selective_reset() if the call fails |
| 809 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 810 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 811 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 812 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 813 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 814 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 815 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 816 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 817 | int status = -EINVAL; |
| 818 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 819 | if (!phba->cfg_enable_hba_reset) |
| 820 | return -EACCES; |
| 821 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 822 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 823 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 824 | |
| 825 | if (status == 0) |
| 826 | return strlen(buf); |
| 827 | else |
| 828 | return status; |
| 829 | } |
| 830 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 831 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 832 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 833 | * @phba: lpfc_hba pointer. |
| 834 | * |
| 835 | * Description: |
| 836 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 837 | * the readyness after performing a firmware reset. |
| 838 | * |
| 839 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 840 | * zero for success, -EPERM when port does not have privilege to perform the |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 841 | * reset, -EIO when port timeout from recovering from the reset. |
| 842 | * |
| 843 | * Note: |
| 844 | * As the caller will interpret the return code by value, be careful in making |
| 845 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 846 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 847 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 848 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 849 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 850 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 851 | int i; |
| 852 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 853 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 854 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 855 | &portstat_reg.word0); |
| 856 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 857 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 858 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 859 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 860 | return -EPERM; |
| 861 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 862 | /* wait for the SLI port firmware ready after firmware reset */ |
| 863 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 864 | msleep(10); |
| 865 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 866 | &portstat_reg.word0); |
| 867 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 868 | continue; |
| 869 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 870 | continue; |
| 871 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 872 | continue; |
| 873 | break; |
| 874 | } |
| 875 | |
| 876 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 877 | return 0; |
| 878 | else |
| 879 | return -EIO; |
| 880 | } |
| 881 | |
| 882 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 883 | * 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] | 884 | * @phba: lpfc_hba pointer. |
| 885 | * |
| 886 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 887 | * Request SLI4 interface type-2 device to perform a physical register set |
| 888 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 889 | * |
| 890 | * Returns: |
| 891 | * zero for success |
| 892 | **/ |
| 893 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 894 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 895 | { |
| 896 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 897 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 898 | uint32_t before_fc_flag; |
| 899 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 900 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 901 | int status = 0, rc = 0; |
| 902 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 903 | |
| 904 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 905 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 906 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 907 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 908 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 909 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 910 | return -EPERM; |
| 911 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 912 | /* Keep state if we need to restore back */ |
| 913 | before_fc_flag = phba->pport->fc_flag; |
| 914 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 915 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 916 | /* Disable SR-IOV virtual functions if enabled */ |
| 917 | if (phba->cfg_sriov_nr_virtfn) { |
| 918 | pci_disable_sriov(pdev); |
| 919 | phba->cfg_sriov_nr_virtfn = 0; |
| 920 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 921 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 922 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 923 | |
| 924 | if (status != 0) |
| 925 | return status; |
| 926 | |
| 927 | /* wait for the device to be quiesced before firmware reset */ |
| 928 | msleep(100); |
| 929 | |
| 930 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 931 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 932 | |
| 933 | if (opcode == LPFC_FW_DUMP) |
| 934 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 935 | else if (opcode == LPFC_FW_RESET) |
| 936 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 937 | else if (opcode == LPFC_DV_RESET) |
| 938 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 939 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 940 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 941 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 942 | /* flush */ |
| 943 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 944 | |
| 945 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 946 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 947 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 948 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 949 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 950 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 951 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 952 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 953 | } else if (rc == -EIO) { |
| 954 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 955 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 956 | "3153 Fail to perform the requested " |
| 957 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 958 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | /* keep the original port state */ |
| 962 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 963 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 964 | |
| 965 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 966 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 967 | LPFC_EVT_ONLINE); |
| 968 | if (!job_posted) |
| 969 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 970 | |
| 971 | wait_for_completion(&online_compl); |
| 972 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 973 | out: |
| 974 | /* in any case, restore the virtual functions enabled as before */ |
| 975 | if (sriov_nr_virtfn) { |
| 976 | sriov_err = |
| 977 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 978 | if (!sriov_err) |
| 979 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 980 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 981 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 982 | /* return proper error code */ |
| 983 | if (!rc) { |
| 984 | if (!job_posted) |
| 985 | rc = -ENOMEM; |
| 986 | else if (status) |
| 987 | rc = -EIO; |
| 988 | } |
| 989 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 993 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 994 | * @dev: class device that is converted into a Scsi_host. |
| 995 | * @attr: device attribute, not used. |
| 996 | * @buf: on return contains the ascii number of nport events. |
| 997 | * |
| 998 | * Returns: size of formatted string. |
| 999 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1000 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1001 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1002 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1003 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1004 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1005 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1006 | struct lpfc_hba *phba = vport->phba; |
| 1007 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1008 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1009 | } |
| 1010 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1011 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1012 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1013 | * @dev: class device that is converted into a Scsi_host. |
| 1014 | * @attr: device attribute, not used. |
| 1015 | * @buf: on return contains the state of the adapter. |
| 1016 | * |
| 1017 | * Returns: size of formatted string. |
| 1018 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1019 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1020 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1021 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1022 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1023 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1024 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1025 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1026 | char * state; |
| 1027 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1028 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1029 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1030 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1031 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1032 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1033 | state = "offline"; |
| 1034 | else |
| 1035 | state = "online"; |
| 1036 | |
| 1037 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1038 | } |
| 1039 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1040 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1041 | * 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] | 1042 | * @dev: class device that is converted into a Scsi_host. |
| 1043 | * @attr: device attribute, not used. |
| 1044 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1045 | * @count: unused variable. |
| 1046 | * |
| 1047 | * Returns: |
| 1048 | * -EACCES if enable hba reset not enabled |
| 1049 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1050 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1051 | * buf length greater than zero indicates success |
| 1052 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1053 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1054 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1055 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1056 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1057 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1058 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1059 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1060 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1061 | char *board_mode_str = NULL; |
| 1062 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1063 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1064 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1065 | if (!phba->cfg_enable_hba_reset) { |
| 1066 | status = -EACCES; |
| 1067 | goto board_mode_out; |
| 1068 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1069 | |
| 1070 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1071 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1072 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1073 | init_completion(&online_compl); |
| 1074 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1075 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1076 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1077 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1078 | if (rc == 0) { |
| 1079 | status = -ENOMEM; |
| 1080 | goto board_mode_out; |
| 1081 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1082 | wait_for_completion(&online_compl); |
| 1083 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1084 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1085 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1086 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1087 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1088 | else |
| 1089 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1090 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1091 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1092 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1093 | else |
| 1094 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1095 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1096 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1097 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1098 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1099 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1100 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1101 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1102 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1103 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1104 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1105 | if (!status) |
| 1106 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1107 | else { |
| 1108 | board_mode_str = strchr(buf, '\n'); |
| 1109 | if (board_mode_str) |
| 1110 | *board_mode_str = '\0'; |
| 1111 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1112 | "3097 Failed \"%s\", status(%d), " |
| 1113 | "fc_flag(x%x)\n", |
| 1114 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1115 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1116 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1117 | } |
| 1118 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1119 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1120 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1121 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1122 | * @mxri: max xri count. |
| 1123 | * @axri: available xri count. |
| 1124 | * @mrpi: max rpi count. |
| 1125 | * @arpi: available rpi count. |
| 1126 | * @mvpi: max vpi count. |
| 1127 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1128 | * |
| 1129 | * Description: |
| 1130 | * If an integer pointer for an count is not null then the value for the |
| 1131 | * count is returned. |
| 1132 | * |
| 1133 | * Returns: |
| 1134 | * zero on error |
| 1135 | * one for success |
| 1136 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1137 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1138 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1139 | uint32_t *mxri, uint32_t *axri, |
| 1140 | uint32_t *mrpi, uint32_t *arpi, |
| 1141 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1142 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1143 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1144 | LPFC_MBOXQ_t *pmboxq; |
| 1145 | MAILBOX_t *pmb; |
| 1146 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1147 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1148 | |
| 1149 | /* |
| 1150 | * prevent udev from issuing mailbox commands until the port is |
| 1151 | * configured. |
| 1152 | */ |
| 1153 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1154 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1155 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1156 | return 0; |
| 1157 | |
| 1158 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1159 | return 0; |
| 1160 | |
| 1161 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1162 | if (!pmboxq) |
| 1163 | return 0; |
| 1164 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1165 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1166 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1167 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1168 | pmb->mbxOwner = OWN_HOST; |
| 1169 | pmboxq->context1 = NULL; |
| 1170 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1171 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1172 | rc = MBX_NOT_FINISHED; |
| 1173 | else |
| 1174 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1175 | |
| 1176 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1177 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1178 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1179 | return 0; |
| 1180 | } |
| 1181 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1182 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1183 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1184 | if (mrpi) |
| 1185 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1186 | if (arpi) |
| 1187 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1188 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1189 | if (mxri) |
| 1190 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1191 | if (axri) |
| 1192 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1193 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1194 | |
| 1195 | /* Account for differences with SLI-3. Get vpi count from |
| 1196 | * mailbox data and subtract one for max vpi value. |
| 1197 | */ |
| 1198 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1199 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1200 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1201 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1202 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1203 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1204 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1205 | } else { |
| 1206 | if (mrpi) |
| 1207 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1208 | if (arpi) |
| 1209 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1210 | if (mxri) |
| 1211 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1212 | if (axri) |
| 1213 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1214 | if (mvpi) |
| 1215 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1216 | if (avpi) |
| 1217 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1218 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1219 | |
| 1220 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1221 | return 1; |
| 1222 | } |
| 1223 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1224 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1225 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1226 | * @dev: class device that is converted into a Scsi_host. |
| 1227 | * @attr: device attribute, not used. |
| 1228 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1229 | * |
| 1230 | * Description: |
| 1231 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1232 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1233 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1234 | * must check for "Unknown" in the buffer to detect a failure. |
| 1235 | * |
| 1236 | * Returns: size of formatted string. |
| 1237 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1238 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1239 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1240 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1241 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1242 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1243 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1244 | struct lpfc_hba *phba = vport->phba; |
| 1245 | uint32_t cnt; |
| 1246 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1247 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1248 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1249 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1250 | } |
| 1251 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1252 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1253 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1254 | * @dev: class device that is converted into a Scsi_host. |
| 1255 | * @attr: device attribute, not used. |
| 1256 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1257 | * |
| 1258 | * Description: |
| 1259 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1260 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1261 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1262 | * must check for "Unknown" in the buffer to detect a failure. |
| 1263 | * |
| 1264 | * Returns: size of formatted string. |
| 1265 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1266 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1267 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1268 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1269 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1270 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1271 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1272 | struct lpfc_hba *phba = vport->phba; |
| 1273 | uint32_t cnt, acnt; |
| 1274 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1275 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1276 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1277 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1278 | } |
| 1279 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1280 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1281 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1282 | * @dev: class device that is converted into a Scsi_host. |
| 1283 | * @attr: device attribute, not used. |
| 1284 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1285 | * |
| 1286 | * Description: |
| 1287 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1288 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1289 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1290 | * must check for "Unknown" in the buffer to detect a failure. |
| 1291 | * |
| 1292 | * Returns: size of formatted string. |
| 1293 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1294 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1295 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1296 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1297 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1298 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1299 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1300 | struct lpfc_hba *phba = vport->phba; |
| 1301 | uint32_t cnt; |
| 1302 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1303 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1304 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1305 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1306 | } |
| 1307 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1308 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1309 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1310 | * @dev: class device that is converted into a Scsi_host. |
| 1311 | * @attr: device attribute, not used. |
| 1312 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1313 | * |
| 1314 | * Description: |
| 1315 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1316 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1317 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1318 | * must check for "Unknown" in the buffer to detect a failure. |
| 1319 | * |
| 1320 | * Returns: size of formatted string. |
| 1321 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1322 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1323 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1324 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1325 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1326 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1327 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1328 | struct lpfc_hba *phba = vport->phba; |
| 1329 | uint32_t cnt, acnt; |
| 1330 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1331 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1332 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1333 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1334 | } |
| 1335 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1336 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1337 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1338 | * @dev: class device that is converted into a Scsi_host. |
| 1339 | * @attr: device attribute, not used. |
| 1340 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1341 | * |
| 1342 | * Description: |
| 1343 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1344 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1345 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1346 | * must check for "Unknown" in the buffer to detect a failure. |
| 1347 | * |
| 1348 | * Returns: size of formatted string. |
| 1349 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1350 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1351 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1352 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1353 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1354 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1355 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1356 | struct lpfc_hba *phba = vport->phba; |
| 1357 | uint32_t cnt; |
| 1358 | |
| 1359 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1360 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1361 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1362 | } |
| 1363 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1364 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1365 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1366 | * @dev: class device that is converted into a Scsi_host. |
| 1367 | * @attr: device attribute, not used. |
| 1368 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1369 | * |
| 1370 | * Description: |
| 1371 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1372 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1373 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1374 | * must check for "Unknown" in the buffer to detect a failure. |
| 1375 | * |
| 1376 | * Returns: size of formatted string. |
| 1377 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1378 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1379 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1380 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1381 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1382 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1383 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1384 | struct lpfc_hba *phba = vport->phba; |
| 1385 | uint32_t cnt, acnt; |
| 1386 | |
| 1387 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1388 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1389 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1390 | } |
| 1391 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1392 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1393 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1394 | * @dev: class device that is converted into a Scsi_host. |
| 1395 | * @attr: device attribute, not used. |
| 1396 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1397 | * |
| 1398 | * Description: |
| 1399 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1400 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1401 | * the id of the vport. |
| 1402 | * |
| 1403 | * Returns: size of formatted string. |
| 1404 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1405 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1406 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1407 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1408 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1409 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1410 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1411 | struct lpfc_hba *phba = vport->phba; |
| 1412 | |
| 1413 | if (!(phba->max_vpi)) |
| 1414 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1415 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1416 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1417 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1418 | } |
| 1419 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1420 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1421 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1422 | * @dev: class device that is converted into a Scsi_host. |
| 1423 | * @attr: device attribute, not used. |
| 1424 | * @buf: on return contains the cfg_poll in hex. |
| 1425 | * |
| 1426 | * Notes: |
| 1427 | * cfg_poll should be a lpfc_polling_flags type. |
| 1428 | * |
| 1429 | * Returns: size of formatted string. |
| 1430 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1431 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1432 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1433 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1434 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1435 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1436 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1437 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1438 | |
| 1439 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1440 | } |
| 1441 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1442 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1443 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1444 | * @dev: class device that is converted into a Scsi_host. |
| 1445 | * @attr: device attribute, not used. |
| 1446 | * @buf: one or more lpfc_polling_flags values. |
| 1447 | * @count: not used. |
| 1448 | * |
| 1449 | * Notes: |
| 1450 | * buf contents converted to integer and checked for a valid value. |
| 1451 | * |
| 1452 | * Returns: |
| 1453 | * -EINVAL if the buffer connot be converted or is out of range |
| 1454 | * length of the buf on success |
| 1455 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1456 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1457 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1458 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1459 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1460 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1461 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1462 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1463 | uint32_t creg_val; |
| 1464 | uint32_t old_val; |
| 1465 | int val=0; |
| 1466 | |
| 1467 | if (!isdigit(buf[0])) |
| 1468 | return -EINVAL; |
| 1469 | |
| 1470 | if (sscanf(buf, "%i", &val) != 1) |
| 1471 | return -EINVAL; |
| 1472 | |
| 1473 | if ((val & 0x3) != val) |
| 1474 | return -EINVAL; |
| 1475 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1476 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1477 | val = 0; |
| 1478 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1479 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1480 | "3051 lpfc_poll changed from %d to %d\n", |
| 1481 | phba->cfg_poll, val); |
| 1482 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1483 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1484 | |
| 1485 | old_val = phba->cfg_poll; |
| 1486 | |
| 1487 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1488 | if ((val & DISABLE_FCP_RING_INT) && |
| 1489 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1490 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1491 | spin_unlock_irq(&phba->hbalock); |
| 1492 | return -EINVAL; |
| 1493 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1494 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1495 | writel(creg_val, phba->HCregaddr); |
| 1496 | readl(phba->HCregaddr); /* flush */ |
| 1497 | |
| 1498 | lpfc_poll_start_timer(phba); |
| 1499 | } |
| 1500 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1501 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1502 | return -EINVAL; |
| 1503 | } |
| 1504 | |
| 1505 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1506 | (old_val & DISABLE_FCP_RING_INT)) |
| 1507 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1508 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1509 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1510 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1511 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1512 | spin_unlock_irq(&phba->hbalock); |
| 1513 | return -EINVAL; |
| 1514 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1515 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1516 | writel(creg_val, phba->HCregaddr); |
| 1517 | readl(phba->HCregaddr); /* flush */ |
| 1518 | } |
| 1519 | |
| 1520 | phba->cfg_poll = val; |
| 1521 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1522 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1523 | |
| 1524 | return strlen(buf); |
| 1525 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1526 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1527 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1528 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1529 | * @dev: class unused variable. |
| 1530 | * @attr: device attribute, not used. |
| 1531 | * @buf: on return contains the module description text. |
| 1532 | * |
| 1533 | * Returns: size of formatted string. |
| 1534 | **/ |
| 1535 | static ssize_t |
| 1536 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1537 | char *buf) |
| 1538 | { |
| 1539 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1540 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1541 | struct lpfc_hba *phba = vport->phba; |
| 1542 | |
| 1543 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1544 | } |
| 1545 | |
| 1546 | /** |
| 1547 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1548 | * @dev: class unused variable. |
| 1549 | * @attr: device attribute, not used. |
| 1550 | * @buf: on return contains the module description text. |
| 1551 | * |
| 1552 | * Returns: size of formatted string. |
| 1553 | **/ |
| 1554 | static ssize_t |
| 1555 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1556 | char *buf) |
| 1557 | { |
| 1558 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1559 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1560 | struct lpfc_hba *phba = vport->phba; |
| 1561 | |
| 1562 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1563 | } |
| 1564 | |
| 1565 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1566 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1567 | * @dev: class converted to a Scsi_host structure. |
| 1568 | * @attr: device attribute, not used. |
| 1569 | * @buf: on return contains the formatted text. |
| 1570 | * |
| 1571 | * Returns: size of formatted string. |
| 1572 | **/ |
| 1573 | static ssize_t |
| 1574 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1575 | char *buf) |
| 1576 | { |
| 1577 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1578 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1579 | struct lpfc_hba *phba = vport->phba; |
| 1580 | |
| 1581 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1582 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1583 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1584 | "" : "Not "); |
| 1585 | } |
| 1586 | |
| 1587 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1588 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1589 | * @dev: class converted to a Scsi_host structure. |
| 1590 | * @attr: device attribute, not used. |
| 1591 | * @buf: on return contains the formatted support level. |
| 1592 | * |
| 1593 | * Description: |
| 1594 | * Returns the maximum number of virtual functions a physical function can |
| 1595 | * support, 0 will be returned if called on virtual function. |
| 1596 | * |
| 1597 | * Returns: size of formatted string. |
| 1598 | **/ |
| 1599 | static ssize_t |
| 1600 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1601 | struct device_attribute *attr, |
| 1602 | char *buf) |
| 1603 | { |
| 1604 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1605 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1606 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1607 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1608 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1609 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1610 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1611 | } |
| 1612 | |
| 1613 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1614 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1615 | * |
| 1616 | * Description: |
| 1617 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1618 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1619 | * |
| 1620 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1621 | * @dev: class device that is converted into a Scsi_host. |
| 1622 | * @attr: device attribute, not used. |
| 1623 | * @buf: on return contains the attribute value in decimal. |
| 1624 | * |
| 1625 | * Returns: size of formatted string. |
| 1626 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1627 | #define lpfc_param_show(attr) \ |
| 1628 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1629 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1630 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1631 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1632 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1633 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1634 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1635 | uint val = 0;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1636 | val = phba->cfg_##attr;\ |
| 1637 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1638 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1639 | } |
| 1640 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1641 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1642 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1643 | * |
| 1644 | * Description: |
| 1645 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1646 | * into a function with the name lpfc_hba_queue_depth_show |
| 1647 | * |
| 1648 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1649 | * @dev: class device that is converted into a Scsi_host. |
| 1650 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1651 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1652 | * |
| 1653 | * Returns: size of formatted string. |
| 1654 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1655 | #define lpfc_param_hex_show(attr) \ |
| 1656 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1657 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1658 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1659 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1660 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1661 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1662 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1663 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1664 | val = phba->cfg_##attr;\ |
| 1665 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1666 | phba->cfg_##attr);\ |
| 1667 | } |
| 1668 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1669 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1670 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1671 | * |
| 1672 | * Description: |
| 1673 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1674 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1675 | * takes a default argument, a minimum and maximum argument. |
| 1676 | * |
| 1677 | * lpfc_##attr##_init: Initializes an attribute. |
| 1678 | * @phba: pointer the the adapter structure. |
| 1679 | * @val: integer attribute value. |
| 1680 | * |
| 1681 | * Validates the min and max values then sets the adapter config field |
| 1682 | * accordingly, or uses the default if out of range and prints an error message. |
| 1683 | * |
| 1684 | * Returns: |
| 1685 | * zero on success |
| 1686 | * -EINVAL if default used |
| 1687 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1688 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1689 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1690 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1691 | { \ |
| 1692 | if (val >= minval && val <= maxval) {\ |
| 1693 | phba->cfg_##attr = val;\ |
| 1694 | return 0;\ |
| 1695 | }\ |
| 1696 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1697 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1698 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1699 | phba->cfg_##attr = default;\ |
| 1700 | return -EINVAL;\ |
| 1701 | } |
| 1702 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1703 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1704 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1705 | * |
| 1706 | * Description: |
| 1707 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1708 | * into a function with the name lpfc_hba_queue_depth_set |
| 1709 | * |
| 1710 | * lpfc_##attr##_set: Sets an attribute value. |
| 1711 | * @phba: pointer the the adapter structure. |
| 1712 | * @val: integer attribute value. |
| 1713 | * |
| 1714 | * Description: |
| 1715 | * Validates the min and max values then sets the |
| 1716 | * adapter config field if in the valid range. prints error message |
| 1717 | * and does not set the parameter if invalid. |
| 1718 | * |
| 1719 | * Returns: |
| 1720 | * zero on success |
| 1721 | * -EINVAL if val is invalid |
| 1722 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1723 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1724 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1725 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1726 | { \ |
| 1727 | if (val >= minval && val <= maxval) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1728 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 1729 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 1730 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1731 | phba->cfg_##attr = val;\ |
| 1732 | return 0;\ |
| 1733 | }\ |
| 1734 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1735 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1736 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1737 | return -EINVAL;\ |
| 1738 | } |
| 1739 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1740 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1741 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1742 | * |
| 1743 | * Description: |
| 1744 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1745 | * into a function with the name lpfc_hba_queue_depth_store. |
| 1746 | * |
| 1747 | * lpfc_##attr##_store: Set an sttribute value. |
| 1748 | * @dev: class device that is converted into a Scsi_host. |
| 1749 | * @attr: device attribute, not used. |
| 1750 | * @buf: contains the attribute value in ascii. |
| 1751 | * @count: not used. |
| 1752 | * |
| 1753 | * Description: |
| 1754 | * Convert the ascii text number to an integer, then |
| 1755 | * use the lpfc_##attr##_set function to set the value. |
| 1756 | * |
| 1757 | * Returns: |
| 1758 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1759 | * length of buffer upon success. |
| 1760 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1761 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1762 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1763 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1764 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1765 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1766 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1767 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1768 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1769 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1770 | if (!isdigit(buf[0]))\ |
| 1771 | return -EINVAL;\ |
| 1772 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1773 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1774 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 1775 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1776 | else \ |
| 1777 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1778 | } |
| 1779 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1780 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1781 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1782 | * |
| 1783 | * Description: |
| 1784 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1785 | * into a function with the name lpfc_hba_queue_depth_show |
| 1786 | * |
| 1787 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 1788 | * @dev: class device that is converted into a Scsi_host. |
| 1789 | * @attr: device attribute, not used. |
| 1790 | * @buf: on return contains the attribute value in decimal. |
| 1791 | * |
| 1792 | * Returns: length of formatted string. |
| 1793 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1794 | #define lpfc_vport_param_show(attr) \ |
| 1795 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1796 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1797 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1798 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1799 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1800 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1801 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1802 | val = vport->cfg_##attr;\ |
| 1803 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 1804 | } |
| 1805 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1806 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1807 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1808 | * |
| 1809 | * Description: |
| 1810 | * Macro that given an attr e.g. |
| 1811 | * hba_queue_depth expands into a function with the name |
| 1812 | * lpfc_hba_queue_depth_show |
| 1813 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1814 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1815 | * @dev: class device that is converted into a Scsi_host. |
| 1816 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1817 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1818 | * |
| 1819 | * Returns: length of formatted string. |
| 1820 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1821 | #define lpfc_vport_param_hex_show(attr) \ |
| 1822 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1823 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1824 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1825 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1826 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1827 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1828 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1829 | val = vport->cfg_##attr;\ |
| 1830 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 1831 | } |
| 1832 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1833 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1834 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1835 | * |
| 1836 | * Description: |
| 1837 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1838 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1839 | * takes a default argument, a minimum and maximum argument. |
| 1840 | * |
| 1841 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 1842 | * adapter config field accordingly, or uses the default if out of range |
| 1843 | * and prints an error message. |
| 1844 | * @phba: pointer the the adapter structure. |
| 1845 | * @val: integer attribute value. |
| 1846 | * |
| 1847 | * Returns: |
| 1848 | * zero on success |
| 1849 | * -EINVAL if default used |
| 1850 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1851 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 1852 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1853 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1854 | { \ |
| 1855 | if (val >= minval && val <= maxval) {\ |
| 1856 | vport->cfg_##attr = val;\ |
| 1857 | return 0;\ |
| 1858 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1859 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1860 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1861 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1862 | vport->cfg_##attr = default;\ |
| 1863 | return -EINVAL;\ |
| 1864 | } |
| 1865 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1866 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1867 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1868 | * |
| 1869 | * Description: |
| 1870 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1871 | * into a function with the name lpfc_hba_queue_depth_set |
| 1872 | * |
| 1873 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 1874 | * adapter config field if in the valid range. prints error message |
| 1875 | * and does not set the parameter if invalid. |
| 1876 | * @phba: pointer the the adapter structure. |
| 1877 | * @val: integer attribute value. |
| 1878 | * |
| 1879 | * Returns: |
| 1880 | * zero on success |
| 1881 | * -EINVAL if val is invalid |
| 1882 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1883 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 1884 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1885 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1886 | { \ |
| 1887 | if (val >= minval && val <= maxval) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1888 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 1889 | "3053 lpfc_" #attr \ |
| 1890 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 1891 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 1892 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1893 | vport->cfg_##attr = val;\ |
| 1894 | return 0;\ |
| 1895 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1896 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1897 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1898 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1899 | return -EINVAL;\ |
| 1900 | } |
| 1901 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1902 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1903 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1904 | * |
| 1905 | * Description: |
| 1906 | * Macro that given an attr e.g. hba_queue_depth |
| 1907 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 1908 | * |
| 1909 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 1910 | * use the lpfc_##attr##_set function to set the value. |
| 1911 | * @cdev: class device that is converted into a Scsi_host. |
| 1912 | * @buf: contains the attribute value in decimal. |
| 1913 | * @count: not used. |
| 1914 | * |
| 1915 | * Returns: |
| 1916 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1917 | * length of buffer upon success. |
| 1918 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1919 | #define lpfc_vport_param_store(attr) \ |
| 1920 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1921 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1922 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1923 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1924 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1925 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1926 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1927 | if (!isdigit(buf[0]))\ |
| 1928 | return -EINVAL;\ |
| 1929 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1930 | return -EINVAL;\ |
| 1931 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 1932 | return strlen(buf);\ |
| 1933 | else \ |
| 1934 | return -EINVAL;\ |
| 1935 | } |
| 1936 | |
| 1937 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1938 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1939 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1940 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1941 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1942 | lpfc_param_init(name, defval, minval, maxval) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1943 | |
| 1944 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1945 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1946 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1947 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1948 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1949 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1950 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1951 | |
| 1952 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1953 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1954 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1955 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1956 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1957 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1958 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1959 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1960 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1961 | lpfc_##name##_show, lpfc_##name##_store) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1962 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1963 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1964 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1965 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1966 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1967 | lpfc_param_hex_show(name)\ |
| 1968 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1969 | 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] | 1970 | |
| 1971 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1972 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1973 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1974 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1975 | lpfc_param_hex_show(name)\ |
| 1976 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1977 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1978 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1979 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1980 | lpfc_##name##_show, lpfc_##name##_store) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1981 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1982 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1983 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1984 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1985 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1986 | lpfc_vport_param_init(name, defval, minval, maxval) |
| 1987 | |
| 1988 | #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1989 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1990 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1991 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1992 | lpfc_vport_param_show(name)\ |
| 1993 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1994 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1995 | |
| 1996 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1997 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1998 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1999 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2000 | lpfc_vport_param_show(name)\ |
| 2001 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2002 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 2003 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2004 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 2005 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2006 | |
| 2007 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2008 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2009 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2010 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2011 | lpfc_vport_param_hex_show(name)\ |
| 2012 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2013 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2014 | |
| 2015 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2016 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2017 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2018 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2019 | lpfc_vport_param_hex_show(name)\ |
| 2020 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2021 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 2022 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2023 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 2024 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2025 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2026 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2027 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2028 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2029 | 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] | 2030 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2031 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2032 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2033 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2034 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2035 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2036 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2037 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2038 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2039 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2040 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2041 | lpfc_option_rom_version_show, NULL); |
| 2042 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2043 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2044 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2045 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 2046 | 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] | 2047 | 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] | 2048 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2049 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2050 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2051 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2052 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2053 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2054 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2055 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2056 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2057 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 2058 | 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] | 2059 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 2060 | 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] | 2061 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2062 | static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, |
| 2063 | lpfc_sriov_hw_max_virtfn_show, NULL); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2064 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2065 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2066 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2067 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2068 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2069 | #define WWN_SZ 8 |
| 2070 | /** |
| 2071 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2072 | * @buf: WWN string. |
| 2073 | * @cnt: Length of string. |
| 2074 | * @wwn: Array to receive converted wwn value. |
| 2075 | * |
| 2076 | * Returns: |
| 2077 | * -EINVAL if the buffer does not contain a valid wwn |
| 2078 | * 0 success |
| 2079 | **/ |
| 2080 | static size_t |
| 2081 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2082 | { |
| 2083 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2084 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2085 | /* Count may include a LF at end of string */ |
| 2086 | if (buf[cnt-1] == '\n') |
| 2087 | cnt--; |
| 2088 | |
| 2089 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2090 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2091 | return -EINVAL; |
| 2092 | |
| 2093 | memset(wwn, 0, WWN_SZ); |
| 2094 | |
| 2095 | /* Validate and store the new name */ |
| 2096 | for (i = 0, j = 0; i < 16; i++) { |
| 2097 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2098 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2099 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2100 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2101 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2102 | j = ((j << 4) | (*buf++ - '0')); |
| 2103 | else |
| 2104 | return -EINVAL; |
| 2105 | if (i % 2) { |
| 2106 | wwn[i/2] = j & 0xff; |
| 2107 | j = 0; |
| 2108 | } |
| 2109 | } |
| 2110 | return 0; |
| 2111 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2112 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2113 | * 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] | 2114 | * @dev: class device that is converted into a Scsi_host. |
| 2115 | * @attr: device attribute, not used. |
| 2116 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2117 | * @count: must be size of lpfc_soft_wwn_key. |
| 2118 | * |
| 2119 | * Returns: |
| 2120 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2121 | * length of buf indicates success |
| 2122 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2123 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2124 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2125 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2126 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2127 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2128 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2129 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2130 | unsigned int cnt = count; |
| 2131 | |
| 2132 | /* |
| 2133 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2134 | * We require that the user write a specific key to enable |
| 2135 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2136 | * is written, the enable key resets. If further updates are |
| 2137 | * desired, the key must be written again to re-enable the |
| 2138 | * attribute. |
| 2139 | * |
| 2140 | * The "key" is not secret - it is a hardcoded string shown |
| 2141 | * here. The intent is to protect against the random user or |
| 2142 | * application that is just writing attributes. |
| 2143 | */ |
| 2144 | |
| 2145 | /* count may include a LF at end of string */ |
| 2146 | if (buf[cnt-1] == '\n') |
| 2147 | cnt--; |
| 2148 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2149 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2150 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2151 | return -EINVAL; |
| 2152 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2153 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2154 | return count; |
| 2155 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2156 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 2157 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2158 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2159 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2160 | * 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] | 2161 | * @dev: class device that is converted into a Scsi_host. |
| 2162 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2163 | * @buf: on return contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2164 | * |
| 2165 | * Returns: size of formatted string. |
| 2166 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2167 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2168 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2169 | char *buf) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2170 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2171 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2172 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2173 | struct lpfc_hba *phba = vport->phba; |
| 2174 | |
Randy Dunlap | afc071e | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 2175 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2176 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2177 | } |
| 2178 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2179 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2180 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2181 | * @dev class device that is converted into a Scsi_host. |
| 2182 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2183 | * @buf: contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2184 | * @count: number of wwpn bytes in buf |
| 2185 | * |
| 2186 | * Returns: |
| 2187 | * -EACCES hba reset not enabled, adapter over temp |
| 2188 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2189 | * -EIO error taking adapter offline or online |
| 2190 | * value of count on success |
| 2191 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2192 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2193 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2194 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2195 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2196 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2197 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2198 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2199 | struct completion online_compl; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2200 | int stat1 = 0, stat2 = 0; |
| 2201 | unsigned int cnt = count; |
| 2202 | u8 wwpn[WWN_SZ]; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2203 | int rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2204 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 2205 | if (!phba->cfg_enable_hba_reset) |
| 2206 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2207 | spin_lock_irq(&phba->hbalock); |
| 2208 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2209 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 2210 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2211 | } |
| 2212 | spin_unlock_irq(&phba->hbalock); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2213 | /* count may include a LF at end of string */ |
| 2214 | if (buf[cnt-1] == '\n') |
| 2215 | cnt--; |
| 2216 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2217 | if (!phba->soft_wwn_enable) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2218 | return -EINVAL; |
| 2219 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2220 | /* lock setting wwpn, wwnn down */ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2221 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2222 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2223 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2224 | if (!rc) { |
| 2225 | /* not able to set wwpn, unlock it */ |
| 2226 | phba->soft_wwn_enable = 1; |
| 2227 | return rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2228 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2229 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2230 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2231 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2232 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2233 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2234 | |
| 2235 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2236 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2237 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 2238 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2239 | if (stat1) |
| 2240 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2241 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2242 | "reinit adapter - %d\n", stat1); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2243 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2244 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2245 | LPFC_EVT_ONLINE); |
| 2246 | if (rc == 0) |
| 2247 | return -ENOMEM; |
| 2248 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2249 | wait_for_completion(&online_compl); |
| 2250 | if (stat2) |
| 2251 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2252 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2253 | "reinit adapter - %d\n", stat2); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2254 | return (stat1 || stat2) ? -EIO : count; |
| 2255 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2256 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2257 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2258 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2259 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2260 | * 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] | 2261 | * @dev: class device that is converted into a Scsi_host. |
| 2262 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2263 | * @buf: on return contains the wwnn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2264 | * |
| 2265 | * Returns: size of formatted string. |
| 2266 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2267 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2268 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2269 | char *buf) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2270 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2271 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2272 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2273 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2274 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2275 | } |
| 2276 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2277 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2278 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2279 | * @cdev: class device that is converted into a Scsi_host. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2280 | * @buf: contains the ww node name in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2281 | * @count: number of wwnn bytes in buf. |
| 2282 | * |
| 2283 | * Returns: |
| 2284 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2285 | * value of count on success |
| 2286 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2287 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2288 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2289 | const char *buf, size_t count) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2290 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2291 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2292 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2293 | unsigned int cnt = count; |
| 2294 | u8 wwnn[WWN_SZ]; |
| 2295 | int rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2296 | |
| 2297 | /* count may include a LF at end of string */ |
| 2298 | if (buf[cnt-1] == '\n') |
| 2299 | cnt--; |
| 2300 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2301 | if (!phba->soft_wwn_enable) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2302 | return -EINVAL; |
| 2303 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2304 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
| 2305 | if (!rc) { |
| 2306 | /* Allow wwnn to be set many times, as long as the enable |
| 2307 | * is set. However, once the wwpn is set, everything locks. |
| 2308 | */ |
| 2309 | return rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2310 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2311 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2312 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2313 | |
| 2314 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2315 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2316 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2317 | |
| 2318 | return count; |
| 2319 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2320 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2321 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2322 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2323 | /** |
| 2324 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2325 | * Optimized Access Storage (OAS) operations. |
| 2326 | * @dev: class device that is converted into a Scsi_host. |
| 2327 | * @attr: device attribute, not used. |
| 2328 | * @buf: buffer for passing information. |
| 2329 | * |
| 2330 | * Returns: |
| 2331 | * value of count |
| 2332 | **/ |
| 2333 | static ssize_t |
| 2334 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2335 | char *buf) |
| 2336 | { |
| 2337 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2338 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2339 | |
| 2340 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2341 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2342 | } |
| 2343 | |
| 2344 | /** |
| 2345 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2346 | * Optimized Access Storage (OAS) operations. |
| 2347 | * @dev: class device that is converted into a Scsi_host. |
| 2348 | * @attr: device attribute, not used. |
| 2349 | * @buf: buffer for passing information. |
| 2350 | * @count: Size of the data buffer. |
| 2351 | * |
| 2352 | * Returns: |
| 2353 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2354 | * -EPERM oas is not supported by hba |
| 2355 | * value of count on success |
| 2356 | **/ |
| 2357 | static ssize_t |
| 2358 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2359 | const char *buf, size_t count) |
| 2360 | { |
| 2361 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2362 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2363 | unsigned int cnt = count; |
| 2364 | uint8_t wwpn[WWN_SZ]; |
| 2365 | int rc; |
| 2366 | |
| 2367 | if (!phba->cfg_EnableXLane) |
| 2368 | return -EPERM; |
| 2369 | |
| 2370 | /* count may include a LF at end of string */ |
| 2371 | if (buf[cnt-1] == '\n') |
| 2372 | cnt--; |
| 2373 | |
| 2374 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2375 | if (rc) |
| 2376 | return rc; |
| 2377 | |
| 2378 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2379 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2380 | if (wwn_to_u64(wwpn) == 0) |
| 2381 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2382 | else |
| 2383 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2384 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2385 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2386 | return count; |
| 2387 | } |
| 2388 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2389 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2390 | |
| 2391 | /** |
| 2392 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2393 | * for Optimized Access Storage (OAS) operations. |
| 2394 | * @dev: class device that is converted into a Scsi_host. |
| 2395 | * @attr: device attribute, not used. |
| 2396 | * @buf: buffer for passing information. |
| 2397 | * |
| 2398 | * Returns: |
| 2399 | * value of count on success |
| 2400 | **/ |
| 2401 | static ssize_t |
| 2402 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2403 | char *buf) |
| 2404 | { |
| 2405 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2406 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2407 | |
| 2408 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2409 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2410 | } |
| 2411 | |
| 2412 | /** |
| 2413 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2414 | * for Optimized Access Storage (OAS) operations. |
| 2415 | * @dev: class device that is converted into a Scsi_host. |
| 2416 | * @attr: device attribute, not used. |
| 2417 | * @buf: buffer for passing information. |
| 2418 | * @count: Size of the data buffer. |
| 2419 | * |
| 2420 | * Returns: |
| 2421 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2422 | * -EPERM oas is not supported by hba |
| 2423 | * value of count on success |
| 2424 | **/ |
| 2425 | static ssize_t |
| 2426 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2427 | const char *buf, size_t count) |
| 2428 | { |
| 2429 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2430 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2431 | unsigned int cnt = count; |
| 2432 | uint8_t wwpn[WWN_SZ]; |
| 2433 | int rc; |
| 2434 | |
| 2435 | if (!phba->cfg_EnableXLane) |
| 2436 | return -EPERM; |
| 2437 | |
| 2438 | /* count may include a LF at end of string */ |
| 2439 | if (buf[cnt-1] == '\n') |
| 2440 | cnt--; |
| 2441 | |
| 2442 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2443 | if (rc) |
| 2444 | return rc; |
| 2445 | |
| 2446 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2447 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2448 | if (wwn_to_u64(wwpn) == 0) |
| 2449 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2450 | else |
| 2451 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2452 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2453 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2454 | return count; |
| 2455 | } |
| 2456 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2457 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2458 | |
| 2459 | /** |
| 2460 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2461 | * of whether luns will be enabled or disabled |
| 2462 | * for Optimized Access Storage (OAS) operations. |
| 2463 | * @dev: class device that is converted into a Scsi_host. |
| 2464 | * @attr: device attribute, not used. |
| 2465 | * @buf: buffer for passing information. |
| 2466 | * |
| 2467 | * Returns: |
| 2468 | * size of formatted string. |
| 2469 | **/ |
| 2470 | static ssize_t |
| 2471 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2472 | char *buf) |
| 2473 | { |
| 2474 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2475 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2476 | |
| 2477 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2478 | } |
| 2479 | |
| 2480 | /** |
| 2481 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2482 | * of whether luns will be enabled or disabled |
| 2483 | * for Optimized Access Storage (OAS) operations. |
| 2484 | * @dev: class device that is converted into a Scsi_host. |
| 2485 | * @attr: device attribute, not used. |
| 2486 | * @buf: buffer for passing information. |
| 2487 | * @count: Size of the data buffer. |
| 2488 | * |
| 2489 | * Returns: |
| 2490 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2491 | * -EPERM oas is not supported by hba |
| 2492 | * value of count on success |
| 2493 | **/ |
| 2494 | static ssize_t |
| 2495 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2496 | const char *buf, size_t count) |
| 2497 | { |
| 2498 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2499 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2500 | int val = 0; |
| 2501 | |
| 2502 | if (!phba->cfg_EnableXLane) |
| 2503 | return -EPERM; |
| 2504 | |
| 2505 | if (!isdigit(buf[0])) |
| 2506 | return -EINVAL; |
| 2507 | |
| 2508 | if (sscanf(buf, "%i", &val) != 1) |
| 2509 | return -EINVAL; |
| 2510 | |
| 2511 | if ((val != 0) && (val != 1)) |
| 2512 | return -EINVAL; |
| 2513 | |
| 2514 | phba->cfg_oas_lun_state = val; |
| 2515 | |
| 2516 | return strlen(buf); |
| 2517 | } |
| 2518 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2519 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2520 | |
| 2521 | /** |
| 2522 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2523 | * Storage (OAS) lun returned by the |
| 2524 | * lpfc_oas_lun_show function. |
| 2525 | * @dev: class device that is converted into a Scsi_host. |
| 2526 | * @attr: device attribute, not used. |
| 2527 | * @buf: buffer for passing information. |
| 2528 | * |
| 2529 | * Returns: |
| 2530 | * size of formatted string. |
| 2531 | **/ |
| 2532 | static ssize_t |
| 2533 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2534 | char *buf) |
| 2535 | { |
| 2536 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2537 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2538 | |
| 2539 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2540 | return -EFAULT; |
| 2541 | |
| 2542 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2543 | } |
| 2544 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2545 | lpfc_oas_lun_status_show, NULL); |
| 2546 | |
| 2547 | |
| 2548 | /** |
| 2549 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2550 | * (OAS) operations. |
| 2551 | * @phba: lpfc_hba pointer. |
| 2552 | * @ndlp: pointer to fcp target node. |
| 2553 | * @lun: the fc lun for setting oas state. |
| 2554 | * @oas_state: the oas state to be set to the lun. |
| 2555 | * |
| 2556 | * Returns: |
| 2557 | * SUCCESS : 0 |
| 2558 | * -EPERM OAS is not enabled or not supported by this port. |
| 2559 | * |
| 2560 | */ |
| 2561 | static size_t |
| 2562 | lpfc_oas_lun_state_set(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2563 | uint8_t tgt_wwpn[], uint64_t lun, uint32_t oas_state) |
| 2564 | { |
| 2565 | |
| 2566 | int rc = 0; |
| 2567 | |
| 2568 | if (!phba->cfg_EnableXLane) |
| 2569 | return -EPERM; |
| 2570 | |
| 2571 | if (oas_state) { |
| 2572 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
| 2573 | (struct lpfc_name *)tgt_wwpn, lun)) |
| 2574 | rc = -ENOMEM; |
| 2575 | } else { |
| 2576 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
| 2577 | (struct lpfc_name *)tgt_wwpn, lun); |
| 2578 | } |
| 2579 | return rc; |
| 2580 | |
| 2581 | } |
| 2582 | |
| 2583 | /** |
| 2584 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2585 | * Access Storage (OAS) operations. |
| 2586 | * @phba: lpfc_hba pointer. |
| 2587 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2588 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2589 | * @lun_status: status of the lun returned lun |
| 2590 | * |
| 2591 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2592 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2593 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2594 | * |
| 2595 | * Return: |
| 2596 | * lun that is OAS enabled for the vport/target |
| 2597 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2598 | */ |
| 2599 | static uint64_t |
| 2600 | lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2601 | uint8_t tgt_wwpn[], uint32_t *lun_status) |
| 2602 | { |
| 2603 | uint64_t found_lun; |
| 2604 | |
| 2605 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2606 | return NOT_OAS_ENABLED_LUN; |
| 2607 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2608 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2609 | (struct lpfc_name *) |
| 2610 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2611 | &phba->sli4_hba.oas_next_lun, |
| 2612 | (struct lpfc_name *)vpt_wwpn, |
| 2613 | (struct lpfc_name *)tgt_wwpn, |
| 2614 | &found_lun, lun_status)) |
| 2615 | return found_lun; |
| 2616 | else |
| 2617 | return NOT_OAS_ENABLED_LUN; |
| 2618 | } |
| 2619 | |
| 2620 | /** |
| 2621 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2622 | * @phba: lpfc_hba pointer. |
| 2623 | * @vpt_wwpn: vport wwpn by reference. |
| 2624 | * @tgt_wwpn: target wwpn by reference. |
| 2625 | * @lun: the fc lun for setting oas state. |
| 2626 | * @oas_state: the oas state to be set to the oas_lun. |
| 2627 | * |
| 2628 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2629 | * a lun for OAS operations. |
| 2630 | * |
| 2631 | * Return: |
| 2632 | * SUCCESS: 0 |
| 2633 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2634 | * -EPERM: OAS is not enabled |
| 2635 | */ |
| 2636 | static ssize_t |
| 2637 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2638 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2639 | uint32_t oas_state) |
| 2640 | { |
| 2641 | |
| 2642 | int rc; |
| 2643 | |
| 2644 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
| 2645 | oas_state); |
| 2646 | return rc; |
| 2647 | } |
| 2648 | |
| 2649 | /** |
| 2650 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2651 | * @dev: class device that is converted into a Scsi_host. |
| 2652 | * @attr: device attribute, not used. |
| 2653 | * @buf: buffer for passing information. |
| 2654 | * |
| 2655 | * This routine returns a lun enabled for OAS each time the function |
| 2656 | * is called. |
| 2657 | * |
| 2658 | * Returns: |
| 2659 | * SUCCESS: size of formatted string. |
| 2660 | * -EFAULT: target or vport wwpn was not set properly. |
| 2661 | * -EPERM: oas is not enabled. |
| 2662 | **/ |
| 2663 | static ssize_t |
| 2664 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 2665 | char *buf) |
| 2666 | { |
| 2667 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2668 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2669 | |
| 2670 | uint64_t oas_lun; |
| 2671 | int len = 0; |
| 2672 | |
| 2673 | if (!phba->cfg_EnableXLane) |
| 2674 | return -EPERM; |
| 2675 | |
| 2676 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2677 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 2678 | return -EFAULT; |
| 2679 | |
| 2680 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2681 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 2682 | return -EFAULT; |
| 2683 | |
| 2684 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 2685 | phba->cfg_oas_tgt_wwpn, |
| 2686 | &phba->cfg_oas_lun_status); |
| 2687 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 2688 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 2689 | |
| 2690 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 2691 | |
| 2692 | return len; |
| 2693 | } |
| 2694 | |
| 2695 | /** |
| 2696 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 2697 | * @dev: class device that is converted into a Scsi_host. |
| 2698 | * @attr: device attribute, not used. |
| 2699 | * @buf: buffer for passing information. |
| 2700 | * |
| 2701 | * This function sets the OAS state for lun. Before this function is called, |
| 2702 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 2703 | * |
| 2704 | * Returns: |
| 2705 | * SUCCESS: size of formatted string. |
| 2706 | * -EFAULT: target or vport wwpn was not set properly. |
| 2707 | * -EPERM: oas is not enabled. |
| 2708 | * size of formatted string. |
| 2709 | **/ |
| 2710 | static ssize_t |
| 2711 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 2712 | const char *buf, size_t count) |
| 2713 | { |
| 2714 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2715 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2716 | uint64_t scsi_lun; |
| 2717 | ssize_t rc; |
| 2718 | |
| 2719 | if (!phba->cfg_EnableXLane) |
| 2720 | return -EPERM; |
| 2721 | |
| 2722 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2723 | return -EFAULT; |
| 2724 | |
| 2725 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2726 | return -EFAULT; |
| 2727 | |
| 2728 | if (!isdigit(buf[0])) |
| 2729 | return -EINVAL; |
| 2730 | |
| 2731 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 2732 | return -EINVAL; |
| 2733 | |
| 2734 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 2735 | "3372 Try to set vport 0x%llx target 0x%llx lun:%lld " |
| 2736 | "with oas set to %d\n", |
| 2737 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 2738 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
| 2739 | phba->cfg_oas_lun_state); |
| 2740 | |
| 2741 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
| 2742 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
| 2743 | phba->cfg_oas_lun_state); |
| 2744 | |
| 2745 | if (rc) |
| 2746 | return rc; |
| 2747 | |
| 2748 | return count; |
| 2749 | } |
| 2750 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 2751 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2752 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2753 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2754 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2755 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 2756 | " 0 - none," |
| 2757 | " 1 - poll with interrupts enabled" |
| 2758 | " 3 - poll and disable FCP ring interrupts"); |
| 2759 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2760 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 2761 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2762 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2763 | int lpfc_sli_mode = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2764 | module_param(lpfc_sli_mode, int, S_IRUGO); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2765 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" |
| 2766 | " 0 - auto (SLI-3 if supported)," |
| 2767 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 2768 | " 3 - select SLI-3"); |
| 2769 | |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2770 | int lpfc_enable_npiv = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2771 | module_param(lpfc_enable_npiv, int, S_IRUGO); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 2772 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); |
| 2773 | lpfc_param_show(enable_npiv); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 2774 | lpfc_param_init(enable_npiv, 1, 0, 1); |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2775 | 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] | 2776 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 2777 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 2778 | "FCF Fast failover=1 Priority failover=2"); |
| 2779 | |
James Smart | c14e995 | 2013-03-01 16:38:01 -0500 | [diff] [blame] | 2780 | int lpfc_enable_rrq = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2781 | module_param(lpfc_enable_rrq, int, S_IRUGO); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2782 | MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality"); |
| 2783 | lpfc_param_show(enable_rrq); |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 2784 | /* |
| 2785 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 2786 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 2787 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 2788 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 2789 | */ |
| 2790 | lpfc_param_init(enable_rrq, 2, 0, 2); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2791 | static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL); |
| 2792 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2793 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2794 | # lpfc_suppress_link_up: Bring link up at initialization |
| 2795 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 2796 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 2797 | # 0x2 = never bring up link |
| 2798 | # Default value is 0. |
| 2799 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2800 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 2801 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 2802 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2803 | /* |
| 2804 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 2805 | # 1 - (1024) |
| 2806 | # 2 - (2048) |
| 2807 | # 3 - (3072) |
| 2808 | # 4 - (4096) |
| 2809 | # 5 - (5120) |
| 2810 | */ |
| 2811 | static ssize_t |
| 2812 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2813 | { |
| 2814 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2815 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2816 | |
| 2817 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 2818 | } |
| 2819 | |
| 2820 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 2821 | lpfc_iocb_hw_show, NULL); |
| 2822 | static ssize_t |
| 2823 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2824 | { |
| 2825 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2826 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2827 | |
| 2828 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2829 | phba->sli.ring[LPFC_ELS_RING].txq_max); |
| 2830 | } |
| 2831 | |
| 2832 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 2833 | lpfc_txq_hw_show, NULL); |
| 2834 | static ssize_t |
| 2835 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 2836 | char *buf) |
| 2837 | { |
| 2838 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2839 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2840 | |
| 2841 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2842 | phba->sli.ring[LPFC_ELS_RING].txcmplq_max); |
| 2843 | } |
| 2844 | |
| 2845 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 2846 | lpfc_txcmplq_hw_show, NULL); |
| 2847 | |
| 2848 | int lpfc_iocb_cnt = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2849 | module_param(lpfc_iocb_cnt, int, S_IRUGO); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2850 | MODULE_PARM_DESC(lpfc_iocb_cnt, |
| 2851 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
| 2852 | lpfc_param_show(iocb_cnt); |
| 2853 | lpfc_param_init(iocb_cnt, 2, 1, 5); |
| 2854 | static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO, |
| 2855 | lpfc_iocb_cnt_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2856 | |
| 2857 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2858 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 2859 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 2860 | */ |
| 2861 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2862 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2863 | module_param(lpfc_nodev_tmo, int, 0); |
| 2864 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 2865 | "Seconds driver will hold I/O waiting " |
| 2866 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2867 | |
| 2868 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2869 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2870 | * @dev: class converted to a Scsi_host structure. |
| 2871 | * @attr: device attribute, not used. |
| 2872 | * @buf: on return contains the dev loss timeout in decimal. |
| 2873 | * |
| 2874 | * Returns: size of formatted string. |
| 2875 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2876 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2877 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 2878 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2879 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2880 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2881 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2882 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2883 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2884 | } |
| 2885 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2886 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2887 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2888 | * @vport: lpfc vport structure pointer. |
| 2889 | * @val: contains the nodev timeout value. |
| 2890 | * |
| 2891 | * Description: |
| 2892 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 2893 | * a kernel error message is printed and zero is returned. |
| 2894 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2895 | * Otherwise nodev tmo is set to the default value. |
| 2896 | * |
| 2897 | * Returns: |
| 2898 | * zero if already set or if val is in range |
| 2899 | * -EINVAL val out of range |
| 2900 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2901 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2902 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2903 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2904 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 2905 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 2906 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2907 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2908 | "0407 Ignoring nodev_tmo module " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2909 | "parameter because devloss_tmo is " |
| 2910 | "set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2911 | return 0; |
| 2912 | } |
| 2913 | |
| 2914 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2915 | vport->cfg_nodev_tmo = val; |
| 2916 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2917 | return 0; |
| 2918 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2919 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2920 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 2921 | " %d, allowed range is [%d, %d]\n", |
| 2922 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2923 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2924 | return -EINVAL; |
| 2925 | } |
| 2926 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2927 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2928 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2929 | * @vport: lpfc vport structure pointer. |
| 2930 | * |
| 2931 | * Description: |
| 2932 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 2933 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2934 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2935 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2936 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2937 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2938 | struct lpfc_nodelist *ndlp; |
| 2939 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2940 | shost = lpfc_shost_from_vport(vport); |
| 2941 | spin_lock_irq(shost->host_lock); |
| 2942 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2943 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2944 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 2945 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2946 | } |
| 2947 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2948 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2949 | * 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] | 2950 | * @vport: lpfc vport structure pointer. |
| 2951 | * @val: contains the tmo value. |
| 2952 | * |
| 2953 | * Description: |
| 2954 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 2955 | * then a kernel error message is printed and zero is returned. |
| 2956 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2957 | * Otherwise nodev tmo is set to the default value. |
| 2958 | * |
| 2959 | * Returns: |
| 2960 | * zero if already set or if val is in range |
| 2961 | * -EINVAL val out of range |
| 2962 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2963 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2964 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2965 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2966 | if (vport->dev_loss_tmo_changed || |
| 2967 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2968 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2969 | "0401 Ignoring change to nodev_tmo " |
| 2970 | "because devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2971 | return 0; |
| 2972 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2973 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2974 | vport->cfg_nodev_tmo = val; |
| 2975 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2976 | /* |
| 2977 | * For compat: set the fc_host dev loss so new rports |
| 2978 | * will get the value. |
| 2979 | */ |
| 2980 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2981 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2982 | return 0; |
| 2983 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2984 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2985 | "0403 lpfc_nodev_tmo attribute cannot be set to" |
| 2986 | "%d, allowed range is [%d, %d]\n", |
| 2987 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2988 | return -EINVAL; |
| 2989 | } |
| 2990 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2991 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2992 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2993 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 2994 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2995 | |
| 2996 | /* |
| 2997 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 2998 | # disappear until the timer expires. Value range is [0,255]. Default |
| 2999 | # value is 30. |
| 3000 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3001 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3002 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3003 | "Seconds driver will hold I/O waiting " |
| 3004 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3005 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3006 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3007 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3008 | |
| 3009 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3010 | * 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] | 3011 | * @vport: lpfc vport structure pointer. |
| 3012 | * @val: contains the tmo value. |
| 3013 | * |
| 3014 | * Description: |
| 3015 | * If val is in a valid range then set the vport nodev tmo, |
| 3016 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3017 | * Else a kernel error message is printed. |
| 3018 | * |
| 3019 | * Returns: |
| 3020 | * zero if val is in range |
| 3021 | * -EINVAL val out of range |
| 3022 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3023 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3024 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3025 | { |
| 3026 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3027 | vport->cfg_nodev_tmo = val; |
| 3028 | vport->cfg_devloss_tmo = val; |
| 3029 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3030 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3031 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3032 | return 0; |
| 3033 | } |
| 3034 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3035 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3036 | "0404 lpfc_devloss_tmo attribute cannot be set to" |
| 3037 | " %d, allowed range is [%d, %d]\n", |
| 3038 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3039 | return -EINVAL; |
| 3040 | } |
| 3041 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3042 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3043 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 3044 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3045 | |
| 3046 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3047 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3048 | # deluged with LOTS of information. |
| 3049 | # 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] | 3050 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3051 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3052 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3053 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3054 | |
| 3055 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3056 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3057 | # objects that have been registered with the nameserver after login. |
| 3058 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3059 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3060 | "Deregister nameserver objects before LOGO"); |
| 3061 | |
| 3062 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3063 | # lun_queue_depth: This parameter is used to limit the number of outstanding |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3064 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3065 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3066 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3067 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3068 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3069 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3070 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3071 | |
| 3072 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3073 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3074 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3075 | */ |
| 3076 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3077 | "Max number of FCP commands we can queue to a specific target port"); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3078 | |
| 3079 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3080 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3081 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3082 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3083 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3084 | # the hba_queue_depth. |
| 3085 | */ |
| 3086 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3087 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3088 | |
| 3089 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3090 | # peer_port_login: This parameter allows/prevents logins |
| 3091 | # between peer ports hosted on the same physical port. |
| 3092 | # When this parameter is set 0 peer ports of same physical port |
| 3093 | # are not allowed to login to each other. |
| 3094 | # When this parameter is set 1 peer ports of same physical port |
| 3095 | # are allowed to login to each other. |
| 3096 | # Default value of this parameter is 0. |
| 3097 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3098 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3099 | "Allow peer ports on the same physical port to login to each " |
| 3100 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3101 | |
| 3102 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3103 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3104 | # between Virtual Ports and remote initiators. |
| 3105 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3106 | # other initiators and will attempt to PLOGI all remote ports. |
| 3107 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3108 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3109 | # This parameter does not restrict to the physical port. |
| 3110 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3111 | # Default value of this parameter is 1. |
| 3112 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3113 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3114 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3115 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3116 | "Restrict virtual ports login to remote initiators."); |
| 3117 | lpfc_vport_param_show(restrict_login); |
| 3118 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3119 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3120 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3121 | * @vport: lpfc vport structure pointer. |
| 3122 | * @val: contains the restrict login value. |
| 3123 | * |
| 3124 | * Description: |
| 3125 | * If val is not in a valid range then log a kernel error message and set |
| 3126 | * the vport restrict login to one. |
| 3127 | * If the port type is physical clear the restrict login flag and return. |
| 3128 | * Else set the restrict login flag to val. |
| 3129 | * |
| 3130 | * Returns: |
| 3131 | * zero if val is in range |
| 3132 | * -EINVAL val out of range |
| 3133 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3134 | static int |
| 3135 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3136 | { |
| 3137 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3138 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3139 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3140 | "be set to %d, allowed range is [0, 1]\n", |
| 3141 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3142 | vport->cfg_restrict_login = 1; |
| 3143 | return -EINVAL; |
| 3144 | } |
| 3145 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3146 | vport->cfg_restrict_login = 0; |
| 3147 | return 0; |
| 3148 | } |
| 3149 | vport->cfg_restrict_login = val; |
| 3150 | return 0; |
| 3151 | } |
| 3152 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3153 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3154 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3155 | * @vport: lpfc vport structure pointer. |
| 3156 | * @val: contains the restrict login value. |
| 3157 | * |
| 3158 | * Description: |
| 3159 | * If val is not in a valid range then log a kernel error message and set |
| 3160 | * the vport restrict login to one. |
| 3161 | * If the port type is physical and the val is not zero log a kernel |
| 3162 | * error message, clear the restrict login flag and return zero. |
| 3163 | * Else set the restrict login flag to val. |
| 3164 | * |
| 3165 | * Returns: |
| 3166 | * zero if val is in range |
| 3167 | * -EINVAL val out of range |
| 3168 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3169 | static int |
| 3170 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3171 | { |
| 3172 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3173 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3174 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3175 | "be set to %d, allowed range is [0, 1]\n", |
| 3176 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3177 | vport->cfg_restrict_login = 1; |
| 3178 | return -EINVAL; |
| 3179 | } |
| 3180 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3181 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3182 | "0468 lpfc_restrict_login must be 0 for " |
| 3183 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3184 | vport->cfg_restrict_login = 0; |
| 3185 | return 0; |
| 3186 | } |
| 3187 | vport->cfg_restrict_login = val; |
| 3188 | return 0; |
| 3189 | } |
| 3190 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3191 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 3192 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3193 | |
| 3194 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3195 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3196 | # From a protocol standpoint "select ID" usually means select the |
| 3197 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3198 | # annex" which contains a table that maps a "select ID" (a number |
| 3199 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3200 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3201 | # ALPA. |
| 3202 | # |
| 3203 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3204 | # cause the lpfc driver to use an inverted table, effectively |
| 3205 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3206 | # |
| 3207 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3208 | # and will not work across a fabric. Also this parameter will take |
| 3209 | # effect only in the case when ALPA map is not available.) |
| 3210 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3211 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3212 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3213 | |
| 3214 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3215 | # lpfc_topology: link topology for init link |
| 3216 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3217 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3218 | # 0x02 = attempt point-to-point mode only |
| 3219 | # 0x04 = attempt loop mode only |
| 3220 | # 0x06 = attempt point-to-point mode then loop |
| 3221 | # Set point-to-point mode if you want to run as an N_Port. |
| 3222 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3223 | # Default value is 0. |
| 3224 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3225 | |
| 3226 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3227 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3228 | * @phba: lpfc_hba pointer. |
| 3229 | * @val: topology value. |
| 3230 | * |
| 3231 | * Description: |
| 3232 | * If val is in a valid range then set the adapter's topology field and |
| 3233 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3234 | * |
| 3235 | * If the value is not in range log a kernel error message and return an error. |
| 3236 | * |
| 3237 | * Returns: |
| 3238 | * zero if val is in range and lip okay |
| 3239 | * non-zero return value from lpfc_issue_lip() |
| 3240 | * -EINVAL val out of range |
| 3241 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3242 | static ssize_t |
| 3243 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3244 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3245 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3246 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3247 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3248 | struct lpfc_hba *phba = vport->phba; |
| 3249 | int val = 0; |
| 3250 | int nolip = 0; |
| 3251 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3252 | int err; |
| 3253 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3254 | |
| 3255 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3256 | nolip = 1; |
| 3257 | val_buf = &buf[strlen("nolip ")]; |
| 3258 | } |
| 3259 | |
| 3260 | if (!isdigit(val_buf[0])) |
| 3261 | return -EINVAL; |
| 3262 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3263 | return -EINVAL; |
| 3264 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3265 | if (val >= 0 && val <= 6) { |
| 3266 | prev_val = phba->cfg_topology; |
| 3267 | phba->cfg_topology = val; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3268 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3269 | val == 4) { |
| 3270 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3271 | "3113 Loop mode not supported at speed %d\n", |
| 3272 | phba->cfg_link_speed); |
| 3273 | phba->cfg_topology = prev_val; |
| 3274 | return -EINVAL; |
| 3275 | } |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3276 | if (nolip) |
| 3277 | return strlen(buf); |
| 3278 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3279 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3280 | "3054 lpfc_topology changed from %d to %d\n", |
| 3281 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3282 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3283 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3284 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3285 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3286 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3287 | return -EINVAL; |
| 3288 | } else |
| 3289 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3290 | } |
| 3291 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3292 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3293 | "allowed range is [0, 6]\n", |
| 3294 | phba->brd_no, val); |
| 3295 | return -EINVAL; |
| 3296 | } |
| 3297 | static int lpfc_topology = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3298 | module_param(lpfc_topology, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3299 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
| 3300 | lpfc_param_show(topology) |
| 3301 | lpfc_param_init(topology, 0, 0, 6) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3302 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3303 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3304 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3305 | /** |
| 3306 | * lpfc_static_vport_show: Read callback function for |
| 3307 | * lpfc_static_vport sysfs file. |
| 3308 | * @dev: Pointer to class device object. |
| 3309 | * @attr: device attribute structure. |
| 3310 | * @buf: Data buffer. |
| 3311 | * |
| 3312 | * This function is the read call back function for |
| 3313 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3314 | * sysfs file report the mageability of the vport. |
| 3315 | **/ |
| 3316 | static ssize_t |
| 3317 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3318 | char *buf) |
| 3319 | { |
| 3320 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3321 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3322 | if (vport->vport_flag & STATIC_VPORT) |
| 3323 | sprintf(buf, "1\n"); |
| 3324 | else |
| 3325 | sprintf(buf, "0\n"); |
| 3326 | |
| 3327 | return strlen(buf); |
| 3328 | } |
| 3329 | |
| 3330 | /* |
| 3331 | * Sysfs attribute to control the statistical data collection. |
| 3332 | */ |
| 3333 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 3334 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3335 | |
| 3336 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3337 | * 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] | 3338 | * @dev: Pointer to class device. |
| 3339 | * @buf: Data buffer. |
| 3340 | * @count: Size of the data buffer. |
| 3341 | * |
| 3342 | * This function get called when an user write to the lpfc_stat_data_ctrl |
| 3343 | * sysfs file. This function parse the command written to the sysfs file |
| 3344 | * and take appropriate action. These commands are used for controlling |
| 3345 | * driver statistical data collection. |
| 3346 | * Following are the command this function handles. |
| 3347 | * |
| 3348 | * setbucket <bucket_type> <base> <step> |
| 3349 | * = Set the latency buckets. |
| 3350 | * destroybucket = destroy all the buckets. |
| 3351 | * start = start data collection |
| 3352 | * stop = stop data collection |
| 3353 | * reset = reset the collected data |
| 3354 | **/ |
| 3355 | static ssize_t |
| 3356 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3357 | const char *buf, size_t count) |
| 3358 | { |
| 3359 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3360 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3361 | struct lpfc_hba *phba = vport->phba; |
| 3362 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3363 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3364 | unsigned long i; |
| 3365 | char *str_ptr, *token; |
| 3366 | struct lpfc_vport **vports; |
| 3367 | struct Scsi_Host *v_shost; |
| 3368 | char *bucket_type_str, *base_str, *step_str; |
| 3369 | unsigned long base, step, bucket_type; |
| 3370 | |
| 3371 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3372 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3373 | return -EINVAL; |
| 3374 | |
| 3375 | strcpy(bucket_data, buf); |
| 3376 | str_ptr = &bucket_data[0]; |
| 3377 | /* Ignore this token - this is command token */ |
| 3378 | token = strsep(&str_ptr, "\t "); |
| 3379 | if (!token) |
| 3380 | return -EINVAL; |
| 3381 | |
| 3382 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3383 | if (!bucket_type_str) |
| 3384 | return -EINVAL; |
| 3385 | |
| 3386 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3387 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3388 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3389 | bucket_type = LPFC_POWER2_BUCKET; |
| 3390 | else |
| 3391 | return -EINVAL; |
| 3392 | |
| 3393 | base_str = strsep(&str_ptr, "\t "); |
| 3394 | if (!base_str) |
| 3395 | return -EINVAL; |
| 3396 | base = simple_strtoul(base_str, NULL, 0); |
| 3397 | |
| 3398 | step_str = strsep(&str_ptr, "\t "); |
| 3399 | if (!step_str) |
| 3400 | return -EINVAL; |
| 3401 | step = simple_strtoul(step_str, NULL, 0); |
| 3402 | if (!step) |
| 3403 | return -EINVAL; |
| 3404 | |
| 3405 | /* Block the data collection for every vport */ |
| 3406 | vports = lpfc_create_vport_work_array(phba); |
| 3407 | if (vports == NULL) |
| 3408 | return -ENOMEM; |
| 3409 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3410 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3411 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3412 | spin_lock_irq(v_shost->host_lock); |
| 3413 | /* Block and reset data collection */ |
| 3414 | vports[i]->stat_data_blocked = 1; |
| 3415 | if (vports[i]->stat_data_enabled) |
| 3416 | lpfc_vport_reset_stat_data(vports[i]); |
| 3417 | spin_unlock_irq(v_shost->host_lock); |
| 3418 | } |
| 3419 | |
| 3420 | /* Set the bucket attributes */ |
| 3421 | phba->bucket_type = bucket_type; |
| 3422 | phba->bucket_base = base; |
| 3423 | phba->bucket_step = step; |
| 3424 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3425 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3426 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3427 | |
| 3428 | /* Unblock data collection */ |
| 3429 | spin_lock_irq(v_shost->host_lock); |
| 3430 | vports[i]->stat_data_blocked = 0; |
| 3431 | spin_unlock_irq(v_shost->host_lock); |
| 3432 | } |
| 3433 | lpfc_destroy_vport_work_array(phba, vports); |
| 3434 | return strlen(buf); |
| 3435 | } |
| 3436 | |
| 3437 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3438 | vports = lpfc_create_vport_work_array(phba); |
| 3439 | if (vports == NULL) |
| 3440 | return -ENOMEM; |
| 3441 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3442 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3443 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3444 | spin_lock_irq(shost->host_lock); |
| 3445 | vports[i]->stat_data_blocked = 1; |
| 3446 | lpfc_free_bucket(vport); |
| 3447 | vport->stat_data_enabled = 0; |
| 3448 | vports[i]->stat_data_blocked = 0; |
| 3449 | spin_unlock_irq(shost->host_lock); |
| 3450 | } |
| 3451 | lpfc_destroy_vport_work_array(phba, vports); |
| 3452 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3453 | phba->bucket_base = 0; |
| 3454 | phba->bucket_step = 0; |
| 3455 | return strlen(buf); |
| 3456 | } |
| 3457 | |
| 3458 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3459 | /* If no buckets configured return error */ |
| 3460 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3461 | return -EINVAL; |
| 3462 | spin_lock_irq(shost->host_lock); |
| 3463 | if (vport->stat_data_enabled) { |
| 3464 | spin_unlock_irq(shost->host_lock); |
| 3465 | return strlen(buf); |
| 3466 | } |
| 3467 | lpfc_alloc_bucket(vport); |
| 3468 | vport->stat_data_enabled = 1; |
| 3469 | spin_unlock_irq(shost->host_lock); |
| 3470 | return strlen(buf); |
| 3471 | } |
| 3472 | |
| 3473 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3474 | spin_lock_irq(shost->host_lock); |
| 3475 | if (vport->stat_data_enabled == 0) { |
| 3476 | spin_unlock_irq(shost->host_lock); |
| 3477 | return strlen(buf); |
| 3478 | } |
| 3479 | lpfc_free_bucket(vport); |
| 3480 | vport->stat_data_enabled = 0; |
| 3481 | spin_unlock_irq(shost->host_lock); |
| 3482 | return strlen(buf); |
| 3483 | } |
| 3484 | |
| 3485 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3486 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3487 | || !vport->stat_data_enabled) |
| 3488 | return strlen(buf); |
| 3489 | spin_lock_irq(shost->host_lock); |
| 3490 | vport->stat_data_blocked = 1; |
| 3491 | lpfc_vport_reset_stat_data(vport); |
| 3492 | vport->stat_data_blocked = 0; |
| 3493 | spin_unlock_irq(shost->host_lock); |
| 3494 | return strlen(buf); |
| 3495 | } |
| 3496 | return -EINVAL; |
| 3497 | } |
| 3498 | |
| 3499 | |
| 3500 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3501 | * 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] | 3502 | * @dev: Pointer to class device object. |
| 3503 | * @buf: Data buffer. |
| 3504 | * |
| 3505 | * This function is the read call back function for |
| 3506 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3507 | * current statistical data collection state. |
| 3508 | **/ |
| 3509 | static ssize_t |
| 3510 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3511 | char *buf) |
| 3512 | { |
| 3513 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3514 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3515 | struct lpfc_hba *phba = vport->phba; |
| 3516 | int index = 0; |
| 3517 | int i; |
| 3518 | char *bucket_type; |
| 3519 | unsigned long bucket_value; |
| 3520 | |
| 3521 | switch (phba->bucket_type) { |
| 3522 | case LPFC_LINEAR_BUCKET: |
| 3523 | bucket_type = "linear"; |
| 3524 | break; |
| 3525 | case LPFC_POWER2_BUCKET: |
| 3526 | bucket_type = "power2"; |
| 3527 | break; |
| 3528 | default: |
| 3529 | bucket_type = "No Bucket"; |
| 3530 | break; |
| 3531 | } |
| 3532 | |
| 3533 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3534 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3535 | " Bucket step :%d\nLatency Ranges :", |
| 3536 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3537 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3538 | index = strlen(buf); |
| 3539 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3540 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3541 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3542 | bucket_value = phba->bucket_base + |
| 3543 | phba->bucket_step * i; |
| 3544 | else |
| 3545 | bucket_value = phba->bucket_base + |
| 3546 | (1 << i) * phba->bucket_step; |
| 3547 | |
| 3548 | if (index + 10 > PAGE_SIZE) |
| 3549 | break; |
| 3550 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3551 | index = strlen(buf); |
| 3552 | } |
| 3553 | } |
| 3554 | sprintf(&buf[index], "\n"); |
| 3555 | return strlen(buf); |
| 3556 | } |
| 3557 | |
| 3558 | /* |
| 3559 | * Sysfs attribute to control the statistical data collection. |
| 3560 | */ |
| 3561 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 3562 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 3563 | |
| 3564 | /* |
| 3565 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3566 | */ |
| 3567 | |
| 3568 | /* |
| 3569 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3570 | * for each target. |
| 3571 | */ |
| 3572 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3573 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3574 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3575 | |
| 3576 | |
| 3577 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3578 | * 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] | 3579 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3580 | * @kobj: Pointer to the kernel object |
| 3581 | * @bin_attr: Attribute object |
| 3582 | * @buff: Buffer pointer |
| 3583 | * @off: File offset |
| 3584 | * @count: Buffer size |
| 3585 | * |
| 3586 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3587 | * sysfs file. This function export the statistical data to user |
| 3588 | * applications. |
| 3589 | **/ |
| 3590 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3591 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3592 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3593 | char *buf, loff_t off, size_t count) |
| 3594 | { |
| 3595 | struct device *dev = container_of(kobj, struct device, |
| 3596 | kobj); |
| 3597 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3598 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3599 | struct lpfc_hba *phba = vport->phba; |
| 3600 | int i = 0, index = 0; |
| 3601 | unsigned long nport_index; |
| 3602 | struct lpfc_nodelist *ndlp = NULL; |
| 3603 | nport_index = (unsigned long)off / |
| 3604 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3605 | |
| 3606 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3607 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3608 | return 0; |
| 3609 | |
| 3610 | spin_lock_irq(shost->host_lock); |
| 3611 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3612 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 3613 | continue; |
| 3614 | |
| 3615 | if (nport_index > 0) { |
| 3616 | nport_index--; |
| 3617 | continue; |
| 3618 | } |
| 3619 | |
| 3620 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 3621 | > count) |
| 3622 | break; |
| 3623 | |
| 3624 | if (!ndlp->lat_data) |
| 3625 | continue; |
| 3626 | |
| 3627 | /* Print the WWN */ |
| 3628 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 3629 | ndlp->nlp_portname.u.wwn[0], |
| 3630 | ndlp->nlp_portname.u.wwn[1], |
| 3631 | ndlp->nlp_portname.u.wwn[2], |
| 3632 | ndlp->nlp_portname.u.wwn[3], |
| 3633 | ndlp->nlp_portname.u.wwn[4], |
| 3634 | ndlp->nlp_portname.u.wwn[5], |
| 3635 | ndlp->nlp_portname.u.wwn[6], |
| 3636 | ndlp->nlp_portname.u.wwn[7]); |
| 3637 | |
| 3638 | index = strlen(buf); |
| 3639 | |
| 3640 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3641 | sprintf(&buf[index], "%010u,", |
| 3642 | ndlp->lat_data[i].cmd_count); |
| 3643 | index = strlen(buf); |
| 3644 | } |
| 3645 | sprintf(&buf[index], "\n"); |
| 3646 | index = strlen(buf); |
| 3647 | } |
| 3648 | spin_unlock_irq(shost->host_lock); |
| 3649 | return index; |
| 3650 | } |
| 3651 | |
| 3652 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 3653 | .attr = { |
| 3654 | .name = "lpfc_drvr_stat_data", |
| 3655 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3656 | }, |
| 3657 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 3658 | .read = sysfs_drvr_stat_data_read, |
| 3659 | .write = NULL, |
| 3660 | }; |
| 3661 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3662 | /* |
| 3663 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 3664 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3665 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3666 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3667 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3668 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3669 | * @phba: lpfc_hba pointer. |
| 3670 | * @val: link speed value. |
| 3671 | * |
| 3672 | * Description: |
| 3673 | * If val is in a valid range then set the adapter's link speed field and |
| 3674 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 3675 | * |
| 3676 | * Notes: |
| 3677 | * If the value is not in range log a kernel error message and return an error. |
| 3678 | * |
| 3679 | * Returns: |
| 3680 | * zero if val is in range and lip okay. |
| 3681 | * non-zero return value from lpfc_issue_lip() |
| 3682 | * -EINVAL val out of range |
| 3683 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3684 | static ssize_t |
| 3685 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 3686 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3687 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3688 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3689 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3690 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3691 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3692 | int nolip = 0; |
| 3693 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3694 | int err; |
| 3695 | uint32_t prev_val; |
| 3696 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3697 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3698 | nolip = 1; |
| 3699 | val_buf = &buf[strlen("nolip ")]; |
| 3700 | } |
| 3701 | |
| 3702 | if (!isdigit(val_buf[0])) |
| 3703 | return -EINVAL; |
| 3704 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3705 | return -EINVAL; |
| 3706 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3707 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3708 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 3709 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 3710 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3711 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 3712 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 3713 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 3714 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 3715 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
| 3716 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb))) { |
| 3717 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3718 | "2879 lpfc_link_speed attribute cannot be set " |
| 3719 | "to %d. Speed is not supported by this port.\n", |
| 3720 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3721 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3722 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3723 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 3724 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 3725 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3726 | "3112 lpfc_link_speed attribute cannot be set " |
| 3727 | "to %d. Speed is not supported in loop mode.\n", |
| 3728 | val); |
| 3729 | return -EINVAL; |
| 3730 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3731 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3732 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3733 | prev_val = phba->cfg_link_speed; |
| 3734 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3735 | if (nolip) |
| 3736 | return strlen(buf); |
| 3737 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3738 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3739 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3740 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3741 | return -EINVAL; |
| 3742 | } else |
| 3743 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3744 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3745 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3746 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 3747 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3748 | return -EINVAL; |
| 3749 | } |
| 3750 | |
| 3751 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3752 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3753 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 3754 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3755 | |
| 3756 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3757 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3758 | * @phba: lpfc_hba pointer. |
| 3759 | * @val: link speed value. |
| 3760 | * |
| 3761 | * Description: |
| 3762 | * If val is in a valid range then set the adapter's link speed field. |
| 3763 | * |
| 3764 | * Notes: |
| 3765 | * If the value is not in range log a kernel error message, clear the link |
| 3766 | * speed and return an error. |
| 3767 | * |
| 3768 | * Returns: |
| 3769 | * zero if val saved. |
| 3770 | * -EINVAL val out of range |
| 3771 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3772 | static int |
| 3773 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 3774 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3775 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 3776 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3777 | "3111 lpfc_link_speed of %d cannot " |
| 3778 | "support loop mode, setting topology to default.\n", |
| 3779 | val); |
| 3780 | phba->cfg_topology = 0; |
| 3781 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3782 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3783 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3784 | phba->cfg_link_speed = val; |
| 3785 | return 0; |
| 3786 | } |
| 3787 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3788 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3789 | "be set to %d, allowed values are " |
| 3790 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3791 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3792 | return -EINVAL; |
| 3793 | } |
| 3794 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3795 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3796 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3797 | |
| 3798 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3799 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 3800 | # 0 = aer disabled or not supported |
| 3801 | # 1 = aer supported and enabled (default) |
| 3802 | # Value range is [0,1]. Default value is 1. |
| 3803 | */ |
| 3804 | |
| 3805 | /** |
| 3806 | * lpfc_aer_support_store - Set the adapter for aer support |
| 3807 | * |
| 3808 | * @dev: class device that is converted into a Scsi_host. |
| 3809 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3810 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3811 | * @count: unused variable. |
| 3812 | * |
| 3813 | * Description: |
| 3814 | * If the val is 1 and currently the device's AER capability was not |
| 3815 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 3816 | * enable the device's AER capability. If the helper routine enabling |
| 3817 | * AER returns success, update the device's cfg_aer_support flag to |
| 3818 | * indicate AER is supported by the device; otherwise, if the device |
| 3819 | * AER capability is already enabled to support AER, then do nothing. |
| 3820 | * |
| 3821 | * If the val is 0 and currently the device's AER support was enabled, |
| 3822 | * invoke the kernel's disable AER helper routine. After that, update |
| 3823 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 3824 | * by the device; otherwise, if the device AER capability is already |
| 3825 | * disabled from supporting AER, then do nothing. |
| 3826 | * |
| 3827 | * Returns: |
| 3828 | * length of the buf on success if val is in range the intended mode |
| 3829 | * is supported. |
| 3830 | * -EINVAL if val out of range or intended mode is not supported. |
| 3831 | **/ |
| 3832 | static ssize_t |
| 3833 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 3834 | const char *buf, size_t count) |
| 3835 | { |
| 3836 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3837 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 3838 | struct lpfc_hba *phba = vport->phba; |
| 3839 | int val = 0, rc = -EINVAL; |
| 3840 | |
| 3841 | if (!isdigit(buf[0])) |
| 3842 | return -EINVAL; |
| 3843 | if (sscanf(buf, "%i", &val) != 1) |
| 3844 | return -EINVAL; |
| 3845 | |
| 3846 | switch (val) { |
| 3847 | case 0: |
| 3848 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 3849 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 3850 | if (!rc) { |
| 3851 | spin_lock_irq(&phba->hbalock); |
| 3852 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 3853 | spin_unlock_irq(&phba->hbalock); |
| 3854 | phba->cfg_aer_support = 0; |
| 3855 | rc = strlen(buf); |
| 3856 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3857 | rc = -EPERM; |
| 3858 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3859 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3860 | rc = strlen(buf); |
| 3861 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3862 | break; |
| 3863 | case 1: |
| 3864 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 3865 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 3866 | if (!rc) { |
| 3867 | spin_lock_irq(&phba->hbalock); |
| 3868 | phba->hba_flag |= HBA_AER_ENABLED; |
| 3869 | spin_unlock_irq(&phba->hbalock); |
| 3870 | phba->cfg_aer_support = 1; |
| 3871 | rc = strlen(buf); |
| 3872 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3873 | rc = -EPERM; |
| 3874 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3875 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3876 | rc = strlen(buf); |
| 3877 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3878 | break; |
| 3879 | default: |
| 3880 | rc = -EINVAL; |
| 3881 | break; |
| 3882 | } |
| 3883 | return rc; |
| 3884 | } |
| 3885 | |
| 3886 | static int lpfc_aer_support = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3887 | module_param(lpfc_aer_support, int, S_IRUGO); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3888 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); |
| 3889 | lpfc_param_show(aer_support) |
| 3890 | |
| 3891 | /** |
| 3892 | * lpfc_aer_support_init - Set the initial adapters aer support flag |
| 3893 | * @phba: lpfc_hba pointer. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3894 | * @val: enable aer or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3895 | * |
| 3896 | * Description: |
| 3897 | * If val is in a valid range [0,1], then set the adapter's initial |
| 3898 | * cfg_aer_support field. It will be up to the driver's probe_one |
| 3899 | * routine to determine whether the device's AER support can be set |
| 3900 | * or not. |
| 3901 | * |
| 3902 | * Notes: |
| 3903 | * If the value is not in range log a kernel error message, and |
| 3904 | * choose the default value of setting AER support and return. |
| 3905 | * |
| 3906 | * Returns: |
| 3907 | * zero if val saved. |
| 3908 | * -EINVAL val out of range |
| 3909 | **/ |
| 3910 | static int |
| 3911 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) |
| 3912 | { |
| 3913 | if (val == 0 || val == 1) { |
| 3914 | phba->cfg_aer_support = val; |
| 3915 | return 0; |
| 3916 | } |
| 3917 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3918 | "2712 lpfc_aer_support attribute value %d out " |
| 3919 | "of range, allowed values are 0|1, setting it " |
| 3920 | "to default value of 1\n", val); |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3921 | /* By default, try to enable AER on a device */ |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3922 | phba->cfg_aer_support = 1; |
| 3923 | return -EINVAL; |
| 3924 | } |
| 3925 | |
| 3926 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 3927 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 3928 | |
| 3929 | /** |
| 3930 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 3931 | * @dev: class device that is converted into a Scsi_host. |
| 3932 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3933 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3934 | * @count: unused variable. |
| 3935 | * |
| 3936 | * Description: |
| 3937 | * If the @buf contains 1 and the device currently has the AER support |
| 3938 | * enabled, then invokes the kernel AER helper routine |
| 3939 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 3940 | * error status register. |
| 3941 | * |
| 3942 | * Notes: |
| 3943 | * |
| 3944 | * Returns: |
| 3945 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 3946 | * enabled with the AER support. |
| 3947 | **/ |
| 3948 | static ssize_t |
| 3949 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 3950 | const char *buf, size_t count) |
| 3951 | { |
| 3952 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3953 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3954 | struct lpfc_hba *phba = vport->phba; |
| 3955 | int val, rc = -1; |
| 3956 | |
| 3957 | if (!isdigit(buf[0])) |
| 3958 | return -EINVAL; |
| 3959 | if (sscanf(buf, "%i", &val) != 1) |
| 3960 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3961 | if (val != 1) |
| 3962 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3963 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3964 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3965 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 3966 | |
| 3967 | if (rc == 0) |
| 3968 | return strlen(buf); |
| 3969 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3970 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3971 | } |
| 3972 | |
| 3973 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 3974 | lpfc_aer_cleanup_state); |
| 3975 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3976 | /** |
| 3977 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 3978 | * |
| 3979 | * @dev: class device that is converted into a Scsi_host. |
| 3980 | * @attr: device attribute, not used. |
| 3981 | * @buf: containing the string the number of vfs to be enabled. |
| 3982 | * @count: unused variable. |
| 3983 | * |
| 3984 | * Description: |
| 3985 | * When this api is called either through user sysfs, the driver shall |
| 3986 | * try to enable or disable SR-IOV virtual functions according to the |
| 3987 | * following: |
| 3988 | * |
| 3989 | * If zero virtual function has been enabled to the physical function, |
| 3990 | * the driver shall invoke the pci enable virtual function api trying |
| 3991 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 3992 | * than the maximum supported, the maximum virtual function number will |
| 3993 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 3994 | * be used for invoking the api. If the api call returned success, the |
| 3995 | * actual number of virtual functions enabled will be set to the driver |
| 3996 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 3997 | * cfg_sriov_nr_virtfn remains zero. |
| 3998 | * |
| 3999 | * If none-zero virtual functions have already been enabled to the |
| 4000 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4001 | * -EINVAL will be returned and the driver does nothing; |
| 4002 | * |
| 4003 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4004 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4005 | * disabling virtual function api shall be invoded to disable all the |
| 4006 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4007 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4008 | * nothing. |
| 4009 | * |
| 4010 | * Returns: |
| 4011 | * length of the buf on success if val is in range the intended mode |
| 4012 | * is supported. |
| 4013 | * -EINVAL if val out of range or intended mode is not supported. |
| 4014 | **/ |
| 4015 | static ssize_t |
| 4016 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4017 | const char *buf, size_t count) |
| 4018 | { |
| 4019 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4020 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4021 | struct lpfc_hba *phba = vport->phba; |
| 4022 | struct pci_dev *pdev = phba->pcidev; |
| 4023 | int val = 0, rc = -EINVAL; |
| 4024 | |
| 4025 | /* Sanity check on user data */ |
| 4026 | if (!isdigit(buf[0])) |
| 4027 | return -EINVAL; |
| 4028 | if (sscanf(buf, "%i", &val) != 1) |
| 4029 | return -EINVAL; |
| 4030 | if (val < 0) |
| 4031 | return -EINVAL; |
| 4032 | |
| 4033 | /* Request disabling virtual functions */ |
| 4034 | if (val == 0) { |
| 4035 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4036 | pci_disable_sriov(pdev); |
| 4037 | phba->cfg_sriov_nr_virtfn = 0; |
| 4038 | } |
| 4039 | return strlen(buf); |
| 4040 | } |
| 4041 | |
| 4042 | /* Request enabling virtual functions */ |
| 4043 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4044 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4045 | "3018 There are %d virtual functions " |
| 4046 | "enabled on physical function.\n", |
| 4047 | phba->cfg_sriov_nr_virtfn); |
| 4048 | return -EEXIST; |
| 4049 | } |
| 4050 | |
| 4051 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4052 | phba->cfg_sriov_nr_virtfn = val; |
| 4053 | else { |
| 4054 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4055 | "3019 Enabling %d virtual functions is not " |
| 4056 | "allowed.\n", val); |
| 4057 | return -EINVAL; |
| 4058 | } |
| 4059 | |
| 4060 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4061 | if (rc) { |
| 4062 | phba->cfg_sriov_nr_virtfn = 0; |
| 4063 | rc = -EPERM; |
| 4064 | } else |
| 4065 | rc = strlen(buf); |
| 4066 | |
| 4067 | return rc; |
| 4068 | } |
| 4069 | |
| 4070 | static int lpfc_sriov_nr_virtfn = LPFC_DEF_VFN_PER_PFN; |
| 4071 | module_param(lpfc_sriov_nr_virtfn, int, S_IRUGO|S_IWUSR); |
| 4072 | MODULE_PARM_DESC(lpfc_sriov_nr_virtfn, "Enable PCIe device SR-IOV virtual fn"); |
| 4073 | lpfc_param_show(sriov_nr_virtfn) |
| 4074 | |
| 4075 | /** |
| 4076 | * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable |
| 4077 | * @phba: lpfc_hba pointer. |
| 4078 | * @val: link speed value. |
| 4079 | * |
| 4080 | * Description: |
| 4081 | * If val is in a valid range [0,255], then set the adapter's initial |
| 4082 | * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum |
| 4083 | * number shall be used instead. It will be up to the driver's probe_one |
| 4084 | * routine to determine whether the device's SR-IOV is supported or not. |
| 4085 | * |
| 4086 | * Returns: |
| 4087 | * zero if val saved. |
| 4088 | * -EINVAL val out of range |
| 4089 | **/ |
| 4090 | static int |
| 4091 | lpfc_sriov_nr_virtfn_init(struct lpfc_hba *phba, int val) |
| 4092 | { |
| 4093 | if (val >= 0 && val <= LPFC_MAX_VFN_PER_PFN) { |
| 4094 | phba->cfg_sriov_nr_virtfn = val; |
| 4095 | return 0; |
| 4096 | } |
| 4097 | |
| 4098 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4099 | "3017 Enabling %d virtual functions is not " |
| 4100 | "allowed.\n", val); |
| 4101 | return -EINVAL; |
| 4102 | } |
| 4103 | static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, |
| 4104 | lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); |
| 4105 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4106 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4107 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4108 | * |
| 4109 | * @dev: class device that is converted into a Scsi_host. |
| 4110 | * @attr: device attribute, not used. |
| 4111 | * @buf: containing the string the number of vfs to be enabled. |
| 4112 | * @count: unused variable. |
| 4113 | * |
| 4114 | * Description: |
| 4115 | * |
| 4116 | * Returns: |
| 4117 | * length of the buf on success if val is in range the intended mode |
| 4118 | * is supported. |
| 4119 | * -EINVAL if val out of range or intended mode is not supported. |
| 4120 | **/ |
| 4121 | static ssize_t |
| 4122 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4123 | struct device_attribute *attr, |
| 4124 | const char *buf, size_t count) |
| 4125 | { |
| 4126 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4127 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4128 | struct lpfc_hba *phba = vport->phba; |
| 4129 | int val = 0, rc = -EINVAL; |
| 4130 | |
| 4131 | /* Sanity check on user data */ |
| 4132 | if (!isdigit(buf[0])) |
| 4133 | return -EINVAL; |
| 4134 | if (sscanf(buf, "%i", &val) != 1) |
| 4135 | return -EINVAL; |
| 4136 | if (val != 1) |
| 4137 | return -EINVAL; |
| 4138 | |
| 4139 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4140 | if (rc) |
| 4141 | rc = -EPERM; |
| 4142 | else |
| 4143 | rc = strlen(buf); |
| 4144 | return rc; |
| 4145 | } |
| 4146 | |
| 4147 | static int lpfc_req_fw_upgrade; |
| 4148 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4149 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4150 | lpfc_param_show(request_firmware_upgrade) |
| 4151 | |
| 4152 | /** |
| 4153 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4154 | * @phba: lpfc_hba pointer. |
| 4155 | * @val: 0 or 1. |
| 4156 | * |
| 4157 | * Description: |
| 4158 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4159 | * |
| 4160 | * Returns: |
| 4161 | * zero if val saved. |
| 4162 | * -EINVAL val out of range |
| 4163 | **/ |
| 4164 | static int |
| 4165 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4166 | { |
| 4167 | if (val >= 0 && val <= 1) { |
| 4168 | phba->cfg_request_firmware_upgrade = val; |
| 4169 | return 0; |
| 4170 | } |
| 4171 | return -EINVAL; |
| 4172 | } |
| 4173 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4174 | lpfc_request_firmware_upgrade_show, |
| 4175 | lpfc_request_firmware_upgrade_store); |
| 4176 | |
| 4177 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4178 | * lpfc_fcp_imax_store |
| 4179 | * |
| 4180 | * @dev: class device that is converted into a Scsi_host. |
| 4181 | * @attr: device attribute, not used. |
| 4182 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4183 | * @count: unused variable. |
| 4184 | * |
| 4185 | * Description: |
| 4186 | * If val is in a valid range [636,651042], then set the adapter's |
| 4187 | * maximum number of fast-path FCP interrupts per second. |
| 4188 | * |
| 4189 | * Returns: |
| 4190 | * length of the buf on success if val is in range the intended mode |
| 4191 | * is supported. |
| 4192 | * -EINVAL if val out of range or intended mode is not supported. |
| 4193 | **/ |
| 4194 | static ssize_t |
| 4195 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4196 | const char *buf, size_t count) |
| 4197 | { |
| 4198 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4199 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4200 | struct lpfc_hba *phba = vport->phba; |
| 4201 | int val = 0, i; |
| 4202 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4203 | /* fcp_imax is only valid for SLI4 */ |
| 4204 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4205 | return -EINVAL; |
| 4206 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4207 | /* Sanity check on user data */ |
| 4208 | if (!isdigit(buf[0])) |
| 4209 | return -EINVAL; |
| 4210 | if (sscanf(buf, "%i", &val) != 1) |
| 4211 | return -EINVAL; |
| 4212 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4213 | /* |
| 4214 | * Value range for the HBA is [5000,5000000] |
| 4215 | * The value for each EQ depends on how many EQs are configured. |
| 4216 | */ |
| 4217 | if (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4218 | return -EINVAL; |
| 4219 | |
| 4220 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4221 | 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] | 4222 | lpfc_modify_fcp_eq_delay(phba, i); |
| 4223 | |
| 4224 | return strlen(buf); |
| 4225 | } |
| 4226 | |
| 4227 | /* |
| 4228 | # 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] | 4229 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4230 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4231 | # 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] | 4232 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4233 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4234 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4235 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4236 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4237 | lpfc_param_show(fcp_imax) |
| 4238 | |
| 4239 | /** |
| 4240 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4241 | * @phba: lpfc_hba pointer. |
| 4242 | * @val: link speed value. |
| 4243 | * |
| 4244 | * Description: |
| 4245 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4246 | * maximum number of fast-path FCP interrupts per second. |
| 4247 | * |
| 4248 | * Returns: |
| 4249 | * zero if val saved. |
| 4250 | * -EINVAL val out of range |
| 4251 | **/ |
| 4252 | static int |
| 4253 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4254 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4255 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4256 | phba->cfg_fcp_imax = 0; |
| 4257 | return 0; |
| 4258 | } |
| 4259 | |
| 4260 | if (val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4261 | phba->cfg_fcp_imax = val; |
| 4262 | return 0; |
| 4263 | } |
| 4264 | |
| 4265 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4266 | "3016 fcp_imax: %d out of range, using default\n", val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4267 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4268 | |
| 4269 | return 0; |
| 4270 | } |
| 4271 | |
| 4272 | static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, |
| 4273 | lpfc_fcp_imax_show, lpfc_fcp_imax_store); |
| 4274 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4275 | /** |
| 4276 | * lpfc_state_show - Display current driver CPU affinity |
| 4277 | * @dev: class converted to a Scsi_host structure. |
| 4278 | * @attr: device attribute, not used. |
| 4279 | * @buf: on return contains text describing the state of the link. |
| 4280 | * |
| 4281 | * Returns: size of formatted string. |
| 4282 | **/ |
| 4283 | static ssize_t |
| 4284 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4285 | char *buf) |
| 4286 | { |
| 4287 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4288 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4289 | struct lpfc_hba *phba = vport->phba; |
| 4290 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4291 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4292 | |
| 4293 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4294 | (phba->intr_type != MSIX)) |
| 4295 | return len; |
| 4296 | |
| 4297 | switch (phba->cfg_fcp_cpu_map) { |
| 4298 | case 0: |
| 4299 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4300 | "fcp_cpu_map: No mapping (%d)\n", |
| 4301 | phba->cfg_fcp_cpu_map); |
| 4302 | return len; |
| 4303 | case 1: |
| 4304 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4305 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4306 | "%d online CPUs\n", |
| 4307 | phba->cfg_fcp_cpu_map, |
| 4308 | phba->sli4_hba.num_online_cpu); |
| 4309 | break; |
| 4310 | case 2: |
| 4311 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4312 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4313 | "%d online CPUs\n", |
| 4314 | phba->cfg_fcp_cpu_map, |
| 4315 | phba->sli4_hba.num_online_cpu); |
| 4316 | break; |
| 4317 | } |
| 4318 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4319 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4320 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4321 | |
| 4322 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4323 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4324 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4325 | "CPU %02d io_chan %02d " |
| 4326 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4327 | phba->sli4_hba.curr_disp_cpu, |
| 4328 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4329 | cpup->core_id); |
| 4330 | else |
| 4331 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4332 | "CPU %02d io_chan %02d " |
| 4333 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4334 | phba->sli4_hba.curr_disp_cpu, |
| 4335 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4336 | cpup->core_id, cpup->irq); |
| 4337 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4338 | phba->sli4_hba.curr_disp_cpu++; |
| 4339 | |
| 4340 | /* display max number of CPUs keeping some margin */ |
| 4341 | if (phba->sli4_hba.curr_disp_cpu < |
| 4342 | phba->sli4_hba.num_present_cpu && |
| 4343 | (len >= (PAGE_SIZE - 64))) { |
| 4344 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4345 | break; |
| 4346 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4347 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4348 | |
| 4349 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4350 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4351 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4352 | return len; |
| 4353 | } |
| 4354 | |
| 4355 | /** |
| 4356 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4357 | * @dev: class device that is converted into a Scsi_host. |
| 4358 | * @attr: device attribute, not used. |
| 4359 | * @buf: one or more lpfc_polling_flags values. |
| 4360 | * @count: not used. |
| 4361 | * |
| 4362 | * Returns: |
| 4363 | * -EINVAL - Not implemented yet. |
| 4364 | **/ |
| 4365 | static ssize_t |
| 4366 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4367 | const char *buf, size_t count) |
| 4368 | { |
| 4369 | int status = -EINVAL; |
| 4370 | return status; |
| 4371 | } |
| 4372 | |
| 4373 | /* |
| 4374 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4375 | # for the HBA. |
| 4376 | # |
| 4377 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4378 | # 0 - Do not affinitze IRQ vectors |
| 4379 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4380 | # (start with CPU0 for each HBA) |
| 4381 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4382 | # (round robin thru all CPUs across all HBAs) |
| 4383 | */ |
| 4384 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4385 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4386 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4387 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4388 | |
| 4389 | /** |
| 4390 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4391 | * @phba: lpfc_hba pointer. |
| 4392 | * @val: link speed value. |
| 4393 | * |
| 4394 | * Description: |
| 4395 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4396 | * MSIX vectors. |
| 4397 | * |
| 4398 | * Returns: |
| 4399 | * zero if val saved. |
| 4400 | * -EINVAL val out of range |
| 4401 | **/ |
| 4402 | static int |
| 4403 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4404 | { |
| 4405 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4406 | phba->cfg_fcp_cpu_map = 0; |
| 4407 | return 0; |
| 4408 | } |
| 4409 | |
| 4410 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4411 | phba->cfg_fcp_cpu_map = val; |
| 4412 | return 0; |
| 4413 | } |
| 4414 | |
| 4415 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4416 | "3326 fcp_cpu_map: %d out of range, using default\n", |
| 4417 | val); |
| 4418 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4419 | |
| 4420 | return 0; |
| 4421 | } |
| 4422 | |
| 4423 | static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, |
| 4424 | lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store); |
| 4425 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4426 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4427 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4428 | # Value range is [2,3]. Default value is 3. |
| 4429 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4430 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4431 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4432 | |
| 4433 | /* |
| 4434 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4435 | # is [0,1]. Default value is 0. |
| 4436 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4437 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4438 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4439 | |
| 4440 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4441 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4442 | # that support first burst. |
| 4443 | # Value range is [0,65536]. Default value is 0. |
| 4444 | */ |
| 4445 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4446 | "First burst size for Targets that support first burst"); |
| 4447 | |
| 4448 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4449 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4450 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4451 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4452 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4453 | # to limit the I/O completion time to the parameter value. |
| 4454 | # The value is set in milliseconds. |
| 4455 | */ |
| 4456 | static int lpfc_max_scsicmpl_time; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4457 | module_param(lpfc_max_scsicmpl_time, int, S_IRUGO); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4458 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, |
| 4459 | "Use command completion time to control queue depth"); |
| 4460 | lpfc_vport_param_show(max_scsicmpl_time); |
| 4461 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); |
| 4462 | static int |
| 4463 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4464 | { |
| 4465 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4466 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4467 | |
| 4468 | if (val == vport->cfg_max_scsicmpl_time) |
| 4469 | return 0; |
| 4470 | if ((val < 0) || (val > 60000)) |
| 4471 | return -EINVAL; |
| 4472 | vport->cfg_max_scsicmpl_time = val; |
| 4473 | |
| 4474 | spin_lock_irq(shost->host_lock); |
| 4475 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4476 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4477 | continue; |
| 4478 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4479 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4480 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4481 | } |
| 4482 | spin_unlock_irq(shost->host_lock); |
| 4483 | return 0; |
| 4484 | } |
| 4485 | lpfc_vport_param_store(max_scsicmpl_time); |
| 4486 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 4487 | lpfc_max_scsicmpl_time_show, |
| 4488 | lpfc_max_scsicmpl_time_store); |
| 4489 | |
| 4490 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4491 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4492 | # range is [0,1]. Default value is 0. |
| 4493 | */ |
| 4494 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4495 | |
| 4496 | /* |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4497 | # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4498 | # range is [0,1]. Default value is 0. |
| 4499 | # For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4500 | # For [1], FCP commands are issued to a Work Queue associated with the |
| 4501 | # current CPU. |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4502 | # It would be set to 1 by the driver if it's able to set up cpu affinity |
| 4503 | # for FCP I/Os through Work Queue associated with the current CPU. Otherwise, |
| 4504 | # roundrobin scheduling of FCP I/Os through WQs will be used. |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4505 | */ |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4506 | LPFC_ATTR_RW(fcp_io_sched, 0, 0, 1, "Determine scheduling algorithm for " |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4507 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
| 4508 | |
| 4509 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4510 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4511 | # range is [0,1]. Default value is 0. |
| 4512 | # For [0], bus reset issues target reset to ALL devices |
| 4513 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4514 | */ |
| 4515 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4516 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4517 | |
| 4518 | |
| 4519 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4520 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4521 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4522 | # 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] | 4523 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4524 | # cr_delay is set to 0. |
| 4525 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4526 | 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] | 4527 | "interrupt response is generated"); |
| 4528 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4529 | 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] | 4530 | "interrupt response is generated"); |
| 4531 | |
| 4532 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4533 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4534 | # cmd/rsp IOCB entries across. |
| 4535 | # Value range is [1,2]. Default value is 1. |
| 4536 | */ |
| 4537 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4538 | "SLI rings to spread IOCB entries across"); |
| 4539 | |
| 4540 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4541 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4542 | # identifies what rctl value to configure the additional ring for. |
| 4543 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4544 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4545 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4546 | 255, "Identifies RCTL for additional ring configuration"); |
| 4547 | |
| 4548 | /* |
| 4549 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4550 | # identifies what type value to configure the additional ring for. |
| 4551 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4552 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4553 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4554 | 255, "Identifies TYPE for additional ring configuration"); |
| 4555 | |
| 4556 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4557 | # lpfc_fdmi_on: controls FDMI support. |
| 4558 | # 0 = no FDMI support |
| 4559 | # 1 = support FDMI without attribute of hostname |
| 4560 | # 2 = support FDMI with attribute of hostname |
| 4561 | # Value range [0,2]. Default value is 0. |
| 4562 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4563 | LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4564 | |
| 4565 | /* |
| 4566 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4567 | # discovery). Value range is [1,64]. Default value = 32. |
| 4568 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4569 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4570 | "during discovery"); |
| 4571 | |
| 4572 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4573 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4574 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4575 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4576 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4577 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4578 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4579 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4580 | # on a target can take minutes of wall clock time. Additionally, |
| 4581 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4582 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4583 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4584 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4585 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4586 | # devices present, when in fact, there is only 1. |
| 4587 | # A customer that is aware of their target behaviors, and the results as |
| 4588 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4589 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4590 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4591 | # Value range is [0,65535]. Default value is 255. |
| 4592 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4593 | */ |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4594 | LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4595 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4596 | /* |
| 4597 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4598 | # Value range is [1,255], default value is 10. |
| 4599 | */ |
| 4600 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4601 | "Milliseconds driver will wait between polling FCP ring"); |
| 4602 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4603 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4604 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4605 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4606 | */ |
| 4607 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4608 | "Maximum time to wait for task management commands to complete"); |
| 4609 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4610 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4611 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4612 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4613 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4614 | # 2 = MSI-X enabled (default) |
| 4615 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4616 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4617 | 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] | 4618 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4619 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4620 | /* |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4621 | # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels |
| 4622 | # |
| 4623 | # Value range is [1,7]. Default value is 4. |
| 4624 | */ |
| 4625 | LPFC_ATTR_R(fcp_io_channel, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN, |
| 4626 | LPFC_FCP_IO_CHAN_MAX, |
| 4627 | "Set the number of FCP I/O channels"); |
| 4628 | |
| 4629 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4630 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 4631 | # 0 = HBA resets disabled |
| 4632 | # 1 = HBA resets enabled (default) |
| 4633 | # Value range is [0,1]. Default value is 1. |
| 4634 | */ |
| 4635 | 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] | 4636 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4637 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4638 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4639 | # 0 = HBA Heartbeat disabled |
| 4640 | # 1 = HBA Heartbeat enabled (default) |
| 4641 | # Value range is [0,1]. Default value is 1. |
| 4642 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4643 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4644 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4645 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4646 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 4647 | # 0x0 Express Lane Feature disabled |
| 4648 | # 0x1 Express Lane Feature enabled |
| 4649 | # Value range is [0,1]. Default value is 0. |
| 4650 | */ |
| 4651 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 4652 | |
| 4653 | /* |
| 4654 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 4655 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 4656 | # Value range is [0x0,0x7f]. Default value is 0 |
| 4657 | */ |
| 4658 | LPFC_ATTR_R(XLanePriority, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature."); |
| 4659 | |
| 4660 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4661 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 4662 | # 0 = BlockGuard disabled (default) |
| 4663 | # 1 = BlockGuard enabled |
| 4664 | # Value range is [0,1]. Default value is 0. |
| 4665 | */ |
| 4666 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 4667 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4668 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4669 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 4670 | # 0 = disabled (default) |
| 4671 | # 1 = enabled |
| 4672 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 4673 | # |
| 4674 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4675 | */ |
| 4676 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 4677 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4678 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4679 | # lpfc_prot_mask: i |
| 4680 | # - Bit mask of host protection capabilities used to register with the |
| 4681 | # SCSI mid-layer |
| 4682 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 4683 | # - Allows you to ultimately specify which profiles to use |
| 4684 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 4685 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 4686 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 4687 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 4688 | # HBA supports DIX Type 0: Host to HBA protection only |
| 4689 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 4690 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4691 | # |
| 4692 | */ |
James Smart | 7c56b9f | 2011-07-22 18:36:25 -0400 | [diff] [blame] | 4693 | unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION | |
| 4694 | SHOST_DIX_TYPE0_PROTECTION | |
| 4695 | SHOST_DIX_TYPE1_PROTECTION; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4696 | |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4697 | module_param(lpfc_prot_mask, uint, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4698 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); |
| 4699 | |
| 4700 | /* |
| 4701 | # lpfc_prot_guard: i |
| 4702 | # - 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] | 4703 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4704 | # - Allows you to ultimately specify which profiles to use |
| 4705 | # - Default will result in registering capabilities for all guard types |
| 4706 | # |
| 4707 | */ |
| 4708 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4709 | module_param(lpfc_prot_guard, byte, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4710 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); |
| 4711 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4712 | /* |
| 4713 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 4714 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 4715 | * This parameter can have value 0 or 1. |
| 4716 | * When this parameter is set to 0, no delay is added to the initial |
| 4717 | * discovery. |
| 4718 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 4719 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 4720 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4721 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 4722 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 4723 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4724 | * Default value is 0. |
| 4725 | */ |
| 4726 | int lpfc_delay_discovery; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4727 | module_param(lpfc_delay_discovery, int, S_IRUGO); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4728 | MODULE_PARM_DESC(lpfc_delay_discovery, |
| 4729 | "Delay NPort discovery when Clean Address bit is cleared. " |
| 4730 | "Allowed values: 0,1."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4731 | |
| 4732 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4733 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4734 | * 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] | 4735 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 4736 | * 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] | 4737 | * Because of the additional overhead involved in setting up T10-DIF, |
| 4738 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 4739 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4740 | */ |
| 4741 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 4742 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 4743 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4744 | /* |
| 4745 | * This parameter will be depricated, the driver cannot limit the |
| 4746 | * protection data s/g list. |
| 4747 | */ |
| 4748 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, |
| 4749 | LPFC_DEFAULT_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT, |
| 4750 | "Max Protection Scatter Gather Segment Count"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4751 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4752 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4753 | &dev_attr_bg_info, |
| 4754 | &dev_attr_bg_guard_err, |
| 4755 | &dev_attr_bg_apptag_err, |
| 4756 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4757 | &dev_attr_info, |
| 4758 | &dev_attr_serialnum, |
| 4759 | &dev_attr_modeldesc, |
| 4760 | &dev_attr_modelname, |
| 4761 | &dev_attr_programtype, |
| 4762 | &dev_attr_portnum, |
| 4763 | &dev_attr_fwrev, |
| 4764 | &dev_attr_hdw, |
| 4765 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4766 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4767 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 4768 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4769 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 4770 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4771 | &dev_attr_lpfc_temp_sensor, |
| 4772 | &dev_attr_lpfc_log_verbose, |
| 4773 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4774 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4775 | &dev_attr_lpfc_hba_queue_depth, |
| 4776 | &dev_attr_lpfc_peer_port_login, |
| 4777 | &dev_attr_lpfc_nodev_tmo, |
| 4778 | &dev_attr_lpfc_devloss_tmo, |
| 4779 | &dev_attr_lpfc_fcp_class, |
| 4780 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4781 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4782 | &dev_attr_lpfc_ack0, |
| 4783 | &dev_attr_lpfc_topology, |
| 4784 | &dev_attr_lpfc_scan_down, |
| 4785 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4786 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4787 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4788 | &dev_attr_lpfc_cr_delay, |
| 4789 | &dev_attr_lpfc_cr_count, |
| 4790 | &dev_attr_lpfc_multi_ring_support, |
| 4791 | &dev_attr_lpfc_multi_ring_rctl, |
| 4792 | &dev_attr_lpfc_multi_ring_type, |
| 4793 | &dev_attr_lpfc_fdmi_on, |
| 4794 | &dev_attr_lpfc_max_luns, |
| 4795 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 4796 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4797 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4798 | &dev_attr_nport_evt_cnt, |
| 4799 | &dev_attr_board_mode, |
| 4800 | &dev_attr_max_vpi, |
| 4801 | &dev_attr_used_vpi, |
| 4802 | &dev_attr_max_rpi, |
| 4803 | &dev_attr_used_rpi, |
| 4804 | &dev_attr_max_xri, |
| 4805 | &dev_attr_used_xri, |
| 4806 | &dev_attr_npiv_info, |
| 4807 | &dev_attr_issue_reset, |
| 4808 | &dev_attr_lpfc_poll, |
| 4809 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4810 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4811 | &dev_attr_lpfc_use_msi, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 4812 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4813 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4814 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4815 | &dev_attr_lpfc_enable_bg, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4816 | &dev_attr_lpfc_soft_wwnn, |
| 4817 | &dev_attr_lpfc_soft_wwpn, |
| 4818 | &dev_attr_lpfc_soft_wwn_enable, |
| 4819 | &dev_attr_lpfc_enable_hba_reset, |
| 4820 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4821 | &dev_attr_lpfc_EnableXLane, |
| 4822 | &dev_attr_lpfc_XLanePriority, |
| 4823 | &dev_attr_lpfc_xlane_lun, |
| 4824 | &dev_attr_lpfc_xlane_tgt, |
| 4825 | &dev_attr_lpfc_xlane_vpt, |
| 4826 | &dev_attr_lpfc_xlane_lun_state, |
| 4827 | &dev_attr_lpfc_xlane_lun_status, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4828 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4829 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4830 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4831 | &dev_attr_lpfc_prot_sg_seg_cnt, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4832 | &dev_attr_lpfc_aer_support, |
| 4833 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4834 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4835 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 4836 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 4837 | &dev_attr_lpfc_iocb_cnt, |
| 4838 | &dev_attr_iocb_hw, |
| 4839 | &dev_attr_txq_hw, |
| 4840 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4841 | &dev_attr_lpfc_fips_level, |
| 4842 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4843 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4844 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 4845 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4846 | &dev_attr_lpfc_xlane_supported, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4847 | NULL, |
| 4848 | }; |
| 4849 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4850 | struct device_attribute *lpfc_vport_attrs[] = { |
| 4851 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4852 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4853 | &dev_attr_num_discovered_ports, |
| 4854 | &dev_attr_lpfc_drvr_version, |
| 4855 | &dev_attr_lpfc_log_verbose, |
| 4856 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4857 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4858 | &dev_attr_lpfc_nodev_tmo, |
| 4859 | &dev_attr_lpfc_devloss_tmo, |
| 4860 | &dev_attr_lpfc_hba_queue_depth, |
| 4861 | &dev_attr_lpfc_peer_port_login, |
| 4862 | &dev_attr_lpfc_restrict_login, |
| 4863 | &dev_attr_lpfc_fcp_class, |
| 4864 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4865 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4866 | &dev_attr_lpfc_fdmi_on, |
| 4867 | &dev_attr_lpfc_max_luns, |
| 4868 | &dev_attr_nport_evt_cnt, |
| 4869 | &dev_attr_npiv_info, |
| 4870 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4871 | &dev_attr_lpfc_max_scsicmpl_time, |
| 4872 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4873 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4874 | &dev_attr_lpfc_fips_level, |
| 4875 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4876 | NULL, |
| 4877 | }; |
| 4878 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4879 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4880 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4881 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4882 | * @kobj: kernel kobject that contains the kernel class device. |
| 4883 | * @bin_attr: kernel attributes passed to us. |
| 4884 | * @buf: contains the data to be written to the adapter IOREG space. |
| 4885 | * @off: offset into buffer to beginning of data. |
| 4886 | * @count: bytes to transfer. |
| 4887 | * |
| 4888 | * Description: |
| 4889 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4890 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 4891 | * |
| 4892 | * Returns: |
| 4893 | * -ERANGE off and count combo out of range |
| 4894 | * -EINVAL off, count or buff address invalid |
| 4895 | * -EPERM adapter is offline |
| 4896 | * value of count, buf contents written |
| 4897 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4898 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4899 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 4900 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 4901 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4902 | { |
| 4903 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4904 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4905 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4906 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4907 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4908 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 4909 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 4910 | return -EPERM; |
| 4911 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4912 | if ((off + count) > FF_REG_AREA_SIZE) |
| 4913 | return -ERANGE; |
| 4914 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4915 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 4916 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4917 | |
| 4918 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 4919 | return -EINVAL; |
| 4920 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4921 | /* This is to protect HBA registers from accidental writes. */ |
| 4922 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 4923 | return -EINVAL; |
| 4924 | |
| 4925 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4926 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4927 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4928 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4929 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 4930 | buf_off += sizeof(uint32_t)) |
| 4931 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4932 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 4933 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4934 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4935 | |
| 4936 | return count; |
| 4937 | } |
| 4938 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4939 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4940 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4941 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4942 | * @kobj: kernel kobject that contains the kernel class device. |
| 4943 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 4944 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4945 | * @off: offset into buffer to beginning of data. |
| 4946 | * @count: bytes to transfer. |
| 4947 | * |
| 4948 | * Description: |
| 4949 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4950 | * Uses the adapter io control registers to read data into buf. |
| 4951 | * |
| 4952 | * Returns: |
| 4953 | * -ERANGE off and count combo out of range |
| 4954 | * -EINVAL off, count or buff address invalid |
| 4955 | * value of count, buf contents read |
| 4956 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4957 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4958 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 4959 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 4960 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4961 | { |
| 4962 | size_t buf_off; |
| 4963 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4964 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4965 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4966 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4967 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4968 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 4969 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 4970 | return -EPERM; |
| 4971 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4972 | if (off > FF_REG_AREA_SIZE) |
| 4973 | return -ERANGE; |
| 4974 | |
| 4975 | if ((off + count) > FF_REG_AREA_SIZE) |
| 4976 | count = FF_REG_AREA_SIZE - off; |
| 4977 | |
| 4978 | if (count == 0) return 0; |
| 4979 | |
| 4980 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 4981 | return -EINVAL; |
| 4982 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4983 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4984 | |
| 4985 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 4986 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 4987 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 4988 | } |
| 4989 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4990 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4991 | |
| 4992 | return count; |
| 4993 | } |
| 4994 | |
| 4995 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 4996 | .attr = { |
| 4997 | .name = "ctlreg", |
| 4998 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4999 | }, |
| 5000 | .size = 256, |
| 5001 | .read = sysfs_ctlreg_read, |
| 5002 | .write = sysfs_ctlreg_write, |
| 5003 | }; |
| 5004 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5005 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5006 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5007 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5008 | * @kobj: kernel kobject that contains the kernel class device. |
| 5009 | * @bin_attr: kernel attributes passed to us. |
| 5010 | * @buf: contains the data to be written to sysfs mbox. |
| 5011 | * @off: offset into buffer to beginning of data. |
| 5012 | * @count: bytes to transfer. |
| 5013 | * |
| 5014 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5015 | * Deprecated function. All mailbox access from user space is performed via the |
| 5016 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5017 | * |
| 5018 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5019 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5020 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5021 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5022 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5023 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5024 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5025 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5026 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5027 | } |
| 5028 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5029 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5030 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5031 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5032 | * @kobj: kernel kobject that contains the kernel class device. |
| 5033 | * @bin_attr: kernel attributes passed to us. |
| 5034 | * @buf: contains the data to be read from sysfs mbox. |
| 5035 | * @off: offset into buffer to beginning of data. |
| 5036 | * @count: bytes to transfer. |
| 5037 | * |
| 5038 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5039 | * Deprecated function. All mailbox access from user space is performed via the |
| 5040 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5041 | * |
| 5042 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5043 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5044 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5045 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5046 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5047 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5048 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5049 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5050 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5051 | } |
| 5052 | |
| 5053 | static struct bin_attribute sysfs_mbox_attr = { |
| 5054 | .attr = { |
| 5055 | .name = "mbox", |
| 5056 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5057 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5058 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5059 | .read = sysfs_mbox_read, |
| 5060 | .write = sysfs_mbox_write, |
| 5061 | }; |
| 5062 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5063 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5064 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5065 | * @vport: address of lpfc vport structure. |
| 5066 | * |
| 5067 | * Return codes: |
| 5068 | * zero on success |
| 5069 | * error return code from sysfs_create_bin_file() |
| 5070 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5071 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5072 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5073 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5074 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5075 | int error; |
| 5076 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5077 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5078 | &sysfs_drvr_stat_data_attr); |
| 5079 | |
| 5080 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5081 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5082 | goto out; |
| 5083 | |
| 5084 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5085 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5086 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5087 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5088 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5089 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5090 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5091 | if (error) |
| 5092 | goto out_remove_ctlreg_attr; |
| 5093 | |
| 5094 | return 0; |
| 5095 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5096 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5097 | out_remove_stat_attr: |
| 5098 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5099 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5100 | out: |
| 5101 | return error; |
| 5102 | } |
| 5103 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5104 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5105 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5106 | * @vport: address of lpfc vport structure. |
| 5107 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5108 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5109 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5110 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5111 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5112 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5113 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5114 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5115 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5116 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5117 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5118 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5119 | } |
| 5120 | |
| 5121 | |
| 5122 | /* |
| 5123 | * Dynamic FC Host Attributes Support |
| 5124 | */ |
| 5125 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5126 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5127 | * 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] | 5128 | * @shost: kernel scsi host pointer. |
| 5129 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5130 | static void |
| 5131 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5132 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5133 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5134 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5135 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5136 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5137 | } |
| 5138 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5139 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5140 | * 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] | 5141 | * @shost: kernel scsi host pointer. |
| 5142 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5143 | static void |
| 5144 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5145 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5146 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5147 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5148 | |
| 5149 | spin_lock_irq(shost->host_lock); |
| 5150 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5151 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5152 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5153 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5154 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5155 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5156 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5157 | else |
| 5158 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5159 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5160 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5161 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5162 | else |
| 5163 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5164 | } |
| 5165 | } else |
| 5166 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5167 | |
| 5168 | spin_unlock_irq(shost->host_lock); |
| 5169 | } |
| 5170 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5171 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5172 | * 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] | 5173 | * @shost: kernel scsi host pointer. |
| 5174 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5175 | static void |
| 5176 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5177 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5178 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5179 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5180 | |
| 5181 | spin_lock_irq(shost->host_lock); |
| 5182 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5183 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5184 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5185 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5186 | switch (phba->link_state) { |
| 5187 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5188 | case LPFC_LINK_DOWN: |
| 5189 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5190 | break; |
| 5191 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5192 | case LPFC_CLEAR_LA: |
| 5193 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5194 | /* Links up, reports port state accordingly */ |
| 5195 | if (vport->port_state < LPFC_VPORT_READY) |
| 5196 | fc_host_port_state(shost) = |
| 5197 | FC_PORTSTATE_BYPASSED; |
| 5198 | else |
| 5199 | fc_host_port_state(shost) = |
| 5200 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5201 | break; |
| 5202 | case LPFC_HBA_ERROR: |
| 5203 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5204 | break; |
| 5205 | default: |
| 5206 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5207 | break; |
| 5208 | } |
| 5209 | } |
| 5210 | |
| 5211 | spin_unlock_irq(shost->host_lock); |
| 5212 | } |
| 5213 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5214 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5215 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5216 | * @shost: kernel scsi host pointer. |
| 5217 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5218 | static void |
| 5219 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5220 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5221 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5222 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5223 | |
| 5224 | spin_lock_irq(shost->host_lock); |
| 5225 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5226 | if (lpfc_is_link_up(phba)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5227 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5228 | case LPFC_LINK_SPEED_1GHZ: |
| 5229 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5230 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5231 | case LPFC_LINK_SPEED_2GHZ: |
| 5232 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5233 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5234 | case LPFC_LINK_SPEED_4GHZ: |
| 5235 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5236 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5237 | case LPFC_LINK_SPEED_8GHZ: |
| 5238 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5239 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5240 | case LPFC_LINK_SPEED_10GHZ: |
| 5241 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5242 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5243 | case LPFC_LINK_SPEED_16GHZ: |
| 5244 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5245 | break; |
| 5246 | default: |
| 5247 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5248 | break; |
| 5249 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5250 | } else |
| 5251 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5252 | |
| 5253 | spin_unlock_irq(shost->host_lock); |
| 5254 | } |
| 5255 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5256 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5257 | * 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] | 5258 | * @shost: kernel scsi host pointer. |
| 5259 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5260 | static void |
| 5261 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5262 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5263 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5264 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5265 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5266 | |
| 5267 | spin_lock_irq(shost->host_lock); |
| 5268 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5269 | if ((vport->port_state > LPFC_FLOGI) && |
| 5270 | ((vport->fc_flag & FC_FABRIC) || |
| 5271 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5272 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5273 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5274 | else |
| 5275 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5276 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5277 | |
| 5278 | spin_unlock_irq(shost->host_lock); |
| 5279 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5280 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5281 | } |
| 5282 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5283 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5284 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5285 | * @shost: kernel scsi host pointer. |
| 5286 | * |
| 5287 | * Notes: |
| 5288 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5289 | * management not allowed, memory allocation error, or mbox error. |
| 5290 | * |
| 5291 | * Returns: |
| 5292 | * NULL for error |
| 5293 | * address of the adapter host statistics |
| 5294 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5295 | static struct fc_host_statistics * |
| 5296 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5297 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5298 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5299 | struct lpfc_hba *phba = vport->phba; |
| 5300 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5301 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5302 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5303 | LPFC_MBOXQ_t *pmboxq; |
| 5304 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5305 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5306 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5307 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5308 | /* |
| 5309 | * prevent udev from issuing mailbox commands until the port is |
| 5310 | * configured. |
| 5311 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5312 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5313 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5314 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5315 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5316 | |
| 5317 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5318 | return NULL; |
| 5319 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5320 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5321 | if (!pmboxq) |
| 5322 | return NULL; |
| 5323 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5324 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5325 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5326 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5327 | pmb->mbxOwner = OWN_HOST; |
| 5328 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5329 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5330 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5331 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5332 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5333 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5334 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5335 | |
| 5336 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5337 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5338 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5339 | return NULL; |
| 5340 | } |
| 5341 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5342 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5343 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5344 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5345 | /* |
| 5346 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5347 | * converted to words |
| 5348 | */ |
| 5349 | hs->tx_words = (uint64_t) |
| 5350 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5351 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5352 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5353 | hs->rx_words = (uint64_t) |
| 5354 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5355 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5356 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5357 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5358 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5359 | pmb->mbxOwner = OWN_HOST; |
| 5360 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5361 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5362 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5363 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5364 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5365 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5366 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5367 | |
| 5368 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5369 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5370 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5371 | return NULL; |
| 5372 | } |
| 5373 | |
| 5374 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5375 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5376 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5377 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5378 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5379 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5380 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5381 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5382 | hs->link_failure_count -= lso->link_failure_count; |
| 5383 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5384 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5385 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5386 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5387 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5388 | hs->error_frames -= lso->error_frames; |
| 5389 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5390 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5391 | hs->lip_count = -1; |
| 5392 | hs->nos_count = (phba->link_events >> 1); |
| 5393 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5394 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5395 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5396 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5397 | hs->nos_count = -1; |
| 5398 | } else { |
| 5399 | hs->lip_count = -1; |
| 5400 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5401 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5402 | } |
| 5403 | |
| 5404 | hs->dumped_frames = -1; |
| 5405 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5406 | seconds = get_seconds(); |
| 5407 | if (seconds < psli->stats_start) |
| 5408 | hs->seconds_since_last_reset = seconds + |
| 5409 | ((unsigned long)-1 - psli->stats_start); |
| 5410 | else |
| 5411 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5412 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5413 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5414 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5415 | return hs; |
| 5416 | } |
| 5417 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5418 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5419 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5420 | * @shost: kernel scsi host pointer. |
| 5421 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5422 | static void |
| 5423 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5424 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5425 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5426 | struct lpfc_hba *phba = vport->phba; |
| 5427 | struct lpfc_sli *psli = &phba->sli; |
| 5428 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5429 | LPFC_MBOXQ_t *pmboxq; |
| 5430 | MAILBOX_t *pmb; |
| 5431 | int rc = 0; |
| 5432 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5433 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5434 | return; |
| 5435 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5436 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5437 | if (!pmboxq) |
| 5438 | return; |
| 5439 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5440 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5441 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5442 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5443 | pmb->mbxOwner = OWN_HOST; |
| 5444 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5445 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5446 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5447 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5448 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5449 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5450 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5451 | else |
| 5452 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5453 | |
| 5454 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5455 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5456 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5457 | return; |
| 5458 | } |
| 5459 | |
| 5460 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5461 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5462 | pmb->mbxOwner = OWN_HOST; |
| 5463 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5464 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5465 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5466 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5467 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5468 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5469 | else |
| 5470 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5471 | |
| 5472 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5473 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5474 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5475 | return; |
| 5476 | } |
| 5477 | |
| 5478 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5479 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5480 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5481 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5482 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5483 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5484 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5485 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5486 | lso->link_events = (phba->link_events >> 1); |
| 5487 | else |
| 5488 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5489 | |
| 5490 | psli->stats_start = get_seconds(); |
| 5491 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5492 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5493 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5494 | return; |
| 5495 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5496 | |
| 5497 | /* |
| 5498 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5499 | * are no sysfs handlers for link_down_tmo. |
| 5500 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5501 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5502 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5503 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5504 | * @starget: kernel scsi target pointer. |
| 5505 | * |
| 5506 | * Returns: |
| 5507 | * address of the node list if found |
| 5508 | * NULL target not found |
| 5509 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5510 | static struct lpfc_nodelist * |
| 5511 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5512 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5513 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5514 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5515 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5516 | |
| 5517 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5518 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5519 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5520 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5521 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5522 | starget->id == ndlp->nlp_sid) { |
| 5523 | spin_unlock_irq(shost->host_lock); |
| 5524 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5525 | } |
| 5526 | } |
| 5527 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5528 | return NULL; |
| 5529 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5530 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5531 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5532 | * 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] | 5533 | * @starget: kernel scsi target pointer. |
| 5534 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5535 | static void |
| 5536 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5537 | { |
| 5538 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5539 | |
| 5540 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5541 | } |
| 5542 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5543 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5544 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5545 | * @starget: kernel scsi target pointer. |
| 5546 | * |
| 5547 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 5548 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5549 | static void |
| 5550 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 5551 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5552 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5553 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5554 | fc_starget_node_name(starget) = |
| 5555 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5556 | } |
| 5557 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5558 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5559 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5560 | * @starget: kernel scsi target pointer. |
| 5561 | * |
| 5562 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 5563 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5564 | static void |
| 5565 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 5566 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5567 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5568 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5569 | fc_starget_port_name(starget) = |
| 5570 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5571 | } |
| 5572 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5573 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5574 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5575 | * @rport: fc rport address. |
| 5576 | * @timeout: new value for dev loss tmo. |
| 5577 | * |
| 5578 | * Description: |
| 5579 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 5580 | * dev_loss_tmo to one. |
| 5581 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5582 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5583 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 5584 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5585 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5586 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5587 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5588 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5589 | } |
| 5590 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5591 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5592 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5593 | * |
| 5594 | * Description: |
| 5595 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 5596 | * |
| 5597 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 5598 | * @cdev: class converted to an fc_rport. |
| 5599 | * @buf: on return contains the target_field or zero. |
| 5600 | * |
| 5601 | * Returns: size of formatted string. |
| 5602 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5603 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 5604 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5605 | lpfc_show_rport_##field (struct device *dev, \ |
| 5606 | struct device_attribute *attr, \ |
| 5607 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5608 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5609 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5610 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 5611 | return snprintf(buf, sz, format_string, \ |
| 5612 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 5613 | } |
| 5614 | |
| 5615 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 5616 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 5617 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 5618 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5619 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5620 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5621 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 5622 | * |
| 5623 | * Description: |
| 5624 | * This function is called by the transport after the @fc_vport's symbolic name |
| 5625 | * 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] | 5626 | * 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] | 5627 | **/ |
| 5628 | static void |
| 5629 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 5630 | { |
| 5631 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 5632 | |
| 5633 | if (vport->port_state == LPFC_VPORT_READY) |
| 5634 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 5635 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5636 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5637 | /** |
| 5638 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 5639 | * @phba: Pointer to lpfc_hba struct. |
| 5640 | * |
| 5641 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 5642 | * 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] | 5643 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5644 | * before hba port or vport created. |
| 5645 | **/ |
| 5646 | static void |
| 5647 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 5648 | { |
| 5649 | phba->cfg_log_verbose = verbose; |
| 5650 | } |
| 5651 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5652 | struct fc_function_template lpfc_transport_functions = { |
| 5653 | /* fixed attributes the driver supports */ |
| 5654 | .show_host_node_name = 1, |
| 5655 | .show_host_port_name = 1, |
| 5656 | .show_host_supported_classes = 1, |
| 5657 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5658 | .show_host_supported_speeds = 1, |
| 5659 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5660 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5661 | |
| 5662 | /* dynamic attributes the driver supports */ |
| 5663 | .get_host_port_id = lpfc_get_host_port_id, |
| 5664 | .show_host_port_id = 1, |
| 5665 | |
| 5666 | .get_host_port_type = lpfc_get_host_port_type, |
| 5667 | .show_host_port_type = 1, |
| 5668 | |
| 5669 | .get_host_port_state = lpfc_get_host_port_state, |
| 5670 | .show_host_port_state = 1, |
| 5671 | |
| 5672 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5673 | .show_host_active_fc4s = 1, |
| 5674 | |
| 5675 | .get_host_speed = lpfc_get_host_speed, |
| 5676 | .show_host_speed = 1, |
| 5677 | |
| 5678 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5679 | .show_host_fabric_name = 1, |
| 5680 | |
| 5681 | /* |
| 5682 | * The LPFC driver treats linkdown handling as target loss events |
| 5683 | * so there are no sysfs handlers for link_down_tmo. |
| 5684 | */ |
| 5685 | |
| 5686 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5687 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5688 | |
| 5689 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5690 | .show_rport_maxframe_size = 1, |
| 5691 | .show_rport_supported_classes = 1, |
| 5692 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5693 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5694 | .show_rport_dev_loss_tmo = 1, |
| 5695 | |
| 5696 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5697 | .show_starget_port_id = 1, |
| 5698 | |
| 5699 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5700 | .show_starget_node_name = 1, |
| 5701 | |
| 5702 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5703 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 5704 | |
| 5705 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5706 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5707 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5708 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5709 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5710 | |
| 5711 | .vport_disable = lpfc_vport_disable, |
| 5712 | |
| 5713 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 5714 | |
| 5715 | .bsg_request = lpfc_bsg_request, |
| 5716 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5717 | }; |
| 5718 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5719 | struct fc_function_template lpfc_vport_transport_functions = { |
| 5720 | /* fixed attributes the driver supports */ |
| 5721 | .show_host_node_name = 1, |
| 5722 | .show_host_port_name = 1, |
| 5723 | .show_host_supported_classes = 1, |
| 5724 | .show_host_supported_fc4s = 1, |
| 5725 | .show_host_supported_speeds = 1, |
| 5726 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5727 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5728 | |
| 5729 | /* dynamic attributes the driver supports */ |
| 5730 | .get_host_port_id = lpfc_get_host_port_id, |
| 5731 | .show_host_port_id = 1, |
| 5732 | |
| 5733 | .get_host_port_type = lpfc_get_host_port_type, |
| 5734 | .show_host_port_type = 1, |
| 5735 | |
| 5736 | .get_host_port_state = lpfc_get_host_port_state, |
| 5737 | .show_host_port_state = 1, |
| 5738 | |
| 5739 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5740 | .show_host_active_fc4s = 1, |
| 5741 | |
| 5742 | .get_host_speed = lpfc_get_host_speed, |
| 5743 | .show_host_speed = 1, |
| 5744 | |
| 5745 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5746 | .show_host_fabric_name = 1, |
| 5747 | |
| 5748 | /* |
| 5749 | * The LPFC driver treats linkdown handling as target loss events |
| 5750 | * so there are no sysfs handlers for link_down_tmo. |
| 5751 | */ |
| 5752 | |
| 5753 | .get_fc_host_stats = lpfc_get_stats, |
| 5754 | .reset_fc_host_stats = lpfc_reset_stats, |
| 5755 | |
| 5756 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5757 | .show_rport_maxframe_size = 1, |
| 5758 | .show_rport_supported_classes = 1, |
| 5759 | |
| 5760 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5761 | .show_rport_dev_loss_tmo = 1, |
| 5762 | |
| 5763 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5764 | .show_starget_port_id = 1, |
| 5765 | |
| 5766 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5767 | .show_starget_node_name = 1, |
| 5768 | |
| 5769 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5770 | .show_starget_port_name = 1, |
| 5771 | |
| 5772 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5773 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 5774 | |
| 5775 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5776 | |
| 5777 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5778 | }; |
| 5779 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5780 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5781 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5782 | * @phba: lpfc_hba pointer. |
| 5783 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5784 | void |
| 5785 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 5786 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5787 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5788 | 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] | 5789 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 5790 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5791 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5792 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 5793 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5794 | lpfc_ack0_init(phba, lpfc_ack0); |
| 5795 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5796 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5797 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5798 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5799 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5800 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5801 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5802 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5803 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5804 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5805 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5806 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 5807 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5808 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 5809 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5810 | phba->cfg_EnableXLane = 0; |
| 5811 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
| 5812 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5813 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5814 | phba->cfg_oas_lun_state = 0; |
| 5815 | phba->cfg_oas_lun_status = 0; |
| 5816 | phba->cfg_oas_flags = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5817 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5818 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 5819 | phba->cfg_poll = 0; |
| 5820 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5821 | phba->cfg_poll = lpfc_poll; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 5822 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5823 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5824 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5825 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5826 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5827 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5828 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5829 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5830 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5831 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5832 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5833 | phba->cfg_enable_dss = 1; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5834 | return; |
| 5835 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 5836 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5837 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5838 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5839 | * @vport: lpfc_vport pointer. |
| 5840 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5841 | void |
| 5842 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 5843 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5844 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5845 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5846 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5847 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 5848 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 5849 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 5850 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 5851 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 5852 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5853 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5854 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5855 | lpfc_fdmi_on_init(vport, lpfc_fdmi_on); |
| 5856 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 5857 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 5858 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 5859 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5860 | return; |
| 5861 | } |