| 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 | 5061157 | 2016-03-31 14:12:34 -0700 | [diff] [blame] | 4 | * Copyright (C) 2004-2016 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" |
James Smart | 93dd191 | 2016-07-06 12:36:10 -0700 | [diff] [blame] | 51 | #include "lpfc_attr.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 52 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 53 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 54 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 55 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 56 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 57 | /* |
| 58 | * Write key size should be multiple of 4. If write key is changed |
| 59 | * make sure that library write key is also changed. |
| 60 | */ |
| 61 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 62 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 63 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 64 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 65 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 66 | * @incr: integer to convert. |
| 67 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 68 | * |
| 69 | * Description: |
| 70 | * JEDEC Joint Electron Device Engineering Council. |
| 71 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 72 | * character string. The string is then terminated with a NULL in byte 9. |
| 73 | * Hex 0-9 becomes ascii '0' to '9'. |
| 74 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 75 | * |
| 76 | * Notes: |
| 77 | * Coded for 32 bit integers only. |
| 78 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 79 | static void |
| 80 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 81 | { |
| 82 | int i, j; |
| 83 | for (i = 0; i < 8; i++) { |
| 84 | j = (incr & 0xf); |
| 85 | if (j <= 9) |
| 86 | hdw[7 - i] = 0x30 + j; |
| 87 | else |
| 88 | hdw[7 - i] = 0x61 + j - 10; |
| 89 | incr = (incr >> 4); |
| 90 | } |
| 91 | hdw[8] = 0; |
| 92 | return; |
| 93 | } |
| 94 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 95 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 96 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 97 | * @dev: class unused variable. |
| 98 | * @attr: device attribute, not used. |
| 99 | * @buf: on return contains the module description text. |
| 100 | * |
| 101 | * Returns: size of formatted string. |
| 102 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 103 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 104 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 105 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 106 | { |
| 107 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 108 | } |
| 109 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 110 | /** |
| 111 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 112 | * @dev: class unused variable. |
| 113 | * @attr: device attribute, not used. |
| 114 | * @buf: on return contains the module description text. |
| 115 | * |
| 116 | * Returns: size of formatted string. |
| 117 | **/ |
| 118 | static ssize_t |
| 119 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 120 | char *buf) |
| 121 | { |
| 122 | struct Scsi_Host *shost = class_to_shost(dev); |
| 123 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 124 | struct lpfc_hba *phba = vport->phba; |
| 125 | |
| 126 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 127 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 128 | else |
| 129 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 130 | } |
| 131 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 132 | static ssize_t |
| 133 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 134 | char *buf) |
| 135 | { |
| 136 | struct Scsi_Host *shost = class_to_shost(dev); |
| 137 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 138 | struct lpfc_hba *phba = vport->phba; |
| 139 | |
| 140 | if (phba->cfg_enable_bg) |
| 141 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 142 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 143 | else |
| 144 | return snprintf(buf, PAGE_SIZE, |
| 145 | "BlockGuard Not Supported\n"); |
| 146 | else |
| 147 | return snprintf(buf, PAGE_SIZE, |
| 148 | "BlockGuard Disabled\n"); |
| 149 | } |
| 150 | |
| 151 | static ssize_t |
| 152 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 153 | char *buf) |
| 154 | { |
| 155 | struct Scsi_Host *shost = class_to_shost(dev); |
| 156 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 157 | struct lpfc_hba *phba = vport->phba; |
| 158 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 159 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 160 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | static ssize_t |
| 164 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 165 | char *buf) |
| 166 | { |
| 167 | struct Scsi_Host *shost = class_to_shost(dev); |
| 168 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 169 | struct lpfc_hba *phba = vport->phba; |
| 170 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 171 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 172 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | static ssize_t |
| 176 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 177 | char *buf) |
| 178 | { |
| 179 | struct Scsi_Host *shost = class_to_shost(dev); |
| 180 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 181 | struct lpfc_hba *phba = vport->phba; |
| 182 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 183 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 184 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 185 | } |
| 186 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 187 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 188 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 189 | * @dev: class converted to a Scsi_host structure. |
| 190 | * @attr: device attribute, not used. |
| 191 | * @buf: on return contains the formatted text from lpfc_info(). |
| 192 | * |
| 193 | * Returns: size of formatted string. |
| 194 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 195 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 196 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 197 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 198 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 199 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 200 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 201 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 202 | } |
| 203 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 204 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 205 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 206 | * @dev: class converted to a Scsi_host structure. |
| 207 | * @attr: device attribute, not used. |
| 208 | * @buf: on return contains the formatted text serial number. |
| 209 | * |
| 210 | * Returns: size of formatted string. |
| 211 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 212 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 213 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 214 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 215 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 216 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 217 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 218 | struct lpfc_hba *phba = vport->phba; |
| 219 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 220 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 221 | } |
| 222 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 223 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 224 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 225 | * @dev: class converted to a Scsi_host structure. |
| 226 | * @attr: device attribute, not used. |
| 227 | * @buf: on return contains the formatted support level. |
| 228 | * |
| 229 | * Description: |
| 230 | * Returns a number indicating the temperature sensor level currently |
| 231 | * supported, zero or one in ascii. |
| 232 | * |
| 233 | * Returns: size of formatted string. |
| 234 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 235 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 236 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 237 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 238 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 239 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 240 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 241 | struct lpfc_hba *phba = vport->phba; |
| 242 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 243 | } |
| 244 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 245 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 246 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 247 | * @dev: class converted to a Scsi_host structure. |
| 248 | * @attr: device attribute, not used. |
| 249 | * @buf: on return contains the scsi vpd model description. |
| 250 | * |
| 251 | * Returns: size of formatted string. |
| 252 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 253 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 254 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 255 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 256 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 257 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 258 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 259 | struct lpfc_hba *phba = vport->phba; |
| 260 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 261 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 262 | } |
| 263 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 264 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 265 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 266 | * @dev: class converted to a Scsi_host structure. |
| 267 | * @attr: device attribute, not used. |
| 268 | * @buf: on return contains the scsi vpd model name. |
| 269 | * |
| 270 | * Returns: size of formatted string. |
| 271 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 272 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 273 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 274 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 275 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 276 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 277 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 278 | struct lpfc_hba *phba = vport->phba; |
| 279 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 280 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 281 | } |
| 282 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 283 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 284 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 285 | * @dev: class converted to a Scsi_host structure. |
| 286 | * @attr: device attribute, not used. |
| 287 | * @buf: on return contains the scsi vpd program type. |
| 288 | * |
| 289 | * Returns: size of formatted string. |
| 290 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 291 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 292 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 293 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 294 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 295 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 296 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 297 | struct lpfc_hba *phba = vport->phba; |
| 298 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 299 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 300 | } |
| 301 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 302 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 303 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 304 | * @dev: class converted to a Scsi_host structure. |
| 305 | * @attr: device attribute, not used. |
| 306 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 307 | * |
| 308 | * Returns: size of formatted string. |
| 309 | **/ |
| 310 | static ssize_t |
| 311 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 312 | { |
| 313 | struct Scsi_Host *shost = class_to_shost(dev); |
| 314 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 315 | struct lpfc_hba *phba = vport->phba; |
| 316 | |
| 317 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 318 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 319 | } |
| 320 | |
| 321 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 322 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 323 | * @dev: class converted to a Scsi_host structure. |
| 324 | * @attr: device attribute, not used. |
| 325 | * @buf: on return contains scsi vpd program type. |
| 326 | * |
| 327 | * Returns: size of formatted string. |
| 328 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 329 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 330 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 331 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 332 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 333 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 334 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 335 | struct lpfc_hba *phba = vport->phba; |
| 336 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 337 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 338 | } |
| 339 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 340 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 341 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 342 | * @dev: class converted to a Scsi_host structure. |
| 343 | * @attr: device attribute, not used. |
| 344 | * @buf: on return contains the scsi vpd program type. |
| 345 | * |
| 346 | * Returns: size of formatted string. |
| 347 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 348 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 349 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 350 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 351 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 352 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 353 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 354 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 355 | uint32_t if_type; |
| 356 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 357 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 358 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 359 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 360 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 361 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 362 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 363 | |
| 364 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 365 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 366 | fwrev, phba->sli_rev); |
| 367 | else |
| 368 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 369 | fwrev, phba->sli_rev, if_type, sli_family); |
| 370 | |
| 371 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 372 | } |
| 373 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 374 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 375 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 376 | * @dev: class converted to a Scsi_host structure. |
| 377 | * @attr: device attribute, not used. |
| 378 | * @buf: on return contains the scsi vpd program type. |
| 379 | * |
| 380 | * Returns: size of formatted string. |
| 381 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 382 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 383 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 384 | { |
| 385 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 386 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 387 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 388 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 389 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 390 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 391 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 392 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 393 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 394 | |
| 395 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 396 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 397 | * @dev: class converted to a Scsi_host structure. |
| 398 | * @attr: device attribute, not used. |
| 399 | * @buf: on return contains the ROM and FCode ascii strings. |
| 400 | * |
| 401 | * Returns: size of formatted string. |
| 402 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 403 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 404 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 405 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 406 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 407 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 408 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 409 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 410 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 411 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 412 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 413 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 414 | |
| 415 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
| 416 | return snprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 417 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 418 | |
| 419 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 420 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 421 | * @dev: class converted to a Scsi_host structure. |
| 422 | * @attr: device attribute, not used. |
| 423 | * @buf: on return contains text describing the state of the link. |
| 424 | * |
| 425 | * Notes: |
| 426 | * The switch statement has no default so zero will be returned. |
| 427 | * |
| 428 | * Returns: size of formatted string. |
| 429 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 430 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 431 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 432 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 433 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 434 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 435 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 436 | struct lpfc_hba *phba = vport->phba; |
| 437 | int len = 0; |
| 438 | |
| 439 | switch (phba->link_state) { |
| 440 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 441 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 442 | case LPFC_INIT_START: |
| 443 | case LPFC_INIT_MBX_CMDS: |
| 444 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 445 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 446 | if (phba->hba_flag & LINK_DISABLED) |
| 447 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 448 | "Link Down - User disabled\n"); |
| 449 | else |
| 450 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 451 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 452 | break; |
| 453 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 454 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 455 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 456 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 457 | |
| 458 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 459 | case LPFC_LOCAL_CFG_LINK: |
| 460 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 461 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 462 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 463 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 464 | case LPFC_FLOGI: |
| 465 | case LPFC_FABRIC_CFG_LINK: |
| 466 | case LPFC_NS_REG: |
| 467 | case LPFC_NS_QRY: |
| 468 | case LPFC_BUILD_DISC_LIST: |
| 469 | case LPFC_DISC_AUTH: |
| 470 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 471 | "Discovery\n"); |
| 472 | break; |
| 473 | case LPFC_VPORT_READY: |
| 474 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 475 | break; |
| 476 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 477 | case LPFC_VPORT_FAILED: |
| 478 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 479 | break; |
| 480 | |
| 481 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 482 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 483 | "Unknown\n"); |
| 484 | break; |
| 485 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 486 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 487 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 488 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 489 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 490 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 491 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 492 | " Public Loop\n"); |
| 493 | else |
| 494 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 495 | " Private Loop\n"); |
| 496 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 497 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 498 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 499 | " Fabric\n"); |
| 500 | else |
| 501 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 502 | " Point-2-Point\n"); |
| 503 | } |
| 504 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 505 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 506 | return len; |
| 507 | } |
| 508 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 509 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 510 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 511 | * @dev: class unused variable. |
| 512 | * @attr: device attribute, not used. |
| 513 | * @buf: on return contains the module description text. |
| 514 | * |
| 515 | * Returns: size of formatted string. |
| 516 | **/ |
| 517 | static ssize_t |
| 518 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 519 | char *buf) |
| 520 | { |
| 521 | struct Scsi_Host *shost = class_to_shost(dev); |
| 522 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 523 | struct lpfc_hba *phba = vport->phba; |
| 524 | |
| 525 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 526 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 527 | |
| 528 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 529 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 530 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 531 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 532 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 533 | } |
| 534 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 535 | } |
| 536 | |
| 537 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 538 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 539 | * (OAS) is supported. |
| 540 | * @dev: class unused variable. |
| 541 | * @attr: device attribute, not used. |
| 542 | * @buf: on return contains the module description text. |
| 543 | * |
| 544 | * Returns: size of formatted string. |
| 545 | **/ |
| 546 | static ssize_t |
| 547 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 548 | char *buf) |
| 549 | { |
| 550 | struct Scsi_Host *shost = class_to_shost(dev); |
| 551 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 552 | struct lpfc_hba *phba = vport->phba; |
| 553 | |
| 554 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 555 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 556 | } |
| 557 | |
| 558 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 559 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 560 | * @dev: class device that is converted into a Scsi_host. |
| 561 | * @attr: device attribute, not used. |
| 562 | * @buf: one or more lpfc_polling_flags values. |
| 563 | * @count: not used. |
| 564 | * |
| 565 | * Returns: |
| 566 | * -EINVAL if the buffer is not "up" or "down" |
| 567 | * return from link state change function if non-zero |
| 568 | * length of the buf on success |
| 569 | **/ |
| 570 | static ssize_t |
| 571 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 572 | const char *buf, size_t count) |
| 573 | { |
| 574 | struct Scsi_Host *shost = class_to_shost(dev); |
| 575 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 576 | struct lpfc_hba *phba = vport->phba; |
| 577 | |
| 578 | int status = -EINVAL; |
| 579 | |
| 580 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 581 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 582 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 583 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 584 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 585 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 586 | |
| 587 | if (status == 0) |
| 588 | return strlen(buf); |
| 589 | else |
| 590 | return status; |
| 591 | } |
| 592 | |
| 593 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 594 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 595 | * @dev: class device that is converted into a Scsi_host. |
| 596 | * @attr: device attribute, not used. |
| 597 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 598 | * |
| 599 | * Description: |
| 600 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 601 | * vport counts. |
| 602 | * |
| 603 | * Returns: size of formatted string. |
| 604 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 605 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 606 | lpfc_num_discovered_ports_show(struct device *dev, |
| 607 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 608 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 609 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 610 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 611 | |
| 612 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 613 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 614 | } |
| 615 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 616 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 617 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 618 | * @shost: Scsi_Host pointer. |
| 619 | * |
| 620 | * Description: |
| 621 | * Bring the link down gracefully then re-init the link. The firmware will |
| 622 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 623 | * |
| 624 | * Returns: |
| 625 | * -EPERM port offline or management commands are being blocked |
| 626 | * -ENOMEM cannot allocate memory for the mailbox command |
| 627 | * -EIO error sending the mailbox command |
| 628 | * zero for success |
| 629 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 630 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 631 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 632 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 633 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 634 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 635 | LPFC_MBOXQ_t *pmboxq; |
| 636 | int mbxstatus = MBXERR_ERROR; |
| 637 | |
James Smart | a3adc58 | 2018-01-30 15:58:55 -0800 | [diff] [blame^] | 638 | /* |
| 639 | * If the link is offline, disabled or BLOCK_MGMT_IO |
| 640 | * it doesn't make any sense to allow issue_lip |
| 641 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 642 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | a3adc58 | 2018-01-30 15:58:55 -0800 | [diff] [blame^] | 643 | (phba->hba_flag & LINK_DISABLED) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 644 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 645 | return -EPERM; |
| 646 | |
| 647 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 648 | |
| 649 | if (!pmboxq) |
| 650 | return -ENOMEM; |
| 651 | |
| 652 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 653 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 654 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 655 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 656 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 657 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 658 | if ((mbxstatus == MBX_SUCCESS) && |
| 659 | (pmboxq->u.mb.mbxStatus == 0 || |
| 660 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 661 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 662 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 663 | phba->cfg_link_speed); |
| 664 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 665 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 666 | if ((mbxstatus == MBX_SUCCESS) && |
| 667 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 668 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 669 | "2859 SLI authentication is required " |
| 670 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 671 | } |
| 672 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 673 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 674 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 675 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 676 | |
| 677 | if (mbxstatus == MBXERR_ERROR) |
| 678 | return -EIO; |
| 679 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 680 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 681 | } |
| 682 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 683 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 684 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 685 | * @phba: lpfc_hba pointer. |
| 686 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 687 | * |
| 688 | * Notes: |
| 689 | * Assumes any error from lpfc_do_offline() will be negative. |
| 690 | * Can wait up to 5 seconds for the port ring buffers count |
| 691 | * 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] | 692 | * 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] | 693 | * |
| 694 | * Returns: |
| 695 | * -EIO error posting the event |
| 696 | * zero for success |
| 697 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 698 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 699 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 700 | { |
| 701 | struct completion online_compl; |
| 702 | struct lpfc_sli_ring *pring; |
| 703 | struct lpfc_sli *psli; |
| 704 | int status = 0; |
| 705 | int cnt = 0; |
| 706 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 707 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 708 | |
| 709 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 710 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 711 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 712 | if (rc == 0) |
| 713 | return -ENOMEM; |
| 714 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 715 | wait_for_completion(&online_compl); |
| 716 | |
| 717 | if (status != 0) |
| 718 | return -EIO; |
| 719 | |
| 720 | psli = &phba->sli; |
| 721 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 722 | /* Wait a little for things to settle down, but not |
| 723 | * long enough for dev loss timeout to expire. |
| 724 | */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 725 | for (i = 0; i < psli->num_rings; i++) { |
| 726 | pring = &psli->ring[i]; |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 727 | while (!list_empty(&pring->txcmplq)) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 728 | msleep(10); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 729 | if (cnt++ > 500) { /* 5 secs */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 730 | lpfc_printf_log(phba, |
| 731 | KERN_WARNING, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 732 | "0466 Outstanding IO when " |
| 733 | "bringing Adapter offline\n"); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 734 | break; |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 740 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 741 | if (rc == 0) |
| 742 | return -ENOMEM; |
| 743 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 744 | wait_for_completion(&online_compl); |
| 745 | |
| 746 | if (status != 0) |
| 747 | return -EIO; |
| 748 | |
| 749 | return 0; |
| 750 | } |
| 751 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 752 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 753 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 754 | * @phba: lpfc_hba pointer. |
| 755 | * |
| 756 | * Description: |
| 757 | * If the port is configured to allow a reset then the hba is brought |
| 758 | * offline then online. |
| 759 | * |
| 760 | * Notes: |
| 761 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 762 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 763 | * |
| 764 | * Returns: |
| 765 | * lpfc_do_offline() return code if not zero |
| 766 | * -EIO reset not configured or error posting the event |
| 767 | * zero for success |
| 768 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 769 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 770 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 771 | { |
| 772 | struct completion online_compl; |
| 773 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 774 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 775 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 776 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 777 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 778 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 779 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 780 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 781 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 782 | if (status != 0) |
| 783 | return status; |
| 784 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 785 | |
| 786 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 787 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 788 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 789 | if (rc == 0) |
| 790 | return -ENOMEM; |
| 791 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 792 | wait_for_completion(&online_compl); |
| 793 | |
| 794 | if (status != 0) |
| 795 | return -EIO; |
| 796 | |
| 797 | return 0; |
| 798 | } |
| 799 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 800 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 801 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 802 | * @dev: class device that is converted into a Scsi_host. |
| 803 | * @attr: device attribute, not used. |
| 804 | * @buf: containing the string "selective". |
| 805 | * @count: unused variable. |
| 806 | * |
| 807 | * Description: |
| 808 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 809 | * is called to perform the reset. |
| 810 | * |
| 811 | * Notes: |
| 812 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 813 | * 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] | 814 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 815 | * |
| 816 | * Returns: |
| 817 | * -EINVAL if the buffer does not contain the string "selective" |
| 818 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 819 | * return value of lpfc_selective_reset() if the call fails |
| 820 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 821 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 822 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 823 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 824 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 825 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 826 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 827 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 828 | int status = -EINVAL; |
| 829 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 830 | if (!phba->cfg_enable_hba_reset) |
| 831 | return -EACCES; |
| 832 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 833 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 834 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 835 | |
| 836 | if (status == 0) |
| 837 | return strlen(buf); |
| 838 | else |
| 839 | return status; |
| 840 | } |
| 841 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 842 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 843 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 844 | * @phba: lpfc_hba pointer. |
| 845 | * |
| 846 | * Description: |
| 847 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 848 | * the readyness after performing a firmware reset. |
| 849 | * |
| 850 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 851 | * 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] | 852 | * reset, -EIO when port timeout from recovering from the reset. |
| 853 | * |
| 854 | * Note: |
| 855 | * As the caller will interpret the return code by value, be careful in making |
| 856 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 857 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 858 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 859 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 860 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 861 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 862 | int i; |
| 863 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 864 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 865 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 866 | &portstat_reg.word0); |
| 867 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 868 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 869 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 870 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 871 | return -EPERM; |
| 872 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 873 | /* wait for the SLI port firmware ready after firmware reset */ |
| 874 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 875 | msleep(10); |
| 876 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 877 | &portstat_reg.word0); |
| 878 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 879 | continue; |
| 880 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 881 | continue; |
| 882 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 883 | continue; |
| 884 | break; |
| 885 | } |
| 886 | |
| 887 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 888 | return 0; |
| 889 | else |
| 890 | return -EIO; |
| 891 | } |
| 892 | |
| 893 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 894 | * 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] | 895 | * @phba: lpfc_hba pointer. |
| 896 | * |
| 897 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 898 | * Request SLI4 interface type-2 device to perform a physical register set |
| 899 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 900 | * |
| 901 | * Returns: |
| 902 | * zero for success |
| 903 | **/ |
| 904 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 905 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 906 | { |
| 907 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 908 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 909 | uint32_t before_fc_flag; |
| 910 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 911 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 912 | int status = 0, rc = 0; |
| 913 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 914 | |
| 915 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 916 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 917 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 918 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 919 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 920 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 921 | return -EPERM; |
| 922 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 923 | /* Keep state if we need to restore back */ |
| 924 | before_fc_flag = phba->pport->fc_flag; |
| 925 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 926 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 927 | /* Disable SR-IOV virtual functions if enabled */ |
| 928 | if (phba->cfg_sriov_nr_virtfn) { |
| 929 | pci_disable_sriov(pdev); |
| 930 | phba->cfg_sriov_nr_virtfn = 0; |
| 931 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 932 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 933 | if (opcode == LPFC_FW_DUMP) |
| 934 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 935 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 936 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 937 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 938 | if (status != 0) { |
| 939 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 940 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 941 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 942 | |
| 943 | /* wait for the device to be quiesced before firmware reset */ |
| 944 | msleep(100); |
| 945 | |
| 946 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 947 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 948 | |
| 949 | if (opcode == LPFC_FW_DUMP) |
| 950 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 951 | else if (opcode == LPFC_FW_RESET) |
| 952 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 953 | else if (opcode == LPFC_DV_RESET) |
| 954 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 955 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 956 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 957 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 958 | /* flush */ |
| 959 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 960 | |
| 961 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 962 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 963 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 964 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 965 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 966 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 967 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 968 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 969 | } else if (rc == -EIO) { |
| 970 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 971 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 972 | "3153 Fail to perform the requested " |
| 973 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 974 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | /* keep the original port state */ |
| 978 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 979 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 980 | |
| 981 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 982 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 983 | LPFC_EVT_ONLINE); |
| 984 | if (!job_posted) |
| 985 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 986 | |
| 987 | wait_for_completion(&online_compl); |
| 988 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 989 | out: |
| 990 | /* in any case, restore the virtual functions enabled as before */ |
| 991 | if (sriov_nr_virtfn) { |
| 992 | sriov_err = |
| 993 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 994 | if (!sriov_err) |
| 995 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 996 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 997 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 998 | /* return proper error code */ |
| 999 | if (!rc) { |
| 1000 | if (!job_posted) |
| 1001 | rc = -ENOMEM; |
| 1002 | else if (status) |
| 1003 | rc = -EIO; |
| 1004 | } |
| 1005 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1009 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1010 | * @dev: class device that is converted into a Scsi_host. |
| 1011 | * @attr: device attribute, not used. |
| 1012 | * @buf: on return contains the ascii number of nport events. |
| 1013 | * |
| 1014 | * Returns: size of formatted string. |
| 1015 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1016 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1017 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1018 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1019 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1020 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1021 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1022 | struct lpfc_hba *phba = vport->phba; |
| 1023 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1024 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1025 | } |
| 1026 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1027 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1028 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1029 | * @dev: class device that is converted into a Scsi_host. |
| 1030 | * @attr: device attribute, not used. |
| 1031 | * @buf: on return contains the state of the adapter. |
| 1032 | * |
| 1033 | * Returns: size of formatted string. |
| 1034 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1035 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1036 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1037 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1038 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1039 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1040 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1041 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1042 | char * state; |
| 1043 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1044 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1045 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1046 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1047 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1048 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1049 | state = "offline"; |
| 1050 | else |
| 1051 | state = "online"; |
| 1052 | |
| 1053 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1054 | } |
| 1055 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1056 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1057 | * 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] | 1058 | * @dev: class device that is converted into a Scsi_host. |
| 1059 | * @attr: device attribute, not used. |
| 1060 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1061 | * @count: unused variable. |
| 1062 | * |
| 1063 | * Returns: |
| 1064 | * -EACCES if enable hba reset not enabled |
| 1065 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1066 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1067 | * buf length greater than zero indicates success |
| 1068 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1069 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1070 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1071 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1072 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1073 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1074 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1075 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1076 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1077 | char *board_mode_str = NULL; |
| 1078 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1079 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1080 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1081 | if (!phba->cfg_enable_hba_reset) { |
| 1082 | status = -EACCES; |
| 1083 | goto board_mode_out; |
| 1084 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1085 | |
| 1086 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1087 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1088 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1089 | init_completion(&online_compl); |
| 1090 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1091 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1092 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1093 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1094 | if (rc == 0) { |
| 1095 | status = -ENOMEM; |
| 1096 | goto board_mode_out; |
| 1097 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1098 | wait_for_completion(&online_compl); |
| 1099 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1100 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1101 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1102 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1103 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1104 | else |
| 1105 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1106 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1107 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1108 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1109 | else |
| 1110 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1111 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1112 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1113 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1114 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1115 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1116 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1117 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1118 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1119 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1120 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1121 | if (!status) |
| 1122 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1123 | else { |
| 1124 | board_mode_str = strchr(buf, '\n'); |
| 1125 | if (board_mode_str) |
| 1126 | *board_mode_str = '\0'; |
| 1127 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1128 | "3097 Failed \"%s\", status(%d), " |
| 1129 | "fc_flag(x%x)\n", |
| 1130 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1131 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1132 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1133 | } |
| 1134 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1135 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1136 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1137 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1138 | * @mxri: max xri count. |
| 1139 | * @axri: available xri count. |
| 1140 | * @mrpi: max rpi count. |
| 1141 | * @arpi: available rpi count. |
| 1142 | * @mvpi: max vpi count. |
| 1143 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1144 | * |
| 1145 | * Description: |
| 1146 | * If an integer pointer for an count is not null then the value for the |
| 1147 | * count is returned. |
| 1148 | * |
| 1149 | * Returns: |
| 1150 | * zero on error |
| 1151 | * one for success |
| 1152 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1153 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1154 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1155 | uint32_t *mxri, uint32_t *axri, |
| 1156 | uint32_t *mrpi, uint32_t *arpi, |
| 1157 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1158 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1159 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1160 | LPFC_MBOXQ_t *pmboxq; |
| 1161 | MAILBOX_t *pmb; |
| 1162 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1163 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1164 | |
| 1165 | /* |
| 1166 | * prevent udev from issuing mailbox commands until the port is |
| 1167 | * configured. |
| 1168 | */ |
| 1169 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1170 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1171 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1172 | return 0; |
| 1173 | |
| 1174 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1175 | return 0; |
| 1176 | |
| 1177 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1178 | if (!pmboxq) |
| 1179 | return 0; |
| 1180 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1181 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1182 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1183 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1184 | pmb->mbxOwner = OWN_HOST; |
| 1185 | pmboxq->context1 = NULL; |
| 1186 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1187 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1188 | rc = MBX_NOT_FINISHED; |
| 1189 | else |
| 1190 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1191 | |
| 1192 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1193 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1194 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1195 | return 0; |
| 1196 | } |
| 1197 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1198 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1199 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1200 | if (mrpi) |
| 1201 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1202 | if (arpi) |
| 1203 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1204 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1205 | if (mxri) |
| 1206 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1207 | if (axri) |
| 1208 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1209 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1210 | |
| 1211 | /* Account for differences with SLI-3. Get vpi count from |
| 1212 | * mailbox data and subtract one for max vpi value. |
| 1213 | */ |
| 1214 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1215 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1216 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1217 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1218 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1219 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1220 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1221 | } else { |
| 1222 | if (mrpi) |
| 1223 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1224 | if (arpi) |
| 1225 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1226 | if (mxri) |
| 1227 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1228 | if (axri) |
| 1229 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1230 | if (mvpi) |
| 1231 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1232 | if (avpi) |
| 1233 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1234 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1235 | |
| 1236 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1237 | return 1; |
| 1238 | } |
| 1239 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1240 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1241 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1242 | * @dev: class device that is converted into a Scsi_host. |
| 1243 | * @attr: device attribute, not used. |
| 1244 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1245 | * |
| 1246 | * Description: |
| 1247 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1248 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1249 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1250 | * must check for "Unknown" in the buffer to detect a failure. |
| 1251 | * |
| 1252 | * Returns: size of formatted string. |
| 1253 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1254 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1255 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1256 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1257 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1258 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1259 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1260 | struct lpfc_hba *phba = vport->phba; |
| 1261 | uint32_t cnt; |
| 1262 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1263 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1264 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1265 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1266 | } |
| 1267 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1268 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1269 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1270 | * @dev: class device that is converted into a Scsi_host. |
| 1271 | * @attr: device attribute, not used. |
| 1272 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1273 | * |
| 1274 | * Description: |
| 1275 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1276 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1277 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1278 | * must check for "Unknown" in the buffer to detect a failure. |
| 1279 | * |
| 1280 | * Returns: size of formatted string. |
| 1281 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1282 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1283 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1284 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1285 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1286 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1287 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1288 | struct lpfc_hba *phba = vport->phba; |
| 1289 | uint32_t cnt, acnt; |
| 1290 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1291 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1292 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1293 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1294 | } |
| 1295 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1296 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1297 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1298 | * @dev: class device that is converted into a Scsi_host. |
| 1299 | * @attr: device attribute, not used. |
| 1300 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1301 | * |
| 1302 | * Description: |
| 1303 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1304 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1305 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1306 | * must check for "Unknown" in the buffer to detect a failure. |
| 1307 | * |
| 1308 | * Returns: size of formatted string. |
| 1309 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1310 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1311 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1312 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1313 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1314 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1315 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1316 | struct lpfc_hba *phba = vport->phba; |
| 1317 | uint32_t cnt; |
| 1318 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1319 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1320 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1321 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1322 | } |
| 1323 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1324 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1325 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1326 | * @dev: class device that is converted into a Scsi_host. |
| 1327 | * @attr: device attribute, not used. |
| 1328 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1329 | * |
| 1330 | * Description: |
| 1331 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1332 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1333 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1334 | * must check for "Unknown" in the buffer to detect a failure. |
| 1335 | * |
| 1336 | * Returns: size of formatted string. |
| 1337 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1338 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1339 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1340 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1341 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1342 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1343 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1344 | struct lpfc_hba *phba = vport->phba; |
| 1345 | uint32_t cnt, acnt; |
| 1346 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1347 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1348 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1349 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1350 | } |
| 1351 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1352 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1353 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1354 | * @dev: class device that is converted into a Scsi_host. |
| 1355 | * @attr: device attribute, not used. |
| 1356 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1357 | * |
| 1358 | * Description: |
| 1359 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1360 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1361 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1362 | * must check for "Unknown" in the buffer to detect a failure. |
| 1363 | * |
| 1364 | * Returns: size of formatted string. |
| 1365 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1366 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1367 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1368 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1369 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1370 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1371 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1372 | struct lpfc_hba *phba = vport->phba; |
| 1373 | uint32_t cnt; |
| 1374 | |
| 1375 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1376 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1377 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1378 | } |
| 1379 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1380 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1381 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1382 | * @dev: class device that is converted into a Scsi_host. |
| 1383 | * @attr: device attribute, not used. |
| 1384 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1385 | * |
| 1386 | * Description: |
| 1387 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1388 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1389 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1390 | * must check for "Unknown" in the buffer to detect a failure. |
| 1391 | * |
| 1392 | * Returns: size of formatted string. |
| 1393 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1394 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1395 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1396 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1397 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1398 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1399 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1400 | struct lpfc_hba *phba = vport->phba; |
| 1401 | uint32_t cnt, acnt; |
| 1402 | |
| 1403 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1404 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1405 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1406 | } |
| 1407 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1408 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1409 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1410 | * @dev: class device that is converted into a Scsi_host. |
| 1411 | * @attr: device attribute, not used. |
| 1412 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1413 | * |
| 1414 | * Description: |
| 1415 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1416 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1417 | * the id of the vport. |
| 1418 | * |
| 1419 | * Returns: size of formatted string. |
| 1420 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1421 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1422 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1423 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1424 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1425 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1426 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1427 | struct lpfc_hba *phba = vport->phba; |
| 1428 | |
| 1429 | if (!(phba->max_vpi)) |
| 1430 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1431 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1432 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1433 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1434 | } |
| 1435 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1436 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1437 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1438 | * @dev: class device that is converted into a Scsi_host. |
| 1439 | * @attr: device attribute, not used. |
| 1440 | * @buf: on return contains the cfg_poll in hex. |
| 1441 | * |
| 1442 | * Notes: |
| 1443 | * cfg_poll should be a lpfc_polling_flags type. |
| 1444 | * |
| 1445 | * Returns: size of formatted string. |
| 1446 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1447 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1448 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1449 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1450 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1451 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1452 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1453 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1454 | |
| 1455 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1456 | } |
| 1457 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1458 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1459 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1460 | * @dev: class device that is converted into a Scsi_host. |
| 1461 | * @attr: device attribute, not used. |
| 1462 | * @buf: one or more lpfc_polling_flags values. |
| 1463 | * @count: not used. |
| 1464 | * |
| 1465 | * Notes: |
| 1466 | * buf contents converted to integer and checked for a valid value. |
| 1467 | * |
| 1468 | * Returns: |
| 1469 | * -EINVAL if the buffer connot be converted or is out of range |
| 1470 | * length of the buf on success |
| 1471 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1472 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1473 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1474 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1475 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1476 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1477 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1478 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1479 | uint32_t creg_val; |
| 1480 | uint32_t old_val; |
| 1481 | int val=0; |
| 1482 | |
| 1483 | if (!isdigit(buf[0])) |
| 1484 | return -EINVAL; |
| 1485 | |
| 1486 | if (sscanf(buf, "%i", &val) != 1) |
| 1487 | return -EINVAL; |
| 1488 | |
| 1489 | if ((val & 0x3) != val) |
| 1490 | return -EINVAL; |
| 1491 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1492 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1493 | val = 0; |
| 1494 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1495 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1496 | "3051 lpfc_poll changed from %d to %d\n", |
| 1497 | phba->cfg_poll, val); |
| 1498 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1499 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1500 | |
| 1501 | old_val = phba->cfg_poll; |
| 1502 | |
| 1503 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1504 | if ((val & DISABLE_FCP_RING_INT) && |
| 1505 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1506 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1507 | spin_unlock_irq(&phba->hbalock); |
| 1508 | return -EINVAL; |
| 1509 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1510 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1511 | writel(creg_val, phba->HCregaddr); |
| 1512 | readl(phba->HCregaddr); /* flush */ |
| 1513 | |
| 1514 | lpfc_poll_start_timer(phba); |
| 1515 | } |
| 1516 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1517 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1518 | return -EINVAL; |
| 1519 | } |
| 1520 | |
| 1521 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1522 | (old_val & DISABLE_FCP_RING_INT)) |
| 1523 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1524 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1525 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1526 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1527 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1528 | spin_unlock_irq(&phba->hbalock); |
| 1529 | return -EINVAL; |
| 1530 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1531 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1532 | writel(creg_val, phba->HCregaddr); |
| 1533 | readl(phba->HCregaddr); /* flush */ |
| 1534 | } |
| 1535 | |
| 1536 | phba->cfg_poll = val; |
| 1537 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1538 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1539 | |
| 1540 | return strlen(buf); |
| 1541 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1542 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1543 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1544 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1545 | * @dev: class unused variable. |
| 1546 | * @attr: device attribute, not used. |
| 1547 | * @buf: on return contains the module description text. |
| 1548 | * |
| 1549 | * Returns: size of formatted string. |
| 1550 | **/ |
| 1551 | static ssize_t |
| 1552 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1553 | char *buf) |
| 1554 | { |
| 1555 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1556 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1557 | struct lpfc_hba *phba = vport->phba; |
| 1558 | |
| 1559 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1560 | } |
| 1561 | |
| 1562 | /** |
| 1563 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1564 | * @dev: class unused variable. |
| 1565 | * @attr: device attribute, not used. |
| 1566 | * @buf: on return contains the module description text. |
| 1567 | * |
| 1568 | * Returns: size of formatted string. |
| 1569 | **/ |
| 1570 | static ssize_t |
| 1571 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1572 | char *buf) |
| 1573 | { |
| 1574 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1575 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1576 | struct lpfc_hba *phba = vport->phba; |
| 1577 | |
| 1578 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1579 | } |
| 1580 | |
| 1581 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1582 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1583 | * @dev: class converted to a Scsi_host structure. |
| 1584 | * @attr: device attribute, not used. |
| 1585 | * @buf: on return contains the formatted text. |
| 1586 | * |
| 1587 | * Returns: size of formatted string. |
| 1588 | **/ |
| 1589 | static ssize_t |
| 1590 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1591 | char *buf) |
| 1592 | { |
| 1593 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1594 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1595 | struct lpfc_hba *phba = vport->phba; |
| 1596 | |
| 1597 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1598 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1599 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1600 | "" : "Not "); |
| 1601 | } |
| 1602 | |
| 1603 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1604 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1605 | * @dev: class converted to a Scsi_host structure. |
| 1606 | * @attr: device attribute, not used. |
| 1607 | * @buf: on return contains the formatted support level. |
| 1608 | * |
| 1609 | * Description: |
| 1610 | * Returns the maximum number of virtual functions a physical function can |
| 1611 | * support, 0 will be returned if called on virtual function. |
| 1612 | * |
| 1613 | * Returns: size of formatted string. |
| 1614 | **/ |
| 1615 | static ssize_t |
| 1616 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1617 | struct device_attribute *attr, |
| 1618 | char *buf) |
| 1619 | { |
| 1620 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1621 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1622 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1623 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1624 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1625 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1626 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1627 | } |
| 1628 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1629 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 1630 | { |
| 1631 | return val >= min && val <= max; |
| 1632 | } |
| 1633 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1634 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1635 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1636 | * |
| 1637 | * Description: |
| 1638 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1639 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1640 | * |
| 1641 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1642 | * @dev: class device that is converted into a Scsi_host. |
| 1643 | * @attr: device attribute, not used. |
| 1644 | * @buf: on return contains the attribute value in decimal. |
| 1645 | * |
| 1646 | * Returns: size of formatted string. |
| 1647 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1648 | #define lpfc_param_show(attr) \ |
| 1649 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1650 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1651 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1652 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1653 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1654 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1655 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1656 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1657 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1658 | } |
| 1659 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1660 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1661 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1662 | * |
| 1663 | * Description: |
| 1664 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1665 | * into a function with the name lpfc_hba_queue_depth_show |
| 1666 | * |
| 1667 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1668 | * @dev: class device that is converted into a Scsi_host. |
| 1669 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1670 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1671 | * |
| 1672 | * Returns: size of formatted string. |
| 1673 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1674 | #define lpfc_param_hex_show(attr) \ |
| 1675 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1676 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1677 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1678 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1679 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1680 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1681 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1682 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1683 | val = phba->cfg_##attr;\ |
| 1684 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1685 | phba->cfg_##attr);\ |
| 1686 | } |
| 1687 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1688 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1689 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1690 | * |
| 1691 | * Description: |
| 1692 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1693 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1694 | * takes a default argument, a minimum and maximum argument. |
| 1695 | * |
| 1696 | * lpfc_##attr##_init: Initializes an attribute. |
| 1697 | * @phba: pointer the the adapter structure. |
| 1698 | * @val: integer attribute value. |
| 1699 | * |
| 1700 | * Validates the min and max values then sets the adapter config field |
| 1701 | * accordingly, or uses the default if out of range and prints an error message. |
| 1702 | * |
| 1703 | * Returns: |
| 1704 | * zero on success |
| 1705 | * -EINVAL if default used |
| 1706 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1707 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1708 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1709 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1710 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1711 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1712 | phba->cfg_##attr = val;\ |
| 1713 | return 0;\ |
| 1714 | }\ |
| 1715 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1716 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1717 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1718 | phba->cfg_##attr = default;\ |
| 1719 | return -EINVAL;\ |
| 1720 | } |
| 1721 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1722 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1723 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1724 | * |
| 1725 | * Description: |
| 1726 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1727 | * into a function with the name lpfc_hba_queue_depth_set |
| 1728 | * |
| 1729 | * lpfc_##attr##_set: Sets an attribute value. |
| 1730 | * @phba: pointer the the adapter structure. |
| 1731 | * @val: integer attribute value. |
| 1732 | * |
| 1733 | * Description: |
| 1734 | * Validates the min and max values then sets the |
| 1735 | * adapter config field if in the valid range. prints error message |
| 1736 | * and does not set the parameter if invalid. |
| 1737 | * |
| 1738 | * Returns: |
| 1739 | * zero on success |
| 1740 | * -EINVAL if val is invalid |
| 1741 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1742 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1743 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1744 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1745 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1746 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1747 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 1748 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 1749 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1750 | phba->cfg_##attr = val;\ |
| 1751 | return 0;\ |
| 1752 | }\ |
| 1753 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1754 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1755 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1756 | return -EINVAL;\ |
| 1757 | } |
| 1758 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1759 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1760 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1761 | * |
| 1762 | * Description: |
| 1763 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1764 | * into a function with the name lpfc_hba_queue_depth_store. |
| 1765 | * |
| 1766 | * lpfc_##attr##_store: Set an sttribute value. |
| 1767 | * @dev: class device that is converted into a Scsi_host. |
| 1768 | * @attr: device attribute, not used. |
| 1769 | * @buf: contains the attribute value in ascii. |
| 1770 | * @count: not used. |
| 1771 | * |
| 1772 | * Description: |
| 1773 | * Convert the ascii text number to an integer, then |
| 1774 | * use the lpfc_##attr##_set function to set the value. |
| 1775 | * |
| 1776 | * Returns: |
| 1777 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1778 | * length of buffer upon success. |
| 1779 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1780 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1781 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1782 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1783 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1784 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1785 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1786 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1787 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1788 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1789 | if (!isdigit(buf[0]))\ |
| 1790 | return -EINVAL;\ |
| 1791 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1792 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1793 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 1794 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1795 | else \ |
| 1796 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1797 | } |
| 1798 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1799 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1800 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1801 | * |
| 1802 | * Description: |
| 1803 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1804 | * into a function with the name lpfc_hba_queue_depth_show |
| 1805 | * |
| 1806 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 1807 | * @dev: class device that is converted into a Scsi_host. |
| 1808 | * @attr: device attribute, not used. |
| 1809 | * @buf: on return contains the attribute value in decimal. |
| 1810 | * |
| 1811 | * Returns: length of formatted string. |
| 1812 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1813 | #define lpfc_vport_param_show(attr) \ |
| 1814 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1815 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1816 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1817 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1818 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1819 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1820 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 1821 | } |
| 1822 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1823 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1824 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1825 | * |
| 1826 | * Description: |
| 1827 | * Macro that given an attr e.g. |
| 1828 | * hba_queue_depth expands into a function with the name |
| 1829 | * lpfc_hba_queue_depth_show |
| 1830 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1831 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1832 | * @dev: class device that is converted into a Scsi_host. |
| 1833 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1834 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1835 | * |
| 1836 | * Returns: length of formatted string. |
| 1837 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1838 | #define lpfc_vport_param_hex_show(attr) \ |
| 1839 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1840 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1841 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1842 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1843 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1844 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1845 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 1846 | } |
| 1847 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1848 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1849 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1850 | * |
| 1851 | * Description: |
| 1852 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1853 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1854 | * takes a default argument, a minimum and maximum argument. |
| 1855 | * |
| 1856 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 1857 | * adapter config field accordingly, or uses the default if out of range |
| 1858 | * and prints an error message. |
| 1859 | * @phba: pointer the the adapter structure. |
| 1860 | * @val: integer attribute value. |
| 1861 | * |
| 1862 | * Returns: |
| 1863 | * zero on success |
| 1864 | * -EINVAL if default used |
| 1865 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1866 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 1867 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1868 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1869 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1870 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1871 | vport->cfg_##attr = val;\ |
| 1872 | return 0;\ |
| 1873 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1874 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1875 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1876 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1877 | vport->cfg_##attr = default;\ |
| 1878 | return -EINVAL;\ |
| 1879 | } |
| 1880 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1881 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1882 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1883 | * |
| 1884 | * Description: |
| 1885 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1886 | * into a function with the name lpfc_hba_queue_depth_set |
| 1887 | * |
| 1888 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 1889 | * adapter config field if in the valid range. prints error message |
| 1890 | * and does not set the parameter if invalid. |
| 1891 | * @phba: pointer the the adapter structure. |
| 1892 | * @val: integer attribute value. |
| 1893 | * |
| 1894 | * Returns: |
| 1895 | * zero on success |
| 1896 | * -EINVAL if val is invalid |
| 1897 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1898 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 1899 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1900 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1901 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1902 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1903 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 1904 | "3053 lpfc_" #attr \ |
| 1905 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 1906 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 1907 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1908 | vport->cfg_##attr = val;\ |
| 1909 | return 0;\ |
| 1910 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1911 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1912 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1913 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1914 | return -EINVAL;\ |
| 1915 | } |
| 1916 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1917 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1918 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1919 | * |
| 1920 | * Description: |
| 1921 | * Macro that given an attr e.g. hba_queue_depth |
| 1922 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 1923 | * |
| 1924 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 1925 | * use the lpfc_##attr##_set function to set the value. |
| 1926 | * @cdev: class device that is converted into a Scsi_host. |
| 1927 | * @buf: contains the attribute value in decimal. |
| 1928 | * @count: not used. |
| 1929 | * |
| 1930 | * Returns: |
| 1931 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1932 | * length of buffer upon success. |
| 1933 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1934 | #define lpfc_vport_param_store(attr) \ |
| 1935 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1936 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1937 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1938 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1939 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1940 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1941 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1942 | if (!isdigit(buf[0]))\ |
| 1943 | return -EINVAL;\ |
| 1944 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1945 | return -EINVAL;\ |
| 1946 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 1947 | return strlen(buf);\ |
| 1948 | else \ |
| 1949 | return -EINVAL;\ |
| 1950 | } |
| 1951 | |
| 1952 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 1953 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 1954 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 1955 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 1956 | 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] | 1957 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 1958 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 1959 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 1960 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 1961 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 1962 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 1963 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 1964 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1965 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 1966 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1967 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 1968 | lpfc_option_rom_version_show, NULL); |
| 1969 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 1970 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 1971 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1972 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 1973 | 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] | 1974 | 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] | 1975 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 1976 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 1977 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 1978 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 1979 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 1980 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 1981 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 1982 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 1983 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 1984 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 1985 | 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] | 1986 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 1987 | 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] | 1988 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1989 | static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, |
| 1990 | lpfc_sriov_hw_max_virtfn_show, NULL); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1991 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1992 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 1993 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1994 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1995 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1996 | #define WWN_SZ 8 |
| 1997 | /** |
| 1998 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 1999 | * @buf: WWN string. |
| 2000 | * @cnt: Length of string. |
| 2001 | * @wwn: Array to receive converted wwn value. |
| 2002 | * |
| 2003 | * Returns: |
| 2004 | * -EINVAL if the buffer does not contain a valid wwn |
| 2005 | * 0 success |
| 2006 | **/ |
| 2007 | static size_t |
| 2008 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2009 | { |
| 2010 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2011 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2012 | /* Count may include a LF at end of string */ |
| 2013 | if (buf[cnt-1] == '\n') |
| 2014 | cnt--; |
| 2015 | |
| 2016 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2017 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2018 | return -EINVAL; |
| 2019 | |
| 2020 | memset(wwn, 0, WWN_SZ); |
| 2021 | |
| 2022 | /* Validate and store the new name */ |
| 2023 | for (i = 0, j = 0; i < 16; i++) { |
| 2024 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2025 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2026 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2027 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2028 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2029 | j = ((j << 4) | (*buf++ - '0')); |
| 2030 | else |
| 2031 | return -EINVAL; |
| 2032 | if (i % 2) { |
| 2033 | wwn[i/2] = j & 0xff; |
| 2034 | j = 0; |
| 2035 | } |
| 2036 | } |
| 2037 | return 0; |
| 2038 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2039 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2040 | * 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] | 2041 | * @dev: class device that is converted into a Scsi_host. |
| 2042 | * @attr: device attribute, not used. |
| 2043 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2044 | * @count: must be size of lpfc_soft_wwn_key. |
| 2045 | * |
| 2046 | * Returns: |
| 2047 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2048 | * length of buf indicates success |
| 2049 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2050 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2051 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2052 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2053 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2054 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2055 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2056 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2057 | unsigned int cnt = count; |
| 2058 | |
| 2059 | /* |
| 2060 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2061 | * We require that the user write a specific key to enable |
| 2062 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2063 | * is written, the enable key resets. If further updates are |
| 2064 | * desired, the key must be written again to re-enable the |
| 2065 | * attribute. |
| 2066 | * |
| 2067 | * The "key" is not secret - it is a hardcoded string shown |
| 2068 | * here. The intent is to protect against the random user or |
| 2069 | * application that is just writing attributes. |
| 2070 | */ |
| 2071 | |
| 2072 | /* count may include a LF at end of string */ |
| 2073 | if (buf[cnt-1] == '\n') |
| 2074 | cnt--; |
| 2075 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2076 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2077 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2078 | return -EINVAL; |
| 2079 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2080 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2081 | return count; |
| 2082 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2083 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 2084 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2085 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2086 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2087 | * 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] | 2088 | * @dev: class device that is converted into a Scsi_host. |
| 2089 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2090 | * @buf: on return contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2091 | * |
| 2092 | * Returns: size of formatted string. |
| 2093 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2094 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2095 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2096 | char *buf) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2097 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2098 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2099 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2100 | struct lpfc_hba *phba = vport->phba; |
| 2101 | |
Randy Dunlap | afc071e | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 2102 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2103 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2104 | } |
| 2105 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2106 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2107 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2108 | * @dev class device that is converted into a Scsi_host. |
| 2109 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2110 | * @buf: contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2111 | * @count: number of wwpn bytes in buf |
| 2112 | * |
| 2113 | * Returns: |
| 2114 | * -EACCES hba reset not enabled, adapter over temp |
| 2115 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2116 | * -EIO error taking adapter offline or online |
| 2117 | * value of count on success |
| 2118 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2119 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2120 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2121 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2122 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2123 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2124 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2125 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2126 | struct completion online_compl; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2127 | int stat1 = 0, stat2 = 0; |
| 2128 | unsigned int cnt = count; |
| 2129 | u8 wwpn[WWN_SZ]; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2130 | int rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2131 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 2132 | if (!phba->cfg_enable_hba_reset) |
| 2133 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2134 | spin_lock_irq(&phba->hbalock); |
| 2135 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2136 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 2137 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2138 | } |
| 2139 | spin_unlock_irq(&phba->hbalock); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2140 | /* count may include a LF at end of string */ |
| 2141 | if (buf[cnt-1] == '\n') |
| 2142 | cnt--; |
| 2143 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2144 | if (!phba->soft_wwn_enable) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2145 | return -EINVAL; |
| 2146 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2147 | /* lock setting wwpn, wwnn down */ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2148 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2149 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2150 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2151 | if (!rc) { |
| 2152 | /* not able to set wwpn, unlock it */ |
| 2153 | phba->soft_wwn_enable = 1; |
| 2154 | return rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2155 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2156 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2157 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2158 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2159 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2160 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2161 | |
| 2162 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2163 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2164 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 2165 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2166 | if (stat1) |
| 2167 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2168 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2169 | "reinit adapter - %d\n", stat1); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2170 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2171 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2172 | LPFC_EVT_ONLINE); |
| 2173 | if (rc == 0) |
| 2174 | return -ENOMEM; |
| 2175 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2176 | wait_for_completion(&online_compl); |
| 2177 | if (stat2) |
| 2178 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2179 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2180 | "reinit adapter - %d\n", stat2); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2181 | return (stat1 || stat2) ? -EIO : count; |
| 2182 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2183 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2184 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2185 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2186 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2187 | * 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] | 2188 | * @dev: class device that is converted into a Scsi_host. |
| 2189 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2190 | * @buf: on return contains the wwnn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2191 | * |
| 2192 | * Returns: size of formatted string. |
| 2193 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2194 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2195 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2196 | char *buf) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2197 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2198 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2199 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2200 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2201 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2202 | } |
| 2203 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2204 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2205 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2206 | * @cdev: class device that is converted into a Scsi_host. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2207 | * @buf: contains the ww node name in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2208 | * @count: number of wwnn bytes in buf. |
| 2209 | * |
| 2210 | * Returns: |
| 2211 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2212 | * value of count on success |
| 2213 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2214 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2215 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2216 | const char *buf, size_t count) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2217 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2218 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2219 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2220 | unsigned int cnt = count; |
| 2221 | u8 wwnn[WWN_SZ]; |
| 2222 | int rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2223 | |
| 2224 | /* count may include a LF at end of string */ |
| 2225 | if (buf[cnt-1] == '\n') |
| 2226 | cnt--; |
| 2227 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2228 | if (!phba->soft_wwn_enable) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2229 | return -EINVAL; |
| 2230 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2231 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
| 2232 | if (!rc) { |
| 2233 | /* Allow wwnn to be set many times, as long as the enable |
| 2234 | * is set. However, once the wwpn is set, everything locks. |
| 2235 | */ |
| 2236 | return rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2237 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2238 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2239 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2240 | |
| 2241 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2242 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2243 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2244 | |
| 2245 | return count; |
| 2246 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2247 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2248 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2249 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2250 | /** |
| 2251 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2252 | * Optimized Access Storage (OAS) operations. |
| 2253 | * @dev: class device that is converted into a Scsi_host. |
| 2254 | * @attr: device attribute, not used. |
| 2255 | * @buf: buffer for passing information. |
| 2256 | * |
| 2257 | * Returns: |
| 2258 | * value of count |
| 2259 | **/ |
| 2260 | static ssize_t |
| 2261 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2262 | char *buf) |
| 2263 | { |
| 2264 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2265 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2266 | |
| 2267 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2268 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2269 | } |
| 2270 | |
| 2271 | /** |
| 2272 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2273 | * Optimized Access Storage (OAS) operations. |
| 2274 | * @dev: class device that is converted into a Scsi_host. |
| 2275 | * @attr: device attribute, not used. |
| 2276 | * @buf: buffer for passing information. |
| 2277 | * @count: Size of the data buffer. |
| 2278 | * |
| 2279 | * Returns: |
| 2280 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2281 | * -EPERM oas is not supported by hba |
| 2282 | * value of count on success |
| 2283 | **/ |
| 2284 | static ssize_t |
| 2285 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2286 | const char *buf, size_t count) |
| 2287 | { |
| 2288 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2289 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2290 | unsigned int cnt = count; |
| 2291 | uint8_t wwpn[WWN_SZ]; |
| 2292 | int rc; |
| 2293 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2294 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2295 | return -EPERM; |
| 2296 | |
| 2297 | /* count may include a LF at end of string */ |
| 2298 | if (buf[cnt-1] == '\n') |
| 2299 | cnt--; |
| 2300 | |
| 2301 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2302 | if (rc) |
| 2303 | return rc; |
| 2304 | |
| 2305 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2306 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2307 | if (wwn_to_u64(wwpn) == 0) |
| 2308 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2309 | else |
| 2310 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2311 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2312 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2313 | return count; |
| 2314 | } |
| 2315 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2316 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2317 | |
| 2318 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2319 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2320 | * Optimized Access Storage (OAS) operations. |
| 2321 | * @dev: class device that is converted into a Scsi_host. |
| 2322 | * @attr: device attribute, not used. |
| 2323 | * @buf: buffer for passing information. |
| 2324 | * |
| 2325 | * Returns: |
| 2326 | * value of count |
| 2327 | **/ |
| 2328 | static ssize_t |
| 2329 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2330 | char *buf) |
| 2331 | { |
| 2332 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2333 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2334 | |
| 2335 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2336 | } |
| 2337 | |
| 2338 | /** |
| 2339 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2340 | * Optimized Access Storage (OAS) operations. |
| 2341 | * @dev: class device that is converted into a Scsi_host. |
| 2342 | * @attr: device attribute, not used. |
| 2343 | * @buf: buffer for passing information. |
| 2344 | * @count: Size of the data buffer. |
| 2345 | * |
| 2346 | * Returns: |
| 2347 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2348 | * -EPERM oas is not supported by hba |
| 2349 | * value of count on success |
| 2350 | **/ |
| 2351 | static ssize_t |
| 2352 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2353 | const char *buf, size_t count) |
| 2354 | { |
| 2355 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2356 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2357 | unsigned int cnt = count; |
| 2358 | unsigned long val; |
| 2359 | int ret; |
| 2360 | |
| 2361 | if (!phba->cfg_fof) |
| 2362 | return -EPERM; |
| 2363 | |
| 2364 | /* count may include a LF at end of string */ |
| 2365 | if (buf[cnt-1] == '\n') |
| 2366 | cnt--; |
| 2367 | |
| 2368 | ret = kstrtoul(buf, 0, &val); |
| 2369 | if (ret || (val > 0x7f)) |
| 2370 | return -EINVAL; |
| 2371 | |
| 2372 | if (val) |
| 2373 | phba->cfg_oas_priority = (uint8_t)val; |
| 2374 | else |
| 2375 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2376 | return count; |
| 2377 | } |
| 2378 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2379 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2380 | |
| 2381 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2382 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2383 | * for Optimized Access Storage (OAS) operations. |
| 2384 | * @dev: class device that is converted into a Scsi_host. |
| 2385 | * @attr: device attribute, not used. |
| 2386 | * @buf: buffer for passing information. |
| 2387 | * |
| 2388 | * Returns: |
| 2389 | * value of count on success |
| 2390 | **/ |
| 2391 | static ssize_t |
| 2392 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2393 | char *buf) |
| 2394 | { |
| 2395 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2396 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2397 | |
| 2398 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2399 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2400 | } |
| 2401 | |
| 2402 | /** |
| 2403 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2404 | * for Optimized Access Storage (OAS) operations. |
| 2405 | * @dev: class device that is converted into a Scsi_host. |
| 2406 | * @attr: device attribute, not used. |
| 2407 | * @buf: buffer for passing information. |
| 2408 | * @count: Size of the data buffer. |
| 2409 | * |
| 2410 | * Returns: |
| 2411 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2412 | * -EPERM oas is not supported by hba |
| 2413 | * value of count on success |
| 2414 | **/ |
| 2415 | static ssize_t |
| 2416 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2417 | const char *buf, size_t count) |
| 2418 | { |
| 2419 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2420 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2421 | unsigned int cnt = count; |
| 2422 | uint8_t wwpn[WWN_SZ]; |
| 2423 | int rc; |
| 2424 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2425 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2426 | return -EPERM; |
| 2427 | |
| 2428 | /* count may include a LF at end of string */ |
| 2429 | if (buf[cnt-1] == '\n') |
| 2430 | cnt--; |
| 2431 | |
| 2432 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2433 | if (rc) |
| 2434 | return rc; |
| 2435 | |
| 2436 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2437 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2438 | if (wwn_to_u64(wwpn) == 0) |
| 2439 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2440 | else |
| 2441 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2442 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2443 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2444 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2445 | return count; |
| 2446 | } |
| 2447 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2448 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2449 | |
| 2450 | /** |
| 2451 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2452 | * of whether luns will be enabled or disabled |
| 2453 | * for Optimized Access Storage (OAS) operations. |
| 2454 | * @dev: class device that is converted into a Scsi_host. |
| 2455 | * @attr: device attribute, not used. |
| 2456 | * @buf: buffer for passing information. |
| 2457 | * |
| 2458 | * Returns: |
| 2459 | * size of formatted string. |
| 2460 | **/ |
| 2461 | static ssize_t |
| 2462 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2463 | char *buf) |
| 2464 | { |
| 2465 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2466 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2467 | |
| 2468 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2469 | } |
| 2470 | |
| 2471 | /** |
| 2472 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2473 | * of whether luns will be enabled or disabled |
| 2474 | * for Optimized Access Storage (OAS) operations. |
| 2475 | * @dev: class device that is converted into a Scsi_host. |
| 2476 | * @attr: device attribute, not used. |
| 2477 | * @buf: buffer for passing information. |
| 2478 | * @count: Size of the data buffer. |
| 2479 | * |
| 2480 | * Returns: |
| 2481 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2482 | * -EPERM oas is not supported by hba |
| 2483 | * value of count on success |
| 2484 | **/ |
| 2485 | static ssize_t |
| 2486 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2487 | const char *buf, size_t count) |
| 2488 | { |
| 2489 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2490 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2491 | int val = 0; |
| 2492 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2493 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2494 | return -EPERM; |
| 2495 | |
| 2496 | if (!isdigit(buf[0])) |
| 2497 | return -EINVAL; |
| 2498 | |
| 2499 | if (sscanf(buf, "%i", &val) != 1) |
| 2500 | return -EINVAL; |
| 2501 | |
| 2502 | if ((val != 0) && (val != 1)) |
| 2503 | return -EINVAL; |
| 2504 | |
| 2505 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2506 | return strlen(buf); |
| 2507 | } |
| 2508 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2509 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2510 | |
| 2511 | /** |
| 2512 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2513 | * Storage (OAS) lun returned by the |
| 2514 | * lpfc_oas_lun_show function. |
| 2515 | * @dev: class device that is converted into a Scsi_host. |
| 2516 | * @attr: device attribute, not used. |
| 2517 | * @buf: buffer for passing information. |
| 2518 | * |
| 2519 | * Returns: |
| 2520 | * size of formatted string. |
| 2521 | **/ |
| 2522 | static ssize_t |
| 2523 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2524 | char *buf) |
| 2525 | { |
| 2526 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2527 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2528 | |
| 2529 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2530 | return -EFAULT; |
| 2531 | |
| 2532 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2533 | } |
| 2534 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2535 | lpfc_oas_lun_status_show, NULL); |
| 2536 | |
| 2537 | |
| 2538 | /** |
| 2539 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2540 | * (OAS) operations. |
| 2541 | * @phba: lpfc_hba pointer. |
| 2542 | * @ndlp: pointer to fcp target node. |
| 2543 | * @lun: the fc lun for setting oas state. |
| 2544 | * @oas_state: the oas state to be set to the lun. |
| 2545 | * |
| 2546 | * Returns: |
| 2547 | * SUCCESS : 0 |
| 2548 | * -EPERM OAS is not enabled or not supported by this port. |
| 2549 | * |
| 2550 | */ |
| 2551 | static size_t |
| 2552 | lpfc_oas_lun_state_set(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2553 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2554 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2555 | { |
| 2556 | |
| 2557 | int rc = 0; |
| 2558 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2559 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2560 | return -EPERM; |
| 2561 | |
| 2562 | if (oas_state) { |
| 2563 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2564 | (struct lpfc_name *)tgt_wwpn, |
| 2565 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2566 | rc = -ENOMEM; |
| 2567 | } else { |
| 2568 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
| 2569 | (struct lpfc_name *)tgt_wwpn, lun); |
| 2570 | } |
| 2571 | return rc; |
| 2572 | |
| 2573 | } |
| 2574 | |
| 2575 | /** |
| 2576 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2577 | * Access Storage (OAS) operations. |
| 2578 | * @phba: lpfc_hba pointer. |
| 2579 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2580 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2581 | * @lun_status: status of the lun returned lun |
| 2582 | * |
| 2583 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2584 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2585 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2586 | * |
| 2587 | * Return: |
| 2588 | * lun that is OAS enabled for the vport/target |
| 2589 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2590 | */ |
| 2591 | static uint64_t |
| 2592 | lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2593 | uint8_t tgt_wwpn[], uint32_t *lun_status) |
| 2594 | { |
| 2595 | uint64_t found_lun; |
| 2596 | |
| 2597 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2598 | return NOT_OAS_ENABLED_LUN; |
| 2599 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2600 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2601 | (struct lpfc_name *) |
| 2602 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2603 | &phba->sli4_hba.oas_next_lun, |
| 2604 | (struct lpfc_name *)vpt_wwpn, |
| 2605 | (struct lpfc_name *)tgt_wwpn, |
| 2606 | &found_lun, lun_status)) |
| 2607 | return found_lun; |
| 2608 | else |
| 2609 | return NOT_OAS_ENABLED_LUN; |
| 2610 | } |
| 2611 | |
| 2612 | /** |
| 2613 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2614 | * @phba: lpfc_hba pointer. |
| 2615 | * @vpt_wwpn: vport wwpn by reference. |
| 2616 | * @tgt_wwpn: target wwpn by reference. |
| 2617 | * @lun: the fc lun for setting oas state. |
| 2618 | * @oas_state: the oas state to be set to the oas_lun. |
| 2619 | * |
| 2620 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2621 | * a lun for OAS operations. |
| 2622 | * |
| 2623 | * Return: |
| 2624 | * SUCCESS: 0 |
| 2625 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2626 | * -EPERM: OAS is not enabled |
| 2627 | */ |
| 2628 | static ssize_t |
| 2629 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2630 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2631 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2632 | { |
| 2633 | |
| 2634 | int rc; |
| 2635 | |
| 2636 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2637 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2638 | return rc; |
| 2639 | } |
| 2640 | |
| 2641 | /** |
| 2642 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2643 | * @dev: class device that is converted into a Scsi_host. |
| 2644 | * @attr: device attribute, not used. |
| 2645 | * @buf: buffer for passing information. |
| 2646 | * |
| 2647 | * This routine returns a lun enabled for OAS each time the function |
| 2648 | * is called. |
| 2649 | * |
| 2650 | * Returns: |
| 2651 | * SUCCESS: size of formatted string. |
| 2652 | * -EFAULT: target or vport wwpn was not set properly. |
| 2653 | * -EPERM: oas is not enabled. |
| 2654 | **/ |
| 2655 | static ssize_t |
| 2656 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 2657 | char *buf) |
| 2658 | { |
| 2659 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2660 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2661 | |
| 2662 | uint64_t oas_lun; |
| 2663 | int len = 0; |
| 2664 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2665 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2666 | return -EPERM; |
| 2667 | |
| 2668 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2669 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 2670 | return -EFAULT; |
| 2671 | |
| 2672 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2673 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 2674 | return -EFAULT; |
| 2675 | |
| 2676 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 2677 | phba->cfg_oas_tgt_wwpn, |
| 2678 | &phba->cfg_oas_lun_status); |
| 2679 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 2680 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 2681 | |
| 2682 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 2683 | |
| 2684 | return len; |
| 2685 | } |
| 2686 | |
| 2687 | /** |
| 2688 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 2689 | * @dev: class device that is converted into a Scsi_host. |
| 2690 | * @attr: device attribute, not used. |
| 2691 | * @buf: buffer for passing information. |
| 2692 | * |
| 2693 | * This function sets the OAS state for lun. Before this function is called, |
| 2694 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 2695 | * |
| 2696 | * Returns: |
| 2697 | * SUCCESS: size of formatted string. |
| 2698 | * -EFAULT: target or vport wwpn was not set properly. |
| 2699 | * -EPERM: oas is not enabled. |
| 2700 | * size of formatted string. |
| 2701 | **/ |
| 2702 | static ssize_t |
| 2703 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 2704 | const char *buf, size_t count) |
| 2705 | { |
| 2706 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2707 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2708 | uint64_t scsi_lun; |
| 2709 | ssize_t rc; |
| 2710 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2711 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2712 | return -EPERM; |
| 2713 | |
| 2714 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2715 | return -EFAULT; |
| 2716 | |
| 2717 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2718 | return -EFAULT; |
| 2719 | |
| 2720 | if (!isdigit(buf[0])) |
| 2721 | return -EINVAL; |
| 2722 | |
| 2723 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 2724 | return -EINVAL; |
| 2725 | |
| 2726 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2727 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 2728 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2729 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 2730 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2731 | phba->cfg_oas_priority, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2732 | |
| 2733 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2734 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
| 2735 | phba->cfg_oas_lun_state, |
| 2736 | phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2737 | if (rc) |
| 2738 | return rc; |
| 2739 | |
| 2740 | return count; |
| 2741 | } |
| 2742 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 2743 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2744 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2745 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2746 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2747 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 2748 | " 0 - none," |
| 2749 | " 1 - poll with interrupts enabled" |
| 2750 | " 3 - poll and disable FCP ring interrupts"); |
| 2751 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2752 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 2753 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2754 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 2755 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 2756 | "SLI mode selector:" |
| 2757 | " 0 - auto (SLI-3 if supported)," |
| 2758 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 2759 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2760 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 2761 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 2762 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2763 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 2764 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 2765 | "FCF Fast failover=1 Priority failover=2"); |
| 2766 | |
James Smart | c14e995 | 2013-03-01 16:38:01 -0500 | [diff] [blame] | 2767 | int lpfc_enable_rrq = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2768 | module_param(lpfc_enable_rrq, int, S_IRUGO); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2769 | MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality"); |
| 2770 | lpfc_param_show(enable_rrq); |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 2771 | /* |
| 2772 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 2773 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 2774 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 2775 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 2776 | */ |
| 2777 | lpfc_param_init(enable_rrq, 2, 0, 2); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2778 | static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL); |
| 2779 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2780 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2781 | # lpfc_suppress_link_up: Bring link up at initialization |
| 2782 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 2783 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 2784 | # 0x2 = never bring up link |
| 2785 | # Default value is 0. |
| 2786 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2787 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 2788 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 2789 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2790 | /* |
| 2791 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 2792 | # 1 - (1024) |
| 2793 | # 2 - (2048) |
| 2794 | # 3 - (3072) |
| 2795 | # 4 - (4096) |
| 2796 | # 5 - (5120) |
| 2797 | */ |
| 2798 | static ssize_t |
| 2799 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2800 | { |
| 2801 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2802 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2803 | |
| 2804 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 2805 | } |
| 2806 | |
| 2807 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 2808 | lpfc_iocb_hw_show, NULL); |
| 2809 | static ssize_t |
| 2810 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2811 | { |
| 2812 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2813 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2814 | |
| 2815 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2816 | phba->sli.ring[LPFC_ELS_RING].txq_max); |
| 2817 | } |
| 2818 | |
| 2819 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 2820 | lpfc_txq_hw_show, NULL); |
| 2821 | static ssize_t |
| 2822 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 2823 | 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].txcmplq_max); |
| 2830 | } |
| 2831 | |
| 2832 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 2833 | lpfc_txcmplq_hw_show, NULL); |
| 2834 | |
| 2835 | int lpfc_iocb_cnt = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2836 | module_param(lpfc_iocb_cnt, int, S_IRUGO); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2837 | MODULE_PARM_DESC(lpfc_iocb_cnt, |
| 2838 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
| 2839 | lpfc_param_show(iocb_cnt); |
| 2840 | lpfc_param_init(iocb_cnt, 2, 1, 5); |
| 2841 | static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO, |
| 2842 | lpfc_iocb_cnt_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2843 | |
| 2844 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2845 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 2846 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 2847 | */ |
| 2848 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2849 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2850 | module_param(lpfc_nodev_tmo, int, 0); |
| 2851 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 2852 | "Seconds driver will hold I/O waiting " |
| 2853 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2854 | |
| 2855 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2856 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2857 | * @dev: class converted to a Scsi_host structure. |
| 2858 | * @attr: device attribute, not used. |
| 2859 | * @buf: on return contains the dev loss timeout in decimal. |
| 2860 | * |
| 2861 | * Returns: size of formatted string. |
| 2862 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2863 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2864 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 2865 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2866 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2867 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2868 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2869 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2870 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2871 | } |
| 2872 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2873 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2874 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2875 | * @vport: lpfc vport structure pointer. |
| 2876 | * @val: contains the nodev timeout value. |
| 2877 | * |
| 2878 | * Description: |
| 2879 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 2880 | * a kernel error message is printed and zero is returned. |
| 2881 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2882 | * Otherwise nodev tmo is set to the default value. |
| 2883 | * |
| 2884 | * Returns: |
| 2885 | * zero if already set or if val is in range |
| 2886 | * -EINVAL val out of range |
| 2887 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2888 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2889 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2890 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2891 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 2892 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 2893 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2894 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2895 | "0407 Ignoring nodev_tmo module " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2896 | "parameter because devloss_tmo is " |
| 2897 | "set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2898 | return 0; |
| 2899 | } |
| 2900 | |
| 2901 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2902 | vport->cfg_nodev_tmo = val; |
| 2903 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2904 | return 0; |
| 2905 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2906 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2907 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 2908 | " %d, allowed range is [%d, %d]\n", |
| 2909 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2910 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2911 | return -EINVAL; |
| 2912 | } |
| 2913 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2914 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2915 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2916 | * @vport: lpfc vport structure pointer. |
| 2917 | * |
| 2918 | * Description: |
| 2919 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 2920 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2921 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2922 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2923 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2924 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2925 | struct lpfc_nodelist *ndlp; |
| 2926 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2927 | shost = lpfc_shost_from_vport(vport); |
| 2928 | spin_lock_irq(shost->host_lock); |
| 2929 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2930 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2931 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 2932 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2933 | } |
| 2934 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2935 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2936 | * 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] | 2937 | * @vport: lpfc vport structure pointer. |
| 2938 | * @val: contains the tmo value. |
| 2939 | * |
| 2940 | * Description: |
| 2941 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 2942 | * then a kernel error message is printed and zero is returned. |
| 2943 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2944 | * Otherwise nodev tmo is set to the default value. |
| 2945 | * |
| 2946 | * Returns: |
| 2947 | * zero if already set or if val is in range |
| 2948 | * -EINVAL val out of range |
| 2949 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2950 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2951 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2952 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2953 | if (vport->dev_loss_tmo_changed || |
| 2954 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2955 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2956 | "0401 Ignoring change to nodev_tmo " |
| 2957 | "because devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2958 | return 0; |
| 2959 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2960 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2961 | vport->cfg_nodev_tmo = val; |
| 2962 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2963 | /* |
| 2964 | * For compat: set the fc_host dev loss so new rports |
| 2965 | * will get the value. |
| 2966 | */ |
| 2967 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2968 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2969 | return 0; |
| 2970 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2971 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2972 | "0403 lpfc_nodev_tmo attribute cannot be set to" |
| 2973 | "%d, allowed range is [%d, %d]\n", |
| 2974 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2975 | return -EINVAL; |
| 2976 | } |
| 2977 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2978 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2979 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2980 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 2981 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2982 | |
| 2983 | /* |
| 2984 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 2985 | # disappear until the timer expires. Value range is [0,255]. Default |
| 2986 | # value is 30. |
| 2987 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2988 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2989 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 2990 | "Seconds driver will hold I/O waiting " |
| 2991 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2992 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 2993 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 2994 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2995 | |
| 2996 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2997 | * 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] | 2998 | * @vport: lpfc vport structure pointer. |
| 2999 | * @val: contains the tmo value. |
| 3000 | * |
| 3001 | * Description: |
| 3002 | * If val is in a valid range then set the vport nodev tmo, |
| 3003 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3004 | * Else a kernel error message is printed. |
| 3005 | * |
| 3006 | * Returns: |
| 3007 | * zero if val is in range |
| 3008 | * -EINVAL val out of range |
| 3009 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3010 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3011 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3012 | { |
| 3013 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3014 | vport->cfg_nodev_tmo = val; |
| 3015 | vport->cfg_devloss_tmo = val; |
| 3016 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3017 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3018 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3019 | return 0; |
| 3020 | } |
| 3021 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3022 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3023 | "0404 lpfc_devloss_tmo attribute cannot be set to" |
| 3024 | " %d, allowed range is [%d, %d]\n", |
| 3025 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3026 | return -EINVAL; |
| 3027 | } |
| 3028 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3029 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3030 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 3031 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3032 | |
| 3033 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3034 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3035 | # deluged with LOTS of information. |
| 3036 | # 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] | 3037 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3038 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3039 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3040 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3041 | |
| 3042 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3043 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3044 | # objects that have been registered with the nameserver after login. |
| 3045 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3046 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3047 | "Deregister nameserver objects before LOGO"); |
| 3048 | |
| 3049 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3050 | # 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] | 3051 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3052 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3053 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3054 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3055 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3056 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3057 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3058 | |
| 3059 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3060 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3061 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3062 | */ |
| 3063 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3064 | "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] | 3065 | |
| 3066 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3067 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3068 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3069 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3070 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3071 | # the hba_queue_depth. |
| 3072 | */ |
| 3073 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3074 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3075 | |
| 3076 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3077 | # peer_port_login: This parameter allows/prevents logins |
| 3078 | # between peer ports hosted on the same physical port. |
| 3079 | # When this parameter is set 0 peer ports of same physical port |
| 3080 | # are not allowed to login to each other. |
| 3081 | # When this parameter is set 1 peer ports of same physical port |
| 3082 | # are allowed to login to each other. |
| 3083 | # Default value of this parameter is 0. |
| 3084 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3085 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3086 | "Allow peer ports on the same physical port to login to each " |
| 3087 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3088 | |
| 3089 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3090 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3091 | # between Virtual Ports and remote initiators. |
| 3092 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3093 | # other initiators and will attempt to PLOGI all remote ports. |
| 3094 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3095 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3096 | # This parameter does not restrict to the physical port. |
| 3097 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3098 | # Default value of this parameter is 1. |
| 3099 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3100 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3101 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3102 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3103 | "Restrict virtual ports login to remote initiators."); |
| 3104 | lpfc_vport_param_show(restrict_login); |
| 3105 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3106 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3107 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3108 | * @vport: lpfc vport structure pointer. |
| 3109 | * @val: contains the restrict login value. |
| 3110 | * |
| 3111 | * Description: |
| 3112 | * If val is not in a valid range then log a kernel error message and set |
| 3113 | * the vport restrict login to one. |
| 3114 | * If the port type is physical clear the restrict login flag and return. |
| 3115 | * Else set the restrict login flag to val. |
| 3116 | * |
| 3117 | * Returns: |
| 3118 | * zero if val is in range |
| 3119 | * -EINVAL val out of range |
| 3120 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3121 | static int |
| 3122 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3123 | { |
| 3124 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3125 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3126 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3127 | "be set to %d, allowed range is [0, 1]\n", |
| 3128 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3129 | vport->cfg_restrict_login = 1; |
| 3130 | return -EINVAL; |
| 3131 | } |
| 3132 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3133 | vport->cfg_restrict_login = 0; |
| 3134 | return 0; |
| 3135 | } |
| 3136 | vport->cfg_restrict_login = val; |
| 3137 | return 0; |
| 3138 | } |
| 3139 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3140 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3141 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3142 | * @vport: lpfc vport structure pointer. |
| 3143 | * @val: contains the restrict login value. |
| 3144 | * |
| 3145 | * Description: |
| 3146 | * If val is not in a valid range then log a kernel error message and set |
| 3147 | * the vport restrict login to one. |
| 3148 | * If the port type is physical and the val is not zero log a kernel |
| 3149 | * error message, clear the restrict login flag and return zero. |
| 3150 | * Else set the restrict login flag to val. |
| 3151 | * |
| 3152 | * Returns: |
| 3153 | * zero if val is in range |
| 3154 | * -EINVAL val out of range |
| 3155 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3156 | static int |
| 3157 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3158 | { |
| 3159 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3160 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3161 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3162 | "be set to %d, allowed range is [0, 1]\n", |
| 3163 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3164 | vport->cfg_restrict_login = 1; |
| 3165 | return -EINVAL; |
| 3166 | } |
| 3167 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3168 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3169 | "0468 lpfc_restrict_login must be 0 for " |
| 3170 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3171 | vport->cfg_restrict_login = 0; |
| 3172 | return 0; |
| 3173 | } |
| 3174 | vport->cfg_restrict_login = val; |
| 3175 | return 0; |
| 3176 | } |
| 3177 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3178 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 3179 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3180 | |
| 3181 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3182 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3183 | # From a protocol standpoint "select ID" usually means select the |
| 3184 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3185 | # annex" which contains a table that maps a "select ID" (a number |
| 3186 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3187 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3188 | # ALPA. |
| 3189 | # |
| 3190 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3191 | # cause the lpfc driver to use an inverted table, effectively |
| 3192 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3193 | # |
| 3194 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3195 | # and will not work across a fabric. Also this parameter will take |
| 3196 | # effect only in the case when ALPA map is not available.) |
| 3197 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3198 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3199 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3200 | |
| 3201 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3202 | # lpfc_topology: link topology for init link |
| 3203 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3204 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3205 | # 0x02 = attempt point-to-point mode only |
| 3206 | # 0x04 = attempt loop mode only |
| 3207 | # 0x06 = attempt point-to-point mode then loop |
| 3208 | # Set point-to-point mode if you want to run as an N_Port. |
| 3209 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3210 | # Default value is 0. |
| 3211 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3212 | |
| 3213 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3214 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3215 | * @phba: lpfc_hba pointer. |
| 3216 | * @val: topology value. |
| 3217 | * |
| 3218 | * Description: |
| 3219 | * If val is in a valid range then set the adapter's topology field and |
| 3220 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3221 | * |
| 3222 | * If the value is not in range log a kernel error message and return an error. |
| 3223 | * |
| 3224 | * Returns: |
| 3225 | * zero if val is in range and lip okay |
| 3226 | * non-zero return value from lpfc_issue_lip() |
| 3227 | * -EINVAL val out of range |
| 3228 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3229 | static ssize_t |
| 3230 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3231 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3232 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3233 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3234 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3235 | struct lpfc_hba *phba = vport->phba; |
| 3236 | int val = 0; |
| 3237 | int nolip = 0; |
| 3238 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3239 | int err; |
| 3240 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3241 | |
| 3242 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3243 | nolip = 1; |
| 3244 | val_buf = &buf[strlen("nolip ")]; |
| 3245 | } |
| 3246 | |
| 3247 | if (!isdigit(val_buf[0])) |
| 3248 | return -EINVAL; |
| 3249 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3250 | return -EINVAL; |
| 3251 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3252 | if (val >= 0 && val <= 6) { |
| 3253 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3254 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3255 | val == 4) { |
| 3256 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3257 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3258 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3259 | return -EINVAL; |
| 3260 | } |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3261 | if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && |
| 3262 | val == 4) { |
| 3263 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3264 | "3114 Loop mode not supported\n"); |
| 3265 | return -EINVAL; |
| 3266 | } |
| 3267 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3268 | if (nolip) |
| 3269 | return strlen(buf); |
| 3270 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3271 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3272 | "3054 lpfc_topology changed from %d to %d\n", |
| 3273 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3274 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3275 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3276 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3277 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3278 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3279 | return -EINVAL; |
| 3280 | } else |
| 3281 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3282 | } |
| 3283 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3284 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3285 | "allowed range is [0, 6]\n", |
| 3286 | phba->brd_no, val); |
| 3287 | return -EINVAL; |
| 3288 | } |
| 3289 | static int lpfc_topology = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3290 | module_param(lpfc_topology, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3291 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
| 3292 | lpfc_param_show(topology) |
| 3293 | lpfc_param_init(topology, 0, 0, 6) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3294 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3295 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3296 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3297 | /** |
| 3298 | * lpfc_static_vport_show: Read callback function for |
| 3299 | * lpfc_static_vport sysfs file. |
| 3300 | * @dev: Pointer to class device object. |
| 3301 | * @attr: device attribute structure. |
| 3302 | * @buf: Data buffer. |
| 3303 | * |
| 3304 | * This function is the read call back function for |
| 3305 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3306 | * sysfs file report the mageability of the vport. |
| 3307 | **/ |
| 3308 | static ssize_t |
| 3309 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3310 | char *buf) |
| 3311 | { |
| 3312 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3313 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3314 | if (vport->vport_flag & STATIC_VPORT) |
| 3315 | sprintf(buf, "1\n"); |
| 3316 | else |
| 3317 | sprintf(buf, "0\n"); |
| 3318 | |
| 3319 | return strlen(buf); |
| 3320 | } |
| 3321 | |
| 3322 | /* |
| 3323 | * Sysfs attribute to control the statistical data collection. |
| 3324 | */ |
| 3325 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 3326 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3327 | |
| 3328 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3329 | * 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] | 3330 | * @dev: Pointer to class device. |
| 3331 | * @buf: Data buffer. |
| 3332 | * @count: Size of the data buffer. |
| 3333 | * |
| 3334 | * This function get called when an user write to the lpfc_stat_data_ctrl |
| 3335 | * sysfs file. This function parse the command written to the sysfs file |
| 3336 | * and take appropriate action. These commands are used for controlling |
| 3337 | * driver statistical data collection. |
| 3338 | * Following are the command this function handles. |
| 3339 | * |
| 3340 | * setbucket <bucket_type> <base> <step> |
| 3341 | * = Set the latency buckets. |
| 3342 | * destroybucket = destroy all the buckets. |
| 3343 | * start = start data collection |
| 3344 | * stop = stop data collection |
| 3345 | * reset = reset the collected data |
| 3346 | **/ |
| 3347 | static ssize_t |
| 3348 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3349 | const char *buf, size_t count) |
| 3350 | { |
| 3351 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3352 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3353 | struct lpfc_hba *phba = vport->phba; |
| 3354 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3355 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3356 | unsigned long i; |
| 3357 | char *str_ptr, *token; |
| 3358 | struct lpfc_vport **vports; |
| 3359 | struct Scsi_Host *v_shost; |
| 3360 | char *bucket_type_str, *base_str, *step_str; |
| 3361 | unsigned long base, step, bucket_type; |
| 3362 | |
| 3363 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3364 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3365 | return -EINVAL; |
| 3366 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 3367 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3368 | str_ptr = &bucket_data[0]; |
| 3369 | /* Ignore this token - this is command token */ |
| 3370 | token = strsep(&str_ptr, "\t "); |
| 3371 | if (!token) |
| 3372 | return -EINVAL; |
| 3373 | |
| 3374 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3375 | if (!bucket_type_str) |
| 3376 | return -EINVAL; |
| 3377 | |
| 3378 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3379 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3380 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3381 | bucket_type = LPFC_POWER2_BUCKET; |
| 3382 | else |
| 3383 | return -EINVAL; |
| 3384 | |
| 3385 | base_str = strsep(&str_ptr, "\t "); |
| 3386 | if (!base_str) |
| 3387 | return -EINVAL; |
| 3388 | base = simple_strtoul(base_str, NULL, 0); |
| 3389 | |
| 3390 | step_str = strsep(&str_ptr, "\t "); |
| 3391 | if (!step_str) |
| 3392 | return -EINVAL; |
| 3393 | step = simple_strtoul(step_str, NULL, 0); |
| 3394 | if (!step) |
| 3395 | return -EINVAL; |
| 3396 | |
| 3397 | /* Block the data collection for every vport */ |
| 3398 | vports = lpfc_create_vport_work_array(phba); |
| 3399 | if (vports == NULL) |
| 3400 | return -ENOMEM; |
| 3401 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3402 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3403 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3404 | spin_lock_irq(v_shost->host_lock); |
| 3405 | /* Block and reset data collection */ |
| 3406 | vports[i]->stat_data_blocked = 1; |
| 3407 | if (vports[i]->stat_data_enabled) |
| 3408 | lpfc_vport_reset_stat_data(vports[i]); |
| 3409 | spin_unlock_irq(v_shost->host_lock); |
| 3410 | } |
| 3411 | |
| 3412 | /* Set the bucket attributes */ |
| 3413 | phba->bucket_type = bucket_type; |
| 3414 | phba->bucket_base = base; |
| 3415 | phba->bucket_step = step; |
| 3416 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3417 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3418 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3419 | |
| 3420 | /* Unblock data collection */ |
| 3421 | spin_lock_irq(v_shost->host_lock); |
| 3422 | vports[i]->stat_data_blocked = 0; |
| 3423 | spin_unlock_irq(v_shost->host_lock); |
| 3424 | } |
| 3425 | lpfc_destroy_vport_work_array(phba, vports); |
| 3426 | return strlen(buf); |
| 3427 | } |
| 3428 | |
| 3429 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3430 | vports = lpfc_create_vport_work_array(phba); |
| 3431 | if (vports == NULL) |
| 3432 | return -ENOMEM; |
| 3433 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3434 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3435 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3436 | spin_lock_irq(shost->host_lock); |
| 3437 | vports[i]->stat_data_blocked = 1; |
| 3438 | lpfc_free_bucket(vport); |
| 3439 | vport->stat_data_enabled = 0; |
| 3440 | vports[i]->stat_data_blocked = 0; |
| 3441 | spin_unlock_irq(shost->host_lock); |
| 3442 | } |
| 3443 | lpfc_destroy_vport_work_array(phba, vports); |
| 3444 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3445 | phba->bucket_base = 0; |
| 3446 | phba->bucket_step = 0; |
| 3447 | return strlen(buf); |
| 3448 | } |
| 3449 | |
| 3450 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3451 | /* If no buckets configured return error */ |
| 3452 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3453 | return -EINVAL; |
| 3454 | spin_lock_irq(shost->host_lock); |
| 3455 | if (vport->stat_data_enabled) { |
| 3456 | spin_unlock_irq(shost->host_lock); |
| 3457 | return strlen(buf); |
| 3458 | } |
| 3459 | lpfc_alloc_bucket(vport); |
| 3460 | vport->stat_data_enabled = 1; |
| 3461 | spin_unlock_irq(shost->host_lock); |
| 3462 | return strlen(buf); |
| 3463 | } |
| 3464 | |
| 3465 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3466 | spin_lock_irq(shost->host_lock); |
| 3467 | if (vport->stat_data_enabled == 0) { |
| 3468 | spin_unlock_irq(shost->host_lock); |
| 3469 | return strlen(buf); |
| 3470 | } |
| 3471 | lpfc_free_bucket(vport); |
| 3472 | vport->stat_data_enabled = 0; |
| 3473 | spin_unlock_irq(shost->host_lock); |
| 3474 | return strlen(buf); |
| 3475 | } |
| 3476 | |
| 3477 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3478 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3479 | || !vport->stat_data_enabled) |
| 3480 | return strlen(buf); |
| 3481 | spin_lock_irq(shost->host_lock); |
| 3482 | vport->stat_data_blocked = 1; |
| 3483 | lpfc_vport_reset_stat_data(vport); |
| 3484 | vport->stat_data_blocked = 0; |
| 3485 | spin_unlock_irq(shost->host_lock); |
| 3486 | return strlen(buf); |
| 3487 | } |
| 3488 | return -EINVAL; |
| 3489 | } |
| 3490 | |
| 3491 | |
| 3492 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3493 | * 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] | 3494 | * @dev: Pointer to class device object. |
| 3495 | * @buf: Data buffer. |
| 3496 | * |
| 3497 | * This function is the read call back function for |
| 3498 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3499 | * current statistical data collection state. |
| 3500 | **/ |
| 3501 | static ssize_t |
| 3502 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3503 | char *buf) |
| 3504 | { |
| 3505 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3506 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3507 | struct lpfc_hba *phba = vport->phba; |
| 3508 | int index = 0; |
| 3509 | int i; |
| 3510 | char *bucket_type; |
| 3511 | unsigned long bucket_value; |
| 3512 | |
| 3513 | switch (phba->bucket_type) { |
| 3514 | case LPFC_LINEAR_BUCKET: |
| 3515 | bucket_type = "linear"; |
| 3516 | break; |
| 3517 | case LPFC_POWER2_BUCKET: |
| 3518 | bucket_type = "power2"; |
| 3519 | break; |
| 3520 | default: |
| 3521 | bucket_type = "No Bucket"; |
| 3522 | break; |
| 3523 | } |
| 3524 | |
| 3525 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3526 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3527 | " Bucket step :%d\nLatency Ranges :", |
| 3528 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3529 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3530 | index = strlen(buf); |
| 3531 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3532 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3533 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3534 | bucket_value = phba->bucket_base + |
| 3535 | phba->bucket_step * i; |
| 3536 | else |
| 3537 | bucket_value = phba->bucket_base + |
| 3538 | (1 << i) * phba->bucket_step; |
| 3539 | |
| 3540 | if (index + 10 > PAGE_SIZE) |
| 3541 | break; |
| 3542 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3543 | index = strlen(buf); |
| 3544 | } |
| 3545 | } |
| 3546 | sprintf(&buf[index], "\n"); |
| 3547 | return strlen(buf); |
| 3548 | } |
| 3549 | |
| 3550 | /* |
| 3551 | * Sysfs attribute to control the statistical data collection. |
| 3552 | */ |
| 3553 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 3554 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 3555 | |
| 3556 | /* |
| 3557 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3558 | */ |
| 3559 | |
| 3560 | /* |
| 3561 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3562 | * for each target. |
| 3563 | */ |
| 3564 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3565 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3566 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3567 | |
| 3568 | |
| 3569 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3570 | * 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] | 3571 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3572 | * @kobj: Pointer to the kernel object |
| 3573 | * @bin_attr: Attribute object |
| 3574 | * @buff: Buffer pointer |
| 3575 | * @off: File offset |
| 3576 | * @count: Buffer size |
| 3577 | * |
| 3578 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3579 | * sysfs file. This function export the statistical data to user |
| 3580 | * applications. |
| 3581 | **/ |
| 3582 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3583 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3584 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3585 | char *buf, loff_t off, size_t count) |
| 3586 | { |
| 3587 | struct device *dev = container_of(kobj, struct device, |
| 3588 | kobj); |
| 3589 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3590 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3591 | struct lpfc_hba *phba = vport->phba; |
| 3592 | int i = 0, index = 0; |
| 3593 | unsigned long nport_index; |
| 3594 | struct lpfc_nodelist *ndlp = NULL; |
| 3595 | nport_index = (unsigned long)off / |
| 3596 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3597 | |
| 3598 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3599 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3600 | return 0; |
| 3601 | |
| 3602 | spin_lock_irq(shost->host_lock); |
| 3603 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3604 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 3605 | continue; |
| 3606 | |
| 3607 | if (nport_index > 0) { |
| 3608 | nport_index--; |
| 3609 | continue; |
| 3610 | } |
| 3611 | |
| 3612 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 3613 | > count) |
| 3614 | break; |
| 3615 | |
| 3616 | if (!ndlp->lat_data) |
| 3617 | continue; |
| 3618 | |
| 3619 | /* Print the WWN */ |
| 3620 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 3621 | ndlp->nlp_portname.u.wwn[0], |
| 3622 | ndlp->nlp_portname.u.wwn[1], |
| 3623 | ndlp->nlp_portname.u.wwn[2], |
| 3624 | ndlp->nlp_portname.u.wwn[3], |
| 3625 | ndlp->nlp_portname.u.wwn[4], |
| 3626 | ndlp->nlp_portname.u.wwn[5], |
| 3627 | ndlp->nlp_portname.u.wwn[6], |
| 3628 | ndlp->nlp_portname.u.wwn[7]); |
| 3629 | |
| 3630 | index = strlen(buf); |
| 3631 | |
| 3632 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3633 | sprintf(&buf[index], "%010u,", |
| 3634 | ndlp->lat_data[i].cmd_count); |
| 3635 | index = strlen(buf); |
| 3636 | } |
| 3637 | sprintf(&buf[index], "\n"); |
| 3638 | index = strlen(buf); |
| 3639 | } |
| 3640 | spin_unlock_irq(shost->host_lock); |
| 3641 | return index; |
| 3642 | } |
| 3643 | |
| 3644 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 3645 | .attr = { |
| 3646 | .name = "lpfc_drvr_stat_data", |
| 3647 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3648 | }, |
| 3649 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 3650 | .read = sysfs_drvr_stat_data_read, |
| 3651 | .write = NULL, |
| 3652 | }; |
| 3653 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3654 | /* |
| 3655 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 3656 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3657 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3658 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3659 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3660 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3661 | * @phba: lpfc_hba pointer. |
| 3662 | * @val: link speed value. |
| 3663 | * |
| 3664 | * Description: |
| 3665 | * If val is in a valid range then set the adapter's link speed field and |
| 3666 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 3667 | * |
| 3668 | * Notes: |
| 3669 | * If the value is not in range log a kernel error message and return an error. |
| 3670 | * |
| 3671 | * Returns: |
| 3672 | * zero if val is in range and lip okay. |
| 3673 | * non-zero return value from lpfc_issue_lip() |
| 3674 | * -EINVAL val out of range |
| 3675 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3676 | static ssize_t |
| 3677 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 3678 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3679 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3680 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3681 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3682 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3683 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3684 | int nolip = 0; |
| 3685 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3686 | int err; |
| 3687 | uint32_t prev_val; |
| 3688 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3689 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3690 | nolip = 1; |
| 3691 | val_buf = &buf[strlen("nolip ")]; |
| 3692 | } |
| 3693 | |
| 3694 | if (!isdigit(val_buf[0])) |
| 3695 | return -EINVAL; |
| 3696 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3697 | return -EINVAL; |
| 3698 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3699 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3700 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 3701 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 3702 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3703 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 3704 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 3705 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 3706 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 3707 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3708 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
| 3709 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3710 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3711 | "2879 lpfc_link_speed attribute cannot be set " |
| 3712 | "to %d. Speed is not supported by this port.\n", |
| 3713 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3714 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3715 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3716 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 3717 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 3718 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3719 | "3112 lpfc_link_speed attribute cannot be set " |
| 3720 | "to %d. Speed is not supported in loop mode.\n", |
| 3721 | val); |
| 3722 | return -EINVAL; |
| 3723 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3724 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3725 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3726 | prev_val = phba->cfg_link_speed; |
| 3727 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3728 | if (nolip) |
| 3729 | return strlen(buf); |
| 3730 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3731 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3732 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3733 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3734 | return -EINVAL; |
| 3735 | } else |
| 3736 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3737 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3738 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3739 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 3740 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3741 | return -EINVAL; |
| 3742 | } |
| 3743 | |
| 3744 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3745 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3746 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 3747 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3748 | |
| 3749 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3750 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3751 | * @phba: lpfc_hba pointer. |
| 3752 | * @val: link speed value. |
| 3753 | * |
| 3754 | * Description: |
| 3755 | * If val is in a valid range then set the adapter's link speed field. |
| 3756 | * |
| 3757 | * Notes: |
| 3758 | * If the value is not in range log a kernel error message, clear the link |
| 3759 | * speed and return an error. |
| 3760 | * |
| 3761 | * Returns: |
| 3762 | * zero if val saved. |
| 3763 | * -EINVAL val out of range |
| 3764 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3765 | static int |
| 3766 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 3767 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3768 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 3769 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3770 | "3111 lpfc_link_speed of %d cannot " |
| 3771 | "support loop mode, setting topology to default.\n", |
| 3772 | val); |
| 3773 | phba->cfg_topology = 0; |
| 3774 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3775 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3776 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3777 | phba->cfg_link_speed = val; |
| 3778 | return 0; |
| 3779 | } |
| 3780 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3781 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3782 | "be set to %d, allowed values are " |
| 3783 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3784 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3785 | return -EINVAL; |
| 3786 | } |
| 3787 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3788 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3789 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3790 | |
| 3791 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3792 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 3793 | # 0 = aer disabled or not supported |
| 3794 | # 1 = aer supported and enabled (default) |
| 3795 | # Value range is [0,1]. Default value is 1. |
| 3796 | */ |
| 3797 | |
| 3798 | /** |
| 3799 | * lpfc_aer_support_store - Set the adapter for aer support |
| 3800 | * |
| 3801 | * @dev: class device that is converted into a Scsi_host. |
| 3802 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3803 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3804 | * @count: unused variable. |
| 3805 | * |
| 3806 | * Description: |
| 3807 | * If the val is 1 and currently the device's AER capability was not |
| 3808 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 3809 | * enable the device's AER capability. If the helper routine enabling |
| 3810 | * AER returns success, update the device's cfg_aer_support flag to |
| 3811 | * indicate AER is supported by the device; otherwise, if the device |
| 3812 | * AER capability is already enabled to support AER, then do nothing. |
| 3813 | * |
| 3814 | * If the val is 0 and currently the device's AER support was enabled, |
| 3815 | * invoke the kernel's disable AER helper routine. After that, update |
| 3816 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 3817 | * by the device; otherwise, if the device AER capability is already |
| 3818 | * disabled from supporting AER, then do nothing. |
| 3819 | * |
| 3820 | * Returns: |
| 3821 | * length of the buf on success if val is in range the intended mode |
| 3822 | * is supported. |
| 3823 | * -EINVAL if val out of range or intended mode is not supported. |
| 3824 | **/ |
| 3825 | static ssize_t |
| 3826 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 3827 | const char *buf, size_t count) |
| 3828 | { |
| 3829 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3830 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 3831 | struct lpfc_hba *phba = vport->phba; |
| 3832 | int val = 0, rc = -EINVAL; |
| 3833 | |
| 3834 | if (!isdigit(buf[0])) |
| 3835 | return -EINVAL; |
| 3836 | if (sscanf(buf, "%i", &val) != 1) |
| 3837 | return -EINVAL; |
| 3838 | |
| 3839 | switch (val) { |
| 3840 | case 0: |
| 3841 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 3842 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 3843 | if (!rc) { |
| 3844 | spin_lock_irq(&phba->hbalock); |
| 3845 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 3846 | spin_unlock_irq(&phba->hbalock); |
| 3847 | phba->cfg_aer_support = 0; |
| 3848 | rc = strlen(buf); |
| 3849 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3850 | rc = -EPERM; |
| 3851 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3852 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3853 | rc = strlen(buf); |
| 3854 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3855 | break; |
| 3856 | case 1: |
| 3857 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 3858 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 3859 | if (!rc) { |
| 3860 | spin_lock_irq(&phba->hbalock); |
| 3861 | phba->hba_flag |= HBA_AER_ENABLED; |
| 3862 | spin_unlock_irq(&phba->hbalock); |
| 3863 | phba->cfg_aer_support = 1; |
| 3864 | rc = strlen(buf); |
| 3865 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3866 | rc = -EPERM; |
| 3867 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3868 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3869 | rc = strlen(buf); |
| 3870 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3871 | break; |
| 3872 | default: |
| 3873 | rc = -EINVAL; |
| 3874 | break; |
| 3875 | } |
| 3876 | return rc; |
| 3877 | } |
| 3878 | |
| 3879 | static int lpfc_aer_support = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3880 | module_param(lpfc_aer_support, int, S_IRUGO); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3881 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); |
| 3882 | lpfc_param_show(aer_support) |
| 3883 | |
| 3884 | /** |
| 3885 | * lpfc_aer_support_init - Set the initial adapters aer support flag |
| 3886 | * @phba: lpfc_hba pointer. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3887 | * @val: enable aer or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3888 | * |
| 3889 | * Description: |
| 3890 | * If val is in a valid range [0,1], then set the adapter's initial |
| 3891 | * cfg_aer_support field. It will be up to the driver's probe_one |
| 3892 | * routine to determine whether the device's AER support can be set |
| 3893 | * or not. |
| 3894 | * |
| 3895 | * Notes: |
| 3896 | * If the value is not in range log a kernel error message, and |
| 3897 | * choose the default value of setting AER support and return. |
| 3898 | * |
| 3899 | * Returns: |
| 3900 | * zero if val saved. |
| 3901 | * -EINVAL val out of range |
| 3902 | **/ |
| 3903 | static int |
| 3904 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) |
| 3905 | { |
| 3906 | if (val == 0 || val == 1) { |
| 3907 | phba->cfg_aer_support = val; |
| 3908 | return 0; |
| 3909 | } |
| 3910 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3911 | "2712 lpfc_aer_support attribute value %d out " |
| 3912 | "of range, allowed values are 0|1, setting it " |
| 3913 | "to default value of 1\n", val); |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3914 | /* By default, try to enable AER on a device */ |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3915 | phba->cfg_aer_support = 1; |
| 3916 | return -EINVAL; |
| 3917 | } |
| 3918 | |
| 3919 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 3920 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 3921 | |
| 3922 | /** |
| 3923 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 3924 | * @dev: class device that is converted into a Scsi_host. |
| 3925 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3926 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3927 | * @count: unused variable. |
| 3928 | * |
| 3929 | * Description: |
| 3930 | * If the @buf contains 1 and the device currently has the AER support |
| 3931 | * enabled, then invokes the kernel AER helper routine |
| 3932 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 3933 | * error status register. |
| 3934 | * |
| 3935 | * Notes: |
| 3936 | * |
| 3937 | * Returns: |
| 3938 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 3939 | * enabled with the AER support. |
| 3940 | **/ |
| 3941 | static ssize_t |
| 3942 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 3943 | const char *buf, size_t count) |
| 3944 | { |
| 3945 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3946 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3947 | struct lpfc_hba *phba = vport->phba; |
| 3948 | int val, rc = -1; |
| 3949 | |
| 3950 | if (!isdigit(buf[0])) |
| 3951 | return -EINVAL; |
| 3952 | if (sscanf(buf, "%i", &val) != 1) |
| 3953 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3954 | if (val != 1) |
| 3955 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3956 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3957 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3958 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 3959 | |
| 3960 | if (rc == 0) |
| 3961 | return strlen(buf); |
| 3962 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3963 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3964 | } |
| 3965 | |
| 3966 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 3967 | lpfc_aer_cleanup_state); |
| 3968 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3969 | /** |
| 3970 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 3971 | * |
| 3972 | * @dev: class device that is converted into a Scsi_host. |
| 3973 | * @attr: device attribute, not used. |
| 3974 | * @buf: containing the string the number of vfs to be enabled. |
| 3975 | * @count: unused variable. |
| 3976 | * |
| 3977 | * Description: |
| 3978 | * When this api is called either through user sysfs, the driver shall |
| 3979 | * try to enable or disable SR-IOV virtual functions according to the |
| 3980 | * following: |
| 3981 | * |
| 3982 | * If zero virtual function has been enabled to the physical function, |
| 3983 | * the driver shall invoke the pci enable virtual function api trying |
| 3984 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 3985 | * than the maximum supported, the maximum virtual function number will |
| 3986 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 3987 | * be used for invoking the api. If the api call returned success, the |
| 3988 | * actual number of virtual functions enabled will be set to the driver |
| 3989 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 3990 | * cfg_sriov_nr_virtfn remains zero. |
| 3991 | * |
| 3992 | * If none-zero virtual functions have already been enabled to the |
| 3993 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 3994 | * -EINVAL will be returned and the driver does nothing; |
| 3995 | * |
| 3996 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 3997 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 3998 | * disabling virtual function api shall be invoded to disable all the |
| 3999 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4000 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4001 | * nothing. |
| 4002 | * |
| 4003 | * Returns: |
| 4004 | * length of the buf on success if val is in range the intended mode |
| 4005 | * is supported. |
| 4006 | * -EINVAL if val out of range or intended mode is not supported. |
| 4007 | **/ |
| 4008 | static ssize_t |
| 4009 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4010 | const char *buf, size_t count) |
| 4011 | { |
| 4012 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4013 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4014 | struct lpfc_hba *phba = vport->phba; |
| 4015 | struct pci_dev *pdev = phba->pcidev; |
| 4016 | int val = 0, rc = -EINVAL; |
| 4017 | |
| 4018 | /* Sanity check on user data */ |
| 4019 | if (!isdigit(buf[0])) |
| 4020 | return -EINVAL; |
| 4021 | if (sscanf(buf, "%i", &val) != 1) |
| 4022 | return -EINVAL; |
| 4023 | if (val < 0) |
| 4024 | return -EINVAL; |
| 4025 | |
| 4026 | /* Request disabling virtual functions */ |
| 4027 | if (val == 0) { |
| 4028 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4029 | pci_disable_sriov(pdev); |
| 4030 | phba->cfg_sriov_nr_virtfn = 0; |
| 4031 | } |
| 4032 | return strlen(buf); |
| 4033 | } |
| 4034 | |
| 4035 | /* Request enabling virtual functions */ |
| 4036 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4037 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4038 | "3018 There are %d virtual functions " |
| 4039 | "enabled on physical function.\n", |
| 4040 | phba->cfg_sriov_nr_virtfn); |
| 4041 | return -EEXIST; |
| 4042 | } |
| 4043 | |
| 4044 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4045 | phba->cfg_sriov_nr_virtfn = val; |
| 4046 | else { |
| 4047 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4048 | "3019 Enabling %d virtual functions is not " |
| 4049 | "allowed.\n", val); |
| 4050 | return -EINVAL; |
| 4051 | } |
| 4052 | |
| 4053 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4054 | if (rc) { |
| 4055 | phba->cfg_sriov_nr_virtfn = 0; |
| 4056 | rc = -EPERM; |
| 4057 | } else |
| 4058 | rc = strlen(buf); |
| 4059 | |
| 4060 | return rc; |
| 4061 | } |
| 4062 | |
| 4063 | static int lpfc_sriov_nr_virtfn = LPFC_DEF_VFN_PER_PFN; |
| 4064 | module_param(lpfc_sriov_nr_virtfn, int, S_IRUGO|S_IWUSR); |
| 4065 | MODULE_PARM_DESC(lpfc_sriov_nr_virtfn, "Enable PCIe device SR-IOV virtual fn"); |
| 4066 | lpfc_param_show(sriov_nr_virtfn) |
| 4067 | |
| 4068 | /** |
| 4069 | * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable |
| 4070 | * @phba: lpfc_hba pointer. |
| 4071 | * @val: link speed value. |
| 4072 | * |
| 4073 | * Description: |
| 4074 | * If val is in a valid range [0,255], then set the adapter's initial |
| 4075 | * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum |
| 4076 | * number shall be used instead. It will be up to the driver's probe_one |
| 4077 | * routine to determine whether the device's SR-IOV is supported or not. |
| 4078 | * |
| 4079 | * Returns: |
| 4080 | * zero if val saved. |
| 4081 | * -EINVAL val out of range |
| 4082 | **/ |
| 4083 | static int |
| 4084 | lpfc_sriov_nr_virtfn_init(struct lpfc_hba *phba, int val) |
| 4085 | { |
| 4086 | if (val >= 0 && val <= LPFC_MAX_VFN_PER_PFN) { |
| 4087 | phba->cfg_sriov_nr_virtfn = val; |
| 4088 | return 0; |
| 4089 | } |
| 4090 | |
| 4091 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4092 | "3017 Enabling %d virtual functions is not " |
| 4093 | "allowed.\n", val); |
| 4094 | return -EINVAL; |
| 4095 | } |
| 4096 | static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, |
| 4097 | lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); |
| 4098 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4099 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4100 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4101 | * |
| 4102 | * @dev: class device that is converted into a Scsi_host. |
| 4103 | * @attr: device attribute, not used. |
| 4104 | * @buf: containing the string the number of vfs to be enabled. |
| 4105 | * @count: unused variable. |
| 4106 | * |
| 4107 | * Description: |
| 4108 | * |
| 4109 | * Returns: |
| 4110 | * length of the buf on success if val is in range the intended mode |
| 4111 | * is supported. |
| 4112 | * -EINVAL if val out of range or intended mode is not supported. |
| 4113 | **/ |
| 4114 | static ssize_t |
| 4115 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4116 | struct device_attribute *attr, |
| 4117 | const char *buf, size_t count) |
| 4118 | { |
| 4119 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4120 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4121 | struct lpfc_hba *phba = vport->phba; |
| 4122 | int val = 0, rc = -EINVAL; |
| 4123 | |
| 4124 | /* Sanity check on user data */ |
| 4125 | if (!isdigit(buf[0])) |
| 4126 | return -EINVAL; |
| 4127 | if (sscanf(buf, "%i", &val) != 1) |
| 4128 | return -EINVAL; |
| 4129 | if (val != 1) |
| 4130 | return -EINVAL; |
| 4131 | |
| 4132 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4133 | if (rc) |
| 4134 | rc = -EPERM; |
| 4135 | else |
| 4136 | rc = strlen(buf); |
| 4137 | return rc; |
| 4138 | } |
| 4139 | |
| 4140 | static int lpfc_req_fw_upgrade; |
| 4141 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4142 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4143 | lpfc_param_show(request_firmware_upgrade) |
| 4144 | |
| 4145 | /** |
| 4146 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4147 | * @phba: lpfc_hba pointer. |
| 4148 | * @val: 0 or 1. |
| 4149 | * |
| 4150 | * Description: |
| 4151 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4152 | * |
| 4153 | * Returns: |
| 4154 | * zero if val saved. |
| 4155 | * -EINVAL val out of range |
| 4156 | **/ |
| 4157 | static int |
| 4158 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4159 | { |
| 4160 | if (val >= 0 && val <= 1) { |
| 4161 | phba->cfg_request_firmware_upgrade = val; |
| 4162 | return 0; |
| 4163 | } |
| 4164 | return -EINVAL; |
| 4165 | } |
| 4166 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4167 | lpfc_request_firmware_upgrade_show, |
| 4168 | lpfc_request_firmware_upgrade_store); |
| 4169 | |
| 4170 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4171 | * lpfc_fcp_imax_store |
| 4172 | * |
| 4173 | * @dev: class device that is converted into a Scsi_host. |
| 4174 | * @attr: device attribute, not used. |
| 4175 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4176 | * @count: unused variable. |
| 4177 | * |
| 4178 | * Description: |
| 4179 | * If val is in a valid range [636,651042], then set the adapter's |
| 4180 | * maximum number of fast-path FCP interrupts per second. |
| 4181 | * |
| 4182 | * Returns: |
| 4183 | * length of the buf on success if val is in range the intended mode |
| 4184 | * is supported. |
| 4185 | * -EINVAL if val out of range or intended mode is not supported. |
| 4186 | **/ |
| 4187 | static ssize_t |
| 4188 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4189 | const char *buf, size_t count) |
| 4190 | { |
| 4191 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4192 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4193 | struct lpfc_hba *phba = vport->phba; |
| 4194 | int val = 0, i; |
| 4195 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4196 | /* fcp_imax is only valid for SLI4 */ |
| 4197 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4198 | return -EINVAL; |
| 4199 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4200 | /* Sanity check on user data */ |
| 4201 | if (!isdigit(buf[0])) |
| 4202 | return -EINVAL; |
| 4203 | if (sscanf(buf, "%i", &val) != 1) |
| 4204 | return -EINVAL; |
| 4205 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4206 | /* |
| 4207 | * Value range for the HBA is [5000,5000000] |
| 4208 | * The value for each EQ depends on how many EQs are configured. |
| 4209 | */ |
| 4210 | if (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4211 | return -EINVAL; |
| 4212 | |
| 4213 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4214 | 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] | 4215 | lpfc_modify_fcp_eq_delay(phba, i); |
| 4216 | |
| 4217 | return strlen(buf); |
| 4218 | } |
| 4219 | |
| 4220 | /* |
| 4221 | # 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] | 4222 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4223 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4224 | # 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] | 4225 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4226 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4227 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4228 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4229 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4230 | lpfc_param_show(fcp_imax) |
| 4231 | |
| 4232 | /** |
| 4233 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4234 | * @phba: lpfc_hba pointer. |
| 4235 | * @val: link speed value. |
| 4236 | * |
| 4237 | * Description: |
| 4238 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4239 | * maximum number of fast-path FCP interrupts per second. |
| 4240 | * |
| 4241 | * Returns: |
| 4242 | * zero if val saved. |
| 4243 | * -EINVAL val out of range |
| 4244 | **/ |
| 4245 | static int |
| 4246 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4247 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4248 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4249 | phba->cfg_fcp_imax = 0; |
| 4250 | return 0; |
| 4251 | } |
| 4252 | |
| 4253 | if (val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4254 | phba->cfg_fcp_imax = val; |
| 4255 | return 0; |
| 4256 | } |
| 4257 | |
| 4258 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4259 | "3016 fcp_imax: %d out of range, using default\n", val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4260 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4261 | |
| 4262 | return 0; |
| 4263 | } |
| 4264 | |
| 4265 | static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, |
| 4266 | lpfc_fcp_imax_show, lpfc_fcp_imax_store); |
| 4267 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4268 | /** |
| 4269 | * lpfc_state_show - Display current driver CPU affinity |
| 4270 | * @dev: class converted to a Scsi_host structure. |
| 4271 | * @attr: device attribute, not used. |
| 4272 | * @buf: on return contains text describing the state of the link. |
| 4273 | * |
| 4274 | * Returns: size of formatted string. |
| 4275 | **/ |
| 4276 | static ssize_t |
| 4277 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4278 | char *buf) |
| 4279 | { |
| 4280 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4281 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4282 | struct lpfc_hba *phba = vport->phba; |
| 4283 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4284 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4285 | |
| 4286 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4287 | (phba->intr_type != MSIX)) |
| 4288 | return len; |
| 4289 | |
| 4290 | switch (phba->cfg_fcp_cpu_map) { |
| 4291 | case 0: |
| 4292 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4293 | "fcp_cpu_map: No mapping (%d)\n", |
| 4294 | phba->cfg_fcp_cpu_map); |
| 4295 | return len; |
| 4296 | case 1: |
| 4297 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4298 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4299 | "%d online CPUs\n", |
| 4300 | phba->cfg_fcp_cpu_map, |
| 4301 | phba->sli4_hba.num_online_cpu); |
| 4302 | break; |
| 4303 | case 2: |
| 4304 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4305 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4306 | "%d online CPUs\n", |
| 4307 | phba->cfg_fcp_cpu_map, |
| 4308 | phba->sli4_hba.num_online_cpu); |
| 4309 | break; |
| 4310 | } |
| 4311 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4312 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4313 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4314 | |
| 4315 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4316 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4317 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4318 | "CPU %02d io_chan %02d " |
| 4319 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4320 | phba->sli4_hba.curr_disp_cpu, |
| 4321 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4322 | cpup->core_id); |
| 4323 | else |
| 4324 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4325 | "CPU %02d io_chan %02d " |
| 4326 | "physid %d coreid %d IRQ %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, cpup->irq); |
| 4330 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4331 | phba->sli4_hba.curr_disp_cpu++; |
| 4332 | |
| 4333 | /* display max number of CPUs keeping some margin */ |
| 4334 | if (phba->sli4_hba.curr_disp_cpu < |
| 4335 | phba->sli4_hba.num_present_cpu && |
| 4336 | (len >= (PAGE_SIZE - 64))) { |
| 4337 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4338 | break; |
| 4339 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4340 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4341 | |
| 4342 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4343 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4344 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4345 | return len; |
| 4346 | } |
| 4347 | |
| 4348 | /** |
| 4349 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4350 | * @dev: class device that is converted into a Scsi_host. |
| 4351 | * @attr: device attribute, not used. |
| 4352 | * @buf: one or more lpfc_polling_flags values. |
| 4353 | * @count: not used. |
| 4354 | * |
| 4355 | * Returns: |
| 4356 | * -EINVAL - Not implemented yet. |
| 4357 | **/ |
| 4358 | static ssize_t |
| 4359 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4360 | const char *buf, size_t count) |
| 4361 | { |
| 4362 | int status = -EINVAL; |
| 4363 | return status; |
| 4364 | } |
| 4365 | |
| 4366 | /* |
| 4367 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4368 | # for the HBA. |
| 4369 | # |
| 4370 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4371 | # 0 - Do not affinitze IRQ vectors |
| 4372 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4373 | # (start with CPU0 for each HBA) |
| 4374 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4375 | # (round robin thru all CPUs across all HBAs) |
| 4376 | */ |
| 4377 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4378 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4379 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4380 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4381 | |
| 4382 | /** |
| 4383 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4384 | * @phba: lpfc_hba pointer. |
| 4385 | * @val: link speed value. |
| 4386 | * |
| 4387 | * Description: |
| 4388 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4389 | * MSIX vectors. |
| 4390 | * |
| 4391 | * Returns: |
| 4392 | * zero if val saved. |
| 4393 | * -EINVAL val out of range |
| 4394 | **/ |
| 4395 | static int |
| 4396 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4397 | { |
| 4398 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4399 | phba->cfg_fcp_cpu_map = 0; |
| 4400 | return 0; |
| 4401 | } |
| 4402 | |
| 4403 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4404 | phba->cfg_fcp_cpu_map = val; |
| 4405 | return 0; |
| 4406 | } |
| 4407 | |
| 4408 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4409 | "3326 fcp_cpu_map: %d out of range, using default\n", |
| 4410 | val); |
| 4411 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4412 | |
| 4413 | return 0; |
| 4414 | } |
| 4415 | |
| 4416 | static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, |
| 4417 | lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store); |
| 4418 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4419 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4420 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4421 | # Value range is [2,3]. Default value is 3. |
| 4422 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4423 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4424 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4425 | |
| 4426 | /* |
| 4427 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4428 | # is [0,1]. Default value is 0. |
| 4429 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4430 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4431 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4432 | |
| 4433 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4434 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4435 | # that support first burst. |
| 4436 | # Value range is [0,65536]. Default value is 0. |
| 4437 | */ |
| 4438 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4439 | "First burst size for Targets that support first burst"); |
| 4440 | |
| 4441 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4442 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4443 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4444 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4445 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4446 | # to limit the I/O completion time to the parameter value. |
| 4447 | # The value is set in milliseconds. |
| 4448 | */ |
| 4449 | static int lpfc_max_scsicmpl_time; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4450 | module_param(lpfc_max_scsicmpl_time, int, S_IRUGO); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4451 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, |
| 4452 | "Use command completion time to control queue depth"); |
| 4453 | lpfc_vport_param_show(max_scsicmpl_time); |
| 4454 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); |
| 4455 | static int |
| 4456 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4457 | { |
| 4458 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4459 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4460 | |
| 4461 | if (val == vport->cfg_max_scsicmpl_time) |
| 4462 | return 0; |
| 4463 | if ((val < 0) || (val > 60000)) |
| 4464 | return -EINVAL; |
| 4465 | vport->cfg_max_scsicmpl_time = val; |
| 4466 | |
| 4467 | spin_lock_irq(shost->host_lock); |
| 4468 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4469 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4470 | continue; |
| 4471 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4472 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4473 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4474 | } |
| 4475 | spin_unlock_irq(shost->host_lock); |
| 4476 | return 0; |
| 4477 | } |
| 4478 | lpfc_vport_param_store(max_scsicmpl_time); |
| 4479 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 4480 | lpfc_max_scsicmpl_time_show, |
| 4481 | lpfc_max_scsicmpl_time_store); |
| 4482 | |
| 4483 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4484 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4485 | # range is [0,1]. Default value is 0. |
| 4486 | */ |
| 4487 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4488 | |
| 4489 | /* |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4490 | # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4491 | # range is [0,1]. Default value is 0. |
| 4492 | # For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4493 | # For [1], FCP commands are issued to a Work Queue associated with the |
| 4494 | # current CPU. |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4495 | # It would be set to 1 by the driver if it's able to set up cpu affinity |
| 4496 | # for FCP I/Os through Work Queue associated with the current CPU. Otherwise, |
| 4497 | # roundrobin scheduling of FCP I/Os through WQs will be used. |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4498 | */ |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4499 | 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] | 4500 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
| 4501 | |
| 4502 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4503 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4504 | # range is [0,1]. Default value is 0. |
| 4505 | # For [0], bus reset issues target reset to ALL devices |
| 4506 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4507 | */ |
| 4508 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4509 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4510 | |
| 4511 | |
| 4512 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4513 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4514 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4515 | # 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] | 4516 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4517 | # cr_delay is set to 0. |
| 4518 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4519 | 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] | 4520 | "interrupt response is generated"); |
| 4521 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4522 | 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] | 4523 | "interrupt response is generated"); |
| 4524 | |
| 4525 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4526 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4527 | # cmd/rsp IOCB entries across. |
| 4528 | # Value range is [1,2]. Default value is 1. |
| 4529 | */ |
| 4530 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4531 | "SLI rings to spread IOCB entries across"); |
| 4532 | |
| 4533 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4534 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4535 | # identifies what rctl value to configure the additional ring for. |
| 4536 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4537 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4538 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4539 | 255, "Identifies RCTL for additional ring configuration"); |
| 4540 | |
| 4541 | /* |
| 4542 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4543 | # identifies what type value to configure the additional ring for. |
| 4544 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4545 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4546 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4547 | 255, "Identifies TYPE for additional ring configuration"); |
| 4548 | |
| 4549 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4550 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 4551 | # 0 = SmartSAN functionality disabled (default) |
| 4552 | # 1 = SmartSAN functionality enabled |
| 4553 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 4554 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4555 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4556 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 4557 | |
| 4558 | /* |
| 4559 | # lpfc_fdmi_on: Controls FDMI support. |
| 4560 | # 0 No FDMI support (default) |
| 4561 | # 1 Traditional FDMI support |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4562 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 4563 | # however, if that fails, it will fallback to FDMI-1. |
| 4564 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 4565 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 4566 | # lpfc_fdmi_on. |
| 4567 | # Value range [0,1]. Default value is 0. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4568 | */ |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4569 | LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4570 | |
| 4571 | /* |
| 4572 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4573 | # discovery). Value range is [1,64]. Default value = 32. |
| 4574 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4575 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4576 | "during discovery"); |
| 4577 | |
| 4578 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4579 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4580 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4581 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4582 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4583 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4584 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4585 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4586 | # on a target can take minutes of wall clock time. Additionally, |
| 4587 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4588 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4589 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4590 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4591 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4592 | # devices present, when in fact, there is only 1. |
| 4593 | # A customer that is aware of their target behaviors, and the results as |
| 4594 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4595 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4596 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4597 | # Value range is [0,65535]. Default value is 255. |
| 4598 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4599 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 4600 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4601 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4602 | /* |
| 4603 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4604 | # Value range is [1,255], default value is 10. |
| 4605 | */ |
| 4606 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4607 | "Milliseconds driver will wait between polling FCP ring"); |
| 4608 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4609 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4610 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4611 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4612 | */ |
| 4613 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4614 | "Maximum time to wait for task management commands to complete"); |
| 4615 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4616 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4617 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4618 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4619 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4620 | # 2 = MSI-X enabled (default) |
| 4621 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4622 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4623 | 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] | 4624 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4625 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4626 | /* |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4627 | # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels |
| 4628 | # |
| 4629 | # Value range is [1,7]. Default value is 4. |
| 4630 | */ |
| 4631 | LPFC_ATTR_R(fcp_io_channel, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN, |
| 4632 | LPFC_FCP_IO_CHAN_MAX, |
| 4633 | "Set the number of FCP I/O channels"); |
| 4634 | |
| 4635 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4636 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 4637 | # 0 = HBA resets disabled |
| 4638 | # 1 = HBA resets enabled (default) |
| 4639 | # Value range is [0,1]. Default value is 1. |
| 4640 | */ |
| 4641 | 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] | 4642 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4643 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4644 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4645 | # 0 = HBA Heartbeat disabled |
| 4646 | # 1 = HBA Heartbeat enabled (default) |
| 4647 | # Value range is [0,1]. Default value is 1. |
| 4648 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4649 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4650 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4651 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4652 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 4653 | # 0x0 Express Lane Feature disabled |
| 4654 | # 0x1 Express Lane Feature enabled |
| 4655 | # Value range is [0,1]. Default value is 0. |
| 4656 | */ |
| 4657 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 4658 | |
| 4659 | /* |
| 4660 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 4661 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 4662 | # Value range is [0x0,0x7f]. Default value is 0 |
| 4663 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 4664 | LPFC_ATTR_RW(XLanePriority, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature."); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4665 | |
| 4666 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4667 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 4668 | # 0 = BlockGuard disabled (default) |
| 4669 | # 1 = BlockGuard enabled |
| 4670 | # Value range is [0,1]. Default value is 0. |
| 4671 | */ |
| 4672 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 4673 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4674 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4675 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 4676 | # 0 = disabled (default) |
| 4677 | # 1 = enabled |
| 4678 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 4679 | # |
| 4680 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4681 | */ |
| 4682 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 4683 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4684 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4685 | # lpfc_prot_mask: i |
| 4686 | # - Bit mask of host protection capabilities used to register with the |
| 4687 | # SCSI mid-layer |
| 4688 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 4689 | # - Allows you to ultimately specify which profiles to use |
| 4690 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 4691 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 4692 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 4693 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 4694 | # HBA supports DIX Type 0: Host to HBA protection only |
| 4695 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 4696 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4697 | # |
| 4698 | */ |
James Smart | 7c56b9f | 2011-07-22 18:36:25 -0400 | [diff] [blame] | 4699 | unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION | |
| 4700 | SHOST_DIX_TYPE0_PROTECTION | |
| 4701 | SHOST_DIX_TYPE1_PROTECTION; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4702 | |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4703 | module_param(lpfc_prot_mask, uint, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4704 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); |
| 4705 | |
| 4706 | /* |
| 4707 | # lpfc_prot_guard: i |
| 4708 | # - 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] | 4709 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4710 | # - Allows you to ultimately specify which profiles to use |
| 4711 | # - Default will result in registering capabilities for all guard types |
| 4712 | # |
| 4713 | */ |
| 4714 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4715 | module_param(lpfc_prot_guard, byte, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4716 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); |
| 4717 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4718 | /* |
| 4719 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 4720 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 4721 | * This parameter can have value 0 or 1. |
| 4722 | * When this parameter is set to 0, no delay is added to the initial |
| 4723 | * discovery. |
| 4724 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 4725 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 4726 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4727 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 4728 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 4729 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4730 | * Default value is 0. |
| 4731 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 4732 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 4733 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4734 | |
| 4735 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4736 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4737 | * 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] | 4738 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 4739 | * 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] | 4740 | * Because of the additional overhead involved in setting up T10-DIF, |
| 4741 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 4742 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4743 | */ |
| 4744 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 4745 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 4746 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4747 | /* |
| 4748 | * This parameter will be depricated, the driver cannot limit the |
| 4749 | * protection data s/g list. |
| 4750 | */ |
| 4751 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, |
| 4752 | LPFC_DEFAULT_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT, |
| 4753 | "Max Protection Scatter Gather Segment Count"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4754 | |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 4755 | /* |
| 4756 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 4757 | * 0 = MDS Diagnostics disabled (default) |
| 4758 | * 1 = MDS Diagnostics enabled |
| 4759 | * Value range is [0,1]. Default value is 0. |
| 4760 | */ |
| 4761 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 4762 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4763 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4764 | &dev_attr_bg_info, |
| 4765 | &dev_attr_bg_guard_err, |
| 4766 | &dev_attr_bg_apptag_err, |
| 4767 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4768 | &dev_attr_info, |
| 4769 | &dev_attr_serialnum, |
| 4770 | &dev_attr_modeldesc, |
| 4771 | &dev_attr_modelname, |
| 4772 | &dev_attr_programtype, |
| 4773 | &dev_attr_portnum, |
| 4774 | &dev_attr_fwrev, |
| 4775 | &dev_attr_hdw, |
| 4776 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4777 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4778 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 4779 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4780 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 4781 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4782 | &dev_attr_lpfc_temp_sensor, |
| 4783 | &dev_attr_lpfc_log_verbose, |
| 4784 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4785 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4786 | &dev_attr_lpfc_hba_queue_depth, |
| 4787 | &dev_attr_lpfc_peer_port_login, |
| 4788 | &dev_attr_lpfc_nodev_tmo, |
| 4789 | &dev_attr_lpfc_devloss_tmo, |
| 4790 | &dev_attr_lpfc_fcp_class, |
| 4791 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4792 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4793 | &dev_attr_lpfc_ack0, |
| 4794 | &dev_attr_lpfc_topology, |
| 4795 | &dev_attr_lpfc_scan_down, |
| 4796 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4797 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4798 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4799 | &dev_attr_lpfc_cr_delay, |
| 4800 | &dev_attr_lpfc_cr_count, |
| 4801 | &dev_attr_lpfc_multi_ring_support, |
| 4802 | &dev_attr_lpfc_multi_ring_rctl, |
| 4803 | &dev_attr_lpfc_multi_ring_type, |
| 4804 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4805 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4806 | &dev_attr_lpfc_max_luns, |
| 4807 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 4808 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4809 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4810 | &dev_attr_nport_evt_cnt, |
| 4811 | &dev_attr_board_mode, |
| 4812 | &dev_attr_max_vpi, |
| 4813 | &dev_attr_used_vpi, |
| 4814 | &dev_attr_max_rpi, |
| 4815 | &dev_attr_used_rpi, |
| 4816 | &dev_attr_max_xri, |
| 4817 | &dev_attr_used_xri, |
| 4818 | &dev_attr_npiv_info, |
| 4819 | &dev_attr_issue_reset, |
| 4820 | &dev_attr_lpfc_poll, |
| 4821 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4822 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4823 | &dev_attr_lpfc_use_msi, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 4824 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4825 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4826 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4827 | &dev_attr_lpfc_enable_bg, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4828 | &dev_attr_lpfc_soft_wwnn, |
| 4829 | &dev_attr_lpfc_soft_wwpn, |
| 4830 | &dev_attr_lpfc_soft_wwn_enable, |
| 4831 | &dev_attr_lpfc_enable_hba_reset, |
| 4832 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4833 | &dev_attr_lpfc_EnableXLane, |
| 4834 | &dev_attr_lpfc_XLanePriority, |
| 4835 | &dev_attr_lpfc_xlane_lun, |
| 4836 | &dev_attr_lpfc_xlane_tgt, |
| 4837 | &dev_attr_lpfc_xlane_vpt, |
| 4838 | &dev_attr_lpfc_xlane_lun_state, |
| 4839 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 4840 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4841 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4842 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4843 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4844 | &dev_attr_lpfc_prot_sg_seg_cnt, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4845 | &dev_attr_lpfc_aer_support, |
| 4846 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4847 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4848 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 4849 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 4850 | &dev_attr_lpfc_iocb_cnt, |
| 4851 | &dev_attr_iocb_hw, |
| 4852 | &dev_attr_txq_hw, |
| 4853 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4854 | &dev_attr_lpfc_fips_level, |
| 4855 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4856 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4857 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 4858 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4859 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 4860 | &dev_attr_lpfc_enable_mds_diags, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4861 | NULL, |
| 4862 | }; |
| 4863 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4864 | struct device_attribute *lpfc_vport_attrs[] = { |
| 4865 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4866 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4867 | &dev_attr_num_discovered_ports, |
| 4868 | &dev_attr_lpfc_drvr_version, |
| 4869 | &dev_attr_lpfc_log_verbose, |
| 4870 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4871 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4872 | &dev_attr_lpfc_nodev_tmo, |
| 4873 | &dev_attr_lpfc_devloss_tmo, |
| 4874 | &dev_attr_lpfc_hba_queue_depth, |
| 4875 | &dev_attr_lpfc_peer_port_login, |
| 4876 | &dev_attr_lpfc_restrict_login, |
| 4877 | &dev_attr_lpfc_fcp_class, |
| 4878 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4879 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4880 | &dev_attr_lpfc_max_luns, |
| 4881 | &dev_attr_nport_evt_cnt, |
| 4882 | &dev_attr_npiv_info, |
| 4883 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4884 | &dev_attr_lpfc_max_scsicmpl_time, |
| 4885 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4886 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4887 | &dev_attr_lpfc_fips_level, |
| 4888 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4889 | NULL, |
| 4890 | }; |
| 4891 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4892 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4893 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4894 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4895 | * @kobj: kernel kobject that contains the kernel class device. |
| 4896 | * @bin_attr: kernel attributes passed to us. |
| 4897 | * @buf: contains the data to be written to the adapter IOREG space. |
| 4898 | * @off: offset into buffer to beginning of data. |
| 4899 | * @count: bytes to transfer. |
| 4900 | * |
| 4901 | * Description: |
| 4902 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4903 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 4904 | * |
| 4905 | * Returns: |
| 4906 | * -ERANGE off and count combo out of range |
| 4907 | * -EINVAL off, count or buff address invalid |
| 4908 | * -EPERM adapter is offline |
| 4909 | * value of count, buf contents written |
| 4910 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4911 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4912 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 4913 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 4914 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4915 | { |
| 4916 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4917 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4918 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4919 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4920 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4921 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 4922 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 4923 | return -EPERM; |
| 4924 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4925 | if ((off + count) > FF_REG_AREA_SIZE) |
| 4926 | return -ERANGE; |
| 4927 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4928 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 4929 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4930 | |
| 4931 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 4932 | return -EINVAL; |
| 4933 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4934 | /* This is to protect HBA registers from accidental writes. */ |
| 4935 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 4936 | return -EINVAL; |
| 4937 | |
| 4938 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4939 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4940 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4941 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4942 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 4943 | buf_off += sizeof(uint32_t)) |
| 4944 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4945 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 4946 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4947 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4948 | |
| 4949 | return count; |
| 4950 | } |
| 4951 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4952 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4953 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4954 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4955 | * @kobj: kernel kobject that contains the kernel class device. |
| 4956 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 4957 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4958 | * @off: offset into buffer to beginning of data. |
| 4959 | * @count: bytes to transfer. |
| 4960 | * |
| 4961 | * Description: |
| 4962 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4963 | * Uses the adapter io control registers to read data into buf. |
| 4964 | * |
| 4965 | * Returns: |
| 4966 | * -ERANGE off and count combo out of range |
| 4967 | * -EINVAL off, count or buff address invalid |
| 4968 | * value of count, buf contents read |
| 4969 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4970 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4971 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 4972 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 4973 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4974 | { |
| 4975 | size_t buf_off; |
| 4976 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4977 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4978 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4979 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4980 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4981 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 4982 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 4983 | return -EPERM; |
| 4984 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4985 | if (off > FF_REG_AREA_SIZE) |
| 4986 | return -ERANGE; |
| 4987 | |
| 4988 | if ((off + count) > FF_REG_AREA_SIZE) |
| 4989 | count = FF_REG_AREA_SIZE - off; |
| 4990 | |
| 4991 | if (count == 0) return 0; |
| 4992 | |
| 4993 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 4994 | return -EINVAL; |
| 4995 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4996 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4997 | |
| 4998 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 4999 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5000 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5001 | } |
| 5002 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5003 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5004 | |
| 5005 | return count; |
| 5006 | } |
| 5007 | |
| 5008 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5009 | .attr = { |
| 5010 | .name = "ctlreg", |
| 5011 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5012 | }, |
| 5013 | .size = 256, |
| 5014 | .read = sysfs_ctlreg_read, |
| 5015 | .write = sysfs_ctlreg_write, |
| 5016 | }; |
| 5017 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5018 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5019 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5020 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5021 | * @kobj: kernel kobject that contains the kernel class device. |
| 5022 | * @bin_attr: kernel attributes passed to us. |
| 5023 | * @buf: contains the data to be written to sysfs mbox. |
| 5024 | * @off: offset into buffer to beginning of data. |
| 5025 | * @count: bytes to transfer. |
| 5026 | * |
| 5027 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5028 | * Deprecated function. All mailbox access from user space is performed via the |
| 5029 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5030 | * |
| 5031 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5032 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5033 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5034 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5035 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5036 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5037 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5038 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5039 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5040 | } |
| 5041 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5042 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5043 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5044 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5045 | * @kobj: kernel kobject that contains the kernel class device. |
| 5046 | * @bin_attr: kernel attributes passed to us. |
| 5047 | * @buf: contains the data to be read from sysfs mbox. |
| 5048 | * @off: offset into buffer to beginning of data. |
| 5049 | * @count: bytes to transfer. |
| 5050 | * |
| 5051 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5052 | * Deprecated function. All mailbox access from user space is performed via the |
| 5053 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5054 | * |
| 5055 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5056 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5057 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5058 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5059 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5060 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5061 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5062 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5063 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5064 | } |
| 5065 | |
| 5066 | static struct bin_attribute sysfs_mbox_attr = { |
| 5067 | .attr = { |
| 5068 | .name = "mbox", |
| 5069 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5070 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5071 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5072 | .read = sysfs_mbox_read, |
| 5073 | .write = sysfs_mbox_write, |
| 5074 | }; |
| 5075 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5076 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5077 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5078 | * @vport: address of lpfc vport structure. |
| 5079 | * |
| 5080 | * Return codes: |
| 5081 | * zero on success |
| 5082 | * error return code from sysfs_create_bin_file() |
| 5083 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5084 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5085 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5086 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5087 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5088 | int error; |
| 5089 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5090 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5091 | &sysfs_drvr_stat_data_attr); |
| 5092 | |
| 5093 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5094 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5095 | goto out; |
| 5096 | |
| 5097 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5098 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5099 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5100 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5101 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5102 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5103 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5104 | if (error) |
| 5105 | goto out_remove_ctlreg_attr; |
| 5106 | |
| 5107 | return 0; |
| 5108 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5109 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5110 | out_remove_stat_attr: |
| 5111 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5112 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5113 | out: |
| 5114 | return error; |
| 5115 | } |
| 5116 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5117 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5118 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5119 | * @vport: address of lpfc vport structure. |
| 5120 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5121 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5122 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5123 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5124 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5125 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5126 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5127 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5128 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5129 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5130 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5131 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5132 | } |
| 5133 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5134 | /* |
| 5135 | * Dynamic FC Host Attributes Support |
| 5136 | */ |
| 5137 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5138 | /** |
James Smart | f89885d | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5139 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 5140 | * @shost: kernel scsi host pointer. |
| 5141 | **/ |
| 5142 | static void |
| 5143 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 5144 | { |
| 5145 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5146 | |
| 5147 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 5148 | sizeof fc_host_symbolic_name(shost)); |
| 5149 | } |
| 5150 | |
| 5151 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5152 | * 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] | 5153 | * @shost: kernel scsi host pointer. |
| 5154 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5155 | static void |
| 5156 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5157 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5158 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5159 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5160 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5161 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5162 | } |
| 5163 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5164 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5165 | * lpfc_get_host_port_type - Set the value of the scsi host port type |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5166 | * @shost: kernel scsi host pointer. |
| 5167 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5168 | static void |
| 5169 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5170 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5171 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5172 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5173 | |
| 5174 | spin_lock_irq(shost->host_lock); |
| 5175 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5176 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5177 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5178 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5179 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5180 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5181 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5182 | else |
| 5183 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5184 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5185 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5186 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5187 | else |
| 5188 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5189 | } |
| 5190 | } else |
| 5191 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5192 | |
| 5193 | spin_unlock_irq(shost->host_lock); |
| 5194 | } |
| 5195 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5196 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5197 | * 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] | 5198 | * @shost: kernel scsi host pointer. |
| 5199 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5200 | static void |
| 5201 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5202 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5203 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5204 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5205 | |
| 5206 | spin_lock_irq(shost->host_lock); |
| 5207 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5208 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5209 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5210 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5211 | switch (phba->link_state) { |
| 5212 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5213 | case LPFC_LINK_DOWN: |
| 5214 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5215 | break; |
| 5216 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5217 | case LPFC_CLEAR_LA: |
| 5218 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5219 | /* Links up, reports port state accordingly */ |
| 5220 | if (vport->port_state < LPFC_VPORT_READY) |
| 5221 | fc_host_port_state(shost) = |
| 5222 | FC_PORTSTATE_BYPASSED; |
| 5223 | else |
| 5224 | fc_host_port_state(shost) = |
| 5225 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5226 | break; |
| 5227 | case LPFC_HBA_ERROR: |
| 5228 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5229 | break; |
| 5230 | default: |
| 5231 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5232 | break; |
| 5233 | } |
| 5234 | } |
| 5235 | |
| 5236 | spin_unlock_irq(shost->host_lock); |
| 5237 | } |
| 5238 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5239 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5240 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5241 | * @shost: kernel scsi host pointer. |
| 5242 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5243 | static void |
| 5244 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5245 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5246 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5247 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5248 | |
| 5249 | spin_lock_irq(shost->host_lock); |
| 5250 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 5251 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5252 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5253 | case LPFC_LINK_SPEED_1GHZ: |
| 5254 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5255 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5256 | case LPFC_LINK_SPEED_2GHZ: |
| 5257 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5258 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5259 | case LPFC_LINK_SPEED_4GHZ: |
| 5260 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5261 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5262 | case LPFC_LINK_SPEED_8GHZ: |
| 5263 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5264 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5265 | case LPFC_LINK_SPEED_10GHZ: |
| 5266 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5267 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5268 | case LPFC_LINK_SPEED_16GHZ: |
| 5269 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5270 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 5271 | case LPFC_LINK_SPEED_32GHZ: |
| 5272 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 5273 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5274 | default: |
| 5275 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5276 | break; |
| 5277 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5278 | } else |
| 5279 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5280 | |
| 5281 | spin_unlock_irq(shost->host_lock); |
| 5282 | } |
| 5283 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5284 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5285 | * 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] | 5286 | * @shost: kernel scsi host pointer. |
| 5287 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5288 | static void |
| 5289 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5290 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5291 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5292 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5293 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5294 | |
| 5295 | spin_lock_irq(shost->host_lock); |
| 5296 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5297 | if ((vport->port_state > LPFC_FLOGI) && |
| 5298 | ((vport->fc_flag & FC_FABRIC) || |
| 5299 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5300 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5301 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5302 | else |
| 5303 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5304 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5305 | |
| 5306 | spin_unlock_irq(shost->host_lock); |
| 5307 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5308 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5309 | } |
| 5310 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5311 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5312 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5313 | * @shost: kernel scsi host pointer. |
| 5314 | * |
| 5315 | * Notes: |
| 5316 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5317 | * management not allowed, memory allocation error, or mbox error. |
| 5318 | * |
| 5319 | * Returns: |
| 5320 | * NULL for error |
| 5321 | * address of the adapter host statistics |
| 5322 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5323 | static struct fc_host_statistics * |
| 5324 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5325 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5326 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5327 | struct lpfc_hba *phba = vport->phba; |
| 5328 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5329 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5330 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5331 | LPFC_MBOXQ_t *pmboxq; |
| 5332 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5333 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5334 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5335 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5336 | /* |
| 5337 | * prevent udev from issuing mailbox commands until the port is |
| 5338 | * configured. |
| 5339 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5340 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5341 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5342 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5343 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5344 | |
| 5345 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5346 | return NULL; |
| 5347 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5348 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5349 | if (!pmboxq) |
| 5350 | return NULL; |
| 5351 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5352 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5353 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5354 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5355 | pmb->mbxOwner = OWN_HOST; |
| 5356 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5357 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5358 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5359 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5360 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5361 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5362 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5363 | |
| 5364 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5365 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5366 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5367 | return NULL; |
| 5368 | } |
| 5369 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5370 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5371 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5372 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5373 | /* |
| 5374 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5375 | * converted to words |
| 5376 | */ |
| 5377 | hs->tx_words = (uint64_t) |
| 5378 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5379 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5380 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5381 | hs->rx_words = (uint64_t) |
| 5382 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5383 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5384 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5385 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5386 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5387 | pmb->mbxOwner = OWN_HOST; |
| 5388 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5389 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5390 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5391 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5392 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5393 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5394 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5395 | |
| 5396 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5397 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5398 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5399 | return NULL; |
| 5400 | } |
| 5401 | |
| 5402 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5403 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5404 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5405 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5406 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5407 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5408 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5409 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5410 | hs->link_failure_count -= lso->link_failure_count; |
| 5411 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5412 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5413 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5414 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5415 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5416 | hs->error_frames -= lso->error_frames; |
| 5417 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5418 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5419 | hs->lip_count = -1; |
| 5420 | hs->nos_count = (phba->link_events >> 1); |
| 5421 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5422 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5423 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5424 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5425 | hs->nos_count = -1; |
| 5426 | } else { |
| 5427 | hs->lip_count = -1; |
| 5428 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5429 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5430 | } |
| 5431 | |
| 5432 | hs->dumped_frames = -1; |
| 5433 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5434 | seconds = get_seconds(); |
| 5435 | if (seconds < psli->stats_start) |
| 5436 | hs->seconds_since_last_reset = seconds + |
| 5437 | ((unsigned long)-1 - psli->stats_start); |
| 5438 | else |
| 5439 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5440 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5441 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5442 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5443 | return hs; |
| 5444 | } |
| 5445 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5446 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5447 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5448 | * @shost: kernel scsi host pointer. |
| 5449 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5450 | static void |
| 5451 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5452 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5453 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5454 | struct lpfc_hba *phba = vport->phba; |
| 5455 | struct lpfc_sli *psli = &phba->sli; |
| 5456 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5457 | LPFC_MBOXQ_t *pmboxq; |
| 5458 | MAILBOX_t *pmb; |
| 5459 | int rc = 0; |
| 5460 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5461 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5462 | return; |
| 5463 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5464 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5465 | if (!pmboxq) |
| 5466 | return; |
| 5467 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5468 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5469 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5470 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5471 | pmb->mbxOwner = OWN_HOST; |
| 5472 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5473 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5474 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5475 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5476 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5477 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5478 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5479 | else |
| 5480 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5481 | |
| 5482 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5483 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5484 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5485 | return; |
| 5486 | } |
| 5487 | |
| 5488 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5489 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5490 | pmb->mbxOwner = OWN_HOST; |
| 5491 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5492 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5493 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5494 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5495 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5496 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5497 | else |
| 5498 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5499 | |
| 5500 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5501 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5502 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5503 | return; |
| 5504 | } |
| 5505 | |
| 5506 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5507 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5508 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5509 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5510 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5511 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5512 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5513 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5514 | lso->link_events = (phba->link_events >> 1); |
| 5515 | else |
| 5516 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5517 | |
| 5518 | psli->stats_start = get_seconds(); |
| 5519 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5520 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5521 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5522 | return; |
| 5523 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5524 | |
| 5525 | /* |
| 5526 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5527 | * are no sysfs handlers for link_down_tmo. |
| 5528 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5529 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5530 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5531 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5532 | * @starget: kernel scsi target pointer. |
| 5533 | * |
| 5534 | * Returns: |
| 5535 | * address of the node list if found |
| 5536 | * NULL target not found |
| 5537 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5538 | static struct lpfc_nodelist * |
| 5539 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5540 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5541 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5542 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5543 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5544 | |
| 5545 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5546 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5547 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5548 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5549 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5550 | starget->id == ndlp->nlp_sid) { |
| 5551 | spin_unlock_irq(shost->host_lock); |
| 5552 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5553 | } |
| 5554 | } |
| 5555 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5556 | return NULL; |
| 5557 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5558 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5559 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5560 | * 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] | 5561 | * @starget: kernel scsi target pointer. |
| 5562 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5563 | static void |
| 5564 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5565 | { |
| 5566 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5567 | |
| 5568 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5569 | } |
| 5570 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5571 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5572 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5573 | * @starget: kernel scsi target pointer. |
| 5574 | * |
| 5575 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 5576 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5577 | static void |
| 5578 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 5579 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5580 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5581 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5582 | fc_starget_node_name(starget) = |
| 5583 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5584 | } |
| 5585 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5586 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5587 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5588 | * @starget: kernel scsi target pointer. |
| 5589 | * |
| 5590 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 5591 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5592 | static void |
| 5593 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 5594 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5595 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5596 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5597 | fc_starget_port_name(starget) = |
| 5598 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5599 | } |
| 5600 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5601 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5602 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5603 | * @rport: fc rport address. |
| 5604 | * @timeout: new value for dev loss tmo. |
| 5605 | * |
| 5606 | * Description: |
| 5607 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 5608 | * dev_loss_tmo to one. |
| 5609 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5610 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5611 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 5612 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5613 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5614 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5615 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5616 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5617 | } |
| 5618 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5619 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5620 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5621 | * |
| 5622 | * Description: |
| 5623 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 5624 | * |
| 5625 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 5626 | * @cdev: class converted to an fc_rport. |
| 5627 | * @buf: on return contains the target_field or zero. |
| 5628 | * |
| 5629 | * Returns: size of formatted string. |
| 5630 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5631 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 5632 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5633 | lpfc_show_rport_##field (struct device *dev, \ |
| 5634 | struct device_attribute *attr, \ |
| 5635 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5636 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5637 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5638 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 5639 | return snprintf(buf, sz, format_string, \ |
| 5640 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 5641 | } |
| 5642 | |
| 5643 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 5644 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 5645 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 5646 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5647 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5648 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5649 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 5650 | * |
| 5651 | * Description: |
| 5652 | * This function is called by the transport after the @fc_vport's symbolic name |
| 5653 | * 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] | 5654 | * 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] | 5655 | **/ |
| 5656 | static void |
| 5657 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 5658 | { |
| 5659 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 5660 | |
| 5661 | if (vport->port_state == LPFC_VPORT_READY) |
| 5662 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 5663 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5664 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5665 | /** |
| 5666 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 5667 | * @phba: Pointer to lpfc_hba struct. |
| 5668 | * |
| 5669 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 5670 | * 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] | 5671 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5672 | * before hba port or vport created. |
| 5673 | **/ |
| 5674 | static void |
| 5675 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 5676 | { |
| 5677 | phba->cfg_log_verbose = verbose; |
| 5678 | } |
| 5679 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5680 | struct fc_function_template lpfc_transport_functions = { |
| 5681 | /* fixed attributes the driver supports */ |
| 5682 | .show_host_node_name = 1, |
| 5683 | .show_host_port_name = 1, |
| 5684 | .show_host_supported_classes = 1, |
| 5685 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5686 | .show_host_supported_speeds = 1, |
| 5687 | .show_host_maxframe_size = 1, |
James Smart | f89885d | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5688 | |
| 5689 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5690 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5691 | |
| 5692 | /* dynamic attributes the driver supports */ |
| 5693 | .get_host_port_id = lpfc_get_host_port_id, |
| 5694 | .show_host_port_id = 1, |
| 5695 | |
| 5696 | .get_host_port_type = lpfc_get_host_port_type, |
| 5697 | .show_host_port_type = 1, |
| 5698 | |
| 5699 | .get_host_port_state = lpfc_get_host_port_state, |
| 5700 | .show_host_port_state = 1, |
| 5701 | |
| 5702 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5703 | .show_host_active_fc4s = 1, |
| 5704 | |
| 5705 | .get_host_speed = lpfc_get_host_speed, |
| 5706 | .show_host_speed = 1, |
| 5707 | |
| 5708 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5709 | .show_host_fabric_name = 1, |
| 5710 | |
| 5711 | /* |
| 5712 | * The LPFC driver treats linkdown handling as target loss events |
| 5713 | * so there are no sysfs handlers for link_down_tmo. |
| 5714 | */ |
| 5715 | |
| 5716 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5717 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5718 | |
| 5719 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5720 | .show_rport_maxframe_size = 1, |
| 5721 | .show_rport_supported_classes = 1, |
| 5722 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5723 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5724 | .show_rport_dev_loss_tmo = 1, |
| 5725 | |
| 5726 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5727 | .show_starget_port_id = 1, |
| 5728 | |
| 5729 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5730 | .show_starget_node_name = 1, |
| 5731 | |
| 5732 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5733 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 5734 | |
| 5735 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5736 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5737 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5738 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5739 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5740 | |
| 5741 | .vport_disable = lpfc_vport_disable, |
| 5742 | |
| 5743 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 5744 | |
| 5745 | .bsg_request = lpfc_bsg_request, |
| 5746 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5747 | }; |
| 5748 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5749 | struct fc_function_template lpfc_vport_transport_functions = { |
| 5750 | /* fixed attributes the driver supports */ |
| 5751 | .show_host_node_name = 1, |
| 5752 | .show_host_port_name = 1, |
| 5753 | .show_host_supported_classes = 1, |
| 5754 | .show_host_supported_fc4s = 1, |
| 5755 | .show_host_supported_speeds = 1, |
| 5756 | .show_host_maxframe_size = 1, |
James Smart | f89885d | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5757 | |
| 5758 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5759 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5760 | |
| 5761 | /* dynamic attributes the driver supports */ |
| 5762 | .get_host_port_id = lpfc_get_host_port_id, |
| 5763 | .show_host_port_id = 1, |
| 5764 | |
| 5765 | .get_host_port_type = lpfc_get_host_port_type, |
| 5766 | .show_host_port_type = 1, |
| 5767 | |
| 5768 | .get_host_port_state = lpfc_get_host_port_state, |
| 5769 | .show_host_port_state = 1, |
| 5770 | |
| 5771 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5772 | .show_host_active_fc4s = 1, |
| 5773 | |
| 5774 | .get_host_speed = lpfc_get_host_speed, |
| 5775 | .show_host_speed = 1, |
| 5776 | |
| 5777 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5778 | .show_host_fabric_name = 1, |
| 5779 | |
| 5780 | /* |
| 5781 | * The LPFC driver treats linkdown handling as target loss events |
| 5782 | * so there are no sysfs handlers for link_down_tmo. |
| 5783 | */ |
| 5784 | |
| 5785 | .get_fc_host_stats = lpfc_get_stats, |
| 5786 | .reset_fc_host_stats = lpfc_reset_stats, |
| 5787 | |
| 5788 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5789 | .show_rport_maxframe_size = 1, |
| 5790 | .show_rport_supported_classes = 1, |
| 5791 | |
| 5792 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5793 | .show_rport_dev_loss_tmo = 1, |
| 5794 | |
| 5795 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5796 | .show_starget_port_id = 1, |
| 5797 | |
| 5798 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5799 | .show_starget_node_name = 1, |
| 5800 | |
| 5801 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5802 | .show_starget_port_name = 1, |
| 5803 | |
| 5804 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5805 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 5806 | |
| 5807 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5808 | |
| 5809 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5810 | }; |
| 5811 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5812 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5813 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5814 | * @phba: lpfc_hba pointer. |
| 5815 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5816 | void |
| 5817 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 5818 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5819 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5820 | 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] | 5821 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 5822 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5823 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5824 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 5825 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5826 | lpfc_ack0_init(phba, lpfc_ack0); |
| 5827 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5828 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5829 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5830 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5831 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5832 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5833 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5834 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 5835 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5836 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5837 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5838 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5839 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5840 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 5841 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5842 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 5843 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5844 | phba->cfg_EnableXLane = 0; |
| 5845 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
| 5846 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5847 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5848 | phba->cfg_oas_lun_state = 0; |
| 5849 | phba->cfg_oas_lun_status = 0; |
| 5850 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5851 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5852 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5853 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 5854 | phba->cfg_poll = 0; |
| 5855 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5856 | phba->cfg_poll = lpfc_poll; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5857 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 5858 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5859 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5860 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5861 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5862 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5863 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5864 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5865 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5866 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5867 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5868 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5869 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 5870 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5871 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5872 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5873 | return; |
| 5874 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 5875 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5876 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5877 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5878 | * @vport: lpfc_vport pointer. |
| 5879 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5880 | void |
| 5881 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 5882 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5883 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5884 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5885 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5886 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 5887 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 5888 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 5889 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 5890 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 5891 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5892 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5893 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5894 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 5895 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 5896 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 5897 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5898 | return; |
| 5899 | } |