| 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 | 2e61f50 | 2014-04-04 13:53:03 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2014 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 8 | * * |
| 9 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 10 | * modify it under the terms of version 2 of the GNU General * |
| 11 | * Public License as published by the Free Software Foundation. * |
| 12 | * This program is distributed in the hope that it will be useful. * |
| 13 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 14 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 16 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 17 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 18 | * more details, a copy of which can be found in the file COPYING * |
| 19 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 20 | *******************************************************************/ |
| 21 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | #include <linux/ctype.h> |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 23 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 24 | #include <linux/pci.h> |
| 25 | #include <linux/interrupt.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 26 | #include <linux/module.h> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 27 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 29 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 30 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 31 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 32 | #include <scsi/scsi_device.h> |
| 33 | #include <scsi/scsi_host.h> |
| 34 | #include <scsi/scsi_tcq.h> |
| 35 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 36 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 37 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 38 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 39 | #include "lpfc_hw.h" |
| 40 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 41 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 42 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 43 | #include "lpfc_disc.h" |
| 44 | #include "lpfc_scsi.h" |
| 45 | #include "lpfc.h" |
| 46 | #include "lpfc_logmsg.h" |
| 47 | #include "lpfc_version.h" |
| 48 | #include "lpfc_compat.h" |
| 49 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 50 | #include "lpfc_vport.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 51 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 52 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 53 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 54 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 55 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 56 | /* |
| 57 | * Write key size should be multiple of 4. If write key is changed |
| 58 | * make sure that library write key is also changed. |
| 59 | */ |
| 60 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 61 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 62 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 63 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 64 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 65 | * @incr: integer to convert. |
| 66 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 67 | * |
| 68 | * Description: |
| 69 | * JEDEC Joint Electron Device Engineering Council. |
| 70 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 71 | * character string. The string is then terminated with a NULL in byte 9. |
| 72 | * Hex 0-9 becomes ascii '0' to '9'. |
| 73 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 74 | * |
| 75 | * Notes: |
| 76 | * Coded for 32 bit integers only. |
| 77 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 78 | static void |
| 79 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 80 | { |
| 81 | int i, j; |
| 82 | for (i = 0; i < 8; i++) { |
| 83 | j = (incr & 0xf); |
| 84 | if (j <= 9) |
| 85 | hdw[7 - i] = 0x30 + j; |
| 86 | else |
| 87 | hdw[7 - i] = 0x61 + j - 10; |
| 88 | incr = (incr >> 4); |
| 89 | } |
| 90 | hdw[8] = 0; |
| 91 | return; |
| 92 | } |
| 93 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 94 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 95 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 96 | * @dev: class unused variable. |
| 97 | * @attr: device attribute, not used. |
| 98 | * @buf: on return contains the module description text. |
| 99 | * |
| 100 | * Returns: size of formatted string. |
| 101 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 102 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 103 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 104 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 105 | { |
| 106 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 107 | } |
| 108 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 109 | /** |
| 110 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 111 | * @dev: class unused variable. |
| 112 | * @attr: device attribute, not used. |
| 113 | * @buf: on return contains the module description text. |
| 114 | * |
| 115 | * Returns: size of formatted string. |
| 116 | **/ |
| 117 | static ssize_t |
| 118 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 119 | char *buf) |
| 120 | { |
| 121 | struct Scsi_Host *shost = class_to_shost(dev); |
| 122 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 123 | struct lpfc_hba *phba = vport->phba; |
| 124 | |
| 125 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 126 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 127 | else |
| 128 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 129 | } |
| 130 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 131 | static ssize_t |
| 132 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 133 | char *buf) |
| 134 | { |
| 135 | struct Scsi_Host *shost = class_to_shost(dev); |
| 136 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 137 | struct lpfc_hba *phba = vport->phba; |
| 138 | |
| 139 | if (phba->cfg_enable_bg) |
| 140 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 141 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 142 | else |
| 143 | return snprintf(buf, PAGE_SIZE, |
| 144 | "BlockGuard Not Supported\n"); |
| 145 | else |
| 146 | return snprintf(buf, PAGE_SIZE, |
| 147 | "BlockGuard Disabled\n"); |
| 148 | } |
| 149 | |
| 150 | static ssize_t |
| 151 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 152 | char *buf) |
| 153 | { |
| 154 | struct Scsi_Host *shost = class_to_shost(dev); |
| 155 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 156 | struct lpfc_hba *phba = vport->phba; |
| 157 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 158 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 159 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static ssize_t |
| 163 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 164 | char *buf) |
| 165 | { |
| 166 | struct Scsi_Host *shost = class_to_shost(dev); |
| 167 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 168 | struct lpfc_hba *phba = vport->phba; |
| 169 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 170 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 171 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | static ssize_t |
| 175 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 176 | char *buf) |
| 177 | { |
| 178 | struct Scsi_Host *shost = class_to_shost(dev); |
| 179 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 180 | struct lpfc_hba *phba = vport->phba; |
| 181 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 182 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 183 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 184 | } |
| 185 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 186 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 187 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 188 | * @dev: class converted to a Scsi_host structure. |
| 189 | * @attr: device attribute, not used. |
| 190 | * @buf: on return contains the formatted text from lpfc_info(). |
| 191 | * |
| 192 | * Returns: size of formatted string. |
| 193 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 194 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 195 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 196 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 197 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 198 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 199 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 200 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 201 | } |
| 202 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 203 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 204 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 205 | * @dev: class converted to a Scsi_host structure. |
| 206 | * @attr: device attribute, not used. |
| 207 | * @buf: on return contains the formatted text serial number. |
| 208 | * |
| 209 | * Returns: size of formatted string. |
| 210 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 211 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 212 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 213 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 214 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 215 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 216 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 217 | struct lpfc_hba *phba = vport->phba; |
| 218 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 219 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 220 | } |
| 221 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 222 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 223 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 224 | * @dev: class converted to a Scsi_host structure. |
| 225 | * @attr: device attribute, not used. |
| 226 | * @buf: on return contains the formatted support level. |
| 227 | * |
| 228 | * Description: |
| 229 | * Returns a number indicating the temperature sensor level currently |
| 230 | * supported, zero or one in ascii. |
| 231 | * |
| 232 | * Returns: size of formatted string. |
| 233 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 234 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 235 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 236 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 237 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 238 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 239 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 240 | struct lpfc_hba *phba = vport->phba; |
| 241 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 242 | } |
| 243 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 244 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 245 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 246 | * @dev: class converted to a Scsi_host structure. |
| 247 | * @attr: device attribute, not used. |
| 248 | * @buf: on return contains the scsi vpd model description. |
| 249 | * |
| 250 | * Returns: size of formatted string. |
| 251 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 252 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 253 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 254 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 255 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 256 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 257 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 258 | struct lpfc_hba *phba = vport->phba; |
| 259 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 260 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 261 | } |
| 262 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 263 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 264 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 265 | * @dev: class converted to a Scsi_host structure. |
| 266 | * @attr: device attribute, not used. |
| 267 | * @buf: on return contains the scsi vpd model name. |
| 268 | * |
| 269 | * Returns: size of formatted string. |
| 270 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 271 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 272 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 273 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 274 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 275 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 276 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 277 | struct lpfc_hba *phba = vport->phba; |
| 278 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 279 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 280 | } |
| 281 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 282 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 283 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 284 | * @dev: class converted to a Scsi_host structure. |
| 285 | * @attr: device attribute, not used. |
| 286 | * @buf: on return contains the scsi vpd program type. |
| 287 | * |
| 288 | * Returns: size of formatted string. |
| 289 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 290 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 291 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 292 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 293 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 294 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 295 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 296 | struct lpfc_hba *phba = vport->phba; |
| 297 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 298 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 299 | } |
| 300 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 301 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 302 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 303 | * @dev: class converted to a Scsi_host structure. |
| 304 | * @attr: device attribute, not used. |
| 305 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 306 | * |
| 307 | * Returns: size of formatted string. |
| 308 | **/ |
| 309 | static ssize_t |
| 310 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 311 | { |
| 312 | struct Scsi_Host *shost = class_to_shost(dev); |
| 313 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 314 | struct lpfc_hba *phba = vport->phba; |
| 315 | |
| 316 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 317 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 318 | } |
| 319 | |
| 320 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 321 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 322 | * @dev: class converted to a Scsi_host structure. |
| 323 | * @attr: device attribute, not used. |
| 324 | * @buf: on return contains scsi vpd program type. |
| 325 | * |
| 326 | * Returns: size of formatted string. |
| 327 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 328 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 329 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 330 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 331 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 332 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 333 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 334 | struct lpfc_hba *phba = vport->phba; |
| 335 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 336 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 337 | } |
| 338 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 339 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 340 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 341 | * @dev: class converted to a Scsi_host structure. |
| 342 | * @attr: device attribute, not used. |
| 343 | * @buf: on return contains the scsi vpd program type. |
| 344 | * |
| 345 | * Returns: size of formatted string. |
| 346 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 347 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 348 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 349 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 350 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 351 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 352 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 353 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 354 | uint32_t if_type; |
| 355 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 356 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 357 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 358 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 359 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 360 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 361 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 362 | |
| 363 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 364 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 365 | fwrev, phba->sli_rev); |
| 366 | else |
| 367 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 368 | fwrev, phba->sli_rev, if_type, sli_family); |
| 369 | |
| 370 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 371 | } |
| 372 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 373 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 374 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 375 | * @dev: class converted to a Scsi_host structure. |
| 376 | * @attr: device attribute, not used. |
| 377 | * @buf: on return contains the scsi vpd program type. |
| 378 | * |
| 379 | * Returns: size of formatted string. |
| 380 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 381 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 382 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 383 | { |
| 384 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 385 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 386 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 387 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 388 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 389 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 390 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 391 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 392 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 393 | |
| 394 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 395 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 396 | * @dev: class converted to a Scsi_host structure. |
| 397 | * @attr: device attribute, not used. |
| 398 | * @buf: on return contains the ROM and FCode ascii strings. |
| 399 | * |
| 400 | * Returns: size of formatted string. |
| 401 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 402 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 403 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 404 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 405 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 406 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 407 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 408 | struct lpfc_hba *phba = vport->phba; |
| 409 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 410 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 411 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 412 | |
| 413 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 414 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 415 | * @dev: class converted to a Scsi_host structure. |
| 416 | * @attr: device attribute, not used. |
| 417 | * @buf: on return contains text describing the state of the link. |
| 418 | * |
| 419 | * Notes: |
| 420 | * The switch statement has no default so zero will be returned. |
| 421 | * |
| 422 | * Returns: size of formatted string. |
| 423 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 424 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 425 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 426 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 427 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 428 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 429 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 430 | struct lpfc_hba *phba = vport->phba; |
| 431 | int len = 0; |
| 432 | |
| 433 | switch (phba->link_state) { |
| 434 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 435 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 436 | case LPFC_INIT_START: |
| 437 | case LPFC_INIT_MBX_CMDS: |
| 438 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 439 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 440 | if (phba->hba_flag & LINK_DISABLED) |
| 441 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 442 | "Link Down - User disabled\n"); |
| 443 | else |
| 444 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 445 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 446 | break; |
| 447 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 448 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 449 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 450 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 451 | |
| 452 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 453 | case LPFC_LOCAL_CFG_LINK: |
| 454 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 455 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 456 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 457 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 458 | case LPFC_FLOGI: |
| 459 | case LPFC_FABRIC_CFG_LINK: |
| 460 | case LPFC_NS_REG: |
| 461 | case LPFC_NS_QRY: |
| 462 | case LPFC_BUILD_DISC_LIST: |
| 463 | case LPFC_DISC_AUTH: |
| 464 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 465 | "Discovery\n"); |
| 466 | break; |
| 467 | case LPFC_VPORT_READY: |
| 468 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 469 | break; |
| 470 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 471 | case LPFC_VPORT_FAILED: |
| 472 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 473 | break; |
| 474 | |
| 475 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 476 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 477 | "Unknown\n"); |
| 478 | break; |
| 479 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 480 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 481 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 482 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 483 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 484 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 485 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 486 | " Public Loop\n"); |
| 487 | else |
| 488 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 489 | " Private Loop\n"); |
| 490 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 491 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 492 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 493 | " Fabric\n"); |
| 494 | else |
| 495 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 496 | " Point-2-Point\n"); |
| 497 | } |
| 498 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 499 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 500 | return len; |
| 501 | } |
| 502 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 503 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 504 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 505 | * @dev: class unused variable. |
| 506 | * @attr: device attribute, not used. |
| 507 | * @buf: on return contains the module description text. |
| 508 | * |
| 509 | * Returns: size of formatted string. |
| 510 | **/ |
| 511 | static ssize_t |
| 512 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 513 | char *buf) |
| 514 | { |
| 515 | struct Scsi_Host *shost = class_to_shost(dev); |
| 516 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 517 | struct lpfc_hba *phba = vport->phba; |
| 518 | |
| 519 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 520 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 521 | |
| 522 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 523 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 524 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 525 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 526 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 527 | } |
| 528 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 529 | } |
| 530 | |
| 531 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 532 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 533 | * (OAS) is supported. |
| 534 | * @dev: class unused variable. |
| 535 | * @attr: device attribute, not used. |
| 536 | * @buf: on return contains the module description text. |
| 537 | * |
| 538 | * Returns: size of formatted string. |
| 539 | **/ |
| 540 | static ssize_t |
| 541 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 542 | char *buf) |
| 543 | { |
| 544 | struct Scsi_Host *shost = class_to_shost(dev); |
| 545 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 546 | struct lpfc_hba *phba = vport->phba; |
| 547 | |
| 548 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 549 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 550 | } |
| 551 | |
| 552 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 553 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 554 | * @dev: class device that is converted into a Scsi_host. |
| 555 | * @attr: device attribute, not used. |
| 556 | * @buf: one or more lpfc_polling_flags values. |
| 557 | * @count: not used. |
| 558 | * |
| 559 | * Returns: |
| 560 | * -EINVAL if the buffer is not "up" or "down" |
| 561 | * return from link state change function if non-zero |
| 562 | * length of the buf on success |
| 563 | **/ |
| 564 | static ssize_t |
| 565 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 566 | const char *buf, size_t count) |
| 567 | { |
| 568 | struct Scsi_Host *shost = class_to_shost(dev); |
| 569 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 570 | struct lpfc_hba *phba = vport->phba; |
| 571 | |
| 572 | int status = -EINVAL; |
| 573 | |
| 574 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 575 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 576 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 577 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 578 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 579 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 580 | |
| 581 | if (status == 0) |
| 582 | return strlen(buf); |
| 583 | else |
| 584 | return status; |
| 585 | } |
| 586 | |
| 587 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 588 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 589 | * @dev: class device that is converted into a Scsi_host. |
| 590 | * @attr: device attribute, not used. |
| 591 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 592 | * |
| 593 | * Description: |
| 594 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 595 | * vport counts. |
| 596 | * |
| 597 | * Returns: size of formatted string. |
| 598 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 599 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 600 | lpfc_num_discovered_ports_show(struct device *dev, |
| 601 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 602 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 603 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 604 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 605 | |
| 606 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 607 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 608 | } |
| 609 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 610 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 611 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 612 | * @shost: Scsi_Host pointer. |
| 613 | * |
| 614 | * Description: |
| 615 | * Bring the link down gracefully then re-init the link. The firmware will |
| 616 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 617 | * |
| 618 | * Returns: |
| 619 | * -EPERM port offline or management commands are being blocked |
| 620 | * -ENOMEM cannot allocate memory for the mailbox command |
| 621 | * -EIO error sending the mailbox command |
| 622 | * zero for success |
| 623 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 624 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 625 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 626 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 627 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 628 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 629 | LPFC_MBOXQ_t *pmboxq; |
| 630 | int mbxstatus = MBXERR_ERROR; |
| 631 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 632 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 633 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 634 | return -EPERM; |
| 635 | |
| 636 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 637 | |
| 638 | if (!pmboxq) |
| 639 | return -ENOMEM; |
| 640 | |
| 641 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 642 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 643 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 644 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 645 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 646 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 647 | if ((mbxstatus == MBX_SUCCESS) && |
| 648 | (pmboxq->u.mb.mbxStatus == 0 || |
| 649 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 650 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 651 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 652 | phba->cfg_link_speed); |
| 653 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 654 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 655 | if ((mbxstatus == MBX_SUCCESS) && |
| 656 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 657 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 658 | "2859 SLI authentication is required " |
| 659 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 660 | } |
| 661 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 662 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 663 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 664 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 665 | |
| 666 | if (mbxstatus == MBXERR_ERROR) |
| 667 | return -EIO; |
| 668 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 669 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | } |
| 671 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 672 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 673 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 674 | * @phba: lpfc_hba pointer. |
| 675 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 676 | * |
| 677 | * Notes: |
| 678 | * Assumes any error from lpfc_do_offline() will be negative. |
| 679 | * Can wait up to 5 seconds for the port ring buffers count |
| 680 | * to reach zero, prints a warning if it is not zero and continues. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 681 | * lpfc_workq_post_event() returns a non-zero return code if call fails. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 682 | * |
| 683 | * Returns: |
| 684 | * -EIO error posting the event |
| 685 | * zero for success |
| 686 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 687 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 688 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 689 | { |
| 690 | struct completion online_compl; |
| 691 | struct lpfc_sli_ring *pring; |
| 692 | struct lpfc_sli *psli; |
| 693 | int status = 0; |
| 694 | int cnt = 0; |
| 695 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 696 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 697 | |
| 698 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 699 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 700 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 701 | if (rc == 0) |
| 702 | return -ENOMEM; |
| 703 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 704 | wait_for_completion(&online_compl); |
| 705 | |
| 706 | if (status != 0) |
| 707 | return -EIO; |
| 708 | |
| 709 | psli = &phba->sli; |
| 710 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 711 | /* Wait a little for things to settle down, but not |
| 712 | * long enough for dev loss timeout to expire. |
| 713 | */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 714 | for (i = 0; i < psli->num_rings; i++) { |
| 715 | pring = &psli->ring[i]; |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 716 | while (!list_empty(&pring->txcmplq)) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 717 | msleep(10); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 718 | if (cnt++ > 500) { /* 5 secs */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 719 | lpfc_printf_log(phba, |
| 720 | KERN_WARNING, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 721 | "0466 Outstanding IO when " |
| 722 | "bringing Adapter offline\n"); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 723 | break; |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 729 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 730 | if (rc == 0) |
| 731 | return -ENOMEM; |
| 732 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 733 | wait_for_completion(&online_compl); |
| 734 | |
| 735 | if (status != 0) |
| 736 | return -EIO; |
| 737 | |
| 738 | return 0; |
| 739 | } |
| 740 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 741 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 742 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 743 | * @phba: lpfc_hba pointer. |
| 744 | * |
| 745 | * Description: |
| 746 | * If the port is configured to allow a reset then the hba is brought |
| 747 | * offline then online. |
| 748 | * |
| 749 | * Notes: |
| 750 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 751 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 752 | * |
| 753 | * Returns: |
| 754 | * lpfc_do_offline() return code if not zero |
| 755 | * -EIO reset not configured or error posting the event |
| 756 | * zero for success |
| 757 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 758 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 759 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 760 | { |
| 761 | struct completion online_compl; |
| 762 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 763 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 764 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 765 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 766 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 767 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 768 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 769 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 770 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 771 | if (status != 0) |
| 772 | return status; |
| 773 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 774 | |
| 775 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 776 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 777 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 778 | if (rc == 0) |
| 779 | return -ENOMEM; |
| 780 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 781 | wait_for_completion(&online_compl); |
| 782 | |
| 783 | if (status != 0) |
| 784 | return -EIO; |
| 785 | |
| 786 | return 0; |
| 787 | } |
| 788 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 789 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 790 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 791 | * @dev: class device that is converted into a Scsi_host. |
| 792 | * @attr: device attribute, not used. |
| 793 | * @buf: containing the string "selective". |
| 794 | * @count: unused variable. |
| 795 | * |
| 796 | * Description: |
| 797 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 798 | * is called to perform the reset. |
| 799 | * |
| 800 | * Notes: |
| 801 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 802 | * If lpfc_selective_reset() returns zero then the length of the buffer |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 803 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 804 | * |
| 805 | * Returns: |
| 806 | * -EINVAL if the buffer does not contain the string "selective" |
| 807 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 808 | * return value of lpfc_selective_reset() if the call fails |
| 809 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 810 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 811 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 812 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 813 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 814 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 815 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 816 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 817 | int status = -EINVAL; |
| 818 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 819 | if (!phba->cfg_enable_hba_reset) |
| 820 | return -EACCES; |
| 821 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 822 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 823 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 824 | |
| 825 | if (status == 0) |
| 826 | return strlen(buf); |
| 827 | else |
| 828 | return status; |
| 829 | } |
| 830 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 831 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 832 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 833 | * @phba: lpfc_hba pointer. |
| 834 | * |
| 835 | * Description: |
| 836 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 837 | * the readyness after performing a firmware reset. |
| 838 | * |
| 839 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 840 | * zero for success, -EPERM when port does not have privilege to perform the |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 841 | * reset, -EIO when port timeout from recovering from the reset. |
| 842 | * |
| 843 | * Note: |
| 844 | * As the caller will interpret the return code by value, be careful in making |
| 845 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 846 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 847 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 848 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 849 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 850 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 851 | int i; |
| 852 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 853 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 854 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 855 | &portstat_reg.word0); |
| 856 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 857 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 858 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 859 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 860 | return -EPERM; |
| 861 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 862 | /* wait for the SLI port firmware ready after firmware reset */ |
| 863 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 864 | msleep(10); |
| 865 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 866 | &portstat_reg.word0); |
| 867 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 868 | continue; |
| 869 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 870 | continue; |
| 871 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 872 | continue; |
| 873 | break; |
| 874 | } |
| 875 | |
| 876 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 877 | return 0; |
| 878 | else |
| 879 | return -EIO; |
| 880 | } |
| 881 | |
| 882 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 883 | * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 884 | * @phba: lpfc_hba pointer. |
| 885 | * |
| 886 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 887 | * Request SLI4 interface type-2 device to perform a physical register set |
| 888 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 889 | * |
| 890 | * Returns: |
| 891 | * zero for success |
| 892 | **/ |
| 893 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 894 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 895 | { |
| 896 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 897 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 898 | uint32_t before_fc_flag; |
| 899 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 900 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 901 | int status = 0, rc = 0; |
| 902 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 903 | |
| 904 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 905 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 906 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 907 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 908 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 909 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 910 | return -EPERM; |
| 911 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 912 | /* Keep state if we need to restore back */ |
| 913 | before_fc_flag = phba->pport->fc_flag; |
| 914 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 915 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 916 | /* Disable SR-IOV virtual functions if enabled */ |
| 917 | if (phba->cfg_sriov_nr_virtfn) { |
| 918 | pci_disable_sriov(pdev); |
| 919 | phba->cfg_sriov_nr_virtfn = 0; |
| 920 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 921 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 922 | if (opcode == LPFC_FW_DUMP) |
| 923 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 924 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 925 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 926 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 927 | if (status != 0) { |
| 928 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 929 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 930 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 931 | |
| 932 | /* wait for the device to be quiesced before firmware reset */ |
| 933 | msleep(100); |
| 934 | |
| 935 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 936 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 937 | |
| 938 | if (opcode == LPFC_FW_DUMP) |
| 939 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 940 | else if (opcode == LPFC_FW_RESET) |
| 941 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 942 | else if (opcode == LPFC_DV_RESET) |
| 943 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 944 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 945 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 946 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 947 | /* flush */ |
| 948 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 949 | |
| 950 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 951 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 952 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 953 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 954 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 955 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 956 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 957 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 958 | } else if (rc == -EIO) { |
| 959 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 960 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 961 | "3153 Fail to perform the requested " |
| 962 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 963 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 964 | } |
| 965 | |
| 966 | /* keep the original port state */ |
| 967 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 968 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 969 | |
| 970 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 971 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 972 | LPFC_EVT_ONLINE); |
| 973 | if (!job_posted) |
| 974 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 975 | |
| 976 | wait_for_completion(&online_compl); |
| 977 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 978 | out: |
| 979 | /* in any case, restore the virtual functions enabled as before */ |
| 980 | if (sriov_nr_virtfn) { |
| 981 | sriov_err = |
| 982 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 983 | if (!sriov_err) |
| 984 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 985 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 986 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 987 | /* return proper error code */ |
| 988 | if (!rc) { |
| 989 | if (!job_posted) |
| 990 | rc = -ENOMEM; |
| 991 | else if (status) |
| 992 | rc = -EIO; |
| 993 | } |
| 994 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 998 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 999 | * @dev: class device that is converted into a Scsi_host. |
| 1000 | * @attr: device attribute, not used. |
| 1001 | * @buf: on return contains the ascii number of nport events. |
| 1002 | * |
| 1003 | * Returns: size of formatted string. |
| 1004 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1005 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1006 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1007 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1008 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1009 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1010 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1011 | struct lpfc_hba *phba = vport->phba; |
| 1012 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1013 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1014 | } |
| 1015 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1016 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1017 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1018 | * @dev: class device that is converted into a Scsi_host. |
| 1019 | * @attr: device attribute, not used. |
| 1020 | * @buf: on return contains the state of the adapter. |
| 1021 | * |
| 1022 | * Returns: size of formatted string. |
| 1023 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1024 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1025 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1026 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1027 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1028 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1029 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1030 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1031 | char * state; |
| 1032 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1033 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1034 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1035 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1036 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1037 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1038 | state = "offline"; |
| 1039 | else |
| 1040 | state = "online"; |
| 1041 | |
| 1042 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1043 | } |
| 1044 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1045 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1046 | * 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] | 1047 | * @dev: class device that is converted into a Scsi_host. |
| 1048 | * @attr: device attribute, not used. |
| 1049 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1050 | * @count: unused variable. |
| 1051 | * |
| 1052 | * Returns: |
| 1053 | * -EACCES if enable hba reset not enabled |
| 1054 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1055 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1056 | * buf length greater than zero indicates success |
| 1057 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1058 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1059 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1060 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1061 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1062 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1063 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1064 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1065 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1066 | char *board_mode_str = NULL; |
| 1067 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1068 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1069 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1070 | if (!phba->cfg_enable_hba_reset) { |
| 1071 | status = -EACCES; |
| 1072 | goto board_mode_out; |
| 1073 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1074 | |
| 1075 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1076 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1077 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1078 | init_completion(&online_compl); |
| 1079 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1080 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1081 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1082 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1083 | if (rc == 0) { |
| 1084 | status = -ENOMEM; |
| 1085 | goto board_mode_out; |
| 1086 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1087 | wait_for_completion(&online_compl); |
| 1088 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1089 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1090 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1091 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1092 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1093 | else |
| 1094 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1095 | else if (strncmp(buf, "error", sizeof("error") - 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_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1100 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1101 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1102 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1103 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1104 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1105 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1106 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1107 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1108 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1109 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1110 | if (!status) |
| 1111 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1112 | else { |
| 1113 | board_mode_str = strchr(buf, '\n'); |
| 1114 | if (board_mode_str) |
| 1115 | *board_mode_str = '\0'; |
| 1116 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1117 | "3097 Failed \"%s\", status(%d), " |
| 1118 | "fc_flag(x%x)\n", |
| 1119 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1120 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1121 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1122 | } |
| 1123 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1124 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1125 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1126 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1127 | * @mxri: max xri count. |
| 1128 | * @axri: available xri count. |
| 1129 | * @mrpi: max rpi count. |
| 1130 | * @arpi: available rpi count. |
| 1131 | * @mvpi: max vpi count. |
| 1132 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1133 | * |
| 1134 | * Description: |
| 1135 | * If an integer pointer for an count is not null then the value for the |
| 1136 | * count is returned. |
| 1137 | * |
| 1138 | * Returns: |
| 1139 | * zero on error |
| 1140 | * one for success |
| 1141 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1142 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1143 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1144 | uint32_t *mxri, uint32_t *axri, |
| 1145 | uint32_t *mrpi, uint32_t *arpi, |
| 1146 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1147 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1148 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1149 | LPFC_MBOXQ_t *pmboxq; |
| 1150 | MAILBOX_t *pmb; |
| 1151 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1152 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1153 | |
| 1154 | /* |
| 1155 | * prevent udev from issuing mailbox commands until the port is |
| 1156 | * configured. |
| 1157 | */ |
| 1158 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1159 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1160 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1161 | return 0; |
| 1162 | |
| 1163 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1164 | return 0; |
| 1165 | |
| 1166 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1167 | if (!pmboxq) |
| 1168 | return 0; |
| 1169 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1170 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1171 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1172 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1173 | pmb->mbxOwner = OWN_HOST; |
| 1174 | pmboxq->context1 = NULL; |
| 1175 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1176 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1177 | rc = MBX_NOT_FINISHED; |
| 1178 | else |
| 1179 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1180 | |
| 1181 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1182 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1183 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1184 | return 0; |
| 1185 | } |
| 1186 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1187 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1188 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1189 | if (mrpi) |
| 1190 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1191 | if (arpi) |
| 1192 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1193 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1194 | if (mxri) |
| 1195 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1196 | if (axri) |
| 1197 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1198 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1199 | |
| 1200 | /* Account for differences with SLI-3. Get vpi count from |
| 1201 | * mailbox data and subtract one for max vpi value. |
| 1202 | */ |
| 1203 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1204 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1205 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1206 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1207 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1208 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1209 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1210 | } else { |
| 1211 | if (mrpi) |
| 1212 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1213 | if (arpi) |
| 1214 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1215 | if (mxri) |
| 1216 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1217 | if (axri) |
| 1218 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1219 | if (mvpi) |
| 1220 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1221 | if (avpi) |
| 1222 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1223 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1224 | |
| 1225 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1226 | return 1; |
| 1227 | } |
| 1228 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1229 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1230 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1231 | * @dev: class device that is converted into a Scsi_host. |
| 1232 | * @attr: device attribute, not used. |
| 1233 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1234 | * |
| 1235 | * Description: |
| 1236 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1237 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1238 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1239 | * must check for "Unknown" in the buffer to detect a failure. |
| 1240 | * |
| 1241 | * Returns: size of formatted string. |
| 1242 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1243 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1244 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1245 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1246 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1247 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1248 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1249 | struct lpfc_hba *phba = vport->phba; |
| 1250 | uint32_t cnt; |
| 1251 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1252 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1253 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1254 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1255 | } |
| 1256 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1257 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1258 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1259 | * @dev: class device that is converted into a Scsi_host. |
| 1260 | * @attr: device attribute, not used. |
| 1261 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1262 | * |
| 1263 | * Description: |
| 1264 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1265 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1266 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1267 | * must check for "Unknown" in the buffer to detect a failure. |
| 1268 | * |
| 1269 | * Returns: size of formatted string. |
| 1270 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1271 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1272 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1273 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1274 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1275 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1276 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1277 | struct lpfc_hba *phba = vport->phba; |
| 1278 | uint32_t cnt, acnt; |
| 1279 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1280 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1281 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1282 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1283 | } |
| 1284 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1285 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1286 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1287 | * @dev: class device that is converted into a Scsi_host. |
| 1288 | * @attr: device attribute, not used. |
| 1289 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1290 | * |
| 1291 | * Description: |
| 1292 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1293 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1294 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1295 | * must check for "Unknown" in the buffer to detect a failure. |
| 1296 | * |
| 1297 | * Returns: size of formatted string. |
| 1298 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1299 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1300 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1301 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1302 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1303 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1304 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1305 | struct lpfc_hba *phba = vport->phba; |
| 1306 | uint32_t cnt; |
| 1307 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1308 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1309 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1310 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1311 | } |
| 1312 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1313 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1314 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1315 | * @dev: class device that is converted into a Scsi_host. |
| 1316 | * @attr: device attribute, not used. |
| 1317 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1318 | * |
| 1319 | * Description: |
| 1320 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1321 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1322 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1323 | * must check for "Unknown" in the buffer to detect a failure. |
| 1324 | * |
| 1325 | * Returns: size of formatted string. |
| 1326 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1327 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1328 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1329 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1330 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1331 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1332 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1333 | struct lpfc_hba *phba = vport->phba; |
| 1334 | uint32_t cnt, acnt; |
| 1335 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1336 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1337 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1338 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1339 | } |
| 1340 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1341 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1342 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1343 | * @dev: class device that is converted into a Scsi_host. |
| 1344 | * @attr: device attribute, not used. |
| 1345 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1346 | * |
| 1347 | * Description: |
| 1348 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1349 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1350 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1351 | * must check for "Unknown" in the buffer to detect a failure. |
| 1352 | * |
| 1353 | * Returns: size of formatted string. |
| 1354 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1355 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1356 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1357 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1358 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1359 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1360 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1361 | struct lpfc_hba *phba = vport->phba; |
| 1362 | uint32_t cnt; |
| 1363 | |
| 1364 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1365 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1366 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1367 | } |
| 1368 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1369 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1370 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1371 | * @dev: class device that is converted into a Scsi_host. |
| 1372 | * @attr: device attribute, not used. |
| 1373 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1374 | * |
| 1375 | * Description: |
| 1376 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1377 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1378 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1379 | * must check for "Unknown" in the buffer to detect a failure. |
| 1380 | * |
| 1381 | * Returns: size of formatted string. |
| 1382 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1383 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1384 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1385 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1386 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1387 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1388 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1389 | struct lpfc_hba *phba = vport->phba; |
| 1390 | uint32_t cnt, acnt; |
| 1391 | |
| 1392 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1393 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1394 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1395 | } |
| 1396 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1397 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1398 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1399 | * @dev: class device that is converted into a Scsi_host. |
| 1400 | * @attr: device attribute, not used. |
| 1401 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1402 | * |
| 1403 | * Description: |
| 1404 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1405 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1406 | * the id of the vport. |
| 1407 | * |
| 1408 | * Returns: size of formatted string. |
| 1409 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1410 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1411 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1412 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1413 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1414 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1415 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1416 | struct lpfc_hba *phba = vport->phba; |
| 1417 | |
| 1418 | if (!(phba->max_vpi)) |
| 1419 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1420 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1421 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1422 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1423 | } |
| 1424 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1425 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1426 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1427 | * @dev: class device that is converted into a Scsi_host. |
| 1428 | * @attr: device attribute, not used. |
| 1429 | * @buf: on return contains the cfg_poll in hex. |
| 1430 | * |
| 1431 | * Notes: |
| 1432 | * cfg_poll should be a lpfc_polling_flags type. |
| 1433 | * |
| 1434 | * Returns: size of formatted string. |
| 1435 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1436 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1437 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1438 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1439 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1440 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1441 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1442 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1443 | |
| 1444 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1445 | } |
| 1446 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1447 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1448 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1449 | * @dev: class device that is converted into a Scsi_host. |
| 1450 | * @attr: device attribute, not used. |
| 1451 | * @buf: one or more lpfc_polling_flags values. |
| 1452 | * @count: not used. |
| 1453 | * |
| 1454 | * Notes: |
| 1455 | * buf contents converted to integer and checked for a valid value. |
| 1456 | * |
| 1457 | * Returns: |
| 1458 | * -EINVAL if the buffer connot be converted or is out of range |
| 1459 | * length of the buf on success |
| 1460 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1461 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1462 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1463 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1464 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1465 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1466 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1467 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1468 | uint32_t creg_val; |
| 1469 | uint32_t old_val; |
| 1470 | int val=0; |
| 1471 | |
| 1472 | if (!isdigit(buf[0])) |
| 1473 | return -EINVAL; |
| 1474 | |
| 1475 | if (sscanf(buf, "%i", &val) != 1) |
| 1476 | return -EINVAL; |
| 1477 | |
| 1478 | if ((val & 0x3) != val) |
| 1479 | return -EINVAL; |
| 1480 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1481 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1482 | val = 0; |
| 1483 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1484 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1485 | "3051 lpfc_poll changed from %d to %d\n", |
| 1486 | phba->cfg_poll, val); |
| 1487 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1488 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1489 | |
| 1490 | old_val = phba->cfg_poll; |
| 1491 | |
| 1492 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1493 | if ((val & DISABLE_FCP_RING_INT) && |
| 1494 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1495 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1496 | spin_unlock_irq(&phba->hbalock); |
| 1497 | return -EINVAL; |
| 1498 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1499 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1500 | writel(creg_val, phba->HCregaddr); |
| 1501 | readl(phba->HCregaddr); /* flush */ |
| 1502 | |
| 1503 | lpfc_poll_start_timer(phba); |
| 1504 | } |
| 1505 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1506 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1507 | return -EINVAL; |
| 1508 | } |
| 1509 | |
| 1510 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1511 | (old_val & DISABLE_FCP_RING_INT)) |
| 1512 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1513 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1514 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1515 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1516 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1517 | spin_unlock_irq(&phba->hbalock); |
| 1518 | return -EINVAL; |
| 1519 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1520 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1521 | writel(creg_val, phba->HCregaddr); |
| 1522 | readl(phba->HCregaddr); /* flush */ |
| 1523 | } |
| 1524 | |
| 1525 | phba->cfg_poll = val; |
| 1526 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1527 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1528 | |
| 1529 | return strlen(buf); |
| 1530 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1531 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1532 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1533 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1534 | * @dev: class unused variable. |
| 1535 | * @attr: device attribute, not used. |
| 1536 | * @buf: on return contains the module description text. |
| 1537 | * |
| 1538 | * Returns: size of formatted string. |
| 1539 | **/ |
| 1540 | static ssize_t |
| 1541 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1542 | char *buf) |
| 1543 | { |
| 1544 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1545 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1546 | struct lpfc_hba *phba = vport->phba; |
| 1547 | |
| 1548 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1549 | } |
| 1550 | |
| 1551 | /** |
| 1552 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1553 | * @dev: class unused variable. |
| 1554 | * @attr: device attribute, not used. |
| 1555 | * @buf: on return contains the module description text. |
| 1556 | * |
| 1557 | * Returns: size of formatted string. |
| 1558 | **/ |
| 1559 | static ssize_t |
| 1560 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1561 | char *buf) |
| 1562 | { |
| 1563 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1564 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1565 | struct lpfc_hba *phba = vport->phba; |
| 1566 | |
| 1567 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1568 | } |
| 1569 | |
| 1570 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1571 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1572 | * @dev: class converted to a Scsi_host structure. |
| 1573 | * @attr: device attribute, not used. |
| 1574 | * @buf: on return contains the formatted text. |
| 1575 | * |
| 1576 | * Returns: size of formatted string. |
| 1577 | **/ |
| 1578 | static ssize_t |
| 1579 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1580 | char *buf) |
| 1581 | { |
| 1582 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1583 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1584 | struct lpfc_hba *phba = vport->phba; |
| 1585 | |
| 1586 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1587 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1588 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1589 | "" : "Not "); |
| 1590 | } |
| 1591 | |
| 1592 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1593 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1594 | * @dev: class converted to a Scsi_host structure. |
| 1595 | * @attr: device attribute, not used. |
| 1596 | * @buf: on return contains the formatted support level. |
| 1597 | * |
| 1598 | * Description: |
| 1599 | * Returns the maximum number of virtual functions a physical function can |
| 1600 | * support, 0 will be returned if called on virtual function. |
| 1601 | * |
| 1602 | * Returns: size of formatted string. |
| 1603 | **/ |
| 1604 | static ssize_t |
| 1605 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1606 | struct device_attribute *attr, |
| 1607 | char *buf) |
| 1608 | { |
| 1609 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1610 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1611 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1612 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1613 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1614 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1615 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1616 | } |
| 1617 | |
| 1618 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1619 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1620 | * |
| 1621 | * Description: |
| 1622 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1623 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1624 | * |
| 1625 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1626 | * @dev: class device that is converted into a Scsi_host. |
| 1627 | * @attr: device attribute, not used. |
| 1628 | * @buf: on return contains the attribute value in decimal. |
| 1629 | * |
| 1630 | * Returns: size of formatted string. |
| 1631 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1632 | #define lpfc_param_show(attr) \ |
| 1633 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1634 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1635 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1636 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1637 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1638 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1639 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1640 | uint val = 0;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1641 | val = phba->cfg_##attr;\ |
| 1642 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1643 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1644 | } |
| 1645 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1646 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1647 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1648 | * |
| 1649 | * Description: |
| 1650 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1651 | * into a function with the name lpfc_hba_queue_depth_show |
| 1652 | * |
| 1653 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1654 | * @dev: class device that is converted into a Scsi_host. |
| 1655 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1656 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1657 | * |
| 1658 | * Returns: size of formatted string. |
| 1659 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1660 | #define lpfc_param_hex_show(attr) \ |
| 1661 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1662 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1663 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1664 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1665 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1666 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1667 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1668 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1669 | val = phba->cfg_##attr;\ |
| 1670 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1671 | phba->cfg_##attr);\ |
| 1672 | } |
| 1673 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1674 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1675 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1676 | * |
| 1677 | * Description: |
| 1678 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1679 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1680 | * takes a default argument, a minimum and maximum argument. |
| 1681 | * |
| 1682 | * lpfc_##attr##_init: Initializes an attribute. |
| 1683 | * @phba: pointer the the adapter structure. |
| 1684 | * @val: integer attribute value. |
| 1685 | * |
| 1686 | * Validates the min and max values then sets the adapter config field |
| 1687 | * accordingly, or uses the default if out of range and prints an error message. |
| 1688 | * |
| 1689 | * Returns: |
| 1690 | * zero on success |
| 1691 | * -EINVAL if default used |
| 1692 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1693 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1694 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1695 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1696 | { \ |
| 1697 | if (val >= minval && val <= maxval) {\ |
| 1698 | phba->cfg_##attr = val;\ |
| 1699 | return 0;\ |
| 1700 | }\ |
| 1701 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1702 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1703 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1704 | phba->cfg_##attr = default;\ |
| 1705 | return -EINVAL;\ |
| 1706 | } |
| 1707 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1708 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1709 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1710 | * |
| 1711 | * Description: |
| 1712 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1713 | * into a function with the name lpfc_hba_queue_depth_set |
| 1714 | * |
| 1715 | * lpfc_##attr##_set: Sets an attribute value. |
| 1716 | * @phba: pointer the the adapter structure. |
| 1717 | * @val: integer attribute value. |
| 1718 | * |
| 1719 | * Description: |
| 1720 | * Validates the min and max values then sets the |
| 1721 | * adapter config field if in the valid range. prints error message |
| 1722 | * and does not set the parameter if invalid. |
| 1723 | * |
| 1724 | * Returns: |
| 1725 | * zero on success |
| 1726 | * -EINVAL if val is invalid |
| 1727 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1728 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1729 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1730 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1731 | { \ |
| 1732 | if (val >= minval && val <= maxval) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1733 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 1734 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 1735 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1736 | phba->cfg_##attr = val;\ |
| 1737 | return 0;\ |
| 1738 | }\ |
| 1739 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1740 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1741 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1742 | return -EINVAL;\ |
| 1743 | } |
| 1744 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1745 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1746 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1747 | * |
| 1748 | * Description: |
| 1749 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1750 | * into a function with the name lpfc_hba_queue_depth_store. |
| 1751 | * |
| 1752 | * lpfc_##attr##_store: Set an sttribute value. |
| 1753 | * @dev: class device that is converted into a Scsi_host. |
| 1754 | * @attr: device attribute, not used. |
| 1755 | * @buf: contains the attribute value in ascii. |
| 1756 | * @count: not used. |
| 1757 | * |
| 1758 | * Description: |
| 1759 | * Convert the ascii text number to an integer, then |
| 1760 | * use the lpfc_##attr##_set function to set the value. |
| 1761 | * |
| 1762 | * Returns: |
| 1763 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1764 | * length of buffer upon success. |
| 1765 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1766 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1767 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1768 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1769 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1770 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1771 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1772 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1773 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1774 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1775 | if (!isdigit(buf[0]))\ |
| 1776 | return -EINVAL;\ |
| 1777 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1778 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1779 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 1780 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1781 | else \ |
| 1782 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1783 | } |
| 1784 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1785 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1786 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1787 | * |
| 1788 | * Description: |
| 1789 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1790 | * into a function with the name lpfc_hba_queue_depth_show |
| 1791 | * |
| 1792 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 1793 | * @dev: class device that is converted into a Scsi_host. |
| 1794 | * @attr: device attribute, not used. |
| 1795 | * @buf: on return contains the attribute value in decimal. |
| 1796 | * |
| 1797 | * Returns: length of formatted string. |
| 1798 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1799 | #define lpfc_vport_param_show(attr) \ |
| 1800 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1801 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1802 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1803 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1804 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1805 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1806 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1807 | val = vport->cfg_##attr;\ |
| 1808 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 1809 | } |
| 1810 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1811 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1812 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1813 | * |
| 1814 | * Description: |
| 1815 | * Macro that given an attr e.g. |
| 1816 | * hba_queue_depth expands into a function with the name |
| 1817 | * lpfc_hba_queue_depth_show |
| 1818 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1819 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1820 | * @dev: class device that is converted into a Scsi_host. |
| 1821 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1822 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1823 | * |
| 1824 | * Returns: length of formatted string. |
| 1825 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1826 | #define lpfc_vport_param_hex_show(attr) \ |
| 1827 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1828 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1829 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1830 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1831 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1832 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1833 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1834 | val = vport->cfg_##attr;\ |
| 1835 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 1836 | } |
| 1837 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1838 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1839 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1840 | * |
| 1841 | * Description: |
| 1842 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1843 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1844 | * takes a default argument, a minimum and maximum argument. |
| 1845 | * |
| 1846 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 1847 | * adapter config field accordingly, or uses the default if out of range |
| 1848 | * and prints an error message. |
| 1849 | * @phba: pointer the the adapter structure. |
| 1850 | * @val: integer attribute value. |
| 1851 | * |
| 1852 | * Returns: |
| 1853 | * zero on success |
| 1854 | * -EINVAL if default used |
| 1855 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1856 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 1857 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1858 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1859 | { \ |
| 1860 | if (val >= minval && val <= maxval) {\ |
| 1861 | vport->cfg_##attr = val;\ |
| 1862 | return 0;\ |
| 1863 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1864 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1865 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1866 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1867 | vport->cfg_##attr = default;\ |
| 1868 | return -EINVAL;\ |
| 1869 | } |
| 1870 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1871 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1872 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1873 | * |
| 1874 | * Description: |
| 1875 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1876 | * into a function with the name lpfc_hba_queue_depth_set |
| 1877 | * |
| 1878 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 1879 | * adapter config field if in the valid range. prints error message |
| 1880 | * and does not set the parameter if invalid. |
| 1881 | * @phba: pointer the the adapter structure. |
| 1882 | * @val: integer attribute value. |
| 1883 | * |
| 1884 | * Returns: |
| 1885 | * zero on success |
| 1886 | * -EINVAL if val is invalid |
| 1887 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1888 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 1889 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1890 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1891 | { \ |
| 1892 | if (val >= minval && val <= maxval) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1893 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 1894 | "3053 lpfc_" #attr \ |
| 1895 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 1896 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 1897 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1898 | vport->cfg_##attr = val;\ |
| 1899 | return 0;\ |
| 1900 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1901 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1902 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1903 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1904 | return -EINVAL;\ |
| 1905 | } |
| 1906 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1907 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1908 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1909 | * |
| 1910 | * Description: |
| 1911 | * Macro that given an attr e.g. hba_queue_depth |
| 1912 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 1913 | * |
| 1914 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 1915 | * use the lpfc_##attr##_set function to set the value. |
| 1916 | * @cdev: class device that is converted into a Scsi_host. |
| 1917 | * @buf: contains the attribute value in decimal. |
| 1918 | * @count: not used. |
| 1919 | * |
| 1920 | * Returns: |
| 1921 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1922 | * length of buffer upon success. |
| 1923 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1924 | #define lpfc_vport_param_store(attr) \ |
| 1925 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1926 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1927 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1928 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1929 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1930 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1931 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1932 | if (!isdigit(buf[0]))\ |
| 1933 | return -EINVAL;\ |
| 1934 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1935 | return -EINVAL;\ |
| 1936 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 1937 | return strlen(buf);\ |
| 1938 | else \ |
| 1939 | return -EINVAL;\ |
| 1940 | } |
| 1941 | |
| 1942 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1943 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1944 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1945 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1946 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1947 | lpfc_param_init(name, defval, minval, maxval) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1948 | |
| 1949 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1950 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1951 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1952 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1953 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1954 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1955 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1956 | |
| 1957 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1958 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1959 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1960 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1961 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1962 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1963 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1964 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1965 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1966 | lpfc_##name##_show, lpfc_##name##_store) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1967 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1968 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1969 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1970 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1971 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1972 | lpfc_param_hex_show(name)\ |
| 1973 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1974 | 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] | 1975 | |
| 1976 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1977 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1978 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1979 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1980 | lpfc_param_hex_show(name)\ |
| 1981 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1982 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1983 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1984 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1985 | lpfc_##name##_show, lpfc_##name##_store) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1986 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1987 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1988 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1989 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1990 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1991 | lpfc_vport_param_init(name, defval, minval, maxval) |
| 1992 | |
| 1993 | #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1994 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1995 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1996 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1997 | lpfc_vport_param_show(name)\ |
| 1998 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1999 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2000 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 2001 | #define LPFC_VPORT_ULL_ATTR_R(name, defval, minval, maxval, desc) \ |
| 2002 | static uint64_t lpfc_##name = defval;\ |
| 2003 | module_param(lpfc_##name, ullong, S_IRUGO);\ |
| 2004 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2005 | lpfc_vport_param_show(name)\ |
| 2006 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2007 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| 2008 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2009 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2010 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2011 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2012 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2013 | lpfc_vport_param_show(name)\ |
| 2014 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2015 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 2016 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2017 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 2018 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2019 | |
| 2020 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2021 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2022 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2023 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2024 | lpfc_vport_param_hex_show(name)\ |
| 2025 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2026 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2027 | |
| 2028 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2029 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2030 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2031 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 2032 | lpfc_vport_param_hex_show(name)\ |
| 2033 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 2034 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 2035 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2036 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 2037 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2038 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2039 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2040 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2041 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2042 | 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] | 2043 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2044 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2045 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2046 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2047 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2048 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2049 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2050 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2051 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2052 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2053 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2054 | lpfc_option_rom_version_show, NULL); |
| 2055 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2056 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2057 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2058 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 2059 | 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] | 2060 | 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] | 2061 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2062 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2063 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2064 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2065 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2066 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2067 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2068 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2069 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2070 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 2071 | 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] | 2072 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 2073 | 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] | 2074 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2075 | static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, |
| 2076 | lpfc_sriov_hw_max_virtfn_show, NULL); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2077 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2078 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2079 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2080 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2081 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2082 | #define WWN_SZ 8 |
| 2083 | /** |
| 2084 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2085 | * @buf: WWN string. |
| 2086 | * @cnt: Length of string. |
| 2087 | * @wwn: Array to receive converted wwn value. |
| 2088 | * |
| 2089 | * Returns: |
| 2090 | * -EINVAL if the buffer does not contain a valid wwn |
| 2091 | * 0 success |
| 2092 | **/ |
| 2093 | static size_t |
| 2094 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2095 | { |
| 2096 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2097 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2098 | /* Count may include a LF at end of string */ |
| 2099 | if (buf[cnt-1] == '\n') |
| 2100 | cnt--; |
| 2101 | |
| 2102 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2103 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2104 | return -EINVAL; |
| 2105 | |
| 2106 | memset(wwn, 0, WWN_SZ); |
| 2107 | |
| 2108 | /* Validate and store the new name */ |
| 2109 | for (i = 0, j = 0; i < 16; i++) { |
| 2110 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2111 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2112 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2113 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2114 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2115 | j = ((j << 4) | (*buf++ - '0')); |
| 2116 | else |
| 2117 | return -EINVAL; |
| 2118 | if (i % 2) { |
| 2119 | wwn[i/2] = j & 0xff; |
| 2120 | j = 0; |
| 2121 | } |
| 2122 | } |
| 2123 | return 0; |
| 2124 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2125 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2126 | * 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] | 2127 | * @dev: class device that is converted into a Scsi_host. |
| 2128 | * @attr: device attribute, not used. |
| 2129 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2130 | * @count: must be size of lpfc_soft_wwn_key. |
| 2131 | * |
| 2132 | * Returns: |
| 2133 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2134 | * length of buf indicates success |
| 2135 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2136 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2137 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2138 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2139 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2140 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2141 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2142 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2143 | unsigned int cnt = count; |
| 2144 | |
| 2145 | /* |
| 2146 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2147 | * We require that the user write a specific key to enable |
| 2148 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2149 | * is written, the enable key resets. If further updates are |
| 2150 | * desired, the key must be written again to re-enable the |
| 2151 | * attribute. |
| 2152 | * |
| 2153 | * The "key" is not secret - it is a hardcoded string shown |
| 2154 | * here. The intent is to protect against the random user or |
| 2155 | * application that is just writing attributes. |
| 2156 | */ |
| 2157 | |
| 2158 | /* count may include a LF at end of string */ |
| 2159 | if (buf[cnt-1] == '\n') |
| 2160 | cnt--; |
| 2161 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2162 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2163 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2164 | return -EINVAL; |
| 2165 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2166 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2167 | return count; |
| 2168 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2169 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 2170 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2171 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2172 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2173 | * 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] | 2174 | * @dev: class device that is converted into a Scsi_host. |
| 2175 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2176 | * @buf: on return contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2177 | * |
| 2178 | * Returns: size of formatted string. |
| 2179 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2180 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2181 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2182 | char *buf) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2183 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2184 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2185 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2186 | struct lpfc_hba *phba = vport->phba; |
| 2187 | |
Randy Dunlap | afc071e | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 2188 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2189 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2190 | } |
| 2191 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2192 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2193 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2194 | * @dev class device that is converted into a Scsi_host. |
| 2195 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2196 | * @buf: contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2197 | * @count: number of wwpn bytes in buf |
| 2198 | * |
| 2199 | * Returns: |
| 2200 | * -EACCES hba reset not enabled, adapter over temp |
| 2201 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2202 | * -EIO error taking adapter offline or online |
| 2203 | * value of count on success |
| 2204 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2205 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2206 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2207 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2208 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2209 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2210 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2211 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2212 | struct completion online_compl; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2213 | int stat1 = 0, stat2 = 0; |
| 2214 | unsigned int cnt = count; |
| 2215 | u8 wwpn[WWN_SZ]; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2216 | int rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2217 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 2218 | if (!phba->cfg_enable_hba_reset) |
| 2219 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2220 | spin_lock_irq(&phba->hbalock); |
| 2221 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2222 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 2223 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 2224 | } |
| 2225 | spin_unlock_irq(&phba->hbalock); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2226 | /* count may include a LF at end of string */ |
| 2227 | if (buf[cnt-1] == '\n') |
| 2228 | cnt--; |
| 2229 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2230 | if (!phba->soft_wwn_enable) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2231 | return -EINVAL; |
| 2232 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2233 | /* lock setting wwpn, wwnn down */ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2234 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2235 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2236 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2237 | if (!rc) { |
| 2238 | /* not able to set wwpn, unlock it */ |
| 2239 | phba->soft_wwn_enable = 1; |
| 2240 | return rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2241 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2242 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2243 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2244 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2245 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2246 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2247 | |
| 2248 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2249 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2250 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 2251 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2252 | if (stat1) |
| 2253 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2254 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2255 | "reinit adapter - %d\n", stat1); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2256 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 2257 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2258 | LPFC_EVT_ONLINE); |
| 2259 | if (rc == 0) |
| 2260 | return -ENOMEM; |
| 2261 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2262 | wait_for_completion(&online_compl); |
| 2263 | if (stat2) |
| 2264 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2265 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2266 | "reinit adapter - %d\n", stat2); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2267 | return (stat1 || stat2) ? -EIO : count; |
| 2268 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2269 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2270 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2271 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2272 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2273 | * 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] | 2274 | * @dev: class device that is converted into a Scsi_host. |
| 2275 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2276 | * @buf: on return contains the wwnn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2277 | * |
| 2278 | * Returns: size of formatted string. |
| 2279 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2280 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2281 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2282 | char *buf) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2283 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2284 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2285 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2286 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2287 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2288 | } |
| 2289 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2290 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2291 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2292 | * @cdev: class device that is converted into a Scsi_host. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2293 | * @buf: contains the ww node name in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2294 | * @count: number of wwnn bytes in buf. |
| 2295 | * |
| 2296 | * Returns: |
| 2297 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2298 | * value of count on success |
| 2299 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2300 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2301 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2302 | const char *buf, size_t count) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2303 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2304 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2305 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2306 | unsigned int cnt = count; |
| 2307 | u8 wwnn[WWN_SZ]; |
| 2308 | int rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2309 | |
| 2310 | /* count may include a LF at end of string */ |
| 2311 | if (buf[cnt-1] == '\n') |
| 2312 | cnt--; |
| 2313 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2314 | if (!phba->soft_wwn_enable) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2315 | return -EINVAL; |
| 2316 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2317 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
| 2318 | if (!rc) { |
| 2319 | /* Allow wwnn to be set many times, as long as the enable |
| 2320 | * is set. However, once the wwpn is set, everything locks. |
| 2321 | */ |
| 2322 | return rc; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2323 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2324 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2325 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2326 | |
| 2327 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2328 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2329 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2330 | |
| 2331 | return count; |
| 2332 | } |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2333 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2334 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2335 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2336 | /** |
| 2337 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2338 | * Optimized Access Storage (OAS) operations. |
| 2339 | * @dev: class device that is converted into a Scsi_host. |
| 2340 | * @attr: device attribute, not used. |
| 2341 | * @buf: buffer for passing information. |
| 2342 | * |
| 2343 | * Returns: |
| 2344 | * value of count |
| 2345 | **/ |
| 2346 | static ssize_t |
| 2347 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2348 | char *buf) |
| 2349 | { |
| 2350 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2351 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2352 | |
| 2353 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2354 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2355 | } |
| 2356 | |
| 2357 | /** |
| 2358 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2359 | * Optimized Access Storage (OAS) operations. |
| 2360 | * @dev: class device that is converted into a Scsi_host. |
| 2361 | * @attr: device attribute, not used. |
| 2362 | * @buf: buffer for passing information. |
| 2363 | * @count: Size of the data buffer. |
| 2364 | * |
| 2365 | * Returns: |
| 2366 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2367 | * -EPERM oas is not supported by hba |
| 2368 | * value of count on success |
| 2369 | **/ |
| 2370 | static ssize_t |
| 2371 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2372 | const char *buf, size_t count) |
| 2373 | { |
| 2374 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2375 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2376 | unsigned int cnt = count; |
| 2377 | uint8_t wwpn[WWN_SZ]; |
| 2378 | int rc; |
| 2379 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2380 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2381 | return -EPERM; |
| 2382 | |
| 2383 | /* count may include a LF at end of string */ |
| 2384 | if (buf[cnt-1] == '\n') |
| 2385 | cnt--; |
| 2386 | |
| 2387 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2388 | if (rc) |
| 2389 | return rc; |
| 2390 | |
| 2391 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2392 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2393 | if (wwn_to_u64(wwpn) == 0) |
| 2394 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2395 | else |
| 2396 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2397 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2398 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2399 | return count; |
| 2400 | } |
| 2401 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2402 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2403 | |
| 2404 | /** |
| 2405 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2406 | * for Optimized Access Storage (OAS) operations. |
| 2407 | * @dev: class device that is converted into a Scsi_host. |
| 2408 | * @attr: device attribute, not used. |
| 2409 | * @buf: buffer for passing information. |
| 2410 | * |
| 2411 | * Returns: |
| 2412 | * value of count on success |
| 2413 | **/ |
| 2414 | static ssize_t |
| 2415 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2416 | char *buf) |
| 2417 | { |
| 2418 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2419 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2420 | |
| 2421 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2422 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2423 | } |
| 2424 | |
| 2425 | /** |
| 2426 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2427 | * for Optimized Access Storage (OAS) operations. |
| 2428 | * @dev: class device that is converted into a Scsi_host. |
| 2429 | * @attr: device attribute, not used. |
| 2430 | * @buf: buffer for passing information. |
| 2431 | * @count: Size of the data buffer. |
| 2432 | * |
| 2433 | * Returns: |
| 2434 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2435 | * -EPERM oas is not supported by hba |
| 2436 | * value of count on success |
| 2437 | **/ |
| 2438 | static ssize_t |
| 2439 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2440 | const char *buf, size_t count) |
| 2441 | { |
| 2442 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2443 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2444 | unsigned int cnt = count; |
| 2445 | uint8_t wwpn[WWN_SZ]; |
| 2446 | int rc; |
| 2447 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2448 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2449 | return -EPERM; |
| 2450 | |
| 2451 | /* count may include a LF at end of string */ |
| 2452 | if (buf[cnt-1] == '\n') |
| 2453 | cnt--; |
| 2454 | |
| 2455 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2456 | if (rc) |
| 2457 | return rc; |
| 2458 | |
| 2459 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2460 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2461 | if (wwn_to_u64(wwpn) == 0) |
| 2462 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2463 | else |
| 2464 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2465 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2466 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2467 | return count; |
| 2468 | } |
| 2469 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2470 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2471 | |
| 2472 | /** |
| 2473 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2474 | * of whether luns will be enabled or disabled |
| 2475 | * for Optimized Access Storage (OAS) operations. |
| 2476 | * @dev: class device that is converted into a Scsi_host. |
| 2477 | * @attr: device attribute, not used. |
| 2478 | * @buf: buffer for passing information. |
| 2479 | * |
| 2480 | * Returns: |
| 2481 | * size of formatted string. |
| 2482 | **/ |
| 2483 | static ssize_t |
| 2484 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2485 | char *buf) |
| 2486 | { |
| 2487 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2488 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2489 | |
| 2490 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2491 | } |
| 2492 | |
| 2493 | /** |
| 2494 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2495 | * of whether luns will be enabled or disabled |
| 2496 | * for Optimized Access Storage (OAS) operations. |
| 2497 | * @dev: class device that is converted into a Scsi_host. |
| 2498 | * @attr: device attribute, not used. |
| 2499 | * @buf: buffer for passing information. |
| 2500 | * @count: Size of the data buffer. |
| 2501 | * |
| 2502 | * Returns: |
| 2503 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2504 | * -EPERM oas is not supported by hba |
| 2505 | * value of count on success |
| 2506 | **/ |
| 2507 | static ssize_t |
| 2508 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2509 | const char *buf, size_t count) |
| 2510 | { |
| 2511 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2512 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2513 | int val = 0; |
| 2514 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2515 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2516 | return -EPERM; |
| 2517 | |
| 2518 | if (!isdigit(buf[0])) |
| 2519 | return -EINVAL; |
| 2520 | |
| 2521 | if (sscanf(buf, "%i", &val) != 1) |
| 2522 | return -EINVAL; |
| 2523 | |
| 2524 | if ((val != 0) && (val != 1)) |
| 2525 | return -EINVAL; |
| 2526 | |
| 2527 | phba->cfg_oas_lun_state = val; |
| 2528 | |
| 2529 | return strlen(buf); |
| 2530 | } |
| 2531 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2532 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2533 | |
| 2534 | /** |
| 2535 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2536 | * Storage (OAS) lun returned by the |
| 2537 | * lpfc_oas_lun_show function. |
| 2538 | * @dev: class device that is converted into a Scsi_host. |
| 2539 | * @attr: device attribute, not used. |
| 2540 | * @buf: buffer for passing information. |
| 2541 | * |
| 2542 | * Returns: |
| 2543 | * size of formatted string. |
| 2544 | **/ |
| 2545 | static ssize_t |
| 2546 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2547 | char *buf) |
| 2548 | { |
| 2549 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2550 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2551 | |
| 2552 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2553 | return -EFAULT; |
| 2554 | |
| 2555 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2556 | } |
| 2557 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2558 | lpfc_oas_lun_status_show, NULL); |
| 2559 | |
| 2560 | |
| 2561 | /** |
| 2562 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2563 | * (OAS) operations. |
| 2564 | * @phba: lpfc_hba pointer. |
| 2565 | * @ndlp: pointer to fcp target node. |
| 2566 | * @lun: the fc lun for setting oas state. |
| 2567 | * @oas_state: the oas state to be set to the lun. |
| 2568 | * |
| 2569 | * Returns: |
| 2570 | * SUCCESS : 0 |
| 2571 | * -EPERM OAS is not enabled or not supported by this port. |
| 2572 | * |
| 2573 | */ |
| 2574 | static size_t |
| 2575 | lpfc_oas_lun_state_set(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2576 | uint8_t tgt_wwpn[], uint64_t lun, uint32_t oas_state) |
| 2577 | { |
| 2578 | |
| 2579 | int rc = 0; |
| 2580 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2581 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2582 | return -EPERM; |
| 2583 | |
| 2584 | if (oas_state) { |
| 2585 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
| 2586 | (struct lpfc_name *)tgt_wwpn, lun)) |
| 2587 | rc = -ENOMEM; |
| 2588 | } else { |
| 2589 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
| 2590 | (struct lpfc_name *)tgt_wwpn, lun); |
| 2591 | } |
| 2592 | return rc; |
| 2593 | |
| 2594 | } |
| 2595 | |
| 2596 | /** |
| 2597 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2598 | * Access Storage (OAS) operations. |
| 2599 | * @phba: lpfc_hba pointer. |
| 2600 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2601 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2602 | * @lun_status: status of the lun returned lun |
| 2603 | * |
| 2604 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2605 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2606 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2607 | * |
| 2608 | * Return: |
| 2609 | * lun that is OAS enabled for the vport/target |
| 2610 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2611 | */ |
| 2612 | static uint64_t |
| 2613 | lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2614 | uint8_t tgt_wwpn[], uint32_t *lun_status) |
| 2615 | { |
| 2616 | uint64_t found_lun; |
| 2617 | |
| 2618 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2619 | return NOT_OAS_ENABLED_LUN; |
| 2620 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2621 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2622 | (struct lpfc_name *) |
| 2623 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2624 | &phba->sli4_hba.oas_next_lun, |
| 2625 | (struct lpfc_name *)vpt_wwpn, |
| 2626 | (struct lpfc_name *)tgt_wwpn, |
| 2627 | &found_lun, lun_status)) |
| 2628 | return found_lun; |
| 2629 | else |
| 2630 | return NOT_OAS_ENABLED_LUN; |
| 2631 | } |
| 2632 | |
| 2633 | /** |
| 2634 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2635 | * @phba: lpfc_hba pointer. |
| 2636 | * @vpt_wwpn: vport wwpn by reference. |
| 2637 | * @tgt_wwpn: target wwpn by reference. |
| 2638 | * @lun: the fc lun for setting oas state. |
| 2639 | * @oas_state: the oas state to be set to the oas_lun. |
| 2640 | * |
| 2641 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2642 | * a lun for OAS operations. |
| 2643 | * |
| 2644 | * Return: |
| 2645 | * SUCCESS: 0 |
| 2646 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2647 | * -EPERM: OAS is not enabled |
| 2648 | */ |
| 2649 | static ssize_t |
| 2650 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2651 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2652 | uint32_t oas_state) |
| 2653 | { |
| 2654 | |
| 2655 | int rc; |
| 2656 | |
| 2657 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
| 2658 | oas_state); |
| 2659 | return rc; |
| 2660 | } |
| 2661 | |
| 2662 | /** |
| 2663 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2664 | * @dev: class device that is converted into a Scsi_host. |
| 2665 | * @attr: device attribute, not used. |
| 2666 | * @buf: buffer for passing information. |
| 2667 | * |
| 2668 | * This routine returns a lun enabled for OAS each time the function |
| 2669 | * is called. |
| 2670 | * |
| 2671 | * Returns: |
| 2672 | * SUCCESS: size of formatted string. |
| 2673 | * -EFAULT: target or vport wwpn was not set properly. |
| 2674 | * -EPERM: oas is not enabled. |
| 2675 | **/ |
| 2676 | static ssize_t |
| 2677 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 2678 | char *buf) |
| 2679 | { |
| 2680 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2681 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2682 | |
| 2683 | uint64_t oas_lun; |
| 2684 | int len = 0; |
| 2685 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2686 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2687 | return -EPERM; |
| 2688 | |
| 2689 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2690 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 2691 | return -EFAULT; |
| 2692 | |
| 2693 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2694 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 2695 | return -EFAULT; |
| 2696 | |
| 2697 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 2698 | phba->cfg_oas_tgt_wwpn, |
| 2699 | &phba->cfg_oas_lun_status); |
| 2700 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 2701 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 2702 | |
| 2703 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 2704 | |
| 2705 | return len; |
| 2706 | } |
| 2707 | |
| 2708 | /** |
| 2709 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 2710 | * @dev: class device that is converted into a Scsi_host. |
| 2711 | * @attr: device attribute, not used. |
| 2712 | * @buf: buffer for passing information. |
| 2713 | * |
| 2714 | * This function sets the OAS state for lun. Before this function is called, |
| 2715 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 2716 | * |
| 2717 | * Returns: |
| 2718 | * SUCCESS: size of formatted string. |
| 2719 | * -EFAULT: target or vport wwpn was not set properly. |
| 2720 | * -EPERM: oas is not enabled. |
| 2721 | * size of formatted string. |
| 2722 | **/ |
| 2723 | static ssize_t |
| 2724 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 2725 | const char *buf, size_t count) |
| 2726 | { |
| 2727 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2728 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2729 | uint64_t scsi_lun; |
| 2730 | ssize_t rc; |
| 2731 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2732 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2733 | return -EPERM; |
| 2734 | |
| 2735 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2736 | return -EFAULT; |
| 2737 | |
| 2738 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2739 | return -EFAULT; |
| 2740 | |
| 2741 | if (!isdigit(buf[0])) |
| 2742 | return -EINVAL; |
| 2743 | |
| 2744 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 2745 | return -EINVAL; |
| 2746 | |
| 2747 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 2748 | "3372 Try to set vport 0x%llx target 0x%llx lun:%lld " |
| 2749 | "with oas set to %d\n", |
| 2750 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 2751 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
| 2752 | phba->cfg_oas_lun_state); |
| 2753 | |
| 2754 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
| 2755 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
| 2756 | phba->cfg_oas_lun_state); |
| 2757 | |
| 2758 | if (rc) |
| 2759 | return rc; |
| 2760 | |
| 2761 | return count; |
| 2762 | } |
| 2763 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 2764 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2765 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2766 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2767 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2768 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 2769 | " 0 - none," |
| 2770 | " 1 - poll with interrupts enabled" |
| 2771 | " 3 - poll and disable FCP ring interrupts"); |
| 2772 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2773 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 2774 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2775 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2776 | int lpfc_sli_mode = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2777 | module_param(lpfc_sli_mode, int, S_IRUGO); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2778 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" |
| 2779 | " 0 - auto (SLI-3 if supported)," |
| 2780 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 2781 | " 3 - select SLI-3"); |
| 2782 | |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2783 | int lpfc_enable_npiv = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2784 | module_param(lpfc_enable_npiv, int, S_IRUGO); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 2785 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); |
| 2786 | lpfc_param_show(enable_npiv); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 2787 | lpfc_param_init(enable_npiv, 1, 0, 1); |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2788 | static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, lpfc_enable_npiv_show, NULL); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2789 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 2790 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 2791 | "FCF Fast failover=1 Priority failover=2"); |
| 2792 | |
James Smart | c14e995 | 2013-03-01 16:38:01 -0500 | [diff] [blame] | 2793 | int lpfc_enable_rrq = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2794 | module_param(lpfc_enable_rrq, int, S_IRUGO); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2795 | MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality"); |
| 2796 | lpfc_param_show(enable_rrq); |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 2797 | /* |
| 2798 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 2799 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 2800 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 2801 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 2802 | */ |
| 2803 | lpfc_param_init(enable_rrq, 2, 0, 2); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2804 | static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL); |
| 2805 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2806 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2807 | # lpfc_suppress_link_up: Bring link up at initialization |
| 2808 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 2809 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 2810 | # 0x2 = never bring up link |
| 2811 | # Default value is 0. |
| 2812 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2813 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 2814 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 2815 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2816 | /* |
| 2817 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 2818 | # 1 - (1024) |
| 2819 | # 2 - (2048) |
| 2820 | # 3 - (3072) |
| 2821 | # 4 - (4096) |
| 2822 | # 5 - (5120) |
| 2823 | */ |
| 2824 | static ssize_t |
| 2825 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2826 | { |
| 2827 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2828 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2829 | |
| 2830 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 2831 | } |
| 2832 | |
| 2833 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 2834 | lpfc_iocb_hw_show, NULL); |
| 2835 | static ssize_t |
| 2836 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2837 | { |
| 2838 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2839 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2840 | |
| 2841 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2842 | phba->sli.ring[LPFC_ELS_RING].txq_max); |
| 2843 | } |
| 2844 | |
| 2845 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 2846 | lpfc_txq_hw_show, NULL); |
| 2847 | static ssize_t |
| 2848 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 2849 | char *buf) |
| 2850 | { |
| 2851 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2852 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2853 | |
| 2854 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2855 | phba->sli.ring[LPFC_ELS_RING].txcmplq_max); |
| 2856 | } |
| 2857 | |
| 2858 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 2859 | lpfc_txcmplq_hw_show, NULL); |
| 2860 | |
| 2861 | int lpfc_iocb_cnt = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2862 | module_param(lpfc_iocb_cnt, int, S_IRUGO); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2863 | MODULE_PARM_DESC(lpfc_iocb_cnt, |
| 2864 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
| 2865 | lpfc_param_show(iocb_cnt); |
| 2866 | lpfc_param_init(iocb_cnt, 2, 1, 5); |
| 2867 | static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO, |
| 2868 | lpfc_iocb_cnt_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2869 | |
| 2870 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2871 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 2872 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 2873 | */ |
| 2874 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2875 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2876 | module_param(lpfc_nodev_tmo, int, 0); |
| 2877 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 2878 | "Seconds driver will hold I/O waiting " |
| 2879 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2880 | |
| 2881 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2882 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2883 | * @dev: class converted to a Scsi_host structure. |
| 2884 | * @attr: device attribute, not used. |
| 2885 | * @buf: on return contains the dev loss timeout in decimal. |
| 2886 | * |
| 2887 | * Returns: size of formatted string. |
| 2888 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2889 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2890 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 2891 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2892 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2893 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2894 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2895 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2896 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2897 | } |
| 2898 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2899 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2900 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2901 | * @vport: lpfc vport structure pointer. |
| 2902 | * @val: contains the nodev timeout value. |
| 2903 | * |
| 2904 | * Description: |
| 2905 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 2906 | * a kernel error message is printed and zero is returned. |
| 2907 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2908 | * Otherwise nodev tmo is set to the default value. |
| 2909 | * |
| 2910 | * Returns: |
| 2911 | * zero if already set or if val is in range |
| 2912 | * -EINVAL val out of range |
| 2913 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2914 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2915 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2916 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2917 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 2918 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 2919 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2920 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2921 | "0407 Ignoring nodev_tmo module " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2922 | "parameter because devloss_tmo is " |
| 2923 | "set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2924 | return 0; |
| 2925 | } |
| 2926 | |
| 2927 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2928 | vport->cfg_nodev_tmo = val; |
| 2929 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2930 | return 0; |
| 2931 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2932 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2933 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 2934 | " %d, allowed range is [%d, %d]\n", |
| 2935 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2936 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2937 | return -EINVAL; |
| 2938 | } |
| 2939 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2940 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2941 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2942 | * @vport: lpfc vport structure pointer. |
| 2943 | * |
| 2944 | * Description: |
| 2945 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 2946 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2947 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2948 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2949 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2950 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2951 | struct lpfc_nodelist *ndlp; |
| 2952 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2953 | shost = lpfc_shost_from_vport(vport); |
| 2954 | spin_lock_irq(shost->host_lock); |
| 2955 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2956 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2957 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 2958 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2959 | } |
| 2960 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2961 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2962 | * 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] | 2963 | * @vport: lpfc vport structure pointer. |
| 2964 | * @val: contains the tmo value. |
| 2965 | * |
| 2966 | * Description: |
| 2967 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 2968 | * then a kernel error message is printed and zero is returned. |
| 2969 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2970 | * Otherwise nodev tmo is set to the default value. |
| 2971 | * |
| 2972 | * Returns: |
| 2973 | * zero if already set or if val is in range |
| 2974 | * -EINVAL val out of range |
| 2975 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2976 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2977 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2978 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2979 | if (vport->dev_loss_tmo_changed || |
| 2980 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2981 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2982 | "0401 Ignoring change to nodev_tmo " |
| 2983 | "because devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2984 | return 0; |
| 2985 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2986 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2987 | vport->cfg_nodev_tmo = val; |
| 2988 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2989 | /* |
| 2990 | * For compat: set the fc_host dev loss so new rports |
| 2991 | * will get the value. |
| 2992 | */ |
| 2993 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2994 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2995 | return 0; |
| 2996 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2997 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2998 | "0403 lpfc_nodev_tmo attribute cannot be set to" |
| 2999 | "%d, allowed range is [%d, %d]\n", |
| 3000 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3001 | return -EINVAL; |
| 3002 | } |
| 3003 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3004 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3005 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3006 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 3007 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3008 | |
| 3009 | /* |
| 3010 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3011 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3012 | # value is 30. |
| 3013 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3014 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3015 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3016 | "Seconds driver will hold I/O waiting " |
| 3017 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3018 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3019 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3020 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3021 | |
| 3022 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3023 | * 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] | 3024 | * @vport: lpfc vport structure pointer. |
| 3025 | * @val: contains the tmo value. |
| 3026 | * |
| 3027 | * Description: |
| 3028 | * If val is in a valid range then set the vport nodev tmo, |
| 3029 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3030 | * Else a kernel error message is printed. |
| 3031 | * |
| 3032 | * Returns: |
| 3033 | * zero 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_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3038 | { |
| 3039 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3040 | vport->cfg_nodev_tmo = val; |
| 3041 | vport->cfg_devloss_tmo = val; |
| 3042 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3043 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3044 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3045 | return 0; |
| 3046 | } |
| 3047 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3048 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3049 | "0404 lpfc_devloss_tmo attribute cannot be set to" |
| 3050 | " %d, allowed range is [%d, %d]\n", |
| 3051 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3052 | return -EINVAL; |
| 3053 | } |
| 3054 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3055 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3056 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 3057 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3058 | |
| 3059 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3060 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3061 | # deluged with LOTS of information. |
| 3062 | # 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] | 3063 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3064 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3065 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3066 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3067 | |
| 3068 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3069 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3070 | # objects that have been registered with the nameserver after login. |
| 3071 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3072 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3073 | "Deregister nameserver objects before LOGO"); |
| 3074 | |
| 3075 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3076 | # 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] | 3077 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3078 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3079 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3080 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3081 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3082 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3083 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3084 | |
| 3085 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3086 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3087 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3088 | */ |
| 3089 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3090 | "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] | 3091 | |
| 3092 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3093 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3094 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3095 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3096 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3097 | # the hba_queue_depth. |
| 3098 | */ |
| 3099 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3100 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3101 | |
| 3102 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3103 | # peer_port_login: This parameter allows/prevents logins |
| 3104 | # between peer ports hosted on the same physical port. |
| 3105 | # When this parameter is set 0 peer ports of same physical port |
| 3106 | # are not allowed to login to each other. |
| 3107 | # When this parameter is set 1 peer ports of same physical port |
| 3108 | # are allowed to login to each other. |
| 3109 | # Default value of this parameter is 0. |
| 3110 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3111 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3112 | "Allow peer ports on the same physical port to login to each " |
| 3113 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3114 | |
| 3115 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3116 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3117 | # between Virtual Ports and remote initiators. |
| 3118 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3119 | # other initiators and will attempt to PLOGI all remote ports. |
| 3120 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3121 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3122 | # This parameter does not restrict to the physical port. |
| 3123 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3124 | # Default value of this parameter is 1. |
| 3125 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3126 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3127 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3128 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3129 | "Restrict virtual ports login to remote initiators."); |
| 3130 | lpfc_vport_param_show(restrict_login); |
| 3131 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3132 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3133 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3134 | * @vport: lpfc vport structure pointer. |
| 3135 | * @val: contains the restrict login value. |
| 3136 | * |
| 3137 | * Description: |
| 3138 | * If val is not in a valid range then log a kernel error message and set |
| 3139 | * the vport restrict login to one. |
| 3140 | * If the port type is physical clear the restrict login flag and return. |
| 3141 | * Else set the restrict login flag to val. |
| 3142 | * |
| 3143 | * Returns: |
| 3144 | * zero if val is in range |
| 3145 | * -EINVAL val out of range |
| 3146 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3147 | static int |
| 3148 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3149 | { |
| 3150 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3151 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3152 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3153 | "be set to %d, allowed range is [0, 1]\n", |
| 3154 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3155 | vport->cfg_restrict_login = 1; |
| 3156 | return -EINVAL; |
| 3157 | } |
| 3158 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3159 | vport->cfg_restrict_login = 0; |
| 3160 | return 0; |
| 3161 | } |
| 3162 | vport->cfg_restrict_login = val; |
| 3163 | return 0; |
| 3164 | } |
| 3165 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3166 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3167 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3168 | * @vport: lpfc vport structure pointer. |
| 3169 | * @val: contains the restrict login value. |
| 3170 | * |
| 3171 | * Description: |
| 3172 | * If val is not in a valid range then log a kernel error message and set |
| 3173 | * the vport restrict login to one. |
| 3174 | * If the port type is physical and the val is not zero log a kernel |
| 3175 | * error message, clear the restrict login flag and return zero. |
| 3176 | * Else set the restrict login flag to val. |
| 3177 | * |
| 3178 | * Returns: |
| 3179 | * zero if val is in range |
| 3180 | * -EINVAL val out of range |
| 3181 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3182 | static int |
| 3183 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3184 | { |
| 3185 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3186 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3187 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3188 | "be set to %d, allowed range is [0, 1]\n", |
| 3189 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3190 | vport->cfg_restrict_login = 1; |
| 3191 | return -EINVAL; |
| 3192 | } |
| 3193 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3194 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3195 | "0468 lpfc_restrict_login must be 0 for " |
| 3196 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3197 | vport->cfg_restrict_login = 0; |
| 3198 | return 0; |
| 3199 | } |
| 3200 | vport->cfg_restrict_login = val; |
| 3201 | return 0; |
| 3202 | } |
| 3203 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3204 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 3205 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3206 | |
| 3207 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3208 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3209 | # From a protocol standpoint "select ID" usually means select the |
| 3210 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3211 | # annex" which contains a table that maps a "select ID" (a number |
| 3212 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3213 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3214 | # ALPA. |
| 3215 | # |
| 3216 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3217 | # cause the lpfc driver to use an inverted table, effectively |
| 3218 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3219 | # |
| 3220 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3221 | # and will not work across a fabric. Also this parameter will take |
| 3222 | # effect only in the case when ALPA map is not available.) |
| 3223 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3224 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3225 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3226 | |
| 3227 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3228 | # lpfc_topology: link topology for init link |
| 3229 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3230 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3231 | # 0x02 = attempt point-to-point mode only |
| 3232 | # 0x04 = attempt loop mode only |
| 3233 | # 0x06 = attempt point-to-point mode then loop |
| 3234 | # Set point-to-point mode if you want to run as an N_Port. |
| 3235 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3236 | # Default value is 0. |
| 3237 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3238 | |
| 3239 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3240 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3241 | * @phba: lpfc_hba pointer. |
| 3242 | * @val: topology value. |
| 3243 | * |
| 3244 | * Description: |
| 3245 | * If val is in a valid range then set the adapter's topology field and |
| 3246 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3247 | * |
| 3248 | * If the value is not in range log a kernel error message and return an error. |
| 3249 | * |
| 3250 | * Returns: |
| 3251 | * zero if val is in range and lip okay |
| 3252 | * non-zero return value from lpfc_issue_lip() |
| 3253 | * -EINVAL val out of range |
| 3254 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3255 | static ssize_t |
| 3256 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3257 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3258 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3259 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3260 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3261 | struct lpfc_hba *phba = vport->phba; |
| 3262 | int val = 0; |
| 3263 | int nolip = 0; |
| 3264 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3265 | int err; |
| 3266 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3267 | |
| 3268 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3269 | nolip = 1; |
| 3270 | val_buf = &buf[strlen("nolip ")]; |
| 3271 | } |
| 3272 | |
| 3273 | if (!isdigit(val_buf[0])) |
| 3274 | return -EINVAL; |
| 3275 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3276 | return -EINVAL; |
| 3277 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3278 | if (val >= 0 && val <= 6) { |
| 3279 | prev_val = phba->cfg_topology; |
| 3280 | phba->cfg_topology = val; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3281 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3282 | val == 4) { |
| 3283 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3284 | "3113 Loop mode not supported at speed %d\n", |
| 3285 | phba->cfg_link_speed); |
| 3286 | phba->cfg_topology = prev_val; |
| 3287 | return -EINVAL; |
| 3288 | } |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3289 | if (nolip) |
| 3290 | return strlen(buf); |
| 3291 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3292 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3293 | "3054 lpfc_topology changed from %d to %d\n", |
| 3294 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3295 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3296 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3297 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3298 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3299 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3300 | return -EINVAL; |
| 3301 | } else |
| 3302 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3303 | } |
| 3304 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3305 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3306 | "allowed range is [0, 6]\n", |
| 3307 | phba->brd_no, val); |
| 3308 | return -EINVAL; |
| 3309 | } |
| 3310 | static int lpfc_topology = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3311 | module_param(lpfc_topology, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3312 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
| 3313 | lpfc_param_show(topology) |
| 3314 | lpfc_param_init(topology, 0, 0, 6) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3315 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3316 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3317 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3318 | /** |
| 3319 | * lpfc_static_vport_show: Read callback function for |
| 3320 | * lpfc_static_vport sysfs file. |
| 3321 | * @dev: Pointer to class device object. |
| 3322 | * @attr: device attribute structure. |
| 3323 | * @buf: Data buffer. |
| 3324 | * |
| 3325 | * This function is the read call back function for |
| 3326 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3327 | * sysfs file report the mageability of the vport. |
| 3328 | **/ |
| 3329 | static ssize_t |
| 3330 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3331 | char *buf) |
| 3332 | { |
| 3333 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3334 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3335 | if (vport->vport_flag & STATIC_VPORT) |
| 3336 | sprintf(buf, "1\n"); |
| 3337 | else |
| 3338 | sprintf(buf, "0\n"); |
| 3339 | |
| 3340 | return strlen(buf); |
| 3341 | } |
| 3342 | |
| 3343 | /* |
| 3344 | * Sysfs attribute to control the statistical data collection. |
| 3345 | */ |
| 3346 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 3347 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3348 | |
| 3349 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3350 | * 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] | 3351 | * @dev: Pointer to class device. |
| 3352 | * @buf: Data buffer. |
| 3353 | * @count: Size of the data buffer. |
| 3354 | * |
| 3355 | * This function get called when an user write to the lpfc_stat_data_ctrl |
| 3356 | * sysfs file. This function parse the command written to the sysfs file |
| 3357 | * and take appropriate action. These commands are used for controlling |
| 3358 | * driver statistical data collection. |
| 3359 | * Following are the command this function handles. |
| 3360 | * |
| 3361 | * setbucket <bucket_type> <base> <step> |
| 3362 | * = Set the latency buckets. |
| 3363 | * destroybucket = destroy all the buckets. |
| 3364 | * start = start data collection |
| 3365 | * stop = stop data collection |
| 3366 | * reset = reset the collected data |
| 3367 | **/ |
| 3368 | static ssize_t |
| 3369 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3370 | const char *buf, size_t count) |
| 3371 | { |
| 3372 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3373 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3374 | struct lpfc_hba *phba = vport->phba; |
| 3375 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3376 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3377 | unsigned long i; |
| 3378 | char *str_ptr, *token; |
| 3379 | struct lpfc_vport **vports; |
| 3380 | struct Scsi_Host *v_shost; |
| 3381 | char *bucket_type_str, *base_str, *step_str; |
| 3382 | unsigned long base, step, bucket_type; |
| 3383 | |
| 3384 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3385 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3386 | return -EINVAL; |
| 3387 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame^] | 3388 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3389 | str_ptr = &bucket_data[0]; |
| 3390 | /* Ignore this token - this is command token */ |
| 3391 | token = strsep(&str_ptr, "\t "); |
| 3392 | if (!token) |
| 3393 | return -EINVAL; |
| 3394 | |
| 3395 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3396 | if (!bucket_type_str) |
| 3397 | return -EINVAL; |
| 3398 | |
| 3399 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3400 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3401 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3402 | bucket_type = LPFC_POWER2_BUCKET; |
| 3403 | else |
| 3404 | return -EINVAL; |
| 3405 | |
| 3406 | base_str = strsep(&str_ptr, "\t "); |
| 3407 | if (!base_str) |
| 3408 | return -EINVAL; |
| 3409 | base = simple_strtoul(base_str, NULL, 0); |
| 3410 | |
| 3411 | step_str = strsep(&str_ptr, "\t "); |
| 3412 | if (!step_str) |
| 3413 | return -EINVAL; |
| 3414 | step = simple_strtoul(step_str, NULL, 0); |
| 3415 | if (!step) |
| 3416 | return -EINVAL; |
| 3417 | |
| 3418 | /* Block the data collection for every vport */ |
| 3419 | vports = lpfc_create_vport_work_array(phba); |
| 3420 | if (vports == NULL) |
| 3421 | return -ENOMEM; |
| 3422 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3423 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3424 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3425 | spin_lock_irq(v_shost->host_lock); |
| 3426 | /* Block and reset data collection */ |
| 3427 | vports[i]->stat_data_blocked = 1; |
| 3428 | if (vports[i]->stat_data_enabled) |
| 3429 | lpfc_vport_reset_stat_data(vports[i]); |
| 3430 | spin_unlock_irq(v_shost->host_lock); |
| 3431 | } |
| 3432 | |
| 3433 | /* Set the bucket attributes */ |
| 3434 | phba->bucket_type = bucket_type; |
| 3435 | phba->bucket_base = base; |
| 3436 | phba->bucket_step = step; |
| 3437 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3438 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3439 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3440 | |
| 3441 | /* Unblock data collection */ |
| 3442 | spin_lock_irq(v_shost->host_lock); |
| 3443 | vports[i]->stat_data_blocked = 0; |
| 3444 | spin_unlock_irq(v_shost->host_lock); |
| 3445 | } |
| 3446 | lpfc_destroy_vport_work_array(phba, vports); |
| 3447 | return strlen(buf); |
| 3448 | } |
| 3449 | |
| 3450 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3451 | vports = lpfc_create_vport_work_array(phba); |
| 3452 | if (vports == NULL) |
| 3453 | return -ENOMEM; |
| 3454 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3455 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3456 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3457 | spin_lock_irq(shost->host_lock); |
| 3458 | vports[i]->stat_data_blocked = 1; |
| 3459 | lpfc_free_bucket(vport); |
| 3460 | vport->stat_data_enabled = 0; |
| 3461 | vports[i]->stat_data_blocked = 0; |
| 3462 | spin_unlock_irq(shost->host_lock); |
| 3463 | } |
| 3464 | lpfc_destroy_vport_work_array(phba, vports); |
| 3465 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3466 | phba->bucket_base = 0; |
| 3467 | phba->bucket_step = 0; |
| 3468 | return strlen(buf); |
| 3469 | } |
| 3470 | |
| 3471 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3472 | /* If no buckets configured return error */ |
| 3473 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3474 | return -EINVAL; |
| 3475 | spin_lock_irq(shost->host_lock); |
| 3476 | if (vport->stat_data_enabled) { |
| 3477 | spin_unlock_irq(shost->host_lock); |
| 3478 | return strlen(buf); |
| 3479 | } |
| 3480 | lpfc_alloc_bucket(vport); |
| 3481 | vport->stat_data_enabled = 1; |
| 3482 | spin_unlock_irq(shost->host_lock); |
| 3483 | return strlen(buf); |
| 3484 | } |
| 3485 | |
| 3486 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3487 | spin_lock_irq(shost->host_lock); |
| 3488 | if (vport->stat_data_enabled == 0) { |
| 3489 | spin_unlock_irq(shost->host_lock); |
| 3490 | return strlen(buf); |
| 3491 | } |
| 3492 | lpfc_free_bucket(vport); |
| 3493 | vport->stat_data_enabled = 0; |
| 3494 | spin_unlock_irq(shost->host_lock); |
| 3495 | return strlen(buf); |
| 3496 | } |
| 3497 | |
| 3498 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3499 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3500 | || !vport->stat_data_enabled) |
| 3501 | return strlen(buf); |
| 3502 | spin_lock_irq(shost->host_lock); |
| 3503 | vport->stat_data_blocked = 1; |
| 3504 | lpfc_vport_reset_stat_data(vport); |
| 3505 | vport->stat_data_blocked = 0; |
| 3506 | spin_unlock_irq(shost->host_lock); |
| 3507 | return strlen(buf); |
| 3508 | } |
| 3509 | return -EINVAL; |
| 3510 | } |
| 3511 | |
| 3512 | |
| 3513 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3514 | * 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] | 3515 | * @dev: Pointer to class device object. |
| 3516 | * @buf: Data buffer. |
| 3517 | * |
| 3518 | * This function is the read call back function for |
| 3519 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3520 | * current statistical data collection state. |
| 3521 | **/ |
| 3522 | static ssize_t |
| 3523 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3524 | char *buf) |
| 3525 | { |
| 3526 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3527 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3528 | struct lpfc_hba *phba = vport->phba; |
| 3529 | int index = 0; |
| 3530 | int i; |
| 3531 | char *bucket_type; |
| 3532 | unsigned long bucket_value; |
| 3533 | |
| 3534 | switch (phba->bucket_type) { |
| 3535 | case LPFC_LINEAR_BUCKET: |
| 3536 | bucket_type = "linear"; |
| 3537 | break; |
| 3538 | case LPFC_POWER2_BUCKET: |
| 3539 | bucket_type = "power2"; |
| 3540 | break; |
| 3541 | default: |
| 3542 | bucket_type = "No Bucket"; |
| 3543 | break; |
| 3544 | } |
| 3545 | |
| 3546 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3547 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3548 | " Bucket step :%d\nLatency Ranges :", |
| 3549 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3550 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3551 | index = strlen(buf); |
| 3552 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3553 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3554 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3555 | bucket_value = phba->bucket_base + |
| 3556 | phba->bucket_step * i; |
| 3557 | else |
| 3558 | bucket_value = phba->bucket_base + |
| 3559 | (1 << i) * phba->bucket_step; |
| 3560 | |
| 3561 | if (index + 10 > PAGE_SIZE) |
| 3562 | break; |
| 3563 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3564 | index = strlen(buf); |
| 3565 | } |
| 3566 | } |
| 3567 | sprintf(&buf[index], "\n"); |
| 3568 | return strlen(buf); |
| 3569 | } |
| 3570 | |
| 3571 | /* |
| 3572 | * Sysfs attribute to control the statistical data collection. |
| 3573 | */ |
| 3574 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 3575 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 3576 | |
| 3577 | /* |
| 3578 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3579 | */ |
| 3580 | |
| 3581 | /* |
| 3582 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3583 | * for each target. |
| 3584 | */ |
| 3585 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3586 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3587 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3588 | |
| 3589 | |
| 3590 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3591 | * 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] | 3592 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3593 | * @kobj: Pointer to the kernel object |
| 3594 | * @bin_attr: Attribute object |
| 3595 | * @buff: Buffer pointer |
| 3596 | * @off: File offset |
| 3597 | * @count: Buffer size |
| 3598 | * |
| 3599 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3600 | * sysfs file. This function export the statistical data to user |
| 3601 | * applications. |
| 3602 | **/ |
| 3603 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3604 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3605 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3606 | char *buf, loff_t off, size_t count) |
| 3607 | { |
| 3608 | struct device *dev = container_of(kobj, struct device, |
| 3609 | kobj); |
| 3610 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3611 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3612 | struct lpfc_hba *phba = vport->phba; |
| 3613 | int i = 0, index = 0; |
| 3614 | unsigned long nport_index; |
| 3615 | struct lpfc_nodelist *ndlp = NULL; |
| 3616 | nport_index = (unsigned long)off / |
| 3617 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3618 | |
| 3619 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3620 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3621 | return 0; |
| 3622 | |
| 3623 | spin_lock_irq(shost->host_lock); |
| 3624 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3625 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 3626 | continue; |
| 3627 | |
| 3628 | if (nport_index > 0) { |
| 3629 | nport_index--; |
| 3630 | continue; |
| 3631 | } |
| 3632 | |
| 3633 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 3634 | > count) |
| 3635 | break; |
| 3636 | |
| 3637 | if (!ndlp->lat_data) |
| 3638 | continue; |
| 3639 | |
| 3640 | /* Print the WWN */ |
| 3641 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 3642 | ndlp->nlp_portname.u.wwn[0], |
| 3643 | ndlp->nlp_portname.u.wwn[1], |
| 3644 | ndlp->nlp_portname.u.wwn[2], |
| 3645 | ndlp->nlp_portname.u.wwn[3], |
| 3646 | ndlp->nlp_portname.u.wwn[4], |
| 3647 | ndlp->nlp_portname.u.wwn[5], |
| 3648 | ndlp->nlp_portname.u.wwn[6], |
| 3649 | ndlp->nlp_portname.u.wwn[7]); |
| 3650 | |
| 3651 | index = strlen(buf); |
| 3652 | |
| 3653 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3654 | sprintf(&buf[index], "%010u,", |
| 3655 | ndlp->lat_data[i].cmd_count); |
| 3656 | index = strlen(buf); |
| 3657 | } |
| 3658 | sprintf(&buf[index], "\n"); |
| 3659 | index = strlen(buf); |
| 3660 | } |
| 3661 | spin_unlock_irq(shost->host_lock); |
| 3662 | return index; |
| 3663 | } |
| 3664 | |
| 3665 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 3666 | .attr = { |
| 3667 | .name = "lpfc_drvr_stat_data", |
| 3668 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3669 | }, |
| 3670 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 3671 | .read = sysfs_drvr_stat_data_read, |
| 3672 | .write = NULL, |
| 3673 | }; |
| 3674 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3675 | /* |
| 3676 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 3677 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3678 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3679 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3680 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3681 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3682 | * @phba: lpfc_hba pointer. |
| 3683 | * @val: link speed value. |
| 3684 | * |
| 3685 | * Description: |
| 3686 | * If val is in a valid range then set the adapter's link speed field and |
| 3687 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 3688 | * |
| 3689 | * Notes: |
| 3690 | * If the value is not in range log a kernel error message and return an error. |
| 3691 | * |
| 3692 | * Returns: |
| 3693 | * zero if val is in range and lip okay. |
| 3694 | * non-zero return value from lpfc_issue_lip() |
| 3695 | * -EINVAL val out of range |
| 3696 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3697 | static ssize_t |
| 3698 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 3699 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3700 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3701 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3702 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3703 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3704 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3705 | int nolip = 0; |
| 3706 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3707 | int err; |
| 3708 | uint32_t prev_val; |
| 3709 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3710 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3711 | nolip = 1; |
| 3712 | val_buf = &buf[strlen("nolip ")]; |
| 3713 | } |
| 3714 | |
| 3715 | if (!isdigit(val_buf[0])) |
| 3716 | return -EINVAL; |
| 3717 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3718 | return -EINVAL; |
| 3719 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3720 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3721 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 3722 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 3723 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3724 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 3725 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 3726 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 3727 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 3728 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
| 3729 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb))) { |
| 3730 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3731 | "2879 lpfc_link_speed attribute cannot be set " |
| 3732 | "to %d. Speed is not supported by this port.\n", |
| 3733 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3734 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3735 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3736 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 3737 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 3738 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3739 | "3112 lpfc_link_speed attribute cannot be set " |
| 3740 | "to %d. Speed is not supported in loop mode.\n", |
| 3741 | val); |
| 3742 | return -EINVAL; |
| 3743 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3744 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3745 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3746 | prev_val = phba->cfg_link_speed; |
| 3747 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3748 | if (nolip) |
| 3749 | return strlen(buf); |
| 3750 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3751 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3752 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3753 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3754 | return -EINVAL; |
| 3755 | } else |
| 3756 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3757 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3758 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3759 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 3760 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3761 | return -EINVAL; |
| 3762 | } |
| 3763 | |
| 3764 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3765 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3766 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 3767 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3768 | |
| 3769 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3770 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3771 | * @phba: lpfc_hba pointer. |
| 3772 | * @val: link speed value. |
| 3773 | * |
| 3774 | * Description: |
| 3775 | * If val is in a valid range then set the adapter's link speed field. |
| 3776 | * |
| 3777 | * Notes: |
| 3778 | * If the value is not in range log a kernel error message, clear the link |
| 3779 | * speed and return an error. |
| 3780 | * |
| 3781 | * Returns: |
| 3782 | * zero if val saved. |
| 3783 | * -EINVAL val out of range |
| 3784 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3785 | static int |
| 3786 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 3787 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3788 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 3789 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3790 | "3111 lpfc_link_speed of %d cannot " |
| 3791 | "support loop mode, setting topology to default.\n", |
| 3792 | val); |
| 3793 | phba->cfg_topology = 0; |
| 3794 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3795 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3796 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3797 | phba->cfg_link_speed = val; |
| 3798 | return 0; |
| 3799 | } |
| 3800 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3801 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3802 | "be set to %d, allowed values are " |
| 3803 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3804 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3805 | return -EINVAL; |
| 3806 | } |
| 3807 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3808 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3809 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3810 | |
| 3811 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3812 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 3813 | # 0 = aer disabled or not supported |
| 3814 | # 1 = aer supported and enabled (default) |
| 3815 | # Value range is [0,1]. Default value is 1. |
| 3816 | */ |
| 3817 | |
| 3818 | /** |
| 3819 | * lpfc_aer_support_store - Set the adapter for aer support |
| 3820 | * |
| 3821 | * @dev: class device that is converted into a Scsi_host. |
| 3822 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3823 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3824 | * @count: unused variable. |
| 3825 | * |
| 3826 | * Description: |
| 3827 | * If the val is 1 and currently the device's AER capability was not |
| 3828 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 3829 | * enable the device's AER capability. If the helper routine enabling |
| 3830 | * AER returns success, update the device's cfg_aer_support flag to |
| 3831 | * indicate AER is supported by the device; otherwise, if the device |
| 3832 | * AER capability is already enabled to support AER, then do nothing. |
| 3833 | * |
| 3834 | * If the val is 0 and currently the device's AER support was enabled, |
| 3835 | * invoke the kernel's disable AER helper routine. After that, update |
| 3836 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 3837 | * by the device; otherwise, if the device AER capability is already |
| 3838 | * disabled from supporting AER, then do nothing. |
| 3839 | * |
| 3840 | * Returns: |
| 3841 | * length of the buf on success if val is in range the intended mode |
| 3842 | * is supported. |
| 3843 | * -EINVAL if val out of range or intended mode is not supported. |
| 3844 | **/ |
| 3845 | static ssize_t |
| 3846 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 3847 | const char *buf, size_t count) |
| 3848 | { |
| 3849 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3850 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 3851 | struct lpfc_hba *phba = vport->phba; |
| 3852 | int val = 0, rc = -EINVAL; |
| 3853 | |
| 3854 | if (!isdigit(buf[0])) |
| 3855 | return -EINVAL; |
| 3856 | if (sscanf(buf, "%i", &val) != 1) |
| 3857 | return -EINVAL; |
| 3858 | |
| 3859 | switch (val) { |
| 3860 | case 0: |
| 3861 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 3862 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 3863 | if (!rc) { |
| 3864 | spin_lock_irq(&phba->hbalock); |
| 3865 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 3866 | spin_unlock_irq(&phba->hbalock); |
| 3867 | phba->cfg_aer_support = 0; |
| 3868 | rc = strlen(buf); |
| 3869 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3870 | rc = -EPERM; |
| 3871 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3872 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3873 | rc = strlen(buf); |
| 3874 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3875 | break; |
| 3876 | case 1: |
| 3877 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 3878 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 3879 | if (!rc) { |
| 3880 | spin_lock_irq(&phba->hbalock); |
| 3881 | phba->hba_flag |= HBA_AER_ENABLED; |
| 3882 | spin_unlock_irq(&phba->hbalock); |
| 3883 | phba->cfg_aer_support = 1; |
| 3884 | rc = strlen(buf); |
| 3885 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3886 | rc = -EPERM; |
| 3887 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3888 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3889 | rc = strlen(buf); |
| 3890 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3891 | break; |
| 3892 | default: |
| 3893 | rc = -EINVAL; |
| 3894 | break; |
| 3895 | } |
| 3896 | return rc; |
| 3897 | } |
| 3898 | |
| 3899 | static int lpfc_aer_support = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3900 | module_param(lpfc_aer_support, int, S_IRUGO); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3901 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); |
| 3902 | lpfc_param_show(aer_support) |
| 3903 | |
| 3904 | /** |
| 3905 | * lpfc_aer_support_init - Set the initial adapters aer support flag |
| 3906 | * @phba: lpfc_hba pointer. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3907 | * @val: enable aer or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3908 | * |
| 3909 | * Description: |
| 3910 | * If val is in a valid range [0,1], then set the adapter's initial |
| 3911 | * cfg_aer_support field. It will be up to the driver's probe_one |
| 3912 | * routine to determine whether the device's AER support can be set |
| 3913 | * or not. |
| 3914 | * |
| 3915 | * Notes: |
| 3916 | * If the value is not in range log a kernel error message, and |
| 3917 | * choose the default value of setting AER support and return. |
| 3918 | * |
| 3919 | * Returns: |
| 3920 | * zero if val saved. |
| 3921 | * -EINVAL val out of range |
| 3922 | **/ |
| 3923 | static int |
| 3924 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) |
| 3925 | { |
| 3926 | if (val == 0 || val == 1) { |
| 3927 | phba->cfg_aer_support = val; |
| 3928 | return 0; |
| 3929 | } |
| 3930 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3931 | "2712 lpfc_aer_support attribute value %d out " |
| 3932 | "of range, allowed values are 0|1, setting it " |
| 3933 | "to default value of 1\n", val); |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3934 | /* By default, try to enable AER on a device */ |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3935 | phba->cfg_aer_support = 1; |
| 3936 | return -EINVAL; |
| 3937 | } |
| 3938 | |
| 3939 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 3940 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 3941 | |
| 3942 | /** |
| 3943 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 3944 | * @dev: class device that is converted into a Scsi_host. |
| 3945 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3946 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3947 | * @count: unused variable. |
| 3948 | * |
| 3949 | * Description: |
| 3950 | * If the @buf contains 1 and the device currently has the AER support |
| 3951 | * enabled, then invokes the kernel AER helper routine |
| 3952 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 3953 | * error status register. |
| 3954 | * |
| 3955 | * Notes: |
| 3956 | * |
| 3957 | * Returns: |
| 3958 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 3959 | * enabled with the AER support. |
| 3960 | **/ |
| 3961 | static ssize_t |
| 3962 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 3963 | const char *buf, size_t count) |
| 3964 | { |
| 3965 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3966 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3967 | struct lpfc_hba *phba = vport->phba; |
| 3968 | int val, rc = -1; |
| 3969 | |
| 3970 | if (!isdigit(buf[0])) |
| 3971 | return -EINVAL; |
| 3972 | if (sscanf(buf, "%i", &val) != 1) |
| 3973 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3974 | if (val != 1) |
| 3975 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3976 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3977 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3978 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 3979 | |
| 3980 | if (rc == 0) |
| 3981 | return strlen(buf); |
| 3982 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3983 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3984 | } |
| 3985 | |
| 3986 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 3987 | lpfc_aer_cleanup_state); |
| 3988 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 3989 | /** |
| 3990 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 3991 | * |
| 3992 | * @dev: class device that is converted into a Scsi_host. |
| 3993 | * @attr: device attribute, not used. |
| 3994 | * @buf: containing the string the number of vfs to be enabled. |
| 3995 | * @count: unused variable. |
| 3996 | * |
| 3997 | * Description: |
| 3998 | * When this api is called either through user sysfs, the driver shall |
| 3999 | * try to enable or disable SR-IOV virtual functions according to the |
| 4000 | * following: |
| 4001 | * |
| 4002 | * If zero virtual function has been enabled to the physical function, |
| 4003 | * the driver shall invoke the pci enable virtual function api trying |
| 4004 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4005 | * than the maximum supported, the maximum virtual function number will |
| 4006 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4007 | * be used for invoking the api. If the api call returned success, the |
| 4008 | * actual number of virtual functions enabled will be set to the driver |
| 4009 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4010 | * cfg_sriov_nr_virtfn remains zero. |
| 4011 | * |
| 4012 | * If none-zero virtual functions have already been enabled to the |
| 4013 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4014 | * -EINVAL will be returned and the driver does nothing; |
| 4015 | * |
| 4016 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4017 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4018 | * disabling virtual function api shall be invoded to disable all the |
| 4019 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4020 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4021 | * nothing. |
| 4022 | * |
| 4023 | * Returns: |
| 4024 | * length of the buf on success if val is in range the intended mode |
| 4025 | * is supported. |
| 4026 | * -EINVAL if val out of range or intended mode is not supported. |
| 4027 | **/ |
| 4028 | static ssize_t |
| 4029 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4030 | const char *buf, size_t count) |
| 4031 | { |
| 4032 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4033 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4034 | struct lpfc_hba *phba = vport->phba; |
| 4035 | struct pci_dev *pdev = phba->pcidev; |
| 4036 | int val = 0, rc = -EINVAL; |
| 4037 | |
| 4038 | /* Sanity check on user data */ |
| 4039 | if (!isdigit(buf[0])) |
| 4040 | return -EINVAL; |
| 4041 | if (sscanf(buf, "%i", &val) != 1) |
| 4042 | return -EINVAL; |
| 4043 | if (val < 0) |
| 4044 | return -EINVAL; |
| 4045 | |
| 4046 | /* Request disabling virtual functions */ |
| 4047 | if (val == 0) { |
| 4048 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4049 | pci_disable_sriov(pdev); |
| 4050 | phba->cfg_sriov_nr_virtfn = 0; |
| 4051 | } |
| 4052 | return strlen(buf); |
| 4053 | } |
| 4054 | |
| 4055 | /* Request enabling virtual functions */ |
| 4056 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4057 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4058 | "3018 There are %d virtual functions " |
| 4059 | "enabled on physical function.\n", |
| 4060 | phba->cfg_sriov_nr_virtfn); |
| 4061 | return -EEXIST; |
| 4062 | } |
| 4063 | |
| 4064 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4065 | phba->cfg_sriov_nr_virtfn = val; |
| 4066 | else { |
| 4067 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4068 | "3019 Enabling %d virtual functions is not " |
| 4069 | "allowed.\n", val); |
| 4070 | return -EINVAL; |
| 4071 | } |
| 4072 | |
| 4073 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4074 | if (rc) { |
| 4075 | phba->cfg_sriov_nr_virtfn = 0; |
| 4076 | rc = -EPERM; |
| 4077 | } else |
| 4078 | rc = strlen(buf); |
| 4079 | |
| 4080 | return rc; |
| 4081 | } |
| 4082 | |
| 4083 | static int lpfc_sriov_nr_virtfn = LPFC_DEF_VFN_PER_PFN; |
| 4084 | module_param(lpfc_sriov_nr_virtfn, int, S_IRUGO|S_IWUSR); |
| 4085 | MODULE_PARM_DESC(lpfc_sriov_nr_virtfn, "Enable PCIe device SR-IOV virtual fn"); |
| 4086 | lpfc_param_show(sriov_nr_virtfn) |
| 4087 | |
| 4088 | /** |
| 4089 | * lpfc_sriov_nr_virtfn_init - Set the initial sr-iov virtual function enable |
| 4090 | * @phba: lpfc_hba pointer. |
| 4091 | * @val: link speed value. |
| 4092 | * |
| 4093 | * Description: |
| 4094 | * If val is in a valid range [0,255], then set the adapter's initial |
| 4095 | * cfg_sriov_nr_virtfn field. If it's greater than the maximum, the maximum |
| 4096 | * number shall be used instead. It will be up to the driver's probe_one |
| 4097 | * routine to determine whether the device's SR-IOV is supported or not. |
| 4098 | * |
| 4099 | * Returns: |
| 4100 | * zero if val saved. |
| 4101 | * -EINVAL val out of range |
| 4102 | **/ |
| 4103 | static int |
| 4104 | lpfc_sriov_nr_virtfn_init(struct lpfc_hba *phba, int val) |
| 4105 | { |
| 4106 | if (val >= 0 && val <= LPFC_MAX_VFN_PER_PFN) { |
| 4107 | phba->cfg_sriov_nr_virtfn = val; |
| 4108 | return 0; |
| 4109 | } |
| 4110 | |
| 4111 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4112 | "3017 Enabling %d virtual functions is not " |
| 4113 | "allowed.\n", val); |
| 4114 | return -EINVAL; |
| 4115 | } |
| 4116 | static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, |
| 4117 | lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); |
| 4118 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4119 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4120 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4121 | * |
| 4122 | * @dev: class device that is converted into a Scsi_host. |
| 4123 | * @attr: device attribute, not used. |
| 4124 | * @buf: containing the string the number of vfs to be enabled. |
| 4125 | * @count: unused variable. |
| 4126 | * |
| 4127 | * Description: |
| 4128 | * |
| 4129 | * Returns: |
| 4130 | * length of the buf on success if val is in range the intended mode |
| 4131 | * is supported. |
| 4132 | * -EINVAL if val out of range or intended mode is not supported. |
| 4133 | **/ |
| 4134 | static ssize_t |
| 4135 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4136 | struct device_attribute *attr, |
| 4137 | const char *buf, size_t count) |
| 4138 | { |
| 4139 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4140 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4141 | struct lpfc_hba *phba = vport->phba; |
| 4142 | int val = 0, rc = -EINVAL; |
| 4143 | |
| 4144 | /* Sanity check on user data */ |
| 4145 | if (!isdigit(buf[0])) |
| 4146 | return -EINVAL; |
| 4147 | if (sscanf(buf, "%i", &val) != 1) |
| 4148 | return -EINVAL; |
| 4149 | if (val != 1) |
| 4150 | return -EINVAL; |
| 4151 | |
| 4152 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4153 | if (rc) |
| 4154 | rc = -EPERM; |
| 4155 | else |
| 4156 | rc = strlen(buf); |
| 4157 | return rc; |
| 4158 | } |
| 4159 | |
| 4160 | static int lpfc_req_fw_upgrade; |
| 4161 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4162 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4163 | lpfc_param_show(request_firmware_upgrade) |
| 4164 | |
| 4165 | /** |
| 4166 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4167 | * @phba: lpfc_hba pointer. |
| 4168 | * @val: 0 or 1. |
| 4169 | * |
| 4170 | * Description: |
| 4171 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4172 | * |
| 4173 | * Returns: |
| 4174 | * zero if val saved. |
| 4175 | * -EINVAL val out of range |
| 4176 | **/ |
| 4177 | static int |
| 4178 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4179 | { |
| 4180 | if (val >= 0 && val <= 1) { |
| 4181 | phba->cfg_request_firmware_upgrade = val; |
| 4182 | return 0; |
| 4183 | } |
| 4184 | return -EINVAL; |
| 4185 | } |
| 4186 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4187 | lpfc_request_firmware_upgrade_show, |
| 4188 | lpfc_request_firmware_upgrade_store); |
| 4189 | |
| 4190 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4191 | * lpfc_fcp_imax_store |
| 4192 | * |
| 4193 | * @dev: class device that is converted into a Scsi_host. |
| 4194 | * @attr: device attribute, not used. |
| 4195 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4196 | * @count: unused variable. |
| 4197 | * |
| 4198 | * Description: |
| 4199 | * If val is in a valid range [636,651042], then set the adapter's |
| 4200 | * maximum number of fast-path FCP interrupts per second. |
| 4201 | * |
| 4202 | * Returns: |
| 4203 | * length of the buf on success if val is in range the intended mode |
| 4204 | * is supported. |
| 4205 | * -EINVAL if val out of range or intended mode is not supported. |
| 4206 | **/ |
| 4207 | static ssize_t |
| 4208 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4209 | const char *buf, size_t count) |
| 4210 | { |
| 4211 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4212 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4213 | struct lpfc_hba *phba = vport->phba; |
| 4214 | int val = 0, i; |
| 4215 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4216 | /* fcp_imax is only valid for SLI4 */ |
| 4217 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4218 | return -EINVAL; |
| 4219 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4220 | /* Sanity check on user data */ |
| 4221 | if (!isdigit(buf[0])) |
| 4222 | return -EINVAL; |
| 4223 | if (sscanf(buf, "%i", &val) != 1) |
| 4224 | return -EINVAL; |
| 4225 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4226 | /* |
| 4227 | * Value range for the HBA is [5000,5000000] |
| 4228 | * The value for each EQ depends on how many EQs are configured. |
| 4229 | */ |
| 4230 | if (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4231 | return -EINVAL; |
| 4232 | |
| 4233 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4234 | 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] | 4235 | lpfc_modify_fcp_eq_delay(phba, i); |
| 4236 | |
| 4237 | return strlen(buf); |
| 4238 | } |
| 4239 | |
| 4240 | /* |
| 4241 | # 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] | 4242 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4243 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4244 | # 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] | 4245 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4246 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4247 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4248 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4249 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4250 | lpfc_param_show(fcp_imax) |
| 4251 | |
| 4252 | /** |
| 4253 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4254 | * @phba: lpfc_hba pointer. |
| 4255 | * @val: link speed value. |
| 4256 | * |
| 4257 | * Description: |
| 4258 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4259 | * maximum number of fast-path FCP interrupts per second. |
| 4260 | * |
| 4261 | * Returns: |
| 4262 | * zero if val saved. |
| 4263 | * -EINVAL val out of range |
| 4264 | **/ |
| 4265 | static int |
| 4266 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4267 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4268 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4269 | phba->cfg_fcp_imax = 0; |
| 4270 | return 0; |
| 4271 | } |
| 4272 | |
| 4273 | if (val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4274 | phba->cfg_fcp_imax = val; |
| 4275 | return 0; |
| 4276 | } |
| 4277 | |
| 4278 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4279 | "3016 fcp_imax: %d out of range, using default\n", val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4280 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4281 | |
| 4282 | return 0; |
| 4283 | } |
| 4284 | |
| 4285 | static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, |
| 4286 | lpfc_fcp_imax_show, lpfc_fcp_imax_store); |
| 4287 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4288 | /** |
| 4289 | * lpfc_state_show - Display current driver CPU affinity |
| 4290 | * @dev: class converted to a Scsi_host structure. |
| 4291 | * @attr: device attribute, not used. |
| 4292 | * @buf: on return contains text describing the state of the link. |
| 4293 | * |
| 4294 | * Returns: size of formatted string. |
| 4295 | **/ |
| 4296 | static ssize_t |
| 4297 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4298 | char *buf) |
| 4299 | { |
| 4300 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4301 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4302 | struct lpfc_hba *phba = vport->phba; |
| 4303 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4304 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4305 | |
| 4306 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4307 | (phba->intr_type != MSIX)) |
| 4308 | return len; |
| 4309 | |
| 4310 | switch (phba->cfg_fcp_cpu_map) { |
| 4311 | case 0: |
| 4312 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4313 | "fcp_cpu_map: No mapping (%d)\n", |
| 4314 | phba->cfg_fcp_cpu_map); |
| 4315 | return len; |
| 4316 | case 1: |
| 4317 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4318 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4319 | "%d online CPUs\n", |
| 4320 | phba->cfg_fcp_cpu_map, |
| 4321 | phba->sli4_hba.num_online_cpu); |
| 4322 | break; |
| 4323 | case 2: |
| 4324 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4325 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4326 | "%d online CPUs\n", |
| 4327 | phba->cfg_fcp_cpu_map, |
| 4328 | phba->sli4_hba.num_online_cpu); |
| 4329 | break; |
| 4330 | } |
| 4331 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4332 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4333 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4334 | |
| 4335 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4336 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4337 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4338 | "CPU %02d io_chan %02d " |
| 4339 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4340 | phba->sli4_hba.curr_disp_cpu, |
| 4341 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4342 | cpup->core_id); |
| 4343 | else |
| 4344 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4345 | "CPU %02d io_chan %02d " |
| 4346 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4347 | phba->sli4_hba.curr_disp_cpu, |
| 4348 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4349 | cpup->core_id, cpup->irq); |
| 4350 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4351 | phba->sli4_hba.curr_disp_cpu++; |
| 4352 | |
| 4353 | /* display max number of CPUs keeping some margin */ |
| 4354 | if (phba->sli4_hba.curr_disp_cpu < |
| 4355 | phba->sli4_hba.num_present_cpu && |
| 4356 | (len >= (PAGE_SIZE - 64))) { |
| 4357 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4358 | break; |
| 4359 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4360 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4361 | |
| 4362 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4363 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4364 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4365 | return len; |
| 4366 | } |
| 4367 | |
| 4368 | /** |
| 4369 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4370 | * @dev: class device that is converted into a Scsi_host. |
| 4371 | * @attr: device attribute, not used. |
| 4372 | * @buf: one or more lpfc_polling_flags values. |
| 4373 | * @count: not used. |
| 4374 | * |
| 4375 | * Returns: |
| 4376 | * -EINVAL - Not implemented yet. |
| 4377 | **/ |
| 4378 | static ssize_t |
| 4379 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4380 | const char *buf, size_t count) |
| 4381 | { |
| 4382 | int status = -EINVAL; |
| 4383 | return status; |
| 4384 | } |
| 4385 | |
| 4386 | /* |
| 4387 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4388 | # for the HBA. |
| 4389 | # |
| 4390 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4391 | # 0 - Do not affinitze IRQ vectors |
| 4392 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4393 | # (start with CPU0 for each HBA) |
| 4394 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4395 | # (round robin thru all CPUs across all HBAs) |
| 4396 | */ |
| 4397 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4398 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4399 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4400 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4401 | |
| 4402 | /** |
| 4403 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4404 | * @phba: lpfc_hba pointer. |
| 4405 | * @val: link speed value. |
| 4406 | * |
| 4407 | * Description: |
| 4408 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4409 | * MSIX vectors. |
| 4410 | * |
| 4411 | * Returns: |
| 4412 | * zero if val saved. |
| 4413 | * -EINVAL val out of range |
| 4414 | **/ |
| 4415 | static int |
| 4416 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4417 | { |
| 4418 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4419 | phba->cfg_fcp_cpu_map = 0; |
| 4420 | return 0; |
| 4421 | } |
| 4422 | |
| 4423 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4424 | phba->cfg_fcp_cpu_map = val; |
| 4425 | return 0; |
| 4426 | } |
| 4427 | |
| 4428 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4429 | "3326 fcp_cpu_map: %d out of range, using default\n", |
| 4430 | val); |
| 4431 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4432 | |
| 4433 | return 0; |
| 4434 | } |
| 4435 | |
| 4436 | static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, |
| 4437 | lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store); |
| 4438 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4439 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4440 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4441 | # Value range is [2,3]. Default value is 3. |
| 4442 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4443 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4444 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4445 | |
| 4446 | /* |
| 4447 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4448 | # is [0,1]. Default value is 0. |
| 4449 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4450 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4451 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4452 | |
| 4453 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4454 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4455 | # that support first burst. |
| 4456 | # Value range is [0,65536]. Default value is 0. |
| 4457 | */ |
| 4458 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4459 | "First burst size for Targets that support first burst"); |
| 4460 | |
| 4461 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4462 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4463 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4464 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4465 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4466 | # to limit the I/O completion time to the parameter value. |
| 4467 | # The value is set in milliseconds. |
| 4468 | */ |
| 4469 | static int lpfc_max_scsicmpl_time; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4470 | module_param(lpfc_max_scsicmpl_time, int, S_IRUGO); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4471 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, |
| 4472 | "Use command completion time to control queue depth"); |
| 4473 | lpfc_vport_param_show(max_scsicmpl_time); |
| 4474 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); |
| 4475 | static int |
| 4476 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4477 | { |
| 4478 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4479 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4480 | |
| 4481 | if (val == vport->cfg_max_scsicmpl_time) |
| 4482 | return 0; |
| 4483 | if ((val < 0) || (val > 60000)) |
| 4484 | return -EINVAL; |
| 4485 | vport->cfg_max_scsicmpl_time = val; |
| 4486 | |
| 4487 | spin_lock_irq(shost->host_lock); |
| 4488 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4489 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4490 | continue; |
| 4491 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4492 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4493 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4494 | } |
| 4495 | spin_unlock_irq(shost->host_lock); |
| 4496 | return 0; |
| 4497 | } |
| 4498 | lpfc_vport_param_store(max_scsicmpl_time); |
| 4499 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 4500 | lpfc_max_scsicmpl_time_show, |
| 4501 | lpfc_max_scsicmpl_time_store); |
| 4502 | |
| 4503 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4504 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4505 | # range is [0,1]. Default value is 0. |
| 4506 | */ |
| 4507 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4508 | |
| 4509 | /* |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4510 | # lpfc_fcp_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4511 | # range is [0,1]. Default value is 0. |
| 4512 | # For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4513 | # For [1], FCP commands are issued to a Work Queue associated with the |
| 4514 | # current CPU. |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4515 | # It would be set to 1 by the driver if it's able to set up cpu affinity |
| 4516 | # for FCP I/Os through Work Queue associated with the current CPU. Otherwise, |
| 4517 | # roundrobin scheduling of FCP I/Os through WQs will be used. |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4518 | */ |
James Smart | ec2087a | 2013-09-06 12:20:36 -0400 | [diff] [blame] | 4519 | 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] | 4520 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
| 4521 | |
| 4522 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4523 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4524 | # range is [0,1]. Default value is 0. |
| 4525 | # For [0], bus reset issues target reset to ALL devices |
| 4526 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4527 | */ |
| 4528 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4529 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4530 | |
| 4531 | |
| 4532 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4533 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4534 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4535 | # 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] | 4536 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4537 | # cr_delay is set to 0. |
| 4538 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4539 | 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] | 4540 | "interrupt response is generated"); |
| 4541 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4542 | 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] | 4543 | "interrupt response is generated"); |
| 4544 | |
| 4545 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4546 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4547 | # cmd/rsp IOCB entries across. |
| 4548 | # Value range is [1,2]. Default value is 1. |
| 4549 | */ |
| 4550 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4551 | "SLI rings to spread IOCB entries across"); |
| 4552 | |
| 4553 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4554 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4555 | # identifies what rctl value to configure the additional ring for. |
| 4556 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4557 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4558 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4559 | 255, "Identifies RCTL for additional ring configuration"); |
| 4560 | |
| 4561 | /* |
| 4562 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4563 | # identifies what type value to configure the additional ring for. |
| 4564 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4565 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4566 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4567 | 255, "Identifies TYPE for additional ring configuration"); |
| 4568 | |
| 4569 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4570 | # lpfc_fdmi_on: controls FDMI support. |
| 4571 | # 0 = no FDMI support |
| 4572 | # 1 = support FDMI without attribute of hostname |
| 4573 | # 2 = support FDMI with attribute of hostname |
| 4574 | # Value range [0,2]. Default value is 0. |
| 4575 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4576 | LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4577 | |
| 4578 | /* |
| 4579 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4580 | # discovery). Value range is [1,64]. Default value = 32. |
| 4581 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4582 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4583 | "during discovery"); |
| 4584 | |
| 4585 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4586 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4587 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4588 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4589 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4590 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4591 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4592 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4593 | # on a target can take minutes of wall clock time. Additionally, |
| 4594 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4595 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4596 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4597 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4598 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4599 | # devices present, when in fact, there is only 1. |
| 4600 | # A customer that is aware of their target behaviors, and the results as |
| 4601 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4602 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4603 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4604 | # Value range is [0,65535]. Default value is 255. |
| 4605 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4606 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 4607 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4608 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4609 | /* |
| 4610 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4611 | # Value range is [1,255], default value is 10. |
| 4612 | */ |
| 4613 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4614 | "Milliseconds driver will wait between polling FCP ring"); |
| 4615 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4616 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4617 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4618 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4619 | */ |
| 4620 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4621 | "Maximum time to wait for task management commands to complete"); |
| 4622 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4623 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4624 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4625 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4626 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4627 | # 2 = MSI-X enabled (default) |
| 4628 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4629 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4630 | 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] | 4631 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4632 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4633 | /* |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4634 | # lpfc_fcp_io_channel: Set the number of FCP EQ/CQ/WQ IO channels |
| 4635 | # |
| 4636 | # Value range is [1,7]. Default value is 4. |
| 4637 | */ |
| 4638 | LPFC_ATTR_R(fcp_io_channel, LPFC_FCP_IO_CHAN_DEF, LPFC_FCP_IO_CHAN_MIN, |
| 4639 | LPFC_FCP_IO_CHAN_MAX, |
| 4640 | "Set the number of FCP I/O channels"); |
| 4641 | |
| 4642 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4643 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 4644 | # 0 = HBA resets disabled |
| 4645 | # 1 = HBA resets enabled (default) |
| 4646 | # Value range is [0,1]. Default value is 1. |
| 4647 | */ |
| 4648 | 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] | 4649 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4650 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4651 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4652 | # 0 = HBA Heartbeat disabled |
| 4653 | # 1 = HBA Heartbeat enabled (default) |
| 4654 | # Value range is [0,1]. Default value is 1. |
| 4655 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4656 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4657 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4658 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4659 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 4660 | # 0x0 Express Lane Feature disabled |
| 4661 | # 0x1 Express Lane Feature enabled |
| 4662 | # Value range is [0,1]. Default value is 0. |
| 4663 | */ |
| 4664 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 4665 | |
| 4666 | /* |
| 4667 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 4668 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 4669 | # Value range is [0x0,0x7f]. Default value is 0 |
| 4670 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 4671 | 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] | 4672 | |
| 4673 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4674 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 4675 | # 0 = BlockGuard disabled (default) |
| 4676 | # 1 = BlockGuard enabled |
| 4677 | # Value range is [0,1]. Default value is 0. |
| 4678 | */ |
| 4679 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 4680 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4681 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4682 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 4683 | # 0 = disabled (default) |
| 4684 | # 1 = enabled |
| 4685 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 4686 | # |
| 4687 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4688 | */ |
| 4689 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 4690 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 4691 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4692 | # lpfc_prot_mask: i |
| 4693 | # - Bit mask of host protection capabilities used to register with the |
| 4694 | # SCSI mid-layer |
| 4695 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 4696 | # - Allows you to ultimately specify which profiles to use |
| 4697 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 4698 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 4699 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 4700 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 4701 | # HBA supports DIX Type 0: Host to HBA protection only |
| 4702 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 4703 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4704 | # |
| 4705 | */ |
James Smart | 7c56b9f | 2011-07-22 18:36:25 -0400 | [diff] [blame] | 4706 | unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION | |
| 4707 | SHOST_DIX_TYPE0_PROTECTION | |
| 4708 | SHOST_DIX_TYPE1_PROTECTION; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4709 | |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4710 | module_param(lpfc_prot_mask, uint, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4711 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); |
| 4712 | |
| 4713 | /* |
| 4714 | # lpfc_prot_guard: i |
| 4715 | # - 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] | 4716 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4717 | # - Allows you to ultimately specify which profiles to use |
| 4718 | # - Default will result in registering capabilities for all guard types |
| 4719 | # |
| 4720 | */ |
| 4721 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4722 | module_param(lpfc_prot_guard, byte, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4723 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); |
| 4724 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4725 | /* |
| 4726 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 4727 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 4728 | * This parameter can have value 0 or 1. |
| 4729 | * When this parameter is set to 0, no delay is added to the initial |
| 4730 | * discovery. |
| 4731 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 4732 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 4733 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4734 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 4735 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 4736 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 4737 | * Default value is 0. |
| 4738 | */ |
| 4739 | int lpfc_delay_discovery; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4740 | module_param(lpfc_delay_discovery, int, S_IRUGO); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4741 | MODULE_PARM_DESC(lpfc_delay_discovery, |
| 4742 | "Delay NPort discovery when Clean Address bit is cleared. " |
| 4743 | "Allowed values: 0,1."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4744 | |
| 4745 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4746 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4747 | * 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] | 4748 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 4749 | * 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] | 4750 | * Because of the additional overhead involved in setting up T10-DIF, |
| 4751 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 4752 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4753 | */ |
| 4754 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 4755 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 4756 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 4757 | /* |
| 4758 | * This parameter will be depricated, the driver cannot limit the |
| 4759 | * protection data s/g list. |
| 4760 | */ |
| 4761 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, |
| 4762 | LPFC_DEFAULT_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT, |
| 4763 | "Max Protection Scatter Gather Segment Count"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4764 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4765 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4766 | &dev_attr_bg_info, |
| 4767 | &dev_attr_bg_guard_err, |
| 4768 | &dev_attr_bg_apptag_err, |
| 4769 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4770 | &dev_attr_info, |
| 4771 | &dev_attr_serialnum, |
| 4772 | &dev_attr_modeldesc, |
| 4773 | &dev_attr_modelname, |
| 4774 | &dev_attr_programtype, |
| 4775 | &dev_attr_portnum, |
| 4776 | &dev_attr_fwrev, |
| 4777 | &dev_attr_hdw, |
| 4778 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4779 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4780 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 4781 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4782 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 4783 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4784 | &dev_attr_lpfc_temp_sensor, |
| 4785 | &dev_attr_lpfc_log_verbose, |
| 4786 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4787 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4788 | &dev_attr_lpfc_hba_queue_depth, |
| 4789 | &dev_attr_lpfc_peer_port_login, |
| 4790 | &dev_attr_lpfc_nodev_tmo, |
| 4791 | &dev_attr_lpfc_devloss_tmo, |
| 4792 | &dev_attr_lpfc_fcp_class, |
| 4793 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4794 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4795 | &dev_attr_lpfc_ack0, |
| 4796 | &dev_attr_lpfc_topology, |
| 4797 | &dev_attr_lpfc_scan_down, |
| 4798 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4799 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4800 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4801 | &dev_attr_lpfc_cr_delay, |
| 4802 | &dev_attr_lpfc_cr_count, |
| 4803 | &dev_attr_lpfc_multi_ring_support, |
| 4804 | &dev_attr_lpfc_multi_ring_rctl, |
| 4805 | &dev_attr_lpfc_multi_ring_type, |
| 4806 | &dev_attr_lpfc_fdmi_on, |
| 4807 | &dev_attr_lpfc_max_luns, |
| 4808 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 4809 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4810 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4811 | &dev_attr_nport_evt_cnt, |
| 4812 | &dev_attr_board_mode, |
| 4813 | &dev_attr_max_vpi, |
| 4814 | &dev_attr_used_vpi, |
| 4815 | &dev_attr_max_rpi, |
| 4816 | &dev_attr_used_rpi, |
| 4817 | &dev_attr_max_xri, |
| 4818 | &dev_attr_used_xri, |
| 4819 | &dev_attr_npiv_info, |
| 4820 | &dev_attr_issue_reset, |
| 4821 | &dev_attr_lpfc_poll, |
| 4822 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4823 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4824 | &dev_attr_lpfc_use_msi, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 4825 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4826 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4827 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4828 | &dev_attr_lpfc_enable_bg, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4829 | &dev_attr_lpfc_soft_wwnn, |
| 4830 | &dev_attr_lpfc_soft_wwpn, |
| 4831 | &dev_attr_lpfc_soft_wwn_enable, |
| 4832 | &dev_attr_lpfc_enable_hba_reset, |
| 4833 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4834 | &dev_attr_lpfc_EnableXLane, |
| 4835 | &dev_attr_lpfc_XLanePriority, |
| 4836 | &dev_attr_lpfc_xlane_lun, |
| 4837 | &dev_attr_lpfc_xlane_tgt, |
| 4838 | &dev_attr_lpfc_xlane_vpt, |
| 4839 | &dev_attr_lpfc_xlane_lun_state, |
| 4840 | &dev_attr_lpfc_xlane_lun_status, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4841 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4842 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4843 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4844 | &dev_attr_lpfc_prot_sg_seg_cnt, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4845 | &dev_attr_lpfc_aer_support, |
| 4846 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4847 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4848 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 4849 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 4850 | &dev_attr_lpfc_iocb_cnt, |
| 4851 | &dev_attr_iocb_hw, |
| 4852 | &dev_attr_txq_hw, |
| 4853 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4854 | &dev_attr_lpfc_fips_level, |
| 4855 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4856 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4857 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 4858 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4859 | &dev_attr_lpfc_xlane_supported, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4860 | NULL, |
| 4861 | }; |
| 4862 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4863 | struct device_attribute *lpfc_vport_attrs[] = { |
| 4864 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 4865 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4866 | &dev_attr_num_discovered_ports, |
| 4867 | &dev_attr_lpfc_drvr_version, |
| 4868 | &dev_attr_lpfc_log_verbose, |
| 4869 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4870 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4871 | &dev_attr_lpfc_nodev_tmo, |
| 4872 | &dev_attr_lpfc_devloss_tmo, |
| 4873 | &dev_attr_lpfc_hba_queue_depth, |
| 4874 | &dev_attr_lpfc_peer_port_login, |
| 4875 | &dev_attr_lpfc_restrict_login, |
| 4876 | &dev_attr_lpfc_fcp_class, |
| 4877 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4878 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4879 | &dev_attr_lpfc_fdmi_on, |
| 4880 | &dev_attr_lpfc_max_luns, |
| 4881 | &dev_attr_nport_evt_cnt, |
| 4882 | &dev_attr_npiv_info, |
| 4883 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4884 | &dev_attr_lpfc_max_scsicmpl_time, |
| 4885 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4886 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 4887 | &dev_attr_lpfc_fips_level, |
| 4888 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4889 | NULL, |
| 4890 | }; |
| 4891 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4892 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4893 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4894 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4895 | * @kobj: kernel kobject that contains the kernel class device. |
| 4896 | * @bin_attr: kernel attributes passed to us. |
| 4897 | * @buf: contains the data to be written to the adapter IOREG space. |
| 4898 | * @off: offset into buffer to beginning of data. |
| 4899 | * @count: bytes to transfer. |
| 4900 | * |
| 4901 | * Description: |
| 4902 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4903 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 4904 | * |
| 4905 | * Returns: |
| 4906 | * -ERANGE off and count combo out of range |
| 4907 | * -EINVAL off, count or buff address invalid |
| 4908 | * -EPERM adapter is offline |
| 4909 | * value of count, buf contents written |
| 4910 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4911 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4912 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 4913 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 4914 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4915 | { |
| 4916 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4917 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4918 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4919 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4920 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4921 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 4922 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 4923 | return -EPERM; |
| 4924 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4925 | if ((off + count) > FF_REG_AREA_SIZE) |
| 4926 | return -ERANGE; |
| 4927 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4928 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 4929 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4930 | |
| 4931 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 4932 | return -EINVAL; |
| 4933 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4934 | /* This is to protect HBA registers from accidental writes. */ |
| 4935 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 4936 | return -EINVAL; |
| 4937 | |
| 4938 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4939 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4940 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4941 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 4942 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 4943 | buf_off += sizeof(uint32_t)) |
| 4944 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4945 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 4946 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4947 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4948 | |
| 4949 | return count; |
| 4950 | } |
| 4951 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4952 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4953 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4954 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4955 | * @kobj: kernel kobject that contains the kernel class device. |
| 4956 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 4957 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4958 | * @off: offset into buffer to beginning of data. |
| 4959 | * @count: bytes to transfer. |
| 4960 | * |
| 4961 | * Description: |
| 4962 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 4963 | * Uses the adapter io control registers to read data into buf. |
| 4964 | * |
| 4965 | * Returns: |
| 4966 | * -ERANGE off and count combo out of range |
| 4967 | * -EINVAL off, count or buff address invalid |
| 4968 | * value of count, buf contents read |
| 4969 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4970 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4971 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 4972 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 4973 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4974 | { |
| 4975 | size_t buf_off; |
| 4976 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4977 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4978 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4979 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4980 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4981 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 4982 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 4983 | return -EPERM; |
| 4984 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4985 | if (off > FF_REG_AREA_SIZE) |
| 4986 | return -ERANGE; |
| 4987 | |
| 4988 | if ((off + count) > FF_REG_AREA_SIZE) |
| 4989 | count = FF_REG_AREA_SIZE - off; |
| 4990 | |
| 4991 | if (count == 0) return 0; |
| 4992 | |
| 4993 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 4994 | return -EINVAL; |
| 4995 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4996 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4997 | |
| 4998 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 4999 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5000 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5001 | } |
| 5002 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5003 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5004 | |
| 5005 | return count; |
| 5006 | } |
| 5007 | |
| 5008 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5009 | .attr = { |
| 5010 | .name = "ctlreg", |
| 5011 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5012 | }, |
| 5013 | .size = 256, |
| 5014 | .read = sysfs_ctlreg_read, |
| 5015 | .write = sysfs_ctlreg_write, |
| 5016 | }; |
| 5017 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5018 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5019 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5020 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5021 | * @kobj: kernel kobject that contains the kernel class device. |
| 5022 | * @bin_attr: kernel attributes passed to us. |
| 5023 | * @buf: contains the data to be written to sysfs mbox. |
| 5024 | * @off: offset into buffer to beginning of data. |
| 5025 | * @count: bytes to transfer. |
| 5026 | * |
| 5027 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5028 | * Deprecated function. All mailbox access from user space is performed via the |
| 5029 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5030 | * |
| 5031 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5032 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5033 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5034 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5035 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5036 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5037 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5038 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5039 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5040 | } |
| 5041 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5042 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5043 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5044 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5045 | * @kobj: kernel kobject that contains the kernel class device. |
| 5046 | * @bin_attr: kernel attributes passed to us. |
| 5047 | * @buf: contains the data to be read from sysfs mbox. |
| 5048 | * @off: offset into buffer to beginning of data. |
| 5049 | * @count: bytes to transfer. |
| 5050 | * |
| 5051 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5052 | * Deprecated function. All mailbox access from user space is performed via the |
| 5053 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5054 | * |
| 5055 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5056 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5057 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5058 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5059 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5060 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5061 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5062 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5063 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5064 | } |
| 5065 | |
| 5066 | static struct bin_attribute sysfs_mbox_attr = { |
| 5067 | .attr = { |
| 5068 | .name = "mbox", |
| 5069 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5070 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5071 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5072 | .read = sysfs_mbox_read, |
| 5073 | .write = sysfs_mbox_write, |
| 5074 | }; |
| 5075 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5076 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5077 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5078 | * @vport: address of lpfc vport structure. |
| 5079 | * |
| 5080 | * Return codes: |
| 5081 | * zero on success |
| 5082 | * error return code from sysfs_create_bin_file() |
| 5083 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5084 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5085 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5086 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5087 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5088 | int error; |
| 5089 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5090 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5091 | &sysfs_drvr_stat_data_attr); |
| 5092 | |
| 5093 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5094 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5095 | goto out; |
| 5096 | |
| 5097 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5098 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5099 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5100 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5101 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5102 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5103 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5104 | if (error) |
| 5105 | goto out_remove_ctlreg_attr; |
| 5106 | |
| 5107 | return 0; |
| 5108 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5109 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5110 | out_remove_stat_attr: |
| 5111 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5112 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5113 | out: |
| 5114 | return error; |
| 5115 | } |
| 5116 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5117 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5118 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5119 | * @vport: address of lpfc vport structure. |
| 5120 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5121 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5122 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5123 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5124 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5125 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5126 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5127 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5128 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5129 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5130 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5131 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5132 | } |
| 5133 | |
| 5134 | |
| 5135 | /* |
| 5136 | * Dynamic FC Host Attributes Support |
| 5137 | */ |
| 5138 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5139 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5140 | * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5141 | * @shost: kernel scsi host pointer. |
| 5142 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5143 | static void |
| 5144 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5145 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5146 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5147 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5148 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5149 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5150 | } |
| 5151 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5152 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5153 | * 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] | 5154 | * @shost: kernel scsi host pointer. |
| 5155 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5156 | static void |
| 5157 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5158 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5159 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5160 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5161 | |
| 5162 | spin_lock_irq(shost->host_lock); |
| 5163 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5164 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5165 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5166 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5167 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5168 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5169 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5170 | else |
| 5171 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5172 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5173 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5174 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5175 | else |
| 5176 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5177 | } |
| 5178 | } else |
| 5179 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5180 | |
| 5181 | spin_unlock_irq(shost->host_lock); |
| 5182 | } |
| 5183 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5184 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5185 | * 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] | 5186 | * @shost: kernel scsi host pointer. |
| 5187 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5188 | static void |
| 5189 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5190 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5191 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5192 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5193 | |
| 5194 | spin_lock_irq(shost->host_lock); |
| 5195 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5196 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5197 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5198 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5199 | switch (phba->link_state) { |
| 5200 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5201 | case LPFC_LINK_DOWN: |
| 5202 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5203 | break; |
| 5204 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5205 | case LPFC_CLEAR_LA: |
| 5206 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5207 | /* Links up, reports port state accordingly */ |
| 5208 | if (vport->port_state < LPFC_VPORT_READY) |
| 5209 | fc_host_port_state(shost) = |
| 5210 | FC_PORTSTATE_BYPASSED; |
| 5211 | else |
| 5212 | fc_host_port_state(shost) = |
| 5213 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5214 | break; |
| 5215 | case LPFC_HBA_ERROR: |
| 5216 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5217 | break; |
| 5218 | default: |
| 5219 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5220 | break; |
| 5221 | } |
| 5222 | } |
| 5223 | |
| 5224 | spin_unlock_irq(shost->host_lock); |
| 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_speed - Set the value of the scsi host speed |
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_speed(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 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5236 | |
| 5237 | spin_lock_irq(shost->host_lock); |
| 5238 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5239 | if (lpfc_is_link_up(phba)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5240 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5241 | case LPFC_LINK_SPEED_1GHZ: |
| 5242 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5243 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5244 | case LPFC_LINK_SPEED_2GHZ: |
| 5245 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5246 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5247 | case LPFC_LINK_SPEED_4GHZ: |
| 5248 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5249 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5250 | case LPFC_LINK_SPEED_8GHZ: |
| 5251 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5252 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5253 | case LPFC_LINK_SPEED_10GHZ: |
| 5254 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5255 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5256 | case LPFC_LINK_SPEED_16GHZ: |
| 5257 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5258 | break; |
| 5259 | default: |
| 5260 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5261 | break; |
| 5262 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5263 | } else |
| 5264 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5265 | |
| 5266 | spin_unlock_irq(shost->host_lock); |
| 5267 | } |
| 5268 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5269 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5270 | * 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] | 5271 | * @shost: kernel scsi host pointer. |
| 5272 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5273 | static void |
| 5274 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5275 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5276 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5277 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5278 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5279 | |
| 5280 | spin_lock_irq(shost->host_lock); |
| 5281 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5282 | if ((vport->port_state > LPFC_FLOGI) && |
| 5283 | ((vport->fc_flag & FC_FABRIC) || |
| 5284 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5285 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5286 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5287 | else |
| 5288 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5289 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5290 | |
| 5291 | spin_unlock_irq(shost->host_lock); |
| 5292 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5293 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5294 | } |
| 5295 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5296 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5297 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5298 | * @shost: kernel scsi host pointer. |
| 5299 | * |
| 5300 | * Notes: |
| 5301 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5302 | * management not allowed, memory allocation error, or mbox error. |
| 5303 | * |
| 5304 | * Returns: |
| 5305 | * NULL for error |
| 5306 | * address of the adapter host statistics |
| 5307 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5308 | static struct fc_host_statistics * |
| 5309 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5310 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5311 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5312 | struct lpfc_hba *phba = vport->phba; |
| 5313 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5314 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5315 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5316 | LPFC_MBOXQ_t *pmboxq; |
| 5317 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5318 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5319 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5320 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5321 | /* |
| 5322 | * prevent udev from issuing mailbox commands until the port is |
| 5323 | * configured. |
| 5324 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5325 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5326 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5327 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5328 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5329 | |
| 5330 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5331 | return NULL; |
| 5332 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5333 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5334 | if (!pmboxq) |
| 5335 | return NULL; |
| 5336 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5337 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5338 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5339 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5340 | pmb->mbxOwner = OWN_HOST; |
| 5341 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5342 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5343 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5344 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5345 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5346 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5347 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5348 | |
| 5349 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5350 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5351 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5352 | return NULL; |
| 5353 | } |
| 5354 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5355 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5356 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5357 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5358 | /* |
| 5359 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5360 | * converted to words |
| 5361 | */ |
| 5362 | hs->tx_words = (uint64_t) |
| 5363 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5364 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5365 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5366 | hs->rx_words = (uint64_t) |
| 5367 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5368 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5369 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5370 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5371 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5372 | pmb->mbxOwner = OWN_HOST; |
| 5373 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5374 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5375 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5376 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5377 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5378 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5379 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5380 | |
| 5381 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5382 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5383 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5384 | return NULL; |
| 5385 | } |
| 5386 | |
| 5387 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5388 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5389 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5390 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5391 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5392 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5393 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5394 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5395 | hs->link_failure_count -= lso->link_failure_count; |
| 5396 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5397 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5398 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5399 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5400 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5401 | hs->error_frames -= lso->error_frames; |
| 5402 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5403 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5404 | hs->lip_count = -1; |
| 5405 | hs->nos_count = (phba->link_events >> 1); |
| 5406 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5407 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5408 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5409 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5410 | hs->nos_count = -1; |
| 5411 | } else { |
| 5412 | hs->lip_count = -1; |
| 5413 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5414 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5415 | } |
| 5416 | |
| 5417 | hs->dumped_frames = -1; |
| 5418 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5419 | seconds = get_seconds(); |
| 5420 | if (seconds < psli->stats_start) |
| 5421 | hs->seconds_since_last_reset = seconds + |
| 5422 | ((unsigned long)-1 - psli->stats_start); |
| 5423 | else |
| 5424 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5425 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5426 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5427 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5428 | return hs; |
| 5429 | } |
| 5430 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5431 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5432 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5433 | * @shost: kernel scsi host pointer. |
| 5434 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5435 | static void |
| 5436 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5437 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5438 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5439 | struct lpfc_hba *phba = vport->phba; |
| 5440 | struct lpfc_sli *psli = &phba->sli; |
| 5441 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5442 | LPFC_MBOXQ_t *pmboxq; |
| 5443 | MAILBOX_t *pmb; |
| 5444 | int rc = 0; |
| 5445 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5446 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5447 | return; |
| 5448 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5449 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5450 | if (!pmboxq) |
| 5451 | return; |
| 5452 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5453 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5454 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5455 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5456 | pmb->mbxOwner = OWN_HOST; |
| 5457 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5458 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5459 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5460 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5461 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5462 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5463 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5464 | else |
| 5465 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5466 | |
| 5467 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5468 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5469 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5470 | return; |
| 5471 | } |
| 5472 | |
| 5473 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5474 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5475 | pmb->mbxOwner = OWN_HOST; |
| 5476 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5477 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5478 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5479 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5480 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5481 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5482 | else |
| 5483 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5484 | |
| 5485 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5486 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5487 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5488 | return; |
| 5489 | } |
| 5490 | |
| 5491 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5492 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5493 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5494 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5495 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5496 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5497 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5498 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5499 | lso->link_events = (phba->link_events >> 1); |
| 5500 | else |
| 5501 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5502 | |
| 5503 | psli->stats_start = get_seconds(); |
| 5504 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5505 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5506 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5507 | return; |
| 5508 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5509 | |
| 5510 | /* |
| 5511 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5512 | * are no sysfs handlers for link_down_tmo. |
| 5513 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5514 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5515 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5516 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5517 | * @starget: kernel scsi target pointer. |
| 5518 | * |
| 5519 | * Returns: |
| 5520 | * address of the node list if found |
| 5521 | * NULL target not found |
| 5522 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5523 | static struct lpfc_nodelist * |
| 5524 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5525 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5526 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5527 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5528 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5529 | |
| 5530 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5531 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5532 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5533 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5534 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5535 | starget->id == ndlp->nlp_sid) { |
| 5536 | spin_unlock_irq(shost->host_lock); |
| 5537 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5538 | } |
| 5539 | } |
| 5540 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5541 | return NULL; |
| 5542 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5543 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5544 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5545 | * 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] | 5546 | * @starget: kernel scsi target pointer. |
| 5547 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5548 | static void |
| 5549 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5550 | { |
| 5551 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5552 | |
| 5553 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5554 | } |
| 5555 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5556 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5557 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5558 | * @starget: kernel scsi target pointer. |
| 5559 | * |
| 5560 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 5561 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5562 | static void |
| 5563 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 5564 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5565 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5566 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5567 | fc_starget_node_name(starget) = |
| 5568 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5569 | } |
| 5570 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5571 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5572 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5573 | * @starget: kernel scsi target pointer. |
| 5574 | * |
| 5575 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 5576 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5577 | static void |
| 5578 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 5579 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5580 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5581 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5582 | fc_starget_port_name(starget) = |
| 5583 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5584 | } |
| 5585 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5586 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5587 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5588 | * @rport: fc rport address. |
| 5589 | * @timeout: new value for dev loss tmo. |
| 5590 | * |
| 5591 | * Description: |
| 5592 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 5593 | * dev_loss_tmo to one. |
| 5594 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5595 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5596 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 5597 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5598 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5599 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5600 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5601 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5602 | } |
| 5603 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5604 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5605 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5606 | * |
| 5607 | * Description: |
| 5608 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 5609 | * |
| 5610 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 5611 | * @cdev: class converted to an fc_rport. |
| 5612 | * @buf: on return contains the target_field or zero. |
| 5613 | * |
| 5614 | * Returns: size of formatted string. |
| 5615 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5616 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 5617 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5618 | lpfc_show_rport_##field (struct device *dev, \ |
| 5619 | struct device_attribute *attr, \ |
| 5620 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5621 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5622 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5623 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 5624 | return snprintf(buf, sz, format_string, \ |
| 5625 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 5626 | } |
| 5627 | |
| 5628 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 5629 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 5630 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 5631 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5632 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5633 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5634 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 5635 | * |
| 5636 | * Description: |
| 5637 | * This function is called by the transport after the @fc_vport's symbolic name |
| 5638 | * 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] | 5639 | * 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] | 5640 | **/ |
| 5641 | static void |
| 5642 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 5643 | { |
| 5644 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 5645 | |
| 5646 | if (vport->port_state == LPFC_VPORT_READY) |
| 5647 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 5648 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5649 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5650 | /** |
| 5651 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 5652 | * @phba: Pointer to lpfc_hba struct. |
| 5653 | * |
| 5654 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 5655 | * 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] | 5656 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5657 | * before hba port or vport created. |
| 5658 | **/ |
| 5659 | static void |
| 5660 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 5661 | { |
| 5662 | phba->cfg_log_verbose = verbose; |
| 5663 | } |
| 5664 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5665 | struct fc_function_template lpfc_transport_functions = { |
| 5666 | /* fixed attributes the driver supports */ |
| 5667 | .show_host_node_name = 1, |
| 5668 | .show_host_port_name = 1, |
| 5669 | .show_host_supported_classes = 1, |
| 5670 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5671 | .show_host_supported_speeds = 1, |
| 5672 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5673 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5674 | |
| 5675 | /* dynamic attributes the driver supports */ |
| 5676 | .get_host_port_id = lpfc_get_host_port_id, |
| 5677 | .show_host_port_id = 1, |
| 5678 | |
| 5679 | .get_host_port_type = lpfc_get_host_port_type, |
| 5680 | .show_host_port_type = 1, |
| 5681 | |
| 5682 | .get_host_port_state = lpfc_get_host_port_state, |
| 5683 | .show_host_port_state = 1, |
| 5684 | |
| 5685 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5686 | .show_host_active_fc4s = 1, |
| 5687 | |
| 5688 | .get_host_speed = lpfc_get_host_speed, |
| 5689 | .show_host_speed = 1, |
| 5690 | |
| 5691 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5692 | .show_host_fabric_name = 1, |
| 5693 | |
| 5694 | /* |
| 5695 | * The LPFC driver treats linkdown handling as target loss events |
| 5696 | * so there are no sysfs handlers for link_down_tmo. |
| 5697 | */ |
| 5698 | |
| 5699 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5700 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5701 | |
| 5702 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5703 | .show_rport_maxframe_size = 1, |
| 5704 | .show_rport_supported_classes = 1, |
| 5705 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5706 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5707 | .show_rport_dev_loss_tmo = 1, |
| 5708 | |
| 5709 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5710 | .show_starget_port_id = 1, |
| 5711 | |
| 5712 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5713 | .show_starget_node_name = 1, |
| 5714 | |
| 5715 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5716 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 5717 | |
| 5718 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5719 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5720 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5721 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5722 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5723 | |
| 5724 | .vport_disable = lpfc_vport_disable, |
| 5725 | |
| 5726 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 5727 | |
| 5728 | .bsg_request = lpfc_bsg_request, |
| 5729 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5730 | }; |
| 5731 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5732 | struct fc_function_template lpfc_vport_transport_functions = { |
| 5733 | /* fixed attributes the driver supports */ |
| 5734 | .show_host_node_name = 1, |
| 5735 | .show_host_port_name = 1, |
| 5736 | .show_host_supported_classes = 1, |
| 5737 | .show_host_supported_fc4s = 1, |
| 5738 | .show_host_supported_speeds = 1, |
| 5739 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5740 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5741 | |
| 5742 | /* dynamic attributes the driver supports */ |
| 5743 | .get_host_port_id = lpfc_get_host_port_id, |
| 5744 | .show_host_port_id = 1, |
| 5745 | |
| 5746 | .get_host_port_type = lpfc_get_host_port_type, |
| 5747 | .show_host_port_type = 1, |
| 5748 | |
| 5749 | .get_host_port_state = lpfc_get_host_port_state, |
| 5750 | .show_host_port_state = 1, |
| 5751 | |
| 5752 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 5753 | .show_host_active_fc4s = 1, |
| 5754 | |
| 5755 | .get_host_speed = lpfc_get_host_speed, |
| 5756 | .show_host_speed = 1, |
| 5757 | |
| 5758 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 5759 | .show_host_fabric_name = 1, |
| 5760 | |
| 5761 | /* |
| 5762 | * The LPFC driver treats linkdown handling as target loss events |
| 5763 | * so there are no sysfs handlers for link_down_tmo. |
| 5764 | */ |
| 5765 | |
| 5766 | .get_fc_host_stats = lpfc_get_stats, |
| 5767 | .reset_fc_host_stats = lpfc_reset_stats, |
| 5768 | |
| 5769 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 5770 | .show_rport_maxframe_size = 1, |
| 5771 | .show_rport_supported_classes = 1, |
| 5772 | |
| 5773 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 5774 | .show_rport_dev_loss_tmo = 1, |
| 5775 | |
| 5776 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 5777 | .show_starget_port_id = 1, |
| 5778 | |
| 5779 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 5780 | .show_starget_node_name = 1, |
| 5781 | |
| 5782 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 5783 | .show_starget_port_name = 1, |
| 5784 | |
| 5785 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 5786 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 5787 | |
| 5788 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5789 | |
| 5790 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5791 | }; |
| 5792 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5793 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5794 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5795 | * @phba: lpfc_hba pointer. |
| 5796 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5797 | void |
| 5798 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 5799 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5800 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5801 | 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] | 5802 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 5803 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5804 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5805 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 5806 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5807 | lpfc_ack0_init(phba, lpfc_ack0); |
| 5808 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 5809 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5810 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5811 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5812 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5813 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5814 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5815 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5816 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5817 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5818 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5819 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 5820 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5821 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 5822 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5823 | phba->cfg_EnableXLane = 0; |
| 5824 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
| 5825 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5826 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 5827 | phba->cfg_oas_lun_state = 0; |
| 5828 | phba->cfg_oas_lun_status = 0; |
| 5829 | phba->cfg_oas_flags = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5830 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5831 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 5832 | phba->cfg_poll = 0; |
| 5833 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5834 | phba->cfg_poll = lpfc_poll; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 5835 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5836 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5837 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5838 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5839 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5840 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5841 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5842 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5843 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5844 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5845 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5846 | phba->cfg_enable_dss = 1; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5847 | return; |
| 5848 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 5849 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5850 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5851 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5852 | * @vport: lpfc_vport pointer. |
| 5853 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5854 | void |
| 5855 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 5856 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5857 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5858 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5859 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5860 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 5861 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 5862 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 5863 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 5864 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 5865 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5866 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5867 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5868 | lpfc_fdmi_on_init(vport, lpfc_fdmi_on); |
| 5869 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 5870 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 5871 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 5872 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5873 | return; |
| 5874 | } |