| 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" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 51 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 52 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 53 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 54 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 55 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 56 | /* |
| 57 | * Write key size should be multiple of 4. If write key is changed |
| 58 | * make sure that library write key is also changed. |
| 59 | */ |
| 60 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 61 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 62 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 63 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 64 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 65 | * @incr: integer to convert. |
| 66 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 67 | * |
| 68 | * Description: |
| 69 | * JEDEC Joint Electron Device Engineering Council. |
| 70 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 71 | * character string. The string is then terminated with a NULL in byte 9. |
| 72 | * Hex 0-9 becomes ascii '0' to '9'. |
| 73 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 74 | * |
| 75 | * Notes: |
| 76 | * Coded for 32 bit integers only. |
| 77 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 78 | static void |
| 79 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 80 | { |
| 81 | int i, j; |
| 82 | for (i = 0; i < 8; i++) { |
| 83 | j = (incr & 0xf); |
| 84 | if (j <= 9) |
| 85 | hdw[7 - i] = 0x30 + j; |
| 86 | else |
| 87 | hdw[7 - i] = 0x61 + j - 10; |
| 88 | incr = (incr >> 4); |
| 89 | } |
| 90 | hdw[8] = 0; |
| 91 | return; |
| 92 | } |
| 93 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 94 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 95 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 96 | * @dev: class unused variable. |
| 97 | * @attr: device attribute, not used. |
| 98 | * @buf: on return contains the module description text. |
| 99 | * |
| 100 | * Returns: size of formatted string. |
| 101 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 102 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 103 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 104 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 105 | { |
| 106 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 107 | } |
| 108 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 109 | /** |
| 110 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 111 | * @dev: class unused variable. |
| 112 | * @attr: device attribute, not used. |
| 113 | * @buf: on return contains the module description text. |
| 114 | * |
| 115 | * Returns: size of formatted string. |
| 116 | **/ |
| 117 | static ssize_t |
| 118 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 119 | char *buf) |
| 120 | { |
| 121 | struct Scsi_Host *shost = class_to_shost(dev); |
| 122 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 123 | struct lpfc_hba *phba = vport->phba; |
| 124 | |
| 125 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 126 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 127 | else |
| 128 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 129 | } |
| 130 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 131 | static ssize_t |
| 132 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 133 | char *buf) |
| 134 | { |
| 135 | struct Scsi_Host *shost = class_to_shost(dev); |
| 136 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 137 | struct lpfc_hba *phba = vport->phba; |
| 138 | |
| 139 | if (phba->cfg_enable_bg) |
| 140 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 141 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 142 | else |
| 143 | return snprintf(buf, PAGE_SIZE, |
| 144 | "BlockGuard Not Supported\n"); |
| 145 | else |
| 146 | return snprintf(buf, PAGE_SIZE, |
| 147 | "BlockGuard Disabled\n"); |
| 148 | } |
| 149 | |
| 150 | static ssize_t |
| 151 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 152 | char *buf) |
| 153 | { |
| 154 | struct Scsi_Host *shost = class_to_shost(dev); |
| 155 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 156 | struct lpfc_hba *phba = vport->phba; |
| 157 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 158 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 159 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static ssize_t |
| 163 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 164 | char *buf) |
| 165 | { |
| 166 | struct Scsi_Host *shost = class_to_shost(dev); |
| 167 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 168 | struct lpfc_hba *phba = vport->phba; |
| 169 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 170 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 171 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | static ssize_t |
| 175 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 176 | char *buf) |
| 177 | { |
| 178 | struct Scsi_Host *shost = class_to_shost(dev); |
| 179 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 180 | struct lpfc_hba *phba = vport->phba; |
| 181 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 182 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 183 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 184 | } |
| 185 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 186 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 187 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 188 | * @dev: class converted to a Scsi_host structure. |
| 189 | * @attr: device attribute, not used. |
| 190 | * @buf: on return contains the formatted text from lpfc_info(). |
| 191 | * |
| 192 | * Returns: size of formatted string. |
| 193 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 194 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 195 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 196 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 197 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 198 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 199 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 200 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 201 | } |
| 202 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 203 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 204 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 205 | * @dev: class converted to a Scsi_host structure. |
| 206 | * @attr: device attribute, not used. |
| 207 | * @buf: on return contains the formatted text serial number. |
| 208 | * |
| 209 | * Returns: size of formatted string. |
| 210 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 211 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 212 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 213 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 214 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 215 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 216 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 217 | struct lpfc_hba *phba = vport->phba; |
| 218 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 219 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 220 | } |
| 221 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 222 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 223 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 224 | * @dev: class converted to a Scsi_host structure. |
| 225 | * @attr: device attribute, not used. |
| 226 | * @buf: on return contains the formatted support level. |
| 227 | * |
| 228 | * Description: |
| 229 | * Returns a number indicating the temperature sensor level currently |
| 230 | * supported, zero or one in ascii. |
| 231 | * |
| 232 | * Returns: size of formatted string. |
| 233 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 234 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 235 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 236 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 237 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 238 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 239 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 240 | struct lpfc_hba *phba = vport->phba; |
| 241 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 242 | } |
| 243 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 244 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 245 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 246 | * @dev: class converted to a Scsi_host structure. |
| 247 | * @attr: device attribute, not used. |
| 248 | * @buf: on return contains the scsi vpd model description. |
| 249 | * |
| 250 | * Returns: size of formatted string. |
| 251 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 252 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 253 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 254 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 255 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 256 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 257 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 258 | struct lpfc_hba *phba = vport->phba; |
| 259 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 260 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 261 | } |
| 262 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 263 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 264 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 265 | * @dev: class converted to a Scsi_host structure. |
| 266 | * @attr: device attribute, not used. |
| 267 | * @buf: on return contains the scsi vpd model name. |
| 268 | * |
| 269 | * Returns: size of formatted string. |
| 270 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 271 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 272 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 273 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 274 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 275 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 276 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 277 | struct lpfc_hba *phba = vport->phba; |
| 278 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 279 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 280 | } |
| 281 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 282 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 283 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 284 | * @dev: class converted to a Scsi_host structure. |
| 285 | * @attr: device attribute, not used. |
| 286 | * @buf: on return contains the scsi vpd program type. |
| 287 | * |
| 288 | * Returns: size of formatted string. |
| 289 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 290 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 291 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 292 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 293 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 294 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 295 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 296 | struct lpfc_hba *phba = vport->phba; |
| 297 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 298 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 299 | } |
| 300 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 301 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 302 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 303 | * @dev: class converted to a Scsi_host structure. |
| 304 | * @attr: device attribute, not used. |
| 305 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 306 | * |
| 307 | * Returns: size of formatted string. |
| 308 | **/ |
| 309 | static ssize_t |
| 310 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 311 | { |
| 312 | struct Scsi_Host *shost = class_to_shost(dev); |
| 313 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 314 | struct lpfc_hba *phba = vport->phba; |
| 315 | |
| 316 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 317 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 318 | } |
| 319 | |
| 320 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 321 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 322 | * @dev: class converted to a Scsi_host structure. |
| 323 | * @attr: device attribute, not used. |
| 324 | * @buf: on return contains scsi vpd program type. |
| 325 | * |
| 326 | * Returns: size of formatted string. |
| 327 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 328 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 329 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 330 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 331 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 332 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 333 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 334 | struct lpfc_hba *phba = vport->phba; |
| 335 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 336 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 337 | } |
| 338 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 339 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 340 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 341 | * @dev: class converted to a Scsi_host structure. |
| 342 | * @attr: device attribute, not used. |
| 343 | * @buf: on return contains the scsi vpd program type. |
| 344 | * |
| 345 | * Returns: size of formatted string. |
| 346 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 347 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 348 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 349 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 350 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 351 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 352 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 353 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 354 | uint32_t if_type; |
| 355 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 356 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 357 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 358 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 359 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 360 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 361 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 362 | |
| 363 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 364 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 365 | fwrev, phba->sli_rev); |
| 366 | else |
| 367 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 368 | fwrev, phba->sli_rev, if_type, sli_family); |
| 369 | |
| 370 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 371 | } |
| 372 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 373 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 374 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 375 | * @dev: class converted to a Scsi_host structure. |
| 376 | * @attr: device attribute, not used. |
| 377 | * @buf: on return contains the scsi vpd program type. |
| 378 | * |
| 379 | * Returns: size of formatted string. |
| 380 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 381 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 382 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 383 | { |
| 384 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 385 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 386 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 387 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 388 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 389 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 390 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 391 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 392 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 393 | |
| 394 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 395 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 396 | * @dev: class converted to a Scsi_host structure. |
| 397 | * @attr: device attribute, not used. |
| 398 | * @buf: on return contains the ROM and FCode ascii strings. |
| 399 | * |
| 400 | * Returns: size of formatted string. |
| 401 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 402 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 403 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 404 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 405 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 406 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 407 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 408 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 409 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 410 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 411 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 412 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 413 | |
| 414 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
| 415 | return snprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 416 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 417 | |
| 418 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 419 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 420 | * @dev: class converted to a Scsi_host structure. |
| 421 | * @attr: device attribute, not used. |
| 422 | * @buf: on return contains text describing the state of the link. |
| 423 | * |
| 424 | * Notes: |
| 425 | * The switch statement has no default so zero will be returned. |
| 426 | * |
| 427 | * Returns: size of formatted string. |
| 428 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 429 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 430 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 431 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 432 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 433 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 434 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 435 | struct lpfc_hba *phba = vport->phba; |
| 436 | int len = 0; |
| 437 | |
| 438 | switch (phba->link_state) { |
| 439 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 440 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 441 | case LPFC_INIT_START: |
| 442 | case LPFC_INIT_MBX_CMDS: |
| 443 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 444 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 445 | if (phba->hba_flag & LINK_DISABLED) |
| 446 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 447 | "Link Down - User disabled\n"); |
| 448 | else |
| 449 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 450 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 451 | break; |
| 452 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 453 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 454 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 455 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 456 | |
| 457 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 458 | case LPFC_LOCAL_CFG_LINK: |
| 459 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 460 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 461 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 462 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 463 | case LPFC_FLOGI: |
| 464 | case LPFC_FABRIC_CFG_LINK: |
| 465 | case LPFC_NS_REG: |
| 466 | case LPFC_NS_QRY: |
| 467 | case LPFC_BUILD_DISC_LIST: |
| 468 | case LPFC_DISC_AUTH: |
| 469 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 470 | "Discovery\n"); |
| 471 | break; |
| 472 | case LPFC_VPORT_READY: |
| 473 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 474 | break; |
| 475 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 476 | case LPFC_VPORT_FAILED: |
| 477 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 478 | break; |
| 479 | |
| 480 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 481 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 482 | "Unknown\n"); |
| 483 | break; |
| 484 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 485 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 486 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 487 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 488 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 489 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 490 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 491 | " Public Loop\n"); |
| 492 | else |
| 493 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 494 | " Private Loop\n"); |
| 495 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 496 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 497 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 498 | " Fabric\n"); |
| 499 | else |
| 500 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 501 | " Point-2-Point\n"); |
| 502 | } |
| 503 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 504 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 505 | return len; |
| 506 | } |
| 507 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 508 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 509 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 510 | * @dev: class unused variable. |
| 511 | * @attr: device attribute, not used. |
| 512 | * @buf: on return contains the module description text. |
| 513 | * |
| 514 | * Returns: size of formatted string. |
| 515 | **/ |
| 516 | static ssize_t |
| 517 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 518 | char *buf) |
| 519 | { |
| 520 | struct Scsi_Host *shost = class_to_shost(dev); |
| 521 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 522 | struct lpfc_hba *phba = vport->phba; |
| 523 | |
| 524 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 525 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 526 | |
| 527 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 528 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 529 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 530 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 531 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 532 | } |
| 533 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 534 | } |
| 535 | |
| 536 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 537 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 538 | * (OAS) is supported. |
| 539 | * @dev: class unused variable. |
| 540 | * @attr: device attribute, not used. |
| 541 | * @buf: on return contains the module description text. |
| 542 | * |
| 543 | * Returns: size of formatted string. |
| 544 | **/ |
| 545 | static ssize_t |
| 546 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 547 | char *buf) |
| 548 | { |
| 549 | struct Scsi_Host *shost = class_to_shost(dev); |
| 550 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 551 | struct lpfc_hba *phba = vport->phba; |
| 552 | |
| 553 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 554 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 555 | } |
| 556 | |
| 557 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 558 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 559 | * @dev: class device that is converted into a Scsi_host. |
| 560 | * @attr: device attribute, not used. |
| 561 | * @buf: one or more lpfc_polling_flags values. |
| 562 | * @count: not used. |
| 563 | * |
| 564 | * Returns: |
| 565 | * -EINVAL if the buffer is not "up" or "down" |
| 566 | * return from link state change function if non-zero |
| 567 | * length of the buf on success |
| 568 | **/ |
| 569 | static ssize_t |
| 570 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 571 | const char *buf, size_t count) |
| 572 | { |
| 573 | struct Scsi_Host *shost = class_to_shost(dev); |
| 574 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 575 | struct lpfc_hba *phba = vport->phba; |
| 576 | |
| 577 | int status = -EINVAL; |
| 578 | |
| 579 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 580 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 581 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 582 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 583 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 584 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 585 | |
| 586 | if (status == 0) |
| 587 | return strlen(buf); |
| 588 | else |
| 589 | return status; |
| 590 | } |
| 591 | |
| 592 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 593 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 594 | * @dev: class device that is converted into a Scsi_host. |
| 595 | * @attr: device attribute, not used. |
| 596 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 597 | * |
| 598 | * Description: |
| 599 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 600 | * vport counts. |
| 601 | * |
| 602 | * Returns: size of formatted string. |
| 603 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 604 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 605 | lpfc_num_discovered_ports_show(struct device *dev, |
| 606 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 607 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 608 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 609 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 610 | |
| 611 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 612 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 613 | } |
| 614 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 615 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 616 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 617 | * @shost: Scsi_Host pointer. |
| 618 | * |
| 619 | * Description: |
| 620 | * Bring the link down gracefully then re-init the link. The firmware will |
| 621 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 622 | * |
| 623 | * Returns: |
| 624 | * -EPERM port offline or management commands are being blocked |
| 625 | * -ENOMEM cannot allocate memory for the mailbox command |
| 626 | * -EIO error sending the mailbox command |
| 627 | * zero for success |
| 628 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 629 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 630 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 631 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 632 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 633 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 634 | LPFC_MBOXQ_t *pmboxq; |
| 635 | int mbxstatus = MBXERR_ERROR; |
| 636 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 637 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 638 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 639 | return -EPERM; |
| 640 | |
| 641 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 642 | |
| 643 | if (!pmboxq) |
| 644 | return -ENOMEM; |
| 645 | |
| 646 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 647 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 648 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 649 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 650 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 651 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 652 | if ((mbxstatus == MBX_SUCCESS) && |
| 653 | (pmboxq->u.mb.mbxStatus == 0 || |
| 654 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 655 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 656 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 657 | phba->cfg_link_speed); |
| 658 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 659 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 660 | if ((mbxstatus == MBX_SUCCESS) && |
| 661 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 662 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 663 | "2859 SLI authentication is required " |
| 664 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 665 | } |
| 666 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 667 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 668 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 669 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | |
| 671 | if (mbxstatus == MBXERR_ERROR) |
| 672 | return -EIO; |
| 673 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 674 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 675 | } |
| 676 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 677 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 678 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 679 | * @phba: lpfc_hba pointer. |
| 680 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 681 | * |
| 682 | * Notes: |
| 683 | * Assumes any error from lpfc_do_offline() will be negative. |
| 684 | * Can wait up to 5 seconds for the port ring buffers count |
| 685 | * 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] | 686 | * 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] | 687 | * |
| 688 | * Returns: |
| 689 | * -EIO error posting the event |
| 690 | * zero for success |
| 691 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 692 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 693 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 694 | { |
| 695 | struct completion online_compl; |
| 696 | struct lpfc_sli_ring *pring; |
| 697 | struct lpfc_sli *psli; |
| 698 | int status = 0; |
| 699 | int cnt = 0; |
| 700 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 701 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 702 | |
| 703 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 704 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 705 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 706 | if (rc == 0) |
| 707 | return -ENOMEM; |
| 708 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 709 | wait_for_completion(&online_compl); |
| 710 | |
| 711 | if (status != 0) |
| 712 | return -EIO; |
| 713 | |
| 714 | psli = &phba->sli; |
| 715 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 716 | /* Wait a little for things to settle down, but not |
| 717 | * long enough for dev loss timeout to expire. |
| 718 | */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 719 | for (i = 0; i < psli->num_rings; i++) { |
| 720 | pring = &psli->ring[i]; |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 721 | while (!list_empty(&pring->txcmplq)) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 722 | msleep(10); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 723 | if (cnt++ > 500) { /* 5 secs */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 724 | lpfc_printf_log(phba, |
| 725 | KERN_WARNING, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 726 | "0466 Outstanding IO when " |
| 727 | "bringing Adapter offline\n"); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 728 | break; |
| 729 | } |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 734 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 735 | if (rc == 0) |
| 736 | return -ENOMEM; |
| 737 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 738 | wait_for_completion(&online_compl); |
| 739 | |
| 740 | if (status != 0) |
| 741 | return -EIO; |
| 742 | |
| 743 | return 0; |
| 744 | } |
| 745 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 746 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 747 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 748 | * @phba: lpfc_hba pointer. |
| 749 | * |
| 750 | * Description: |
| 751 | * If the port is configured to allow a reset then the hba is brought |
| 752 | * offline then online. |
| 753 | * |
| 754 | * Notes: |
| 755 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 756 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 757 | * |
| 758 | * Returns: |
| 759 | * lpfc_do_offline() return code if not zero |
| 760 | * -EIO reset not configured or error posting the event |
| 761 | * zero for success |
| 762 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 763 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 764 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 765 | { |
| 766 | struct completion online_compl; |
| 767 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 768 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 769 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 770 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 771 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 772 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 773 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 774 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 775 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 776 | if (status != 0) |
| 777 | return status; |
| 778 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 779 | |
| 780 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 781 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 782 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 783 | if (rc == 0) |
| 784 | return -ENOMEM; |
| 785 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 786 | wait_for_completion(&online_compl); |
| 787 | |
| 788 | if (status != 0) |
| 789 | return -EIO; |
| 790 | |
| 791 | return 0; |
| 792 | } |
| 793 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 794 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 795 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 796 | * @dev: class device that is converted into a Scsi_host. |
| 797 | * @attr: device attribute, not used. |
| 798 | * @buf: containing the string "selective". |
| 799 | * @count: unused variable. |
| 800 | * |
| 801 | * Description: |
| 802 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 803 | * is called to perform the reset. |
| 804 | * |
| 805 | * Notes: |
| 806 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 807 | * 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] | 808 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 809 | * |
| 810 | * Returns: |
| 811 | * -EINVAL if the buffer does not contain the string "selective" |
| 812 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 813 | * return value of lpfc_selective_reset() if the call fails |
| 814 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 815 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 816 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 817 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 818 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 819 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 820 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 821 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 822 | int status = -EINVAL; |
| 823 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 824 | if (!phba->cfg_enable_hba_reset) |
| 825 | return -EACCES; |
| 826 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 827 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 828 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 829 | |
| 830 | if (status == 0) |
| 831 | return strlen(buf); |
| 832 | else |
| 833 | return status; |
| 834 | } |
| 835 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 836 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 837 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 838 | * @phba: lpfc_hba pointer. |
| 839 | * |
| 840 | * Description: |
| 841 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 842 | * the readyness after performing a firmware reset. |
| 843 | * |
| 844 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 845 | * 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] | 846 | * reset, -EIO when port timeout from recovering from the reset. |
| 847 | * |
| 848 | * Note: |
| 849 | * As the caller will interpret the return code by value, be careful in making |
| 850 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 851 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 852 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 853 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 854 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 855 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 856 | int i; |
| 857 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 858 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 859 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 860 | &portstat_reg.word0); |
| 861 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 862 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 863 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 864 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 865 | return -EPERM; |
| 866 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 867 | /* wait for the SLI port firmware ready after firmware reset */ |
| 868 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 869 | msleep(10); |
| 870 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 871 | &portstat_reg.word0); |
| 872 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 873 | continue; |
| 874 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 875 | continue; |
| 876 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 877 | continue; |
| 878 | break; |
| 879 | } |
| 880 | |
| 881 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 882 | return 0; |
| 883 | else |
| 884 | return -EIO; |
| 885 | } |
| 886 | |
| 887 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 888 | * 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] | 889 | * @phba: lpfc_hba pointer. |
| 890 | * |
| 891 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 892 | * Request SLI4 interface type-2 device to perform a physical register set |
| 893 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 894 | * |
| 895 | * Returns: |
| 896 | * zero for success |
| 897 | **/ |
| 898 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 899 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 900 | { |
| 901 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 902 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 903 | uint32_t before_fc_flag; |
| 904 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 905 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 906 | int status = 0, rc = 0; |
| 907 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 908 | |
| 909 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 910 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 911 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 912 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 913 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 914 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 915 | return -EPERM; |
| 916 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 917 | /* Keep state if we need to restore back */ |
| 918 | before_fc_flag = phba->pport->fc_flag; |
| 919 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 920 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 921 | /* Disable SR-IOV virtual functions if enabled */ |
| 922 | if (phba->cfg_sriov_nr_virtfn) { |
| 923 | pci_disable_sriov(pdev); |
| 924 | phba->cfg_sriov_nr_virtfn = 0; |
| 925 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 926 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 927 | if (opcode == LPFC_FW_DUMP) |
| 928 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 929 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 930 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 931 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 932 | if (status != 0) { |
| 933 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 934 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 935 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 936 | |
| 937 | /* wait for the device to be quiesced before firmware reset */ |
| 938 | msleep(100); |
| 939 | |
| 940 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 941 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 942 | |
| 943 | if (opcode == LPFC_FW_DUMP) |
| 944 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 945 | else if (opcode == LPFC_FW_RESET) |
| 946 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 947 | else if (opcode == LPFC_DV_RESET) |
| 948 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 949 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 950 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 951 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 952 | /* flush */ |
| 953 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 954 | |
| 955 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 956 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 957 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 958 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 959 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 960 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 961 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 962 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 963 | } else if (rc == -EIO) { |
| 964 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 965 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 966 | "3153 Fail to perform the requested " |
| 967 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 968 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | /* keep the original port state */ |
| 972 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 973 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 974 | |
| 975 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 976 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 977 | LPFC_EVT_ONLINE); |
| 978 | if (!job_posted) |
| 979 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 980 | |
| 981 | wait_for_completion(&online_compl); |
| 982 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 983 | out: |
| 984 | /* in any case, restore the virtual functions enabled as before */ |
| 985 | if (sriov_nr_virtfn) { |
| 986 | sriov_err = |
| 987 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 988 | if (!sriov_err) |
| 989 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 990 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 991 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 992 | /* return proper error code */ |
| 993 | if (!rc) { |
| 994 | if (!job_posted) |
| 995 | rc = -ENOMEM; |
| 996 | else if (status) |
| 997 | rc = -EIO; |
| 998 | } |
| 999 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1003 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1004 | * @dev: class device that is converted into a Scsi_host. |
| 1005 | * @attr: device attribute, not used. |
| 1006 | * @buf: on return contains the ascii number of nport events. |
| 1007 | * |
| 1008 | * Returns: size of formatted string. |
| 1009 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1010 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1011 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1012 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1013 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1014 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1015 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1016 | struct lpfc_hba *phba = vport->phba; |
| 1017 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1018 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1019 | } |
| 1020 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1021 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1022 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1023 | * @dev: class device that is converted into a Scsi_host. |
| 1024 | * @attr: device attribute, not used. |
| 1025 | * @buf: on return contains the state of the adapter. |
| 1026 | * |
| 1027 | * Returns: size of formatted string. |
| 1028 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1029 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1030 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1031 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1032 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1033 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1034 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1035 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1036 | char * state; |
| 1037 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1038 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1039 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1040 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1041 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1042 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1043 | state = "offline"; |
| 1044 | else |
| 1045 | state = "online"; |
| 1046 | |
| 1047 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1048 | } |
| 1049 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1050 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1051 | * 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] | 1052 | * @dev: class device that is converted into a Scsi_host. |
| 1053 | * @attr: device attribute, not used. |
| 1054 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1055 | * @count: unused variable. |
| 1056 | * |
| 1057 | * Returns: |
| 1058 | * -EACCES if enable hba reset not enabled |
| 1059 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1060 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1061 | * buf length greater than zero indicates success |
| 1062 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1063 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1064 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1065 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1066 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1067 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1068 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1069 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1070 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1071 | char *board_mode_str = NULL; |
| 1072 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1073 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1074 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1075 | if (!phba->cfg_enable_hba_reset) { |
| 1076 | status = -EACCES; |
| 1077 | goto board_mode_out; |
| 1078 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1079 | |
| 1080 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1081 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1082 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1083 | init_completion(&online_compl); |
| 1084 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1085 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1086 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1087 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1088 | if (rc == 0) { |
| 1089 | status = -ENOMEM; |
| 1090 | goto board_mode_out; |
| 1091 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1092 | wait_for_completion(&online_compl); |
| 1093 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1094 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1095 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1096 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1097 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1098 | else |
| 1099 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1100 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1101 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1102 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1103 | else |
| 1104 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1105 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1106 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1107 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1108 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1109 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1110 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1111 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1112 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1113 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1114 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1115 | if (!status) |
| 1116 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1117 | else { |
| 1118 | board_mode_str = strchr(buf, '\n'); |
| 1119 | if (board_mode_str) |
| 1120 | *board_mode_str = '\0'; |
| 1121 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1122 | "3097 Failed \"%s\", status(%d), " |
| 1123 | "fc_flag(x%x)\n", |
| 1124 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1125 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1126 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1127 | } |
| 1128 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1129 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1130 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1131 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1132 | * @mxri: max xri count. |
| 1133 | * @axri: available xri count. |
| 1134 | * @mrpi: max rpi count. |
| 1135 | * @arpi: available rpi count. |
| 1136 | * @mvpi: max vpi count. |
| 1137 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1138 | * |
| 1139 | * Description: |
| 1140 | * If an integer pointer for an count is not null then the value for the |
| 1141 | * count is returned. |
| 1142 | * |
| 1143 | * Returns: |
| 1144 | * zero on error |
| 1145 | * one for success |
| 1146 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1147 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1148 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1149 | uint32_t *mxri, uint32_t *axri, |
| 1150 | uint32_t *mrpi, uint32_t *arpi, |
| 1151 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1152 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1153 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1154 | LPFC_MBOXQ_t *pmboxq; |
| 1155 | MAILBOX_t *pmb; |
| 1156 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1157 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1158 | |
| 1159 | /* |
| 1160 | * prevent udev from issuing mailbox commands until the port is |
| 1161 | * configured. |
| 1162 | */ |
| 1163 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1164 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1165 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1166 | return 0; |
| 1167 | |
| 1168 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1169 | return 0; |
| 1170 | |
| 1171 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1172 | if (!pmboxq) |
| 1173 | return 0; |
| 1174 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1175 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1176 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1177 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1178 | pmb->mbxOwner = OWN_HOST; |
| 1179 | pmboxq->context1 = NULL; |
| 1180 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1181 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1182 | rc = MBX_NOT_FINISHED; |
| 1183 | else |
| 1184 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1185 | |
| 1186 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1187 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1188 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1189 | return 0; |
| 1190 | } |
| 1191 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1192 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1193 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1194 | if (mrpi) |
| 1195 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1196 | if (arpi) |
| 1197 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1198 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1199 | if (mxri) |
| 1200 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1201 | if (axri) |
| 1202 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1203 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1204 | |
| 1205 | /* Account for differences with SLI-3. Get vpi count from |
| 1206 | * mailbox data and subtract one for max vpi value. |
| 1207 | */ |
| 1208 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1209 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1210 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1211 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1212 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1213 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1214 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1215 | } else { |
| 1216 | if (mrpi) |
| 1217 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1218 | if (arpi) |
| 1219 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1220 | if (mxri) |
| 1221 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1222 | if (axri) |
| 1223 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1224 | if (mvpi) |
| 1225 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1226 | if (avpi) |
| 1227 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1228 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1229 | |
| 1230 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1231 | return 1; |
| 1232 | } |
| 1233 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1234 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1235 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1236 | * @dev: class device that is converted into a Scsi_host. |
| 1237 | * @attr: device attribute, not used. |
| 1238 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1239 | * |
| 1240 | * Description: |
| 1241 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1242 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1243 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1244 | * must check for "Unknown" in the buffer to detect a failure. |
| 1245 | * |
| 1246 | * Returns: size of formatted string. |
| 1247 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1248 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1249 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1250 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1251 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1252 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1253 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1254 | struct lpfc_hba *phba = vport->phba; |
| 1255 | uint32_t cnt; |
| 1256 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1257 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1258 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1259 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1260 | } |
| 1261 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1262 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1263 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1264 | * @dev: class device that is converted into a Scsi_host. |
| 1265 | * @attr: device attribute, not used. |
| 1266 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1267 | * |
| 1268 | * Description: |
| 1269 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1270 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1271 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1272 | * must check for "Unknown" in the buffer to detect a failure. |
| 1273 | * |
| 1274 | * Returns: size of formatted string. |
| 1275 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1276 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1277 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1278 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1279 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1280 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1281 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1282 | struct lpfc_hba *phba = vport->phba; |
| 1283 | uint32_t cnt, acnt; |
| 1284 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1285 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1286 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1287 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1288 | } |
| 1289 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1290 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1291 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1292 | * @dev: class device that is converted into a Scsi_host. |
| 1293 | * @attr: device attribute, not used. |
| 1294 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1295 | * |
| 1296 | * Description: |
| 1297 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1298 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1299 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1300 | * must check for "Unknown" in the buffer to detect a failure. |
| 1301 | * |
| 1302 | * Returns: size of formatted string. |
| 1303 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1304 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1305 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1306 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1307 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1308 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1309 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1310 | struct lpfc_hba *phba = vport->phba; |
| 1311 | uint32_t cnt; |
| 1312 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1313 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1314 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1315 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1316 | } |
| 1317 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1318 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1319 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1320 | * @dev: class device that is converted into a Scsi_host. |
| 1321 | * @attr: device attribute, not used. |
| 1322 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1323 | * |
| 1324 | * Description: |
| 1325 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1326 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1327 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1328 | * must check for "Unknown" in the buffer to detect a failure. |
| 1329 | * |
| 1330 | * Returns: size of formatted string. |
| 1331 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1332 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1333 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1334 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1335 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1336 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1337 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1338 | struct lpfc_hba *phba = vport->phba; |
| 1339 | uint32_t cnt, acnt; |
| 1340 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1341 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1342 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1343 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1344 | } |
| 1345 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1346 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1347 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1348 | * @dev: class device that is converted into a Scsi_host. |
| 1349 | * @attr: device attribute, not used. |
| 1350 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1351 | * |
| 1352 | * Description: |
| 1353 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1354 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1355 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1356 | * must check for "Unknown" in the buffer to detect a failure. |
| 1357 | * |
| 1358 | * Returns: size of formatted string. |
| 1359 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1360 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1361 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1362 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1363 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1364 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1365 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1366 | struct lpfc_hba *phba = vport->phba; |
| 1367 | uint32_t cnt; |
| 1368 | |
| 1369 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1370 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1371 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1372 | } |
| 1373 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1374 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1375 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1376 | * @dev: class device that is converted into a Scsi_host. |
| 1377 | * @attr: device attribute, not used. |
| 1378 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1379 | * |
| 1380 | * Description: |
| 1381 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1382 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1383 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1384 | * must check for "Unknown" in the buffer to detect a failure. |
| 1385 | * |
| 1386 | * Returns: size of formatted string. |
| 1387 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1388 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1389 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1390 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1391 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1392 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1393 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1394 | struct lpfc_hba *phba = vport->phba; |
| 1395 | uint32_t cnt, acnt; |
| 1396 | |
| 1397 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1398 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1399 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1400 | } |
| 1401 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1402 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1403 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1404 | * @dev: class device that is converted into a Scsi_host. |
| 1405 | * @attr: device attribute, not used. |
| 1406 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1407 | * |
| 1408 | * Description: |
| 1409 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1410 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1411 | * the id of the vport. |
| 1412 | * |
| 1413 | * Returns: size of formatted string. |
| 1414 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1415 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1416 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1417 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1418 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1419 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1420 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1421 | struct lpfc_hba *phba = vport->phba; |
| 1422 | |
| 1423 | if (!(phba->max_vpi)) |
| 1424 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1425 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1426 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1427 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1428 | } |
| 1429 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1430 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1431 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1432 | * @dev: class device that is converted into a Scsi_host. |
| 1433 | * @attr: device attribute, not used. |
| 1434 | * @buf: on return contains the cfg_poll in hex. |
| 1435 | * |
| 1436 | * Notes: |
| 1437 | * cfg_poll should be a lpfc_polling_flags type. |
| 1438 | * |
| 1439 | * Returns: size of formatted string. |
| 1440 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1441 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1442 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1443 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1444 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1445 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1446 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1447 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1448 | |
| 1449 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1450 | } |
| 1451 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1452 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1453 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1454 | * @dev: class device that is converted into a Scsi_host. |
| 1455 | * @attr: device attribute, not used. |
| 1456 | * @buf: one or more lpfc_polling_flags values. |
| 1457 | * @count: not used. |
| 1458 | * |
| 1459 | * Notes: |
| 1460 | * buf contents converted to integer and checked for a valid value. |
| 1461 | * |
| 1462 | * Returns: |
| 1463 | * -EINVAL if the buffer connot be converted or is out of range |
| 1464 | * length of the buf on success |
| 1465 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1466 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1467 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1468 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1469 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1470 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1471 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1472 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1473 | uint32_t creg_val; |
| 1474 | uint32_t old_val; |
| 1475 | int val=0; |
| 1476 | |
| 1477 | if (!isdigit(buf[0])) |
| 1478 | return -EINVAL; |
| 1479 | |
| 1480 | if (sscanf(buf, "%i", &val) != 1) |
| 1481 | return -EINVAL; |
| 1482 | |
| 1483 | if ((val & 0x3) != val) |
| 1484 | return -EINVAL; |
| 1485 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1486 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1487 | val = 0; |
| 1488 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1489 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1490 | "3051 lpfc_poll changed from %d to %d\n", |
| 1491 | phba->cfg_poll, val); |
| 1492 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1493 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1494 | |
| 1495 | old_val = phba->cfg_poll; |
| 1496 | |
| 1497 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1498 | if ((val & DISABLE_FCP_RING_INT) && |
| 1499 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1500 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1501 | spin_unlock_irq(&phba->hbalock); |
| 1502 | return -EINVAL; |
| 1503 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1504 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1505 | writel(creg_val, phba->HCregaddr); |
| 1506 | readl(phba->HCregaddr); /* flush */ |
| 1507 | |
| 1508 | lpfc_poll_start_timer(phba); |
| 1509 | } |
| 1510 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1511 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1512 | return -EINVAL; |
| 1513 | } |
| 1514 | |
| 1515 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1516 | (old_val & DISABLE_FCP_RING_INT)) |
| 1517 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1518 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1519 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1520 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1521 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1522 | spin_unlock_irq(&phba->hbalock); |
| 1523 | return -EINVAL; |
| 1524 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1525 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1526 | writel(creg_val, phba->HCregaddr); |
| 1527 | readl(phba->HCregaddr); /* flush */ |
| 1528 | } |
| 1529 | |
| 1530 | phba->cfg_poll = val; |
| 1531 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1532 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1533 | |
| 1534 | return strlen(buf); |
| 1535 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1536 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1537 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1538 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1539 | * @dev: class unused variable. |
| 1540 | * @attr: device attribute, not used. |
| 1541 | * @buf: on return contains the module description text. |
| 1542 | * |
| 1543 | * Returns: size of formatted string. |
| 1544 | **/ |
| 1545 | static ssize_t |
| 1546 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1547 | char *buf) |
| 1548 | { |
| 1549 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1550 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1551 | struct lpfc_hba *phba = vport->phba; |
| 1552 | |
| 1553 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1554 | } |
| 1555 | |
| 1556 | /** |
| 1557 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1558 | * @dev: class unused variable. |
| 1559 | * @attr: device attribute, not used. |
| 1560 | * @buf: on return contains the module description text. |
| 1561 | * |
| 1562 | * Returns: size of formatted string. |
| 1563 | **/ |
| 1564 | static ssize_t |
| 1565 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1566 | char *buf) |
| 1567 | { |
| 1568 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1569 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1570 | struct lpfc_hba *phba = vport->phba; |
| 1571 | |
| 1572 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1573 | } |
| 1574 | |
| 1575 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1576 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1577 | * @dev: class converted to a Scsi_host structure. |
| 1578 | * @attr: device attribute, not used. |
| 1579 | * @buf: on return contains the formatted text. |
| 1580 | * |
| 1581 | * Returns: size of formatted string. |
| 1582 | **/ |
| 1583 | static ssize_t |
| 1584 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1585 | char *buf) |
| 1586 | { |
| 1587 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1588 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1589 | struct lpfc_hba *phba = vport->phba; |
| 1590 | |
| 1591 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1592 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1593 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1594 | "" : "Not "); |
| 1595 | } |
| 1596 | |
| 1597 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1598 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1599 | * @dev: class converted to a Scsi_host structure. |
| 1600 | * @attr: device attribute, not used. |
| 1601 | * @buf: on return contains the formatted support level. |
| 1602 | * |
| 1603 | * Description: |
| 1604 | * Returns the maximum number of virtual functions a physical function can |
| 1605 | * support, 0 will be returned if called on virtual function. |
| 1606 | * |
| 1607 | * Returns: size of formatted string. |
| 1608 | **/ |
| 1609 | static ssize_t |
| 1610 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1611 | struct device_attribute *attr, |
| 1612 | char *buf) |
| 1613 | { |
| 1614 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1615 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1616 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1617 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1618 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1619 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1620 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1624 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1625 | * |
| 1626 | * Description: |
| 1627 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1628 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1629 | * |
| 1630 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1631 | * @dev: class device that is converted into a Scsi_host. |
| 1632 | * @attr: device attribute, not used. |
| 1633 | * @buf: on return contains the attribute value in decimal. |
| 1634 | * |
| 1635 | * Returns: size of formatted string. |
| 1636 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1637 | #define lpfc_param_show(attr) \ |
| 1638 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1639 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1640 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1641 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1642 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1643 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1644 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1645 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1646 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1647 | } |
| 1648 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1649 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1650 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1651 | * |
| 1652 | * Description: |
| 1653 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1654 | * into a function with the name lpfc_hba_queue_depth_show |
| 1655 | * |
| 1656 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1657 | * @dev: class device that is converted into a Scsi_host. |
| 1658 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1659 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1660 | * |
| 1661 | * Returns: size of formatted string. |
| 1662 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1663 | #define lpfc_param_hex_show(attr) \ |
| 1664 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1665 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1666 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1667 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1668 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1669 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1670 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1671 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1672 | val = phba->cfg_##attr;\ |
| 1673 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1674 | phba->cfg_##attr);\ |
| 1675 | } |
| 1676 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1677 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1678 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1679 | * |
| 1680 | * Description: |
| 1681 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1682 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1683 | * takes a default argument, a minimum and maximum argument. |
| 1684 | * |
| 1685 | * lpfc_##attr##_init: Initializes an attribute. |
| 1686 | * @phba: pointer the the adapter structure. |
| 1687 | * @val: integer attribute value. |
| 1688 | * |
| 1689 | * Validates the min and max values then sets the adapter config field |
| 1690 | * accordingly, or uses the default if out of range and prints an error message. |
| 1691 | * |
| 1692 | * Returns: |
| 1693 | * zero on success |
| 1694 | * -EINVAL if default used |
| 1695 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1696 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1697 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1698 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1699 | { \ |
| 1700 | if (val >= minval && val <= maxval) {\ |
| 1701 | phba->cfg_##attr = val;\ |
| 1702 | return 0;\ |
| 1703 | }\ |
| 1704 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1705 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1706 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1707 | phba->cfg_##attr = default;\ |
| 1708 | return -EINVAL;\ |
| 1709 | } |
| 1710 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1711 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1712 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1713 | * |
| 1714 | * Description: |
| 1715 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1716 | * into a function with the name lpfc_hba_queue_depth_set |
| 1717 | * |
| 1718 | * lpfc_##attr##_set: Sets an attribute value. |
| 1719 | * @phba: pointer the the adapter structure. |
| 1720 | * @val: integer attribute value. |
| 1721 | * |
| 1722 | * Description: |
| 1723 | * Validates the min and max values then sets the |
| 1724 | * adapter config field if in the valid range. prints error message |
| 1725 | * and does not set the parameter if invalid. |
| 1726 | * |
| 1727 | * Returns: |
| 1728 | * zero on success |
| 1729 | * -EINVAL if val is invalid |
| 1730 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1731 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1732 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1733 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1734 | { \ |
| 1735 | if (val >= minval && val <= maxval) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1736 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 1737 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 1738 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1739 | phba->cfg_##attr = val;\ |
| 1740 | return 0;\ |
| 1741 | }\ |
| 1742 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1743 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1744 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1745 | return -EINVAL;\ |
| 1746 | } |
| 1747 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1748 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1749 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1750 | * |
| 1751 | * Description: |
| 1752 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1753 | * into a function with the name lpfc_hba_queue_depth_store. |
| 1754 | * |
| 1755 | * lpfc_##attr##_store: Set an sttribute value. |
| 1756 | * @dev: class device that is converted into a Scsi_host. |
| 1757 | * @attr: device attribute, not used. |
| 1758 | * @buf: contains the attribute value in ascii. |
| 1759 | * @count: not used. |
| 1760 | * |
| 1761 | * Description: |
| 1762 | * Convert the ascii text number to an integer, then |
| 1763 | * use the lpfc_##attr##_set function to set the value. |
| 1764 | * |
| 1765 | * Returns: |
| 1766 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1767 | * length of buffer upon success. |
| 1768 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1769 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1770 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1771 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1772 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1773 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1774 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1775 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1776 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1777 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1778 | if (!isdigit(buf[0]))\ |
| 1779 | return -EINVAL;\ |
| 1780 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1781 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1782 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 1783 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1784 | else \ |
| 1785 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1786 | } |
| 1787 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1788 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1789 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1790 | * |
| 1791 | * Description: |
| 1792 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1793 | * into a function with the name lpfc_hba_queue_depth_show |
| 1794 | * |
| 1795 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 1796 | * @dev: class device that is converted into a Scsi_host. |
| 1797 | * @attr: device attribute, not used. |
| 1798 | * @buf: on return contains the attribute value in decimal. |
| 1799 | * |
| 1800 | * Returns: length of formatted string. |
| 1801 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1802 | #define lpfc_vport_param_show(attr) \ |
| 1803 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1804 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1805 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1806 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1807 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1808 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1809 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 1810 | } |
| 1811 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1812 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1813 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1814 | * |
| 1815 | * Description: |
| 1816 | * Macro that given an attr e.g. |
| 1817 | * hba_queue_depth expands into a function with the name |
| 1818 | * lpfc_hba_queue_depth_show |
| 1819 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1820 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1821 | * @dev: class device that is converted into a Scsi_host. |
| 1822 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1823 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1824 | * |
| 1825 | * Returns: length of formatted string. |
| 1826 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1827 | #define lpfc_vport_param_hex_show(attr) \ |
| 1828 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1829 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1830 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1831 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1832 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1833 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1834 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 1835 | } |
| 1836 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1837 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1838 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1839 | * |
| 1840 | * Description: |
| 1841 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1842 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1843 | * takes a default argument, a minimum and maximum argument. |
| 1844 | * |
| 1845 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 1846 | * adapter config field accordingly, or uses the default if out of range |
| 1847 | * and prints an error message. |
| 1848 | * @phba: pointer the the adapter structure. |
| 1849 | * @val: integer attribute value. |
| 1850 | * |
| 1851 | * Returns: |
| 1852 | * zero on success |
| 1853 | * -EINVAL if default used |
| 1854 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1855 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 1856 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1857 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1858 | { \ |
| 1859 | if (val >= minval && val <= maxval) {\ |
| 1860 | vport->cfg_##attr = val;\ |
| 1861 | return 0;\ |
| 1862 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1863 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1864 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1865 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1866 | vport->cfg_##attr = default;\ |
| 1867 | return -EINVAL;\ |
| 1868 | } |
| 1869 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1870 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1871 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1872 | * |
| 1873 | * Description: |
| 1874 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1875 | * into a function with the name lpfc_hba_queue_depth_set |
| 1876 | * |
| 1877 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 1878 | * adapter config field if in the valid range. prints error message |
| 1879 | * and does not set the parameter if invalid. |
| 1880 | * @phba: pointer the the adapter structure. |
| 1881 | * @val: integer attribute value. |
| 1882 | * |
| 1883 | * Returns: |
| 1884 | * zero on success |
| 1885 | * -EINVAL if val is invalid |
| 1886 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1887 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 1888 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1889 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1890 | { \ |
| 1891 | if (val >= minval && val <= maxval) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1892 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 1893 | "3053 lpfc_" #attr \ |
| 1894 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 1895 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 1896 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1897 | vport->cfg_##attr = val;\ |
| 1898 | return 0;\ |
| 1899 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1900 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1901 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1902 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1903 | return -EINVAL;\ |
| 1904 | } |
| 1905 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1906 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1907 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1908 | * |
| 1909 | * Description: |
| 1910 | * Macro that given an attr e.g. hba_queue_depth |
| 1911 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 1912 | * |
| 1913 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 1914 | * use the lpfc_##attr##_set function to set the value. |
| 1915 | * @cdev: class device that is converted into a Scsi_host. |
| 1916 | * @buf: contains the attribute value in decimal. |
| 1917 | * @count: not used. |
| 1918 | * |
| 1919 | * Returns: |
| 1920 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1921 | * length of buffer upon success. |
| 1922 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1923 | #define lpfc_vport_param_store(attr) \ |
| 1924 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1925 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1926 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1927 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1928 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1929 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1930 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1931 | if (!isdigit(buf[0]))\ |
| 1932 | return -EINVAL;\ |
| 1933 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1934 | return -EINVAL;\ |
| 1935 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 1936 | return strlen(buf);\ |
| 1937 | else \ |
| 1938 | return -EINVAL;\ |
| 1939 | } |
| 1940 | |
| 1941 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1942 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1943 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1944 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1945 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1946 | lpfc_param_init(name, defval, minval, maxval) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1947 | |
| 1948 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1949 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1950 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1951 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1952 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1953 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1954 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1955 | |
| 1956 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1957 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1958 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1959 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1960 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1961 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1962 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1963 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1964 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1965 | lpfc_##name##_show, lpfc_##name##_store) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1966 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1967 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1968 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1969 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1970 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1971 | lpfc_param_hex_show(name)\ |
| 1972 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1973 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1974 | |
| 1975 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1976 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1977 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1978 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1979 | lpfc_param_hex_show(name)\ |
| 1980 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1981 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1982 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1983 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1984 | lpfc_##name##_show, lpfc_##name##_store) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1985 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1986 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1987 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1988 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1989 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1990 | lpfc_vport_param_init(name, defval, minval, maxval) |
| 1991 | |
| 1992 | #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1993 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1994 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1995 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1996 | lpfc_vport_param_show(name)\ |
| 1997 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1998 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1999 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 2000 | #define LPFC_VPORT_ULL_ATTR_R(name, defval, minval, maxval, desc) \ |
| 2001 | static uint64_t lpfc_##name = defval;\ |
| 2002 | module_param(lpfc_##name, ullong, S_IRUGO);\ |
| 2003 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2004 | lpfc_vport_param_show(name)\ |
| 2005 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2006 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| 2007 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2008 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2009 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2010 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2011 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2012 | lpfc_vport_param_show(name)\ |
| 2013 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2014 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 2015 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2016 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 2017 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2018 | |
| 2019 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2020 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2021 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2022 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2023 | lpfc_vport_param_hex_show(name)\ |
| 2024 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2025 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2026 | |
| 2027 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2028 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2029 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2030 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2031 | lpfc_vport_param_hex_show(name)\ |
| 2032 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2033 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 2034 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2035 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 2036 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2037 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2038 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2039 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2040 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2041 | 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] | 2042 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2043 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2044 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2045 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2046 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2047 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2048 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2049 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2050 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2051 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2052 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2053 | lpfc_option_rom_version_show, NULL); |
| 2054 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2055 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2056 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2057 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 2058 | 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] | 2059 | 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] | 2060 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2061 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2062 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2063 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2064 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2065 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2066 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2067 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2068 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2069 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 2070 | 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] | 2071 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 2072 | 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] | 2073 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2074 | static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, |
| 2075 | lpfc_sriov_hw_max_virtfn_show, NULL); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2076 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2077 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2078 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2079 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2080 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2081 | #define WWN_SZ 8 |
| 2082 | /** |
| 2083 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2084 | * @buf: WWN string. |
| 2085 | * @cnt: Length of string. |
| 2086 | * @wwn: Array to receive converted wwn value. |
| 2087 | * |
| 2088 | * Returns: |
| 2089 | * -EINVAL if the buffer does not contain a valid wwn |
| 2090 | * 0 success |
| 2091 | **/ |
| 2092 | static size_t |
| 2093 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2094 | { |
| 2095 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2096 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2097 | /* Count may include a LF at end of string */ |
| 2098 | if (buf[cnt-1] == '\n') |
| 2099 | cnt--; |
| 2100 | |
| 2101 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2102 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2103 | return -EINVAL; |
| 2104 | |
| 2105 | memset(wwn, 0, WWN_SZ); |
| 2106 | |
| 2107 | /* Validate and store the new name */ |
| 2108 | for (i = 0, j = 0; i < 16; i++) { |
| 2109 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2110 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2111 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2112 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2113 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2114 | j = ((j << 4) | (*buf++ - '0')); |
| 2115 | else |
| 2116 | return -EINVAL; |
| 2117 | if (i % 2) { |
| 2118 | wwn[i/2] = j & 0xff; |
| 2119 | j = 0; |
| 2120 | } |
| 2121 | } |
| 2122 | return 0; |
| 2123 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2124 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2125 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2126 | * @dev: class device that is converted into a Scsi_host. |
| 2127 | * @attr: device attribute, not used. |
| 2128 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2129 | * @count: must be size of lpfc_soft_wwn_key. |
| 2130 | * |
| 2131 | * Returns: |
| 2132 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2133 | * length of buf indicates success |
| 2134 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2135 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2136 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2137 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2138 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2139 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2140 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2141 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2142 | unsigned int cnt = count; |
| 2143 | |
| 2144 | /* |
| 2145 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2146 | * We require that the user write a specific key to enable |
| 2147 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2148 | * is written, the enable key resets. If further updates are |
| 2149 | * desired, the key must be written again to re-enable the |
| 2150 | * attribute. |
| 2151 | * |
| 2152 | * The "key" is not secret - it is a hardcoded string shown |
| 2153 | * here. The intent is to protect against the random user or |
| 2154 | * application that is just writing attributes. |
| 2155 | */ |
| 2156 | |
| 2157 | /* count may include a LF at end of string */ |
| 2158 | if (buf[cnt-1] == '\n') |
| 2159 | cnt--; |
| 2160 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2161 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2162 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2163 | return -EINVAL; |
| 2164 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2165 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2166 | return count; |
| 2167 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2168 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 2169 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2170 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2171 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2172 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2173 | * @dev: class device that is converted into a Scsi_host. |
| 2174 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2175 | * @buf: on return contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2176 | * |
| 2177 | * Returns: size of formatted string. |
| 2178 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2179 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2180 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2181 | char *buf) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2182 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2183 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2184 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2185 | struct lpfc_hba *phba = vport->phba; |
| 2186 | |
Randy Dunlap | afc071e | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 2187 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2188 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2189 | } |
| 2190 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2191 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2192 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2193 | * @dev class device that is converted into a Scsi_host. |
| 2194 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2195 | * @buf: contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2196 | * @count: number of wwpn bytes in buf |
| 2197 | * |
| 2198 | * Returns: |
| 2199 | * -EACCES hba reset not enabled, adapter over temp |
| 2200 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2201 | * -EIO error taking adapter offline or online |
| 2202 | * value of count on success |
| 2203 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2204 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2205 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2206 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2207 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2208 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2209 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2210 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2211 | struct completion online_compl; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2212 | int stat1 = 0, stat2 = 0; |
| 2213 | unsigned int cnt = count; |
| 2214 | u8 wwpn[WWN_SZ]; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2215 | int rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2216 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 2217 | if (!phba->cfg_enable_hba_reset) |
| 2218 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2219 | spin_lock_irq(&phba->hbalock); |
| 2220 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2221 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 2222 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2223 | } |
| 2224 | spin_unlock_irq(&phba->hbalock); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2225 | /* count may include a LF at end of string */ |
| 2226 | if (buf[cnt-1] == '\n') |
| 2227 | cnt--; |
| 2228 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2229 | if (!phba->soft_wwn_enable) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2230 | return -EINVAL; |
| 2231 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2232 | /* lock setting wwpn, wwnn down */ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2233 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2234 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2235 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2236 | if (!rc) { |
| 2237 | /* not able to set wwpn, unlock it */ |
| 2238 | phba->soft_wwn_enable = 1; |
| 2239 | return rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2240 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2241 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2242 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2243 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2244 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2245 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2246 | |
| 2247 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2248 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2249 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 2250 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2251 | if (stat1) |
| 2252 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2253 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2254 | "reinit adapter - %d\n", stat1); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2255 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2256 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2257 | LPFC_EVT_ONLINE); |
| 2258 | if (rc == 0) |
| 2259 | return -ENOMEM; |
| 2260 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2261 | wait_for_completion(&online_compl); |
| 2262 | if (stat2) |
| 2263 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2264 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2265 | "reinit adapter - %d\n", stat2); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2266 | return (stat1 || stat2) ? -EIO : count; |
| 2267 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2268 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2269 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2270 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2271 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2272 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2273 | * @dev: class device that is converted into a Scsi_host. |
| 2274 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2275 | * @buf: on return contains the wwnn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2276 | * |
| 2277 | * Returns: size of formatted string. |
| 2278 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2279 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2280 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2281 | char *buf) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2282 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2283 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2284 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2285 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2286 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2287 | } |
| 2288 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2289 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2290 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2291 | * @cdev: class device that is converted into a Scsi_host. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2292 | * @buf: contains the ww node name in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2293 | * @count: number of wwnn bytes in buf. |
| 2294 | * |
| 2295 | * Returns: |
| 2296 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2297 | * value of count on success |
| 2298 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2299 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2300 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2301 | const char *buf, size_t count) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2302 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2303 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2304 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2305 | unsigned int cnt = count; |
| 2306 | u8 wwnn[WWN_SZ]; |
| 2307 | int rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2308 | |
| 2309 | /* count may include a LF at end of string */ |
| 2310 | if (buf[cnt-1] == '\n') |
| 2311 | cnt--; |
| 2312 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2313 | if (!phba->soft_wwn_enable) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2314 | return -EINVAL; |
| 2315 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2316 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
| 2317 | if (!rc) { |
| 2318 | /* Allow wwnn to be set many times, as long as the enable |
| 2319 | * is set. However, once the wwpn is set, everything locks. |
| 2320 | */ |
| 2321 | return rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2322 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2323 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2324 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2325 | |
| 2326 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2327 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2328 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2329 | |
| 2330 | return count; |
| 2331 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2332 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2333 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2334 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2335 | /** |
| 2336 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2337 | * Optimized Access Storage (OAS) operations. |
| 2338 | * @dev: class device that is converted into a Scsi_host. |
| 2339 | * @attr: device attribute, not used. |
| 2340 | * @buf: buffer for passing information. |
| 2341 | * |
| 2342 | * Returns: |
| 2343 | * value of count |
| 2344 | **/ |
| 2345 | static ssize_t |
| 2346 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2347 | char *buf) |
| 2348 | { |
| 2349 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2350 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2351 | |
| 2352 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2353 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2354 | } |
| 2355 | |
| 2356 | /** |
| 2357 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2358 | * Optimized Access Storage (OAS) operations. |
| 2359 | * @dev: class device that is converted into a Scsi_host. |
| 2360 | * @attr: device attribute, not used. |
| 2361 | * @buf: buffer for passing information. |
| 2362 | * @count: Size of the data buffer. |
| 2363 | * |
| 2364 | * Returns: |
| 2365 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2366 | * -EPERM oas is not supported by hba |
| 2367 | * value of count on success |
| 2368 | **/ |
| 2369 | static ssize_t |
| 2370 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2371 | const char *buf, size_t count) |
| 2372 | { |
| 2373 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2374 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2375 | unsigned int cnt = count; |
| 2376 | uint8_t wwpn[WWN_SZ]; |
| 2377 | int rc; |
| 2378 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2379 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2380 | return -EPERM; |
| 2381 | |
| 2382 | /* count may include a LF at end of string */ |
| 2383 | if (buf[cnt-1] == '\n') |
| 2384 | cnt--; |
| 2385 | |
| 2386 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2387 | if (rc) |
| 2388 | return rc; |
| 2389 | |
| 2390 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2391 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2392 | if (wwn_to_u64(wwpn) == 0) |
| 2393 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2394 | else |
| 2395 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2396 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2397 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2398 | return count; |
| 2399 | } |
| 2400 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2401 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2402 | |
| 2403 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2404 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2405 | * Optimized Access Storage (OAS) operations. |
| 2406 | * @dev: class device that is converted into a Scsi_host. |
| 2407 | * @attr: device attribute, not used. |
| 2408 | * @buf: buffer for passing information. |
| 2409 | * |
| 2410 | * Returns: |
| 2411 | * value of count |
| 2412 | **/ |
| 2413 | static ssize_t |
| 2414 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2415 | char *buf) |
| 2416 | { |
| 2417 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2418 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2419 | |
| 2420 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2421 | } |
| 2422 | |
| 2423 | /** |
| 2424 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2425 | * Optimized Access Storage (OAS) operations. |
| 2426 | * @dev: class device that is converted into a Scsi_host. |
| 2427 | * @attr: device attribute, not used. |
| 2428 | * @buf: buffer for passing information. |
| 2429 | * @count: Size of the data buffer. |
| 2430 | * |
| 2431 | * Returns: |
| 2432 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2433 | * -EPERM oas is not supported by hba |
| 2434 | * value of count on success |
| 2435 | **/ |
| 2436 | static ssize_t |
| 2437 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2438 | const char *buf, size_t count) |
| 2439 | { |
| 2440 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2441 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2442 | unsigned int cnt = count; |
| 2443 | unsigned long val; |
| 2444 | int ret; |
| 2445 | |
| 2446 | if (!phba->cfg_fof) |
| 2447 | return -EPERM; |
| 2448 | |
| 2449 | /* count may include a LF at end of string */ |
| 2450 | if (buf[cnt-1] == '\n') |
| 2451 | cnt--; |
| 2452 | |
| 2453 | ret = kstrtoul(buf, 0, &val); |
| 2454 | if (ret || (val > 0x7f)) |
| 2455 | return -EINVAL; |
| 2456 | |
| 2457 | if (val) |
| 2458 | phba->cfg_oas_priority = (uint8_t)val; |
| 2459 | else |
| 2460 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2461 | return count; |
| 2462 | } |
| 2463 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2464 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2465 | |
| 2466 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2467 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2468 | * for Optimized Access Storage (OAS) operations. |
| 2469 | * @dev: class device that is converted into a Scsi_host. |
| 2470 | * @attr: device attribute, not used. |
| 2471 | * @buf: buffer for passing information. |
| 2472 | * |
| 2473 | * Returns: |
| 2474 | * value of count on success |
| 2475 | **/ |
| 2476 | static ssize_t |
| 2477 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2478 | char *buf) |
| 2479 | { |
| 2480 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2481 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2482 | |
| 2483 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2484 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2485 | } |
| 2486 | |
| 2487 | /** |
| 2488 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2489 | * for Optimized Access Storage (OAS) operations. |
| 2490 | * @dev: class device that is converted into a Scsi_host. |
| 2491 | * @attr: device attribute, not used. |
| 2492 | * @buf: buffer for passing information. |
| 2493 | * @count: Size of the data buffer. |
| 2494 | * |
| 2495 | * Returns: |
| 2496 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2497 | * -EPERM oas is not supported by hba |
| 2498 | * value of count on success |
| 2499 | **/ |
| 2500 | static ssize_t |
| 2501 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2502 | const char *buf, size_t count) |
| 2503 | { |
| 2504 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2505 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2506 | unsigned int cnt = count; |
| 2507 | uint8_t wwpn[WWN_SZ]; |
| 2508 | int rc; |
| 2509 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2510 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2511 | return -EPERM; |
| 2512 | |
| 2513 | /* count may include a LF at end of string */ |
| 2514 | if (buf[cnt-1] == '\n') |
| 2515 | cnt--; |
| 2516 | |
| 2517 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2518 | if (rc) |
| 2519 | return rc; |
| 2520 | |
| 2521 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2522 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2523 | if (wwn_to_u64(wwpn) == 0) |
| 2524 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2525 | else |
| 2526 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2527 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2528 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2529 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2530 | return count; |
| 2531 | } |
| 2532 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2533 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2534 | |
| 2535 | /** |
| 2536 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2537 | * of whether luns will be enabled or disabled |
| 2538 | * for Optimized Access Storage (OAS) operations. |
| 2539 | * @dev: class device that is converted into a Scsi_host. |
| 2540 | * @attr: device attribute, not used. |
| 2541 | * @buf: buffer for passing information. |
| 2542 | * |
| 2543 | * Returns: |
| 2544 | * size of formatted string. |
| 2545 | **/ |
| 2546 | static ssize_t |
| 2547 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2548 | char *buf) |
| 2549 | { |
| 2550 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2551 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2552 | |
| 2553 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2554 | } |
| 2555 | |
| 2556 | /** |
| 2557 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2558 | * of whether luns will be enabled or disabled |
| 2559 | * for Optimized Access Storage (OAS) operations. |
| 2560 | * @dev: class device that is converted into a Scsi_host. |
| 2561 | * @attr: device attribute, not used. |
| 2562 | * @buf: buffer for passing information. |
| 2563 | * @count: Size of the data buffer. |
| 2564 | * |
| 2565 | * Returns: |
| 2566 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2567 | * -EPERM oas is not supported by hba |
| 2568 | * value of count on success |
| 2569 | **/ |
| 2570 | static ssize_t |
| 2571 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2572 | const char *buf, size_t count) |
| 2573 | { |
| 2574 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2575 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2576 | int val = 0; |
| 2577 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2578 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2579 | return -EPERM; |
| 2580 | |
| 2581 | if (!isdigit(buf[0])) |
| 2582 | return -EINVAL; |
| 2583 | |
| 2584 | if (sscanf(buf, "%i", &val) != 1) |
| 2585 | return -EINVAL; |
| 2586 | |
| 2587 | if ((val != 0) && (val != 1)) |
| 2588 | return -EINVAL; |
| 2589 | |
| 2590 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2591 | return strlen(buf); |
| 2592 | } |
| 2593 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2594 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2595 | |
| 2596 | /** |
| 2597 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2598 | * Storage (OAS) lun returned by the |
| 2599 | * lpfc_oas_lun_show function. |
| 2600 | * @dev: class device that is converted into a Scsi_host. |
| 2601 | * @attr: device attribute, not used. |
| 2602 | * @buf: buffer for passing information. |
| 2603 | * |
| 2604 | * Returns: |
| 2605 | * size of formatted string. |
| 2606 | **/ |
| 2607 | static ssize_t |
| 2608 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2609 | char *buf) |
| 2610 | { |
| 2611 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2612 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2613 | |
| 2614 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2615 | return -EFAULT; |
| 2616 | |
| 2617 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2618 | } |
| 2619 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2620 | lpfc_oas_lun_status_show, NULL); |
| 2621 | |
| 2622 | |
| 2623 | /** |
| 2624 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2625 | * (OAS) operations. |
| 2626 | * @phba: lpfc_hba pointer. |
| 2627 | * @ndlp: pointer to fcp target node. |
| 2628 | * @lun: the fc lun for setting oas state. |
| 2629 | * @oas_state: the oas state to be set to the lun. |
| 2630 | * |
| 2631 | * Returns: |
| 2632 | * SUCCESS : 0 |
| 2633 | * -EPERM OAS is not enabled or not supported by this port. |
| 2634 | * |
| 2635 | */ |
| 2636 | static size_t |
| 2637 | 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] | 2638 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2639 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2640 | { |
| 2641 | |
| 2642 | int rc = 0; |
| 2643 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2644 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2645 | return -EPERM; |
| 2646 | |
| 2647 | if (oas_state) { |
| 2648 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2649 | (struct lpfc_name *)tgt_wwpn, |
| 2650 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2651 | rc = -ENOMEM; |
| 2652 | } else { |
| 2653 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
| 2654 | (struct lpfc_name *)tgt_wwpn, lun); |
| 2655 | } |
| 2656 | return rc; |
| 2657 | |
| 2658 | } |
| 2659 | |
| 2660 | /** |
| 2661 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2662 | * Access Storage (OAS) operations. |
| 2663 | * @phba: lpfc_hba pointer. |
| 2664 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2665 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2666 | * @lun_status: status of the lun returned lun |
| 2667 | * |
| 2668 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2669 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2670 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2671 | * |
| 2672 | * Return: |
| 2673 | * lun that is OAS enabled for the vport/target |
| 2674 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2675 | */ |
| 2676 | static uint64_t |
| 2677 | lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2678 | uint8_t tgt_wwpn[], uint32_t *lun_status) |
| 2679 | { |
| 2680 | uint64_t found_lun; |
| 2681 | |
| 2682 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2683 | return NOT_OAS_ENABLED_LUN; |
| 2684 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2685 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2686 | (struct lpfc_name *) |
| 2687 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2688 | &phba->sli4_hba.oas_next_lun, |
| 2689 | (struct lpfc_name *)vpt_wwpn, |
| 2690 | (struct lpfc_name *)tgt_wwpn, |
| 2691 | &found_lun, lun_status)) |
| 2692 | return found_lun; |
| 2693 | else |
| 2694 | return NOT_OAS_ENABLED_LUN; |
| 2695 | } |
| 2696 | |
| 2697 | /** |
| 2698 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2699 | * @phba: lpfc_hba pointer. |
| 2700 | * @vpt_wwpn: vport wwpn by reference. |
| 2701 | * @tgt_wwpn: target wwpn by reference. |
| 2702 | * @lun: the fc lun for setting oas state. |
| 2703 | * @oas_state: the oas state to be set to the oas_lun. |
| 2704 | * |
| 2705 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2706 | * a lun for OAS operations. |
| 2707 | * |
| 2708 | * Return: |
| 2709 | * SUCCESS: 0 |
| 2710 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2711 | * -EPERM: OAS is not enabled |
| 2712 | */ |
| 2713 | static ssize_t |
| 2714 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2715 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2716 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2717 | { |
| 2718 | |
| 2719 | int rc; |
| 2720 | |
| 2721 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2722 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2723 | return rc; |
| 2724 | } |
| 2725 | |
| 2726 | /** |
| 2727 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2728 | * @dev: class device that is converted into a Scsi_host. |
| 2729 | * @attr: device attribute, not used. |
| 2730 | * @buf: buffer for passing information. |
| 2731 | * |
| 2732 | * This routine returns a lun enabled for OAS each time the function |
| 2733 | * is called. |
| 2734 | * |
| 2735 | * Returns: |
| 2736 | * SUCCESS: size of formatted string. |
| 2737 | * -EFAULT: target or vport wwpn was not set properly. |
| 2738 | * -EPERM: oas is not enabled. |
| 2739 | **/ |
| 2740 | static ssize_t |
| 2741 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 2742 | char *buf) |
| 2743 | { |
| 2744 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2745 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2746 | |
| 2747 | uint64_t oas_lun; |
| 2748 | int len = 0; |
| 2749 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2750 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2751 | return -EPERM; |
| 2752 | |
| 2753 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2754 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 2755 | return -EFAULT; |
| 2756 | |
| 2757 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2758 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 2759 | return -EFAULT; |
| 2760 | |
| 2761 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 2762 | phba->cfg_oas_tgt_wwpn, |
| 2763 | &phba->cfg_oas_lun_status); |
| 2764 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 2765 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 2766 | |
| 2767 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 2768 | |
| 2769 | return len; |
| 2770 | } |
| 2771 | |
| 2772 | /** |
| 2773 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 2774 | * @dev: class device that is converted into a Scsi_host. |
| 2775 | * @attr: device attribute, not used. |
| 2776 | * @buf: buffer for passing information. |
| 2777 | * |
| 2778 | * This function sets the OAS state for lun. Before this function is called, |
| 2779 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 2780 | * |
| 2781 | * Returns: |
| 2782 | * SUCCESS: size of formatted string. |
| 2783 | * -EFAULT: target or vport wwpn was not set properly. |
| 2784 | * -EPERM: oas is not enabled. |
| 2785 | * size of formatted string. |
| 2786 | **/ |
| 2787 | static ssize_t |
| 2788 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 2789 | const char *buf, size_t count) |
| 2790 | { |
| 2791 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2792 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2793 | uint64_t scsi_lun; |
| 2794 | ssize_t rc; |
| 2795 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2796 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2797 | return -EPERM; |
| 2798 | |
| 2799 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2800 | return -EFAULT; |
| 2801 | |
| 2802 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2803 | return -EFAULT; |
| 2804 | |
| 2805 | if (!isdigit(buf[0])) |
| 2806 | return -EINVAL; |
| 2807 | |
| 2808 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 2809 | return -EINVAL; |
| 2810 | |
| 2811 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2812 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 2813 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2814 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 2815 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2816 | phba->cfg_oas_priority, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2817 | |
| 2818 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2819 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
| 2820 | phba->cfg_oas_lun_state, |
| 2821 | phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2822 | if (rc) |
| 2823 | return rc; |
| 2824 | |
| 2825 | return count; |
| 2826 | } |
| 2827 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 2828 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2829 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2830 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2831 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2832 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 2833 | " 0 - none," |
| 2834 | " 1 - poll with interrupts enabled" |
| 2835 | " 3 - poll and disable FCP ring interrupts"); |
| 2836 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2837 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 2838 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2839 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2840 | int lpfc_sli_mode = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2841 | module_param(lpfc_sli_mode, int, S_IRUGO); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2842 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" |
| 2843 | " 0 - auto (SLI-3 if supported)," |
| 2844 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 2845 | " 3 - select SLI-3"); |
| 2846 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame^] | 2847 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 2848 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2849 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 2850 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 2851 | "FCF Fast failover=1 Priority failover=2"); |
| 2852 | |
James Smart | c14e995 | 2013-03-01 16:38:01 -0500 | [diff] [blame] | 2853 | int lpfc_enable_rrq = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2854 | module_param(lpfc_enable_rrq, int, S_IRUGO); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2855 | MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality"); |
| 2856 | lpfc_param_show(enable_rrq); |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 2857 | /* |
| 2858 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 2859 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 2860 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 2861 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 2862 | */ |
| 2863 | lpfc_param_init(enable_rrq, 2, 0, 2); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2864 | static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL); |
| 2865 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2866 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2867 | # lpfc_suppress_link_up: Bring link up at initialization |
| 2868 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 2869 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 2870 | # 0x2 = never bring up link |
| 2871 | # Default value is 0. |
| 2872 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2873 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 2874 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 2875 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2876 | /* |
| 2877 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 2878 | # 1 - (1024) |
| 2879 | # 2 - (2048) |
| 2880 | # 3 - (3072) |
| 2881 | # 4 - (4096) |
| 2882 | # 5 - (5120) |
| 2883 | */ |
| 2884 | static ssize_t |
| 2885 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2886 | { |
| 2887 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2888 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2889 | |
| 2890 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 2891 | } |
| 2892 | |
| 2893 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 2894 | lpfc_iocb_hw_show, NULL); |
| 2895 | static ssize_t |
| 2896 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2897 | { |
| 2898 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2899 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2900 | |
| 2901 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2902 | phba->sli.ring[LPFC_ELS_RING].txq_max); |
| 2903 | } |
| 2904 | |
| 2905 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 2906 | lpfc_txq_hw_show, NULL); |
| 2907 | static ssize_t |
| 2908 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 2909 | char *buf) |
| 2910 | { |
| 2911 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2912 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2913 | |
| 2914 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2915 | phba->sli.ring[LPFC_ELS_RING].txcmplq_max); |
| 2916 | } |
| 2917 | |
| 2918 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 2919 | lpfc_txcmplq_hw_show, NULL); |
| 2920 | |
| 2921 | int lpfc_iocb_cnt = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2922 | module_param(lpfc_iocb_cnt, int, S_IRUGO); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2923 | MODULE_PARM_DESC(lpfc_iocb_cnt, |
| 2924 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
| 2925 | lpfc_param_show(iocb_cnt); |
| 2926 | lpfc_param_init(iocb_cnt, 2, 1, 5); |
| 2927 | static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO, |
| 2928 | lpfc_iocb_cnt_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2929 | |
| 2930 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2931 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 2932 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 2933 | */ |
| 2934 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2935 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2936 | module_param(lpfc_nodev_tmo, int, 0); |
| 2937 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 2938 | "Seconds driver will hold I/O waiting " |
| 2939 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2940 | |
| 2941 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2942 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2943 | * @dev: class converted to a Scsi_host structure. |
| 2944 | * @attr: device attribute, not used. |
| 2945 | * @buf: on return contains the dev loss timeout in decimal. |
| 2946 | * |
| 2947 | * Returns: size of formatted string. |
| 2948 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2949 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2950 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 2951 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2952 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2953 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2954 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2955 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2956 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2957 | } |
| 2958 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2959 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2960 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2961 | * @vport: lpfc vport structure pointer. |
| 2962 | * @val: contains the nodev timeout value. |
| 2963 | * |
| 2964 | * Description: |
| 2965 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 2966 | * a kernel error message is printed and zero is returned. |
| 2967 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2968 | * Otherwise nodev tmo is set to the default value. |
| 2969 | * |
| 2970 | * Returns: |
| 2971 | * zero if already set or if val is in range |
| 2972 | * -EINVAL val out of range |
| 2973 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2974 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2975 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2976 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2977 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 2978 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 2979 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2980 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2981 | "0407 Ignoring nodev_tmo module " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2982 | "parameter because devloss_tmo is " |
| 2983 | "set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2984 | return 0; |
| 2985 | } |
| 2986 | |
| 2987 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2988 | vport->cfg_nodev_tmo = val; |
| 2989 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2990 | return 0; |
| 2991 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2992 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2993 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 2994 | " %d, allowed range is [%d, %d]\n", |
| 2995 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2996 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2997 | return -EINVAL; |
| 2998 | } |
| 2999 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3000 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3001 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3002 | * @vport: lpfc vport structure pointer. |
| 3003 | * |
| 3004 | * Description: |
| 3005 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3006 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3007 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3008 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3009 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3010 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3011 | struct lpfc_nodelist *ndlp; |
| 3012 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3013 | shost = lpfc_shost_from_vport(vport); |
| 3014 | spin_lock_irq(shost->host_lock); |
| 3015 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3016 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3017 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 3018 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3019 | } |
| 3020 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3021 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3022 | * 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] | 3023 | * @vport: lpfc vport structure pointer. |
| 3024 | * @val: contains the tmo value. |
| 3025 | * |
| 3026 | * Description: |
| 3027 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3028 | * then a kernel error message is printed and zero is returned. |
| 3029 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3030 | * Otherwise nodev tmo is set to the default value. |
| 3031 | * |
| 3032 | * Returns: |
| 3033 | * zero if already set or if val is in range |
| 3034 | * -EINVAL val out of range |
| 3035 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3036 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3037 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3038 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3039 | if (vport->dev_loss_tmo_changed || |
| 3040 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3041 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3042 | "0401 Ignoring change to nodev_tmo " |
| 3043 | "because devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3044 | return 0; |
| 3045 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3046 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3047 | vport->cfg_nodev_tmo = val; |
| 3048 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3049 | /* |
| 3050 | * For compat: set the fc_host dev loss so new rports |
| 3051 | * will get the value. |
| 3052 | */ |
| 3053 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3054 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3055 | return 0; |
| 3056 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3057 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3058 | "0403 lpfc_nodev_tmo attribute cannot be set to" |
| 3059 | "%d, allowed range is [%d, %d]\n", |
| 3060 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3061 | return -EINVAL; |
| 3062 | } |
| 3063 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3064 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3065 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3066 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 3067 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3068 | |
| 3069 | /* |
| 3070 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3071 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3072 | # value is 30. |
| 3073 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3074 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3075 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3076 | "Seconds driver will hold I/O waiting " |
| 3077 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3078 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3079 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3080 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3081 | |
| 3082 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3083 | * 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] | 3084 | * @vport: lpfc vport structure pointer. |
| 3085 | * @val: contains the tmo value. |
| 3086 | * |
| 3087 | * Description: |
| 3088 | * If val is in a valid range then set the vport nodev tmo, |
| 3089 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3090 | * Else a kernel error message is printed. |
| 3091 | * |
| 3092 | * Returns: |
| 3093 | * zero if val is in range |
| 3094 | * -EINVAL val out of range |
| 3095 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3096 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3097 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3098 | { |
| 3099 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3100 | vport->cfg_nodev_tmo = val; |
| 3101 | vport->cfg_devloss_tmo = val; |
| 3102 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3103 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3104 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3105 | return 0; |
| 3106 | } |
| 3107 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3108 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3109 | "0404 lpfc_devloss_tmo attribute cannot be set to" |
| 3110 | " %d, allowed range is [%d, %d]\n", |
| 3111 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3112 | return -EINVAL; |
| 3113 | } |
| 3114 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3115 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3116 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 3117 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3118 | |
| 3119 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3120 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3121 | # deluged with LOTS of information. |
| 3122 | # 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] | 3123 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3124 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3125 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3126 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3127 | |
| 3128 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3129 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3130 | # objects that have been registered with the nameserver after login. |
| 3131 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3132 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3133 | "Deregister nameserver objects before LOGO"); |
| 3134 | |
| 3135 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3136 | # 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] | 3137 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3138 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3139 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3140 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3141 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3142 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3143 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3144 | |
| 3145 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3146 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3147 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3148 | */ |
| 3149 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3150 | "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] | 3151 | |
| 3152 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3153 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3154 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3155 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3156 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3157 | # the hba_queue_depth. |
| 3158 | */ |
| 3159 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3160 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3161 | |
| 3162 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3163 | # peer_port_login: This parameter allows/prevents logins |
| 3164 | # between peer ports hosted on the same physical port. |
| 3165 | # When this parameter is set 0 peer ports of same physical port |
| 3166 | # are not allowed to login to each other. |
| 3167 | # When this parameter is set 1 peer ports of same physical port |
| 3168 | # are allowed to login to each other. |
| 3169 | # Default value of this parameter is 0. |
| 3170 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3171 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3172 | "Allow peer ports on the same physical port to login to each " |
| 3173 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3174 | |
| 3175 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3176 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3177 | # between Virtual Ports and remote initiators. |
| 3178 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3179 | # other initiators and will attempt to PLOGI all remote ports. |
| 3180 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3181 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3182 | # This parameter does not restrict to the physical port. |
| 3183 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3184 | # Default value of this parameter is 1. |
| 3185 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3186 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3187 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3188 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3189 | "Restrict virtual ports login to remote initiators."); |
| 3190 | lpfc_vport_param_show(restrict_login); |
| 3191 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3192 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3193 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3194 | * @vport: lpfc vport structure pointer. |
| 3195 | * @val: contains the restrict login value. |
| 3196 | * |
| 3197 | * Description: |
| 3198 | * If val is not in a valid range then log a kernel error message and set |
| 3199 | * the vport restrict login to one. |
| 3200 | * If the port type is physical clear the restrict login flag and return. |
| 3201 | * Else set the restrict login flag to val. |
| 3202 | * |
| 3203 | * Returns: |
| 3204 | * zero if val is in range |
| 3205 | * -EINVAL val out of range |
| 3206 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3207 | static int |
| 3208 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3209 | { |
| 3210 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3211 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3212 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3213 | "be set to %d, allowed range is [0, 1]\n", |
| 3214 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3215 | vport->cfg_restrict_login = 1; |
| 3216 | return -EINVAL; |
| 3217 | } |
| 3218 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3219 | vport->cfg_restrict_login = 0; |
| 3220 | return 0; |
| 3221 | } |
| 3222 | vport->cfg_restrict_login = val; |
| 3223 | return 0; |
| 3224 | } |
| 3225 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3226 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3227 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3228 | * @vport: lpfc vport structure pointer. |
| 3229 | * @val: contains the restrict login value. |
| 3230 | * |
| 3231 | * Description: |
| 3232 | * If val is not in a valid range then log a kernel error message and set |
| 3233 | * the vport restrict login to one. |
| 3234 | * If the port type is physical and the val is not zero log a kernel |
| 3235 | * error message, clear the restrict login flag and return zero. |
| 3236 | * Else set the restrict login flag to val. |
| 3237 | * |
| 3238 | * Returns: |
| 3239 | * zero if val is in range |
| 3240 | * -EINVAL val out of range |
| 3241 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3242 | static int |
| 3243 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3244 | { |
| 3245 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3246 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3247 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3248 | "be set to %d, allowed range is [0, 1]\n", |
| 3249 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3250 | vport->cfg_restrict_login = 1; |
| 3251 | return -EINVAL; |
| 3252 | } |
| 3253 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3254 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3255 | "0468 lpfc_restrict_login must be 0 for " |
| 3256 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3257 | vport->cfg_restrict_login = 0; |
| 3258 | return 0; |
| 3259 | } |
| 3260 | vport->cfg_restrict_login = val; |
| 3261 | return 0; |
| 3262 | } |
| 3263 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3264 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 3265 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3266 | |
| 3267 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3268 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3269 | # From a protocol standpoint "select ID" usually means select the |
| 3270 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3271 | # annex" which contains a table that maps a "select ID" (a number |
| 3272 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3273 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3274 | # ALPA. |
| 3275 | # |
| 3276 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3277 | # cause the lpfc driver to use an inverted table, effectively |
| 3278 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3279 | # |
| 3280 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3281 | # and will not work across a fabric. Also this parameter will take |
| 3282 | # effect only in the case when ALPA map is not available.) |
| 3283 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3284 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3285 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3286 | |
| 3287 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3288 | # lpfc_topology: link topology for init link |
| 3289 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3290 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3291 | # 0x02 = attempt point-to-point mode only |
| 3292 | # 0x04 = attempt loop mode only |
| 3293 | # 0x06 = attempt point-to-point mode then loop |
| 3294 | # Set point-to-point mode if you want to run as an N_Port. |
| 3295 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3296 | # Default value is 0. |
| 3297 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3298 | |
| 3299 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3300 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3301 | * @phba: lpfc_hba pointer. |
| 3302 | * @val: topology value. |
| 3303 | * |
| 3304 | * Description: |
| 3305 | * If val is in a valid range then set the adapter's topology field and |
| 3306 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3307 | * |
| 3308 | * If the value is not in range log a kernel error message and return an error. |
| 3309 | * |
| 3310 | * Returns: |
| 3311 | * zero if val is in range and lip okay |
| 3312 | * non-zero return value from lpfc_issue_lip() |
| 3313 | * -EINVAL val out of range |
| 3314 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3315 | static ssize_t |
| 3316 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3317 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3318 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3319 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3320 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3321 | struct lpfc_hba *phba = vport->phba; |
| 3322 | int val = 0; |
| 3323 | int nolip = 0; |
| 3324 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3325 | int err; |
| 3326 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3327 | |
| 3328 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3329 | nolip = 1; |
| 3330 | val_buf = &buf[strlen("nolip ")]; |
| 3331 | } |
| 3332 | |
| 3333 | if (!isdigit(val_buf[0])) |
| 3334 | return -EINVAL; |
| 3335 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3336 | return -EINVAL; |
| 3337 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3338 | if (val >= 0 && val <= 6) { |
| 3339 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3340 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3341 | val == 4) { |
| 3342 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3343 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3344 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3345 | return -EINVAL; |
| 3346 | } |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3347 | if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && |
| 3348 | val == 4) { |
| 3349 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3350 | "3114 Loop mode not supported\n"); |
| 3351 | return -EINVAL; |
| 3352 | } |
| 3353 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3354 | if (nolip) |
| 3355 | return strlen(buf); |
| 3356 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3357 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3358 | "3054 lpfc_topology changed from %d to %d\n", |
| 3359 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3360 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3361 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3362 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3363 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3364 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3365 | return -EINVAL; |
| 3366 | } else |
| 3367 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3368 | } |
| 3369 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3370 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3371 | "allowed range is [0, 6]\n", |
| 3372 | phba->brd_no, val); |
| 3373 | return -EINVAL; |
| 3374 | } |
| 3375 | static int lpfc_topology = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3376 | module_param(lpfc_topology, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3377 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
| 3378 | lpfc_param_show(topology) |
| 3379 | lpfc_param_init(topology, 0, 0, 6) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3380 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3381 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3382 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3383 | /** |
| 3384 | * lpfc_static_vport_show: Read callback function for |
| 3385 | * lpfc_static_vport sysfs file. |
| 3386 | * @dev: Pointer to class device object. |
| 3387 | * @attr: device attribute structure. |
| 3388 | * @buf: Data buffer. |
| 3389 | * |
| 3390 | * This function is the read call back function for |
| 3391 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3392 | * sysfs file report the mageability of the vport. |
| 3393 | **/ |
| 3394 | static ssize_t |
| 3395 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3396 | char *buf) |
| 3397 | { |
| 3398 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3399 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3400 | if (vport->vport_flag & STATIC_VPORT) |
| 3401 | sprintf(buf, "1\n"); |
| 3402 | else |
| 3403 | sprintf(buf, "0\n"); |
| 3404 | |
| 3405 | return strlen(buf); |
| 3406 | } |
| 3407 | |
| 3408 | /* |
| 3409 | * Sysfs attribute to control the statistical data collection. |
| 3410 | */ |
| 3411 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 3412 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3413 | |
| 3414 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3415 | * 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] | 3416 | * @dev: Pointer to class device. |
| 3417 | * @buf: Data buffer. |
| 3418 | * @count: Size of the data buffer. |
| 3419 | * |
| 3420 | * This function get called when an user write to the lpfc_stat_data_ctrl |
| 3421 | * sysfs file. This function parse the command written to the sysfs file |
| 3422 | * and take appropriate action. These commands are used for controlling |
| 3423 | * driver statistical data collection. |
| 3424 | * Following are the command this function handles. |
| 3425 | * |
| 3426 | * setbucket <bucket_type> <base> <step> |
| 3427 | * = Set the latency buckets. |
| 3428 | * destroybucket = destroy all the buckets. |
| 3429 | * start = start data collection |
| 3430 | * stop = stop data collection |
| 3431 | * reset = reset the collected data |
| 3432 | **/ |
| 3433 | static ssize_t |
| 3434 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3435 | const char *buf, size_t count) |
| 3436 | { |
| 3437 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3438 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3439 | struct lpfc_hba *phba = vport->phba; |
| 3440 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3441 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3442 | unsigned long i; |
| 3443 | char *str_ptr, *token; |
| 3444 | struct lpfc_vport **vports; |
| 3445 | struct Scsi_Host *v_shost; |
| 3446 | char *bucket_type_str, *base_str, *step_str; |
| 3447 | unsigned long base, step, bucket_type; |
| 3448 | |
| 3449 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3450 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3451 | return -EINVAL; |
| 3452 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 3453 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3454 | str_ptr = &bucket_data[0]; |
| 3455 | /* Ignore this token - this is command token */ |
| 3456 | token = strsep(&str_ptr, "\t "); |
| 3457 | if (!token) |
| 3458 | return -EINVAL; |
| 3459 | |
| 3460 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3461 | if (!bucket_type_str) |
| 3462 | return -EINVAL; |
| 3463 | |
| 3464 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3465 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3466 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3467 | bucket_type = LPFC_POWER2_BUCKET; |
| 3468 | else |
| 3469 | return -EINVAL; |
| 3470 | |
| 3471 | base_str = strsep(&str_ptr, "\t "); |
| 3472 | if (!base_str) |
| 3473 | return -EINVAL; |
| 3474 | base = simple_strtoul(base_str, NULL, 0); |
| 3475 | |
| 3476 | step_str = strsep(&str_ptr, "\t "); |
| 3477 | if (!step_str) |
| 3478 | return -EINVAL; |
| 3479 | step = simple_strtoul(step_str, NULL, 0); |
| 3480 | if (!step) |
| 3481 | return -EINVAL; |
| 3482 | |
| 3483 | /* Block the data collection for every vport */ |
| 3484 | vports = lpfc_create_vport_work_array(phba); |
| 3485 | if (vports == NULL) |
| 3486 | return -ENOMEM; |
| 3487 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3488 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3489 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3490 | spin_lock_irq(v_shost->host_lock); |
| 3491 | /* Block and reset data collection */ |
| 3492 | vports[i]->stat_data_blocked = 1; |
| 3493 | if (vports[i]->stat_data_enabled) |
| 3494 | lpfc_vport_reset_stat_data(vports[i]); |
| 3495 | spin_unlock_irq(v_shost->host_lock); |
| 3496 | } |
| 3497 | |
| 3498 | /* Set the bucket attributes */ |
| 3499 | phba->bucket_type = bucket_type; |
| 3500 | phba->bucket_base = base; |
| 3501 | phba->bucket_step = step; |
| 3502 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3503 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3504 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3505 | |
| 3506 | /* Unblock data collection */ |
| 3507 | spin_lock_irq(v_shost->host_lock); |
| 3508 | vports[i]->stat_data_blocked = 0; |
| 3509 | spin_unlock_irq(v_shost->host_lock); |
| 3510 | } |
| 3511 | lpfc_destroy_vport_work_array(phba, vports); |
| 3512 | return strlen(buf); |
| 3513 | } |
| 3514 | |
| 3515 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3516 | vports = lpfc_create_vport_work_array(phba); |
| 3517 | if (vports == NULL) |
| 3518 | return -ENOMEM; |
| 3519 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3520 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3521 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3522 | spin_lock_irq(shost->host_lock); |
| 3523 | vports[i]->stat_data_blocked = 1; |
| 3524 | lpfc_free_bucket(vport); |
| 3525 | vport->stat_data_enabled = 0; |
| 3526 | vports[i]->stat_data_blocked = 0; |
| 3527 | spin_unlock_irq(shost->host_lock); |
| 3528 | } |
| 3529 | lpfc_destroy_vport_work_array(phba, vports); |
| 3530 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3531 | phba->bucket_base = 0; |
| 3532 | phba->bucket_step = 0; |
| 3533 | return strlen(buf); |
| 3534 | } |
| 3535 | |
| 3536 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3537 | /* If no buckets configured return error */ |
| 3538 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3539 | return -EINVAL; |
| 3540 | spin_lock_irq(shost->host_lock); |
| 3541 | if (vport->stat_data_enabled) { |
| 3542 | spin_unlock_irq(shost->host_lock); |
| 3543 | return strlen(buf); |
| 3544 | } |
| 3545 | lpfc_alloc_bucket(vport); |
| 3546 | vport->stat_data_enabled = 1; |
| 3547 | spin_unlock_irq(shost->host_lock); |
| 3548 | return strlen(buf); |
| 3549 | } |
| 3550 | |
| 3551 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3552 | spin_lock_irq(shost->host_lock); |
| 3553 | if (vport->stat_data_enabled == 0) { |
| 3554 | spin_unlock_irq(shost->host_lock); |
| 3555 | return strlen(buf); |
| 3556 | } |
| 3557 | lpfc_free_bucket(vport); |
| 3558 | vport->stat_data_enabled = 0; |
| 3559 | spin_unlock_irq(shost->host_lock); |
| 3560 | return strlen(buf); |
| 3561 | } |
| 3562 | |
| 3563 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3564 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3565 | || !vport->stat_data_enabled) |
| 3566 | return strlen(buf); |
| 3567 | spin_lock_irq(shost->host_lock); |
| 3568 | vport->stat_data_blocked = 1; |
| 3569 | lpfc_vport_reset_stat_data(vport); |
| 3570 | vport->stat_data_blocked = 0; |
| 3571 | spin_unlock_irq(shost->host_lock); |
| 3572 | return strlen(buf); |
| 3573 | } |
| 3574 | return -EINVAL; |
| 3575 | } |
| 3576 | |
| 3577 | |
| 3578 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3579 | * 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] | 3580 | * @dev: Pointer to class device object. |
| 3581 | * @buf: Data buffer. |
| 3582 | * |
| 3583 | * This function is the read call back function for |
| 3584 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3585 | * current statistical data collection state. |
| 3586 | **/ |
| 3587 | static ssize_t |
| 3588 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3589 | char *buf) |
| 3590 | { |
| 3591 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3592 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3593 | struct lpfc_hba *phba = vport->phba; |
| 3594 | int index = 0; |
| 3595 | int i; |
| 3596 | char *bucket_type; |
| 3597 | unsigned long bucket_value; |
| 3598 | |
| 3599 | switch (phba->bucket_type) { |
| 3600 | case LPFC_LINEAR_BUCKET: |
| 3601 | bucket_type = "linear"; |
| 3602 | break; |
| 3603 | case LPFC_POWER2_BUCKET: |
| 3604 | bucket_type = "power2"; |
| 3605 | break; |
| 3606 | default: |
| 3607 | bucket_type = "No Bucket"; |
| 3608 | break; |
| 3609 | } |
| 3610 | |
| 3611 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3612 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3613 | " Bucket step :%d\nLatency Ranges :", |
| 3614 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3615 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3616 | index = strlen(buf); |
| 3617 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3618 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3619 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3620 | bucket_value = phba->bucket_base + |
| 3621 | phba->bucket_step * i; |
| 3622 | else |
| 3623 | bucket_value = phba->bucket_base + |
| 3624 | (1 << i) * phba->bucket_step; |
| 3625 | |
| 3626 | if (index + 10 > PAGE_SIZE) |
| 3627 | break; |
| 3628 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3629 | index = strlen(buf); |
| 3630 | } |
| 3631 | } |
| 3632 | sprintf(&buf[index], "\n"); |
| 3633 | return strlen(buf); |
| 3634 | } |
| 3635 | |
| 3636 | /* |
| 3637 | * Sysfs attribute to control the statistical data collection. |
| 3638 | */ |
| 3639 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 3640 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 3641 | |
| 3642 | /* |
| 3643 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3644 | */ |
| 3645 | |
| 3646 | /* |
| 3647 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3648 | * for each target. |
| 3649 | */ |
| 3650 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3651 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3652 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3653 | |
| 3654 | |
| 3655 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3656 | * 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] | 3657 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3658 | * @kobj: Pointer to the kernel object |
| 3659 | * @bin_attr: Attribute object |
| 3660 | * @buff: Buffer pointer |
| 3661 | * @off: File offset |
| 3662 | * @count: Buffer size |
| 3663 | * |
| 3664 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3665 | * sysfs file. This function export the statistical data to user |
| 3666 | * applications. |
| 3667 | **/ |
| 3668 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3669 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3670 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3671 | char *buf, loff_t off, size_t count) |
| 3672 | { |
| 3673 | struct device *dev = container_of(kobj, struct device, |
| 3674 | kobj); |
| 3675 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3676 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3677 | struct lpfc_hba *phba = vport->phba; |
| 3678 | int i = 0, index = 0; |
| 3679 | unsigned long nport_index; |
| 3680 | struct lpfc_nodelist *ndlp = NULL; |
| 3681 | nport_index = (unsigned long)off / |
| 3682 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3683 | |
| 3684 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3685 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3686 | return 0; |
| 3687 | |
| 3688 | spin_lock_irq(shost->host_lock); |
| 3689 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3690 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 3691 | continue; |
| 3692 | |
| 3693 | if (nport_index > 0) { |
| 3694 | nport_index--; |
| 3695 | continue; |
| 3696 | } |
| 3697 | |
| 3698 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 3699 | > count) |
| 3700 | break; |
| 3701 | |
| 3702 | if (!ndlp->lat_data) |
| 3703 | continue; |
| 3704 | |
| 3705 | /* Print the WWN */ |
| 3706 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 3707 | ndlp->nlp_portname.u.wwn[0], |
| 3708 | ndlp->nlp_portname.u.wwn[1], |
| 3709 | ndlp->nlp_portname.u.wwn[2], |
| 3710 | ndlp->nlp_portname.u.wwn[3], |
| 3711 | ndlp->nlp_portname.u.wwn[4], |
| 3712 | ndlp->nlp_portname.u.wwn[5], |
| 3713 | ndlp->nlp_portname.u.wwn[6], |
| 3714 | ndlp->nlp_portname.u.wwn[7]); |
| 3715 | |
| 3716 | index = strlen(buf); |
| 3717 | |
| 3718 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3719 | sprintf(&buf[index], "%010u,", |
| 3720 | ndlp->lat_data[i].cmd_count); |
| 3721 | index = strlen(buf); |
| 3722 | } |
| 3723 | sprintf(&buf[index], "\n"); |
| 3724 | index = strlen(buf); |
| 3725 | } |
| 3726 | spin_unlock_irq(shost->host_lock); |
| 3727 | return index; |
| 3728 | } |
| 3729 | |
| 3730 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 3731 | .attr = { |
| 3732 | .name = "lpfc_drvr_stat_data", |
| 3733 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3734 | }, |
| 3735 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 3736 | .read = sysfs_drvr_stat_data_read, |
| 3737 | .write = NULL, |
| 3738 | }; |
| 3739 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3740 | /* |
| 3741 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 3742 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3743 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3744 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3745 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3746 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3747 | * @phba: lpfc_hba pointer. |
| 3748 | * @val: link speed value. |
| 3749 | * |
| 3750 | * Description: |
| 3751 | * If val is in a valid range then set the adapter's link speed field and |
| 3752 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 3753 | * |
| 3754 | * Notes: |
| 3755 | * If the value is not in range log a kernel error message and return an error. |
| 3756 | * |
| 3757 | * Returns: |
| 3758 | * zero if val is in range and lip okay. |
| 3759 | * non-zero return value from lpfc_issue_lip() |
| 3760 | * -EINVAL val out of range |
| 3761 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3762 | static ssize_t |
| 3763 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 3764 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3765 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3766 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3767 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3768 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3769 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3770 | int nolip = 0; |
| 3771 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3772 | int err; |
| 3773 | uint32_t prev_val; |
| 3774 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3775 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3776 | nolip = 1; |
| 3777 | val_buf = &buf[strlen("nolip ")]; |
| 3778 | } |
| 3779 | |
| 3780 | if (!isdigit(val_buf[0])) |
| 3781 | return -EINVAL; |
| 3782 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3783 | return -EINVAL; |
| 3784 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3785 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3786 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 3787 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 3788 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3789 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 3790 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 3791 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 3792 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 3793 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3794 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
| 3795 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3796 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3797 | "2879 lpfc_link_speed attribute cannot be set " |
| 3798 | "to %d. Speed is not supported by this port.\n", |
| 3799 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3800 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3801 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3802 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 3803 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 3804 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3805 | "3112 lpfc_link_speed attribute cannot be set " |
| 3806 | "to %d. Speed is not supported in loop mode.\n", |
| 3807 | val); |
| 3808 | return -EINVAL; |
| 3809 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3810 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3811 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3812 | prev_val = phba->cfg_link_speed; |
| 3813 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3814 | if (nolip) |
| 3815 | return strlen(buf); |
| 3816 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3817 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3818 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3819 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3820 | return -EINVAL; |
| 3821 | } else |
| 3822 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3823 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3824 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3825 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 3826 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3827 | return -EINVAL; |
| 3828 | } |
| 3829 | |
| 3830 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3831 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3832 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 3833 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3834 | |
| 3835 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3836 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3837 | * @phba: lpfc_hba pointer. |
| 3838 | * @val: link speed value. |
| 3839 | * |
| 3840 | * Description: |
| 3841 | * If val is in a valid range then set the adapter's link speed field. |
| 3842 | * |
| 3843 | * Notes: |
| 3844 | * If the value is not in range log a kernel error message, clear the link |
| 3845 | * speed and return an error. |
| 3846 | * |
| 3847 | * Returns: |
| 3848 | * zero if val saved. |
| 3849 | * -EINVAL val out of range |
| 3850 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3851 | static int |
| 3852 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 3853 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3854 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 3855 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3856 | "3111 lpfc_link_speed of %d cannot " |
| 3857 | "support loop mode, setting topology to default.\n", |
| 3858 | val); |
| 3859 | phba->cfg_topology = 0; |
| 3860 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3861 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3862 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3863 | phba->cfg_link_speed = val; |
| 3864 | return 0; |
| 3865 | } |
| 3866 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3867 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3868 | "be set to %d, allowed values are " |
| 3869 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3870 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3871 | return -EINVAL; |
| 3872 | } |
| 3873 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3874 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3875 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3876 | |
| 3877 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3878 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 3879 | # 0 = aer disabled or not supported |
| 3880 | # 1 = aer supported and enabled (default) |
| 3881 | # Value range is [0,1]. Default value is 1. |
| 3882 | */ |
| 3883 | |
| 3884 | /** |
| 3885 | * lpfc_aer_support_store - Set the adapter for aer support |
| 3886 | * |
| 3887 | * @dev: class device that is converted into a Scsi_host. |
| 3888 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3889 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3890 | * @count: unused variable. |
| 3891 | * |
| 3892 | * Description: |
| 3893 | * If the val is 1 and currently the device's AER capability was not |
| 3894 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 3895 | * enable the device's AER capability. If the helper routine enabling |
| 3896 | * AER returns success, update the device's cfg_aer_support flag to |
| 3897 | * indicate AER is supported by the device; otherwise, if the device |
| 3898 | * AER capability is already enabled to support AER, then do nothing. |
| 3899 | * |
| 3900 | * If the val is 0 and currently the device's AER support was enabled, |
| 3901 | * invoke the kernel's disable AER helper routine. After that, update |
| 3902 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 3903 | * by the device; otherwise, if the device AER capability is already |
| 3904 | * disabled from supporting AER, then do nothing. |
| 3905 | * |
| 3906 | * Returns: |
| 3907 | * length of the buf on success if val is in range the intended mode |
| 3908 | * is supported. |
| 3909 | * -EINVAL if val out of range or intended mode is not supported. |
| 3910 | **/ |
| 3911 | static ssize_t |
| 3912 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 3913 | const char *buf, size_t count) |
| 3914 | { |
| 3915 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3916 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 3917 | struct lpfc_hba *phba = vport->phba; |
| 3918 | int val = 0, rc = -EINVAL; |
| 3919 | |
| 3920 | if (!isdigit(buf[0])) |
| 3921 | return -EINVAL; |
| 3922 | if (sscanf(buf, "%i", &val) != 1) |
| 3923 | return -EINVAL; |
| 3924 | |
| 3925 | switch (val) { |
| 3926 | case 0: |
| 3927 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 3928 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 3929 | if (!rc) { |
| 3930 | spin_lock_irq(&phba->hbalock); |
| 3931 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 3932 | spin_unlock_irq(&phba->hbalock); |
| 3933 | phba->cfg_aer_support = 0; |
| 3934 | rc = strlen(buf); |
| 3935 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3936 | rc = -EPERM; |
| 3937 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3938 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3939 | rc = strlen(buf); |
| 3940 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3941 | break; |
| 3942 | case 1: |
| 3943 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 3944 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 3945 | if (!rc) { |
| 3946 | spin_lock_irq(&phba->hbalock); |
| 3947 | phba->hba_flag |= HBA_AER_ENABLED; |
| 3948 | spin_unlock_irq(&phba->hbalock); |
| 3949 | phba->cfg_aer_support = 1; |
| 3950 | rc = strlen(buf); |
| 3951 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3952 | rc = -EPERM; |
| 3953 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3954 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3955 | rc = strlen(buf); |
| 3956 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3957 | break; |
| 3958 | default: |
| 3959 | rc = -EINVAL; |
| 3960 | break; |
| 3961 | } |
| 3962 | return rc; |
| 3963 | } |
| 3964 | |
| 3965 | static int lpfc_aer_support = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3966 | module_param(lpfc_aer_support, int, S_IRUGO); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3967 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); |
| 3968 | lpfc_param_show(aer_support) |
| 3969 | |
| 3970 | /** |
| 3971 | * lpfc_aer_support_init - Set the initial adapters aer support flag |
| 3972 | * @phba: lpfc_hba pointer. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3973 | * @val: enable aer or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3974 | * |
| 3975 | * Description: |
| 3976 | * If val is in a valid range [0,1], then set the adapter's initial |
| 3977 | * cfg_aer_support field. It will be up to the driver's probe_one |
| 3978 | * routine to determine whether the device's AER support can be set |
| 3979 | * or not. |
| 3980 | * |
| 3981 | * Notes: |
| 3982 | * If the value is not in range log a kernel error message, and |
| 3983 | * choose the default value of setting AER support and return. |
| 3984 | * |
| 3985 | * Returns: |
| 3986 | * zero if val saved. |
| 3987 | * -EINVAL val out of range |
| 3988 | **/ |
| 3989 | static int |
| 3990 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) |
| 3991 | { |
| 3992 | if (val == 0 || val == 1) { |
| 3993 | phba->cfg_aer_support = val; |
| 3994 | return 0; |
| 3995 | } |
| 3996 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3997 | "2712 lpfc_aer_support attribute value %d out " |
| 3998 | "of range, allowed values are 0|1, setting it " |
| 3999 | "to default value of 1\n", val); |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4000 | /* By default, try to enable AER on a device */ |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4001 | phba->cfg_aer_support = 1; |
| 4002 | return -EINVAL; |
| 4003 | } |
| 4004 | |
| 4005 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 4006 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 4007 | |
| 4008 | /** |
| 4009 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4010 | * @dev: class device that is converted into a Scsi_host. |
| 4011 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4012 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4013 | * @count: unused variable. |
| 4014 | * |
| 4015 | * Description: |
| 4016 | * If the @buf contains 1 and the device currently has the AER support |
| 4017 | * enabled, then invokes the kernel AER helper routine |
| 4018 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4019 | * error status register. |
| 4020 | * |
| 4021 | * Notes: |
| 4022 | * |
| 4023 | * Returns: |
| 4024 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4025 | * enabled with the AER support. |
| 4026 | **/ |
| 4027 | static ssize_t |
| 4028 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4029 | const char *buf, size_t count) |
| 4030 | { |
| 4031 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4032 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4033 | struct lpfc_hba *phba = vport->phba; |
| 4034 | int val, rc = -1; |
| 4035 | |
| 4036 | if (!isdigit(buf[0])) |
| 4037 | return -EINVAL; |
| 4038 | if (sscanf(buf, "%i", &val) != 1) |
| 4039 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4040 | if (val != 1) |
| 4041 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4042 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4043 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4044 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4045 | |
| 4046 | if (rc == 0) |
| 4047 | return strlen(buf); |
| 4048 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4049 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4053 | lpfc_aer_cleanup_state); |
| 4054 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4055 | /** |
| 4056 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4057 | * |
| 4058 | * @dev: class device that is converted into a Scsi_host. |
| 4059 | * @attr: device attribute, not used. |
| 4060 | * @buf: containing the string the number of vfs to be enabled. |
| 4061 | * @count: unused variable. |
| 4062 | * |
| 4063 | * Description: |
| 4064 | * When this api is called either through user sysfs, the driver shall |
| 4065 | * try to enable or disable SR-IOV virtual functions according to the |
| 4066 | * following: |
| 4067 | * |
| 4068 | * If zero virtual function has been enabled to the physical function, |
| 4069 | * the driver shall invoke the pci enable virtual function api trying |
| 4070 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4071 | * than the maximum supported, the maximum virtual function number will |
| 4072 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4073 | * be used for invoking the api. If the api call returned success, the |
| 4074 | * actual number of virtual functions enabled will be set to the driver |
| 4075 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4076 | * cfg_sriov_nr_virtfn remains zero. |
| 4077 | * |
| 4078 | * If none-zero virtual functions have already been enabled to the |
| 4079 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4080 | * -EINVAL will be returned and the driver does nothing; |
| 4081 | * |
| 4082 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4083 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4084 | * disabling virtual function api shall be invoded to disable all the |
| 4085 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4086 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4087 | * nothing. |
| 4088 | * |
| 4089 | * Returns: |
| 4090 | * length of the buf on success if val is in range the intended mode |
| 4091 | * is supported. |
| 4092 | * -EINVAL if val out of range or intended mode is not supported. |
| 4093 | **/ |
| 4094 | static ssize_t |
| 4095 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4096 | const char *buf, size_t count) |
| 4097 | { |
| 4098 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4099 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4100 | struct lpfc_hba *phba = vport->phba; |
| 4101 | struct pci_dev *pdev = phba->pcidev; |
| 4102 | int val = 0, rc = -EINVAL; |
| 4103 | |
| 4104 | /* Sanity check on user data */ |
| 4105 | if (!isdigit(buf[0])) |
| 4106 | return -EINVAL; |
| 4107 | if (sscanf(buf, "%i", &val) != 1) |
| 4108 | return -EINVAL; |
| 4109 | if (val < 0) |
| 4110 | return -EINVAL; |
| 4111 | |
| 4112 | /* Request disabling virtual functions */ |
| 4113 | if (val == 0) { |
| 4114 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4115 | pci_disable_sriov(pdev); |
| 4116 | phba->cfg_sriov_nr_virtfn = 0; |
| 4117 | } |
| 4118 | return strlen(buf); |
| 4119 | } |
| 4120 | |
| 4121 | /* Request enabling virtual functions */ |
| 4122 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4123 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4124 | "3018 There are %d virtual functions " |
| 4125 | "enabled on physical function.\n", |
| 4126 | phba->cfg_sriov_nr_virtfn); |
| 4127 | return -EEXIST; |
| 4128 | } |
| 4129 | |
| 4130 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4131 | phba->cfg_sriov_nr_virtfn = val; |
| 4132 | else { |
| 4133 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4134 | "3019 Enabling %d virtual functions is not " |
| 4135 | "allowed.\n", val); |
| 4136 | return -EINVAL; |
| 4137 | } |
| 4138 | |
| 4139 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4140 | if (rc) { |
| 4141 | phba->cfg_sriov_nr_virtfn = 0; |
| 4142 | rc = -EPERM; |
| 4143 | } else |
| 4144 | rc = strlen(buf); |
| 4145 | |
| 4146 | return rc; |
| 4147 | } |
| 4148 | |
| 4149 | static int lpfc_sriov_nr_virtfn = LPFC_DEF_VFN_PER_PFN; |
| 4150 | module_param(lpfc_sriov_nr_virtfn, int, S_IRUGO|S_IWUSR); |
| 4151 | MODULE_PARM_DESC(lpfc_sriov_nr_virtfn, "Enable PCIe device SR-IOV virtual fn"); |
| 4152 | lpfc_param_show(sriov_nr_virtfn) |
| 4153 | |
| 4154 | /** |
| 4155 | * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable |
| 4156 | * @phba: lpfc_hba pointer. |
| 4157 | * @val: link speed value. |
| 4158 | * |
| 4159 | * Description: |
| 4160 | * If val is in a valid range [0,255], then set the adapter's initial |
| 4161 | * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum |
| 4162 | * number shall be used instead. It will be up to the driver's probe_one |
| 4163 | * routine to determine whether the device's SR-IOV is supported or not. |
| 4164 | * |
| 4165 | * Returns: |
| 4166 | * zero if val saved. |
| 4167 | * -EINVAL val out of range |
| 4168 | **/ |
| 4169 | static int |
| 4170 | lpfc_sriov_nr_virtfn_init(struct lpfc_hba *phba, int val) |
| 4171 | { |
| 4172 | if (val >= 0 && val <= LPFC_MAX_VFN_PER_PFN) { |
| 4173 | phba->cfg_sriov_nr_virtfn = val; |
| 4174 | return 0; |
| 4175 | } |
| 4176 | |
| 4177 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4178 | "3017 Enabling %d virtual functions is not " |
| 4179 | "allowed.\n", val); |
| 4180 | return -EINVAL; |
| 4181 | } |
| 4182 | static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, |
| 4183 | lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); |
| 4184 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4185 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4186 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4187 | * |
| 4188 | * @dev: class device that is converted into a Scsi_host. |
| 4189 | * @attr: device attribute, not used. |
| 4190 | * @buf: containing the string the number of vfs to be enabled. |
| 4191 | * @count: unused variable. |
| 4192 | * |
| 4193 | * Description: |
| 4194 | * |
| 4195 | * Returns: |
| 4196 | * length of the buf on success if val is in range the intended mode |
| 4197 | * is supported. |
| 4198 | * -EINVAL if val out of range or intended mode is not supported. |
| 4199 | **/ |
| 4200 | static ssize_t |
| 4201 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4202 | struct device_attribute *attr, |
| 4203 | const char *buf, size_t count) |
| 4204 | { |
| 4205 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4206 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4207 | struct lpfc_hba *phba = vport->phba; |
| 4208 | int val = 0, rc = -EINVAL; |
| 4209 | |
| 4210 | /* Sanity check on user data */ |
| 4211 | if (!isdigit(buf[0])) |
| 4212 | return -EINVAL; |
| 4213 | if (sscanf(buf, "%i", &val) != 1) |
| 4214 | return -EINVAL; |
| 4215 | if (val != 1) |
| 4216 | return -EINVAL; |
| 4217 | |
| 4218 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4219 | if (rc) |
| 4220 | rc = -EPERM; |
| 4221 | else |
| 4222 | rc = strlen(buf); |
| 4223 | return rc; |
| 4224 | } |
| 4225 | |
| 4226 | static int lpfc_req_fw_upgrade; |
| 4227 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4228 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4229 | lpfc_param_show(request_firmware_upgrade) |
| 4230 | |
| 4231 | /** |
| 4232 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4233 | * @phba: lpfc_hba pointer. |
| 4234 | * @val: 0 or 1. |
| 4235 | * |
| 4236 | * Description: |
| 4237 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4238 | * |
| 4239 | * Returns: |
| 4240 | * zero if val saved. |
| 4241 | * -EINVAL val out of range |
| 4242 | **/ |
| 4243 | static int |
| 4244 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4245 | { |
| 4246 | if (val >= 0 && val <= 1) { |
| 4247 | phba->cfg_request_firmware_upgrade = val; |
| 4248 | return 0; |
| 4249 | } |
| 4250 | return -EINVAL; |
| 4251 | } |
| 4252 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4253 | lpfc_request_firmware_upgrade_show, |
| 4254 | lpfc_request_firmware_upgrade_store); |
| 4255 | |
| 4256 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4257 | * lpfc_fcp_imax_store |
| 4258 | * |
| 4259 | * @dev: class device that is converted into a Scsi_host. |
| 4260 | * @attr: device attribute, not used. |
| 4261 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4262 | * @count: unused variable. |
| 4263 | * |
| 4264 | * Description: |
| 4265 | * If val is in a valid range [636,651042], then set the adapter's |
| 4266 | * maximum number of fast-path FCP interrupts per second. |
| 4267 | * |
| 4268 | * Returns: |
| 4269 | * length of the buf on success if val is in range the intended mode |
| 4270 | * is supported. |
| 4271 | * -EINVAL if val out of range or intended mode is not supported. |
| 4272 | **/ |
| 4273 | static ssize_t |
| 4274 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4275 | const char *buf, size_t count) |
| 4276 | { |
| 4277 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4278 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4279 | struct lpfc_hba *phba = vport->phba; |
| 4280 | int val = 0, i; |
| 4281 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4282 | /* fcp_imax is only valid for SLI4 */ |
| 4283 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4284 | return -EINVAL; |
| 4285 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4286 | /* Sanity check on user data */ |
| 4287 | if (!isdigit(buf[0])) |
| 4288 | return -EINVAL; |
| 4289 | if (sscanf(buf, "%i", &val) != 1) |
| 4290 | return -EINVAL; |
| 4291 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4292 | /* |
| 4293 | * Value range for the HBA is [5000,5000000] |
| 4294 | * The value for each EQ depends on how many EQs are configured. |
| 4295 | */ |
| 4296 | if (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4297 | return -EINVAL; |
| 4298 | |
| 4299 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4300 | 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] | 4301 | lpfc_modify_fcp_eq_delay(phba, i); |
| 4302 | |
| 4303 | return strlen(buf); |
| 4304 | } |
| 4305 | |
| 4306 | /* |
| 4307 | # 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] | 4308 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4309 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4310 | # 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] | 4311 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4312 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4313 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4314 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4315 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4316 | lpfc_param_show(fcp_imax) |
| 4317 | |
| 4318 | /** |
| 4319 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4320 | * @phba: lpfc_hba pointer. |
| 4321 | * @val: link speed value. |
| 4322 | * |
| 4323 | * Description: |
| 4324 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4325 | * maximum number of fast-path FCP interrupts per second. |
| 4326 | * |
| 4327 | * Returns: |
| 4328 | * zero if val saved. |
| 4329 | * -EINVAL val out of range |
| 4330 | **/ |
| 4331 | static int |
| 4332 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4333 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4334 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4335 | phba->cfg_fcp_imax = 0; |
| 4336 | return 0; |
| 4337 | } |
| 4338 | |
| 4339 | if (val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4340 | phba->cfg_fcp_imax = val; |
| 4341 | return 0; |
| 4342 | } |
| 4343 | |
| 4344 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4345 | "3016 fcp_imax: %d out of range, using default\n", val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4346 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4347 | |
| 4348 | return 0; |
| 4349 | } |
| 4350 | |
| 4351 | static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, |
| 4352 | lpfc_fcp_imax_show, lpfc_fcp_imax_store); |
| 4353 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4354 | /** |
| 4355 | * lpfc_state_show - Display current driver CPU affinity |
| 4356 | * @dev: class converted to a Scsi_host structure. |
| 4357 | * @attr: device attribute, not used. |
| 4358 | * @buf: on return contains text describing the state of the link. |
| 4359 | * |
| 4360 | * Returns: size of formatted string. |
| 4361 | **/ |
| 4362 | static ssize_t |
| 4363 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4364 | char *buf) |
| 4365 | { |
| 4366 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4367 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4368 | struct lpfc_hba *phba = vport->phba; |
| 4369 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4370 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4371 | |
| 4372 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4373 | (phba->intr_type != MSIX)) |
| 4374 | return len; |
| 4375 | |
| 4376 | switch (phba->cfg_fcp_cpu_map) { |
| 4377 | case 0: |
| 4378 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4379 | "fcp_cpu_map: No mapping (%d)\n", |
| 4380 | phba->cfg_fcp_cpu_map); |
| 4381 | return len; |
| 4382 | case 1: |
| 4383 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4384 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4385 | "%d online CPUs\n", |
| 4386 | phba->cfg_fcp_cpu_map, |
| 4387 | phba->sli4_hba.num_online_cpu); |
| 4388 | break; |
| 4389 | case 2: |
| 4390 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4391 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4392 | "%d online CPUs\n", |
| 4393 | phba->cfg_fcp_cpu_map, |
| 4394 | phba->sli4_hba.num_online_cpu); |
| 4395 | break; |
| 4396 | } |
| 4397 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4398 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4399 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4400 | |
| 4401 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4402 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4403 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4404 | "CPU %02d io_chan %02d " |
| 4405 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4406 | phba->sli4_hba.curr_disp_cpu, |
| 4407 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4408 | cpup->core_id); |
| 4409 | else |
| 4410 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4411 | "CPU %02d io_chan %02d " |
| 4412 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4413 | phba->sli4_hba.curr_disp_cpu, |
| 4414 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4415 | cpup->core_id, cpup->irq); |
| 4416 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4417 | phba->sli4_hba.curr_disp_cpu++; |
| 4418 | |
| 4419 | /* display max number of CPUs keeping some margin */ |
| 4420 | if (phba->sli4_hba.curr_disp_cpu < |
| 4421 | phba->sli4_hba.num_present_cpu && |
| 4422 | (len >= (PAGE_SIZE - 64))) { |
| 4423 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4424 | break; |
| 4425 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4426 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4427 | |
| 4428 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4429 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4430 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4431 | return len; |
| 4432 | } |
| 4433 | |
| 4434 | /** |
| 4435 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4436 | * @dev: class device that is converted into a Scsi_host. |
| 4437 | * @attr: device attribute, not used. |
| 4438 | * @buf: one or more lpfc_polling_flags values. |
| 4439 | * @count: not used. |
| 4440 | * |
| 4441 | * Returns: |
| 4442 | * -EINVAL - Not implemented yet. |
| 4443 | **/ |
| 4444 | static ssize_t |
| 4445 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4446 | const char *buf, size_t count) |
| 4447 | { |
| 4448 | int status = -EINVAL; |
| 4449 | return status; |
| 4450 | } |
| 4451 | |
| 4452 | /* |
| 4453 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4454 | # for the HBA. |
| 4455 | # |
| 4456 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4457 | # 0 - Do not affinitze IRQ vectors |
| 4458 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4459 | # (start with CPU0 for each HBA) |
| 4460 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4461 | # (round robin thru all CPUs across all HBAs) |
| 4462 | */ |
| 4463 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4464 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4465 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4466 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4467 | |
| 4468 | /** |
| 4469 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4470 | * @phba: lpfc_hba pointer. |
| 4471 | * @val: link speed value. |
| 4472 | * |
| 4473 | * Description: |
| 4474 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4475 | * MSIX vectors. |
| 4476 | * |
| 4477 | * Returns: |
| 4478 | * zero if val saved. |
| 4479 | * -EINVAL val out of range |
| 4480 | **/ |
| 4481 | static int |
| 4482 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4483 | { |
| 4484 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4485 | phba->cfg_fcp_cpu_map = 0; |
| 4486 | return 0; |
| 4487 | } |
| 4488 | |
| 4489 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4490 | phba->cfg_fcp_cpu_map = val; |
| 4491 | return 0; |
| 4492 | } |
| 4493 | |
| 4494 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4495 | "3326 fcp_cpu_map: %d out of range, using default\n", |
| 4496 | val); |
| 4497 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4498 | |
| 4499 | return 0; |
| 4500 | } |
| 4501 | |
| 4502 | static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, |
| 4503 | lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store); |
| 4504 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4505 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4506 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4507 | # Value range is [2,3]. Default value is 3. |
| 4508 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4509 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4510 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4511 | |
| 4512 | /* |
| 4513 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4514 | # is [0,1]. Default value is 0. |
| 4515 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4516 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4517 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4518 | |
| 4519 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4520 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4521 | # that support first burst. |
| 4522 | # Value range is [0,65536]. Default value is 0. |
| 4523 | */ |
| 4524 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4525 | "First burst size for Targets that support first burst"); |
| 4526 | |
| 4527 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4528 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4529 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4530 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4531 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4532 | # to limit the I/O completion time to the parameter value. |
| 4533 | # The value is set in milliseconds. |
| 4534 | */ |
| 4535 | static int lpfc_max_scsicmpl_time; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4536 | module_param(lpfc_max_scsicmpl_time, int, S_IRUGO); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4537 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, |
| 4538 | "Use command completion time to control queue depth"); |
| 4539 | lpfc_vport_param_show(max_scsicmpl_time); |
| 4540 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); |
| 4541 | static int |
| 4542 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4543 | { |
| 4544 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4545 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4546 | |
| 4547 | if (val == vport->cfg_max_scsicmpl_time) |
| 4548 | return 0; |
| 4549 | if ((val < 0) || (val > 60000)) |
| 4550 | return -EINVAL; |
| 4551 | vport->cfg_max_scsicmpl_time = val; |
| 4552 | |
| 4553 | spin_lock_irq(shost->host_lock); |
| 4554 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4555 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4556 | continue; |
| 4557 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4558 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4559 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4560 | } |
| 4561 | spin_unlock_irq(shost->host_lock); |
| 4562 | return 0; |
| 4563 | } |
| 4564 | lpfc_vport_param_store(max_scsicmpl_time); |
| 4565 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 4566 | lpfc_max_scsicmpl_time_show, |
| 4567 | lpfc_max_scsicmpl_time_store); |
| 4568 | |
| 4569 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4570 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4571 | # range is [0,1]. Default value is 0. |
| 4572 | */ |
| 4573 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4574 | |
| 4575 | /* |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4576 | # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4577 | # range is [0,1]. Default value is 0. |
| 4578 | # For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4579 | # For [1], FCP commands are issued to a Work Queue associated with the |
| 4580 | # current CPU. |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4581 | # It would be set to 1 by the driver if it's able to set up cpu affinity |
| 4582 | # for FCP I/Os through Work Queue associated with the current CPU. Otherwise, |
| 4583 | # roundrobin scheduling of FCP I/Os through WQs will be used. |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4584 | */ |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4585 | 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] | 4586 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
| 4587 | |
| 4588 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4589 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4590 | # range is [0,1]. Default value is 0. |
| 4591 | # For [0], bus reset issues target reset to ALL devices |
| 4592 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4593 | */ |
| 4594 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4595 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4596 | |
| 4597 | |
| 4598 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4599 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4600 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4601 | # 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] | 4602 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4603 | # cr_delay is set to 0. |
| 4604 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4605 | 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] | 4606 | "interrupt response is generated"); |
| 4607 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4608 | 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] | 4609 | "interrupt response is generated"); |
| 4610 | |
| 4611 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4612 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4613 | # cmd/rsp IOCB entries across. |
| 4614 | # Value range is [1,2]. Default value is 1. |
| 4615 | */ |
| 4616 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4617 | "SLI rings to spread IOCB entries across"); |
| 4618 | |
| 4619 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4620 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4621 | # identifies what rctl value to configure the additional ring for. |
| 4622 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4623 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4624 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4625 | 255, "Identifies RCTL for additional ring configuration"); |
| 4626 | |
| 4627 | /* |
| 4628 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4629 | # identifies what type value to configure the additional ring for. |
| 4630 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4631 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4632 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4633 | 255, "Identifies TYPE for additional ring configuration"); |
| 4634 | |
| 4635 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4636 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 4637 | # 0 = SmartSAN functionality disabled (default) |
| 4638 | # 1 = SmartSAN functionality enabled |
| 4639 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 4640 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4641 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4642 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 4643 | |
| 4644 | /* |
| 4645 | # lpfc_fdmi_on: Controls FDMI support. |
| 4646 | # 0 No FDMI support (default) |
| 4647 | # 1 Traditional FDMI support |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4648 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 4649 | # however, if that fails, it will fallback to FDMI-1. |
| 4650 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 4651 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 4652 | # lpfc_fdmi_on. |
| 4653 | # Value range [0,1]. Default value is 0. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4654 | */ |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4655 | LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4656 | |
| 4657 | /* |
| 4658 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4659 | # discovery). Value range is [1,64]. Default value = 32. |
| 4660 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4661 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4662 | "during discovery"); |
| 4663 | |
| 4664 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4665 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4666 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4667 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4668 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4669 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4670 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4671 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4672 | # on a target can take minutes of wall clock time. Additionally, |
| 4673 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4674 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4675 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4676 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4677 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4678 | # devices present, when in fact, there is only 1. |
| 4679 | # A customer that is aware of their target behaviors, and the results as |
| 4680 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4681 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4682 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4683 | # Value range is [0,65535]. Default value is 255. |
| 4684 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4685 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 4686 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4687 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4688 | /* |
| 4689 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4690 | # Value range is [1,255], default value is 10. |
| 4691 | */ |
| 4692 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4693 | "Milliseconds driver will wait between polling FCP ring"); |
| 4694 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4695 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4696 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4697 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4698 | */ |
| 4699 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4700 | "Maximum time to wait for task management commands to complete"); |
| 4701 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4702 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4703 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4704 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4705 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4706 | # 2 = MSI-X enabled (default) |
| 4707 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4708 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4709 | 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] | 4710 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4711 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4712 | /* |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4713 | # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels |
| 4714 | # |
| 4715 | # Value range is [1,7]. Default value is 4. |
| 4716 | */ |
| 4717 | LPFC_ATTR_R(fcp_io_channel, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN, |
| 4718 | LPFC_FCP_IO_CHAN_MAX, |
| 4719 | "Set the number of FCP I/O channels"); |
| 4720 | |
| 4721 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4722 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 4723 | # 0 = HBA resets disabled |
| 4724 | # 1 = HBA resets enabled (default) |
| 4725 | # Value range is [0,1]. Default value is 1. |
| 4726 | */ |
| 4727 | 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] | 4728 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4729 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4730 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4731 | # 0 = HBA Heartbeat disabled |
| 4732 | # 1 = HBA Heartbeat enabled (default) |
| 4733 | # Value range is [0,1]. Default value is 1. |
| 4734 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4735 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4736 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4737 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4738 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 4739 | # 0x0 Express Lane Feature disabled |
| 4740 | # 0x1 Express Lane Feature enabled |
| 4741 | # Value range is [0,1]. Default value is 0. |
| 4742 | */ |
| 4743 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 4744 | |
| 4745 | /* |
| 4746 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 4747 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 4748 | # Value range is [0x0,0x7f]. Default value is 0 |
| 4749 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 4750 | 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] | 4751 | |
| 4752 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4753 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 4754 | # 0 = BlockGuard disabled (default) |
| 4755 | # 1 = BlockGuard enabled |
| 4756 | # Value range is [0,1]. Default value is 0. |
| 4757 | */ |
| 4758 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 4759 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4760 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4761 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 4762 | # 0 = disabled (default) |
| 4763 | # 1 = enabled |
| 4764 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 4765 | # |
| 4766 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4767 | */ |
| 4768 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 4769 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4770 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4771 | # lpfc_prot_mask: i |
| 4772 | # - Bit mask of host protection capabilities used to register with the |
| 4773 | # SCSI mid-layer |
| 4774 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 4775 | # - Allows you to ultimately specify which profiles to use |
| 4776 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 4777 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 4778 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 4779 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 4780 | # HBA supports DIX Type 0: Host to HBA protection only |
| 4781 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 4782 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4783 | # |
| 4784 | */ |
James Smart | 7c56b9f | 2011-07-22 18:36:25 -0400 | [diff] [blame] | 4785 | unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION | |
| 4786 | SHOST_DIX_TYPE0_PROTECTION | |
| 4787 | SHOST_DIX_TYPE1_PROTECTION; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4788 | |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4789 | module_param(lpfc_prot_mask, uint, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4790 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); |
| 4791 | |
| 4792 | /* |
| 4793 | # lpfc_prot_guard: i |
| 4794 | # - 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] | 4795 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4796 | # - Allows you to ultimately specify which profiles to use |
| 4797 | # - Default will result in registering capabilities for all guard types |
| 4798 | # |
| 4799 | */ |
| 4800 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4801 | module_param(lpfc_prot_guard, byte, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4802 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); |
| 4803 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4804 | /* |
| 4805 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 4806 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 4807 | * This parameter can have value 0 or 1. |
| 4808 | * When this parameter is set to 0, no delay is added to the initial |
| 4809 | * discovery. |
| 4810 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 4811 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 4812 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4813 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 4814 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 4815 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4816 | * Default value is 0. |
| 4817 | */ |
| 4818 | int lpfc_delay_discovery; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4819 | module_param(lpfc_delay_discovery, int, S_IRUGO); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4820 | MODULE_PARM_DESC(lpfc_delay_discovery, |
| 4821 | "Delay NPort discovery when Clean Address bit is cleared. " |
| 4822 | "Allowed values: 0,1."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4823 | |
| 4824 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4825 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4826 | * 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] | 4827 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 4828 | * 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] | 4829 | * Because of the additional overhead involved in setting up T10-DIF, |
| 4830 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 4831 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4832 | */ |
| 4833 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 4834 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 4835 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4836 | /* |
| 4837 | * This parameter will be depricated, the driver cannot limit the |
| 4838 | * protection data s/g list. |
| 4839 | */ |
| 4840 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, |
| 4841 | LPFC_DEFAULT_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT, |
| 4842 | "Max Protection Scatter Gather Segment Count"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4843 | |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 4844 | /* |
| 4845 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 4846 | * 0 = MDS Diagnostics disabled (default) |
| 4847 | * 1 = MDS Diagnostics enabled |
| 4848 | * Value range is [0,1]. Default value is 0. |
| 4849 | */ |
| 4850 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 4851 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4852 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4853 | &dev_attr_bg_info, |
| 4854 | &dev_attr_bg_guard_err, |
| 4855 | &dev_attr_bg_apptag_err, |
| 4856 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4857 | &dev_attr_info, |
| 4858 | &dev_attr_serialnum, |
| 4859 | &dev_attr_modeldesc, |
| 4860 | &dev_attr_modelname, |
| 4861 | &dev_attr_programtype, |
| 4862 | &dev_attr_portnum, |
| 4863 | &dev_attr_fwrev, |
| 4864 | &dev_attr_hdw, |
| 4865 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4866 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4867 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 4868 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4869 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 4870 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4871 | &dev_attr_lpfc_temp_sensor, |
| 4872 | &dev_attr_lpfc_log_verbose, |
| 4873 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4874 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4875 | &dev_attr_lpfc_hba_queue_depth, |
| 4876 | &dev_attr_lpfc_peer_port_login, |
| 4877 | &dev_attr_lpfc_nodev_tmo, |
| 4878 | &dev_attr_lpfc_devloss_tmo, |
| 4879 | &dev_attr_lpfc_fcp_class, |
| 4880 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4881 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4882 | &dev_attr_lpfc_ack0, |
| 4883 | &dev_attr_lpfc_topology, |
| 4884 | &dev_attr_lpfc_scan_down, |
| 4885 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4886 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4887 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4888 | &dev_attr_lpfc_cr_delay, |
| 4889 | &dev_attr_lpfc_cr_count, |
| 4890 | &dev_attr_lpfc_multi_ring_support, |
| 4891 | &dev_attr_lpfc_multi_ring_rctl, |
| 4892 | &dev_attr_lpfc_multi_ring_type, |
| 4893 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4894 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4895 | &dev_attr_lpfc_max_luns, |
| 4896 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 4897 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4898 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4899 | &dev_attr_nport_evt_cnt, |
| 4900 | &dev_attr_board_mode, |
| 4901 | &dev_attr_max_vpi, |
| 4902 | &dev_attr_used_vpi, |
| 4903 | &dev_attr_max_rpi, |
| 4904 | &dev_attr_used_rpi, |
| 4905 | &dev_attr_max_xri, |
| 4906 | &dev_attr_used_xri, |
| 4907 | &dev_attr_npiv_info, |
| 4908 | &dev_attr_issue_reset, |
| 4909 | &dev_attr_lpfc_poll, |
| 4910 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4911 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4912 | &dev_attr_lpfc_use_msi, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 4913 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4914 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4915 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4916 | &dev_attr_lpfc_enable_bg, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4917 | &dev_attr_lpfc_soft_wwnn, |
| 4918 | &dev_attr_lpfc_soft_wwpn, |
| 4919 | &dev_attr_lpfc_soft_wwn_enable, |
| 4920 | &dev_attr_lpfc_enable_hba_reset, |
| 4921 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4922 | &dev_attr_lpfc_EnableXLane, |
| 4923 | &dev_attr_lpfc_XLanePriority, |
| 4924 | &dev_attr_lpfc_xlane_lun, |
| 4925 | &dev_attr_lpfc_xlane_tgt, |
| 4926 | &dev_attr_lpfc_xlane_vpt, |
| 4927 | &dev_attr_lpfc_xlane_lun_state, |
| 4928 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 4929 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4930 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4931 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4932 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4933 | &dev_attr_lpfc_prot_sg_seg_cnt, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4934 | &dev_attr_lpfc_aer_support, |
| 4935 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4936 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4937 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 4938 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 4939 | &dev_attr_lpfc_iocb_cnt, |
| 4940 | &dev_attr_iocb_hw, |
| 4941 | &dev_attr_txq_hw, |
| 4942 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4943 | &dev_attr_lpfc_fips_level, |
| 4944 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4945 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4946 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 4947 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4948 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 4949 | &dev_attr_lpfc_enable_mds_diags, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4950 | NULL, |
| 4951 | }; |
| 4952 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4953 | struct device_attribute *lpfc_vport_attrs[] = { |
| 4954 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4955 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4956 | &dev_attr_num_discovered_ports, |
| 4957 | &dev_attr_lpfc_drvr_version, |
| 4958 | &dev_attr_lpfc_log_verbose, |
| 4959 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4960 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4961 | &dev_attr_lpfc_nodev_tmo, |
| 4962 | &dev_attr_lpfc_devloss_tmo, |
| 4963 | &dev_attr_lpfc_hba_queue_depth, |
| 4964 | &dev_attr_lpfc_peer_port_login, |
| 4965 | &dev_attr_lpfc_restrict_login, |
| 4966 | &dev_attr_lpfc_fcp_class, |
| 4967 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4968 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4969 | &dev_attr_lpfc_max_luns, |
| 4970 | &dev_attr_nport_evt_cnt, |
| 4971 | &dev_attr_npiv_info, |
| 4972 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4973 | &dev_attr_lpfc_max_scsicmpl_time, |
| 4974 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4975 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4976 | &dev_attr_lpfc_fips_level, |
| 4977 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4978 | NULL, |
| 4979 | }; |
| 4980 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4981 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4982 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4983 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4984 | * @kobj: kernel kobject that contains the kernel class device. |
| 4985 | * @bin_attr: kernel attributes passed to us. |
| 4986 | * @buf: contains the data to be written to the adapter IOREG space. |
| 4987 | * @off: offset into buffer to beginning of data. |
| 4988 | * @count: bytes to transfer. |
| 4989 | * |
| 4990 | * Description: |
| 4991 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4992 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 4993 | * |
| 4994 | * Returns: |
| 4995 | * -ERANGE off and count combo out of range |
| 4996 | * -EINVAL off, count or buff address invalid |
| 4997 | * -EPERM adapter is offline |
| 4998 | * value of count, buf contents written |
| 4999 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5000 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5001 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 5002 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5003 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5004 | { |
| 5005 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5006 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5007 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5008 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5009 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5010 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5011 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5012 | return -EPERM; |
| 5013 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5014 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5015 | return -ERANGE; |
| 5016 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5017 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 5018 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5019 | |
| 5020 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5021 | return -EINVAL; |
| 5022 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5023 | /* This is to protect HBA registers from accidental writes. */ |
| 5024 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 5025 | return -EINVAL; |
| 5026 | |
| 5027 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5028 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5029 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5030 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5031 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 5032 | buf_off += sizeof(uint32_t)) |
| 5033 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5034 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 5035 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5036 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5037 | |
| 5038 | return count; |
| 5039 | } |
| 5040 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5041 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5042 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5043 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5044 | * @kobj: kernel kobject that contains the kernel class device. |
| 5045 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5046 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5047 | * @off: offset into buffer to beginning of data. |
| 5048 | * @count: bytes to transfer. |
| 5049 | * |
| 5050 | * Description: |
| 5051 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5052 | * Uses the adapter io control registers to read data into buf. |
| 5053 | * |
| 5054 | * Returns: |
| 5055 | * -ERANGE off and count combo out of range |
| 5056 | * -EINVAL off, count or buff address invalid |
| 5057 | * value of count, buf contents read |
| 5058 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5059 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5060 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 5061 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5062 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5063 | { |
| 5064 | size_t buf_off; |
| 5065 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5066 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5067 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5068 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5069 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5070 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5071 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5072 | return -EPERM; |
| 5073 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5074 | if (off > FF_REG_AREA_SIZE) |
| 5075 | return -ERANGE; |
| 5076 | |
| 5077 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5078 | count = FF_REG_AREA_SIZE - off; |
| 5079 | |
| 5080 | if (count == 0) return 0; |
| 5081 | |
| 5082 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5083 | return -EINVAL; |
| 5084 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5085 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5086 | |
| 5087 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 5088 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5089 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5090 | } |
| 5091 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5092 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5093 | |
| 5094 | return count; |
| 5095 | } |
| 5096 | |
| 5097 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5098 | .attr = { |
| 5099 | .name = "ctlreg", |
| 5100 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5101 | }, |
| 5102 | .size = 256, |
| 5103 | .read = sysfs_ctlreg_read, |
| 5104 | .write = sysfs_ctlreg_write, |
| 5105 | }; |
| 5106 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5107 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5108 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5109 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5110 | * @kobj: kernel kobject that contains the kernel class device. |
| 5111 | * @bin_attr: kernel attributes passed to us. |
| 5112 | * @buf: contains the data to be written to sysfs mbox. |
| 5113 | * @off: offset into buffer to beginning of data. |
| 5114 | * @count: bytes to transfer. |
| 5115 | * |
| 5116 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5117 | * Deprecated function. All mailbox access from user space is performed via the |
| 5118 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5119 | * |
| 5120 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5121 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5122 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5123 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5124 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5125 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5126 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5127 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5128 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5129 | } |
| 5130 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5131 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5132 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5133 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5134 | * @kobj: kernel kobject that contains the kernel class device. |
| 5135 | * @bin_attr: kernel attributes passed to us. |
| 5136 | * @buf: contains the data to be read from sysfs mbox. |
| 5137 | * @off: offset into buffer to beginning of data. |
| 5138 | * @count: bytes to transfer. |
| 5139 | * |
| 5140 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5141 | * Deprecated function. All mailbox access from user space is performed via the |
| 5142 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5143 | * |
| 5144 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5145 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5146 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5147 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5148 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5149 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5150 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5151 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5152 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5153 | } |
| 5154 | |
| 5155 | static struct bin_attribute sysfs_mbox_attr = { |
| 5156 | .attr = { |
| 5157 | .name = "mbox", |
| 5158 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5159 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5160 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5161 | .read = sysfs_mbox_read, |
| 5162 | .write = sysfs_mbox_write, |
| 5163 | }; |
| 5164 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5165 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5166 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5167 | * @vport: address of lpfc vport structure. |
| 5168 | * |
| 5169 | * Return codes: |
| 5170 | * zero on success |
| 5171 | * error return code from sysfs_create_bin_file() |
| 5172 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5173 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5174 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5175 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5176 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5177 | int error; |
| 5178 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5179 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5180 | &sysfs_drvr_stat_data_attr); |
| 5181 | |
| 5182 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5183 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5184 | goto out; |
| 5185 | |
| 5186 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5187 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5188 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5189 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5190 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5191 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5192 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5193 | if (error) |
| 5194 | goto out_remove_ctlreg_attr; |
| 5195 | |
| 5196 | return 0; |
| 5197 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5198 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5199 | out_remove_stat_attr: |
| 5200 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5201 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5202 | out: |
| 5203 | return error; |
| 5204 | } |
| 5205 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5206 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5207 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5208 | * @vport: address of lpfc vport structure. |
| 5209 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5210 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5211 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5212 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5213 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5214 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5215 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5216 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5217 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5218 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5219 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5220 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5221 | } |
| 5222 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5223 | /* |
| 5224 | * Dynamic FC Host Attributes Support |
| 5225 | */ |
| 5226 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5227 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5228 | * 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] | 5229 | * @shost: kernel scsi host pointer. |
| 5230 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5231 | static void |
| 5232 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5233 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5234 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5235 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5236 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5237 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5238 | } |
| 5239 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5240 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5241 | * 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] | 5242 | * @shost: kernel scsi host pointer. |
| 5243 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5244 | static void |
| 5245 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5246 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5247 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5248 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5249 | |
| 5250 | spin_lock_irq(shost->host_lock); |
| 5251 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5252 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5253 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5254 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5255 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5256 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5257 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5258 | else |
| 5259 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5260 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5261 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5262 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5263 | else |
| 5264 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5265 | } |
| 5266 | } else |
| 5267 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5268 | |
| 5269 | spin_unlock_irq(shost->host_lock); |
| 5270 | } |
| 5271 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5272 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5273 | * 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] | 5274 | * @shost: kernel scsi host pointer. |
| 5275 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5276 | static void |
| 5277 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5278 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5279 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5280 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5281 | |
| 5282 | spin_lock_irq(shost->host_lock); |
| 5283 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5284 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5285 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5286 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5287 | switch (phba->link_state) { |
| 5288 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5289 | case LPFC_LINK_DOWN: |
| 5290 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5291 | break; |
| 5292 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5293 | case LPFC_CLEAR_LA: |
| 5294 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5295 | /* Links up, reports port state accordingly */ |
| 5296 | if (vport->port_state < LPFC_VPORT_READY) |
| 5297 | fc_host_port_state(shost) = |
| 5298 | FC_PORTSTATE_BYPASSED; |
| 5299 | else |
| 5300 | fc_host_port_state(shost) = |
| 5301 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5302 | break; |
| 5303 | case LPFC_HBA_ERROR: |
| 5304 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5305 | break; |
| 5306 | default: |
| 5307 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5308 | break; |
| 5309 | } |
| 5310 | } |
| 5311 | |
| 5312 | spin_unlock_irq(shost->host_lock); |
| 5313 | } |
| 5314 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5315 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5316 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5317 | * @shost: kernel scsi host pointer. |
| 5318 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5319 | static void |
| 5320 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5321 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5322 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5323 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5324 | |
| 5325 | spin_lock_irq(shost->host_lock); |
| 5326 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 5327 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5328 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5329 | case LPFC_LINK_SPEED_1GHZ: |
| 5330 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5331 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5332 | case LPFC_LINK_SPEED_2GHZ: |
| 5333 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5334 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5335 | case LPFC_LINK_SPEED_4GHZ: |
| 5336 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5337 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5338 | case LPFC_LINK_SPEED_8GHZ: |
| 5339 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5340 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5341 | case LPFC_LINK_SPEED_10GHZ: |
| 5342 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5343 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5344 | case LPFC_LINK_SPEED_16GHZ: |
| 5345 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5346 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 5347 | case LPFC_LINK_SPEED_32GHZ: |
| 5348 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 5349 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5350 | default: |
| 5351 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5352 | break; |
| 5353 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5354 | } else |
| 5355 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5356 | |
| 5357 | spin_unlock_irq(shost->host_lock); |
| 5358 | } |
| 5359 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5360 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5361 | * 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] | 5362 | * @shost: kernel scsi host pointer. |
| 5363 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5364 | static void |
| 5365 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5366 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5367 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5368 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5369 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5370 | |
| 5371 | spin_lock_irq(shost->host_lock); |
| 5372 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5373 | if ((vport->port_state > LPFC_FLOGI) && |
| 5374 | ((vport->fc_flag & FC_FABRIC) || |
| 5375 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5376 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5377 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5378 | else |
| 5379 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5380 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5381 | |
| 5382 | spin_unlock_irq(shost->host_lock); |
| 5383 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5384 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5385 | } |
| 5386 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5387 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5388 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5389 | * @shost: kernel scsi host pointer. |
| 5390 | * |
| 5391 | * Notes: |
| 5392 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5393 | * management not allowed, memory allocation error, or mbox error. |
| 5394 | * |
| 5395 | * Returns: |
| 5396 | * NULL for error |
| 5397 | * address of the adapter host statistics |
| 5398 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5399 | static struct fc_host_statistics * |
| 5400 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5401 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5402 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5403 | struct lpfc_hba *phba = vport->phba; |
| 5404 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5405 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5406 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5407 | LPFC_MBOXQ_t *pmboxq; |
| 5408 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5409 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5410 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5411 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5412 | /* |
| 5413 | * prevent udev from issuing mailbox commands until the port is |
| 5414 | * configured. |
| 5415 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5416 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5417 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5418 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5419 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5420 | |
| 5421 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5422 | return NULL; |
| 5423 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5424 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5425 | if (!pmboxq) |
| 5426 | return NULL; |
| 5427 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5428 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5429 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5430 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5431 | pmb->mbxOwner = OWN_HOST; |
| 5432 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5433 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5434 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5435 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5436 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5437 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5438 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5439 | |
| 5440 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5441 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5442 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5443 | return NULL; |
| 5444 | } |
| 5445 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5446 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5447 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5448 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5449 | /* |
| 5450 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5451 | * converted to words |
| 5452 | */ |
| 5453 | hs->tx_words = (uint64_t) |
| 5454 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5455 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5456 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5457 | hs->rx_words = (uint64_t) |
| 5458 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5459 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5460 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5461 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5462 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5463 | pmb->mbxOwner = OWN_HOST; |
| 5464 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5465 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5466 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5467 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5468 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5469 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5470 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5471 | |
| 5472 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5473 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5474 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5475 | return NULL; |
| 5476 | } |
| 5477 | |
| 5478 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5479 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5480 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5481 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5482 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5483 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5484 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5485 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5486 | hs->link_failure_count -= lso->link_failure_count; |
| 5487 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5488 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5489 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5490 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5491 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5492 | hs->error_frames -= lso->error_frames; |
| 5493 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5494 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5495 | hs->lip_count = -1; |
| 5496 | hs->nos_count = (phba->link_events >> 1); |
| 5497 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5498 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5499 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5500 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5501 | hs->nos_count = -1; |
| 5502 | } else { |
| 5503 | hs->lip_count = -1; |
| 5504 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5505 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5506 | } |
| 5507 | |
| 5508 | hs->dumped_frames = -1; |
| 5509 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5510 | seconds = get_seconds(); |
| 5511 | if (seconds < psli->stats_start) |
| 5512 | hs->seconds_since_last_reset = seconds + |
| 5513 | ((unsigned long)-1 - psli->stats_start); |
| 5514 | else |
| 5515 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5516 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5517 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5518 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5519 | return hs; |
| 5520 | } |
| 5521 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5522 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5523 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5524 | * @shost: kernel scsi host pointer. |
| 5525 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5526 | static void |
| 5527 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5528 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5529 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5530 | struct lpfc_hba *phba = vport->phba; |
| 5531 | struct lpfc_sli *psli = &phba->sli; |
| 5532 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5533 | LPFC_MBOXQ_t *pmboxq; |
| 5534 | MAILBOX_t *pmb; |
| 5535 | int rc = 0; |
| 5536 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5537 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5538 | return; |
| 5539 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5540 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5541 | if (!pmboxq) |
| 5542 | return; |
| 5543 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5544 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5545 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5546 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5547 | pmb->mbxOwner = OWN_HOST; |
| 5548 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5549 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5550 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5551 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5552 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5553 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5554 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5555 | else |
| 5556 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5557 | |
| 5558 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5559 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5560 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5561 | return; |
| 5562 | } |
| 5563 | |
| 5564 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5565 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5566 | pmb->mbxOwner = OWN_HOST; |
| 5567 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5568 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5569 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5570 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5571 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5572 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5573 | else |
| 5574 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5575 | |
| 5576 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5577 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5578 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5579 | return; |
| 5580 | } |
| 5581 | |
| 5582 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5583 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5584 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5585 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5586 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5587 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5588 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5589 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5590 | lso->link_events = (phba->link_events >> 1); |
| 5591 | else |
| 5592 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5593 | |
| 5594 | psli->stats_start = get_seconds(); |
| 5595 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5596 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5597 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5598 | return; |
| 5599 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5600 | |
| 5601 | /* |
| 5602 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5603 | * are no sysfs handlers for link_down_tmo. |
| 5604 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5605 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5606 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5607 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5608 | * @starget: kernel scsi target pointer. |
| 5609 | * |
| 5610 | * Returns: |
| 5611 | * address of the node list if found |
| 5612 | * NULL target not found |
| 5613 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5614 | static struct lpfc_nodelist * |
| 5615 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5616 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5617 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5618 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5619 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5620 | |
| 5621 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5622 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5623 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5624 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5625 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5626 | starget->id == ndlp->nlp_sid) { |
| 5627 | spin_unlock_irq(shost->host_lock); |
| 5628 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5629 | } |
| 5630 | } |
| 5631 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5632 | return NULL; |
| 5633 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5634 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5635 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5636 | * 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] | 5637 | * @starget: kernel scsi target pointer. |
| 5638 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5639 | static void |
| 5640 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5641 | { |
| 5642 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5643 | |
| 5644 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5645 | } |
| 5646 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5647 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5648 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5649 | * @starget: kernel scsi target pointer. |
| 5650 | * |
| 5651 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 5652 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5653 | static void |
| 5654 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 5655 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5656 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5657 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5658 | fc_starget_node_name(starget) = |
| 5659 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5660 | } |
| 5661 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5662 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5663 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5664 | * @starget: kernel scsi target pointer. |
| 5665 | * |
| 5666 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 5667 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5668 | static void |
| 5669 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 5670 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5671 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5672 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5673 | fc_starget_port_name(starget) = |
| 5674 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5675 | } |
| 5676 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5677 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5678 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5679 | * @rport: fc rport address. |
| 5680 | * @timeout: new value for dev loss tmo. |
| 5681 | * |
| 5682 | * Description: |
| 5683 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 5684 | * dev_loss_tmo to one. |
| 5685 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5686 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5687 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 5688 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5689 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5690 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5691 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5692 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5693 | } |
| 5694 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5695 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5696 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5697 | * |
| 5698 | * Description: |
| 5699 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 5700 | * |
| 5701 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 5702 | * @cdev: class converted to an fc_rport. |
| 5703 | * @buf: on return contains the target_field or zero. |
| 5704 | * |
| 5705 | * Returns: size of formatted string. |
| 5706 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5707 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 5708 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5709 | lpfc_show_rport_##field (struct device *dev, \ |
| 5710 | struct device_attribute *attr, \ |
| 5711 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5712 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5713 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5714 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 5715 | return snprintf(buf, sz, format_string, \ |
| 5716 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 5717 | } |
| 5718 | |
| 5719 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 5720 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 5721 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 5722 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5723 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5724 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5725 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 5726 | * |
| 5727 | * Description: |
| 5728 | * This function is called by the transport after the @fc_vport's symbolic name |
| 5729 | * 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] | 5730 | * 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] | 5731 | **/ |
| 5732 | static void |
| 5733 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 5734 | { |
| 5735 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 5736 | |
| 5737 | if (vport->port_state == LPFC_VPORT_READY) |
| 5738 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 5739 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5740 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5741 | /** |
| 5742 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 5743 | * @phba: Pointer to lpfc_hba struct. |
| 5744 | * |
| 5745 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 5746 | * 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] | 5747 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5748 | * before hba port or vport created. |
| 5749 | **/ |
| 5750 | static void |
| 5751 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 5752 | { |
| 5753 | phba->cfg_log_verbose = verbose; |
| 5754 | } |
| 5755 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5756 | struct fc_function_template lpfc_transport_functions = { |
| 5757 | /* fixed attributes the driver supports */ |
| 5758 | .show_host_node_name = 1, |
| 5759 | .show_host_port_name = 1, |
| 5760 | .show_host_supported_classes = 1, |
| 5761 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5762 | .show_host_supported_speeds = 1, |
| 5763 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5764 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5765 | |
| 5766 | /* dynamic attributes the driver supports */ |
| 5767 | .get_host_port_id = lpfc_get_host_port_id, |
| 5768 | .show_host_port_id = 1, |
| 5769 | |
| 5770 | .get_host_port_type = lpfc_get_host_port_type, |
| 5771 | .show_host_port_type = 1, |
| 5772 | |
| 5773 | .get_host_port_state = lpfc_get_host_port_state, |
| 5774 | .show_host_port_state = 1, |
| 5775 | |
| 5776 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5777 | .show_host_active_fc4s = 1, |
| 5778 | |
| 5779 | .get_host_speed = lpfc_get_host_speed, |
| 5780 | .show_host_speed = 1, |
| 5781 | |
| 5782 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5783 | .show_host_fabric_name = 1, |
| 5784 | |
| 5785 | /* |
| 5786 | * The LPFC driver treats linkdown handling as target loss events |
| 5787 | * so there are no sysfs handlers for link_down_tmo. |
| 5788 | */ |
| 5789 | |
| 5790 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5791 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5792 | |
| 5793 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5794 | .show_rport_maxframe_size = 1, |
| 5795 | .show_rport_supported_classes = 1, |
| 5796 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5797 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5798 | .show_rport_dev_loss_tmo = 1, |
| 5799 | |
| 5800 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5801 | .show_starget_port_id = 1, |
| 5802 | |
| 5803 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5804 | .show_starget_node_name = 1, |
| 5805 | |
| 5806 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5807 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 5808 | |
| 5809 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5810 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5811 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5812 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5813 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5814 | |
| 5815 | .vport_disable = lpfc_vport_disable, |
| 5816 | |
| 5817 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 5818 | |
| 5819 | .bsg_request = lpfc_bsg_request, |
| 5820 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5821 | }; |
| 5822 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5823 | struct fc_function_template lpfc_vport_transport_functions = { |
| 5824 | /* fixed attributes the driver supports */ |
| 5825 | .show_host_node_name = 1, |
| 5826 | .show_host_port_name = 1, |
| 5827 | .show_host_supported_classes = 1, |
| 5828 | .show_host_supported_fc4s = 1, |
| 5829 | .show_host_supported_speeds = 1, |
| 5830 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5831 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5832 | |
| 5833 | /* dynamic attributes the driver supports */ |
| 5834 | .get_host_port_id = lpfc_get_host_port_id, |
| 5835 | .show_host_port_id = 1, |
| 5836 | |
| 5837 | .get_host_port_type = lpfc_get_host_port_type, |
| 5838 | .show_host_port_type = 1, |
| 5839 | |
| 5840 | .get_host_port_state = lpfc_get_host_port_state, |
| 5841 | .show_host_port_state = 1, |
| 5842 | |
| 5843 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5844 | .show_host_active_fc4s = 1, |
| 5845 | |
| 5846 | .get_host_speed = lpfc_get_host_speed, |
| 5847 | .show_host_speed = 1, |
| 5848 | |
| 5849 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5850 | .show_host_fabric_name = 1, |
| 5851 | |
| 5852 | /* |
| 5853 | * The LPFC driver treats linkdown handling as target loss events |
| 5854 | * so there are no sysfs handlers for link_down_tmo. |
| 5855 | */ |
| 5856 | |
| 5857 | .get_fc_host_stats = lpfc_get_stats, |
| 5858 | .reset_fc_host_stats = lpfc_reset_stats, |
| 5859 | |
| 5860 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5861 | .show_rport_maxframe_size = 1, |
| 5862 | .show_rport_supported_classes = 1, |
| 5863 | |
| 5864 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5865 | .show_rport_dev_loss_tmo = 1, |
| 5866 | |
| 5867 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5868 | .show_starget_port_id = 1, |
| 5869 | |
| 5870 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5871 | .show_starget_node_name = 1, |
| 5872 | |
| 5873 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5874 | .show_starget_port_name = 1, |
| 5875 | |
| 5876 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5877 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 5878 | |
| 5879 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5880 | |
| 5881 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5882 | }; |
| 5883 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5884 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5885 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5886 | * @phba: lpfc_hba pointer. |
| 5887 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5888 | void |
| 5889 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 5890 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5891 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5892 | 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] | 5893 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 5894 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5895 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5896 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 5897 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5898 | lpfc_ack0_init(phba, lpfc_ack0); |
| 5899 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5900 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5901 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5902 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5903 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5904 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5905 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5906 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 5907 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5908 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5909 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5910 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5911 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5912 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 5913 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5914 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 5915 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5916 | phba->cfg_EnableXLane = 0; |
| 5917 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
| 5918 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5919 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5920 | phba->cfg_oas_lun_state = 0; |
| 5921 | phba->cfg_oas_lun_status = 0; |
| 5922 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5923 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5924 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5925 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 5926 | phba->cfg_poll = 0; |
| 5927 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5928 | phba->cfg_poll = lpfc_poll; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5929 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 5930 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5931 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5932 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5933 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5934 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5935 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5936 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5937 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5938 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5939 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5940 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5941 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5942 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5943 | return; |
| 5944 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 5945 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5946 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5947 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5948 | * @vport: lpfc_vport pointer. |
| 5949 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5950 | void |
| 5951 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 5952 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5953 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5954 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5955 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5956 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 5957 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 5958 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 5959 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 5960 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 5961 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5962 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5963 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5964 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 5965 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 5966 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 5967 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5968 | return; |
| 5969 | } |