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