| 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 | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 4 | * Copyright (C) 2004-2011 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> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 26 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 27 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 28 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 29 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 30 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 31 | #include <scsi/scsi_device.h> |
| 32 | #include <scsi/scsi_host.h> |
| 33 | #include <scsi/scsi_tcq.h> |
| 34 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 35 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 36 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 37 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 38 | #include "lpfc_hw.h" |
| 39 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 40 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 41 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 42 | #include "lpfc_disc.h" |
| 43 | #include "lpfc_scsi.h" |
| 44 | #include "lpfc.h" |
| 45 | #include "lpfc_logmsg.h" |
| 46 | #include "lpfc_version.h" |
| 47 | #include "lpfc_compat.h" |
| 48 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 49 | #include "lpfc_vport.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 50 | |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 51 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 52 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 53 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 54 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 55 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 56 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 57 | * @incr: integer to convert. |
| 58 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 59 | * |
| 60 | * Description: |
| 61 | * JEDEC Joint Electron Device Engineering Council. |
| 62 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 63 | * character string. The string is then terminated with a NULL in byte 9. |
| 64 | * Hex 0-9 becomes ascii '0' to '9'. |
| 65 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 66 | * |
| 67 | * Notes: |
| 68 | * Coded for 32 bit integers only. |
| 69 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 70 | static void |
| 71 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 72 | { |
| 73 | int i, j; |
| 74 | for (i = 0; i < 8; i++) { |
| 75 | j = (incr & 0xf); |
| 76 | if (j <= 9) |
| 77 | hdw[7 - i] = 0x30 + j; |
| 78 | else |
| 79 | hdw[7 - i] = 0x61 + j - 10; |
| 80 | incr = (incr >> 4); |
| 81 | } |
| 82 | hdw[8] = 0; |
| 83 | return; |
| 84 | } |
| 85 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 86 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 87 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 88 | * @dev: class unused variable. |
| 89 | * @attr: device attribute, not used. |
| 90 | * @buf: on return contains the module description text. |
| 91 | * |
| 92 | * Returns: size of formatted string. |
| 93 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 94 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 95 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 96 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 97 | { |
| 98 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 99 | } |
| 100 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 101 | /** |
| 102 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 103 | * @dev: class unused variable. |
| 104 | * @attr: device attribute, not used. |
| 105 | * @buf: on return contains the module description text. |
| 106 | * |
| 107 | * Returns: size of formatted string. |
| 108 | **/ |
| 109 | static ssize_t |
| 110 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 111 | char *buf) |
| 112 | { |
| 113 | struct Scsi_Host *shost = class_to_shost(dev); |
| 114 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 115 | struct lpfc_hba *phba = vport->phba; |
| 116 | |
| 117 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 118 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 119 | else |
| 120 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 121 | } |
| 122 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 123 | static ssize_t |
| 124 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 125 | char *buf) |
| 126 | { |
| 127 | struct Scsi_Host *shost = class_to_shost(dev); |
| 128 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 129 | struct lpfc_hba *phba = vport->phba; |
| 130 | |
| 131 | if (phba->cfg_enable_bg) |
| 132 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 133 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 134 | else |
| 135 | return snprintf(buf, PAGE_SIZE, |
| 136 | "BlockGuard Not Supported\n"); |
| 137 | else |
| 138 | return snprintf(buf, PAGE_SIZE, |
| 139 | "BlockGuard Disabled\n"); |
| 140 | } |
| 141 | |
| 142 | static ssize_t |
| 143 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 144 | char *buf) |
| 145 | { |
| 146 | struct Scsi_Host *shost = class_to_shost(dev); |
| 147 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 148 | struct lpfc_hba *phba = vport->phba; |
| 149 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 150 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 151 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | static ssize_t |
| 155 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 156 | char *buf) |
| 157 | { |
| 158 | struct Scsi_Host *shost = class_to_shost(dev); |
| 159 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 160 | struct lpfc_hba *phba = vport->phba; |
| 161 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 162 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 163 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | static ssize_t |
| 167 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 168 | char *buf) |
| 169 | { |
| 170 | struct Scsi_Host *shost = class_to_shost(dev); |
| 171 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 172 | struct lpfc_hba *phba = vport->phba; |
| 173 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 174 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 175 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 176 | } |
| 177 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 178 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 179 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 180 | * @dev: class converted to a Scsi_host structure. |
| 181 | * @attr: device attribute, not used. |
| 182 | * @buf: on return contains the formatted text from lpfc_info(). |
| 183 | * |
| 184 | * Returns: size of formatted string. |
| 185 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 186 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 187 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 188 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 189 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 190 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 191 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 192 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 193 | } |
| 194 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 195 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 196 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 197 | * @dev: class converted to a Scsi_host structure. |
| 198 | * @attr: device attribute, not used. |
| 199 | * @buf: on return contains the formatted text serial number. |
| 200 | * |
| 201 | * Returns: size of formatted string. |
| 202 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 203 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 204 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 205 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 206 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 207 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 208 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 209 | struct lpfc_hba *phba = vport->phba; |
| 210 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 211 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 212 | } |
| 213 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 214 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 215 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 216 | * @dev: class converted to a Scsi_host structure. |
| 217 | * @attr: device attribute, not used. |
| 218 | * @buf: on return contains the formatted support level. |
| 219 | * |
| 220 | * Description: |
| 221 | * Returns a number indicating the temperature sensor level currently |
| 222 | * supported, zero or one in ascii. |
| 223 | * |
| 224 | * Returns: size of formatted string. |
| 225 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 226 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 227 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 228 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 229 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 230 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 231 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 232 | struct lpfc_hba *phba = vport->phba; |
| 233 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 234 | } |
| 235 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 236 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 237 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 238 | * @dev: class converted to a Scsi_host structure. |
| 239 | * @attr: device attribute, not used. |
| 240 | * @buf: on return contains the scsi vpd model description. |
| 241 | * |
| 242 | * Returns: size of formatted string. |
| 243 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 244 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 245 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 246 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 247 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 248 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 249 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 250 | struct lpfc_hba *phba = vport->phba; |
| 251 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 252 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 253 | } |
| 254 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 255 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 256 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 257 | * @dev: class converted to a Scsi_host structure. |
| 258 | * @attr: device attribute, not used. |
| 259 | * @buf: on return contains the scsi vpd model name. |
| 260 | * |
| 261 | * Returns: size of formatted string. |
| 262 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 263 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 264 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 265 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 266 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 267 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 268 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 269 | struct lpfc_hba *phba = vport->phba; |
| 270 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 271 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 272 | } |
| 273 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 274 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 275 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 276 | * @dev: class converted to a Scsi_host structure. |
| 277 | * @attr: device attribute, not used. |
| 278 | * @buf: on return contains the scsi vpd program type. |
| 279 | * |
| 280 | * Returns: size of formatted string. |
| 281 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 282 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 283 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 284 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 285 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 286 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 287 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 288 | struct lpfc_hba *phba = vport->phba; |
| 289 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 290 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 291 | } |
| 292 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 293 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 294 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 295 | * @dev: class converted to a Scsi_host structure. |
| 296 | * @attr: device attribute, not used. |
| 297 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 298 | * |
| 299 | * Returns: size of formatted string. |
| 300 | **/ |
| 301 | static ssize_t |
| 302 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 303 | { |
| 304 | struct Scsi_Host *shost = class_to_shost(dev); |
| 305 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 306 | struct lpfc_hba *phba = vport->phba; |
| 307 | |
| 308 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 309 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 310 | } |
| 311 | |
| 312 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 313 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 314 | * @dev: class converted to a Scsi_host structure. |
| 315 | * @attr: device attribute, not used. |
| 316 | * @buf: on return contains scsi vpd program type. |
| 317 | * |
| 318 | * Returns: size of formatted string. |
| 319 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 320 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 321 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 322 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 323 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 324 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 325 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 326 | struct lpfc_hba *phba = vport->phba; |
| 327 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 328 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 329 | } |
| 330 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 331 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 332 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 333 | * @dev: class converted to a Scsi_host structure. |
| 334 | * @attr: device attribute, not used. |
| 335 | * @buf: on return contains the scsi vpd program type. |
| 336 | * |
| 337 | * Returns: size of formatted string. |
| 338 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 339 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 340 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 341 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 342 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 343 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 344 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 345 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 346 | char fwrev[32]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 347 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 348 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 349 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 350 | } |
| 351 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 352 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 353 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 354 | * @dev: class converted to a Scsi_host structure. |
| 355 | * @attr: device attribute, not used. |
| 356 | * @buf: on return contains the scsi vpd program type. |
| 357 | * |
| 358 | * Returns: size of formatted string. |
| 359 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 360 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 361 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 362 | { |
| 363 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 364 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 365 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 366 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 367 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 368 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 369 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 370 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 371 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 372 | |
| 373 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 374 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
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 ROM and FCode ascii strings. |
| 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_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 383 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 384 | { |
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; |
| 388 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 389 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 390 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 391 | |
| 392 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 393 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 394 | * @dev: class converted to a Scsi_host structure. |
| 395 | * @attr: device attribute, not used. |
| 396 | * @buf: on return contains text describing the state of the link. |
| 397 | * |
| 398 | * Notes: |
| 399 | * The switch statement has no default so zero will be returned. |
| 400 | * |
| 401 | * Returns: size of formatted string. |
| 402 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 403 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 404 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 405 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 406 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 407 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 408 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 409 | struct lpfc_hba *phba = vport->phba; |
| 410 | int len = 0; |
| 411 | |
| 412 | switch (phba->link_state) { |
| 413 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 414 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 415 | case LPFC_INIT_START: |
| 416 | case LPFC_INIT_MBX_CMDS: |
| 417 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 418 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 419 | if (phba->hba_flag & LINK_DISABLED) |
| 420 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 421 | "Link Down - User disabled\n"); |
| 422 | else |
| 423 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 424 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 425 | break; |
| 426 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 427 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 428 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 429 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 430 | |
| 431 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 432 | case LPFC_LOCAL_CFG_LINK: |
| 433 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 434 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 435 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 436 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 437 | case LPFC_FLOGI: |
| 438 | case LPFC_FABRIC_CFG_LINK: |
| 439 | case LPFC_NS_REG: |
| 440 | case LPFC_NS_QRY: |
| 441 | case LPFC_BUILD_DISC_LIST: |
| 442 | case LPFC_DISC_AUTH: |
| 443 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 444 | "Discovery\n"); |
| 445 | break; |
| 446 | case LPFC_VPORT_READY: |
| 447 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 448 | break; |
| 449 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 450 | case LPFC_VPORT_FAILED: |
| 451 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 452 | break; |
| 453 | |
| 454 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 455 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 456 | "Unknown\n"); |
| 457 | break; |
| 458 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 459 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 460 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 461 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 462 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 463 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 464 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 465 | " Public Loop\n"); |
| 466 | else |
| 467 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 468 | " Private Loop\n"); |
| 469 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 470 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 471 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 472 | " Fabric\n"); |
| 473 | else |
| 474 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 475 | " Point-2-Point\n"); |
| 476 | } |
| 477 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 478 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 479 | return len; |
| 480 | } |
| 481 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 482 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 483 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 484 | * @dev: class device that is converted into a Scsi_host. |
| 485 | * @attr: device attribute, not used. |
| 486 | * @buf: one or more lpfc_polling_flags values. |
| 487 | * @count: not used. |
| 488 | * |
| 489 | * Returns: |
| 490 | * -EINVAL if the buffer is not "up" or "down" |
| 491 | * return from link state change function if non-zero |
| 492 | * length of the buf on success |
| 493 | **/ |
| 494 | static ssize_t |
| 495 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 496 | const char *buf, size_t count) |
| 497 | { |
| 498 | struct Scsi_Host *shost = class_to_shost(dev); |
| 499 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 500 | struct lpfc_hba *phba = vport->phba; |
| 501 | |
| 502 | int status = -EINVAL; |
| 503 | |
| 504 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 505 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 506 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 507 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 508 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 509 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 510 | |
| 511 | if (status == 0) |
| 512 | return strlen(buf); |
| 513 | else |
| 514 | return status; |
| 515 | } |
| 516 | |
| 517 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 518 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 519 | * @dev: class device that is converted into a Scsi_host. |
| 520 | * @attr: device attribute, not used. |
| 521 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 522 | * |
| 523 | * Description: |
| 524 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 525 | * vport counts. |
| 526 | * |
| 527 | * Returns: size of formatted string. |
| 528 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 529 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 530 | lpfc_num_discovered_ports_show(struct device *dev, |
| 531 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 532 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 533 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 534 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 535 | |
| 536 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 537 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 538 | } |
| 539 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 540 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 541 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 542 | * @shost: Scsi_Host pointer. |
| 543 | * |
| 544 | * Description: |
| 545 | * Bring the link down gracefully then re-init the link. The firmware will |
| 546 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 547 | * |
| 548 | * Returns: |
| 549 | * -EPERM port offline or management commands are being blocked |
| 550 | * -ENOMEM cannot allocate memory for the mailbox command |
| 551 | * -EIO error sending the mailbox command |
| 552 | * zero for success |
| 553 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 554 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 555 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 556 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 557 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 558 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 559 | LPFC_MBOXQ_t *pmboxq; |
| 560 | int mbxstatus = MBXERR_ERROR; |
| 561 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 562 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 563 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 564 | return -EPERM; |
| 565 | |
| 566 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 567 | |
| 568 | if (!pmboxq) |
| 569 | return -ENOMEM; |
| 570 | |
| 571 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 572 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 573 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 574 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 575 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 576 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 577 | if ((mbxstatus == MBX_SUCCESS) && |
| 578 | (pmboxq->u.mb.mbxStatus == 0 || |
| 579 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 580 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 581 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 582 | phba->cfg_link_speed); |
| 583 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 584 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 585 | if ((mbxstatus == MBX_SUCCESS) && |
| 586 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 587 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 588 | "2859 SLI authentication is required " |
| 589 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 590 | } |
| 591 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 592 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 593 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 594 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 595 | |
| 596 | if (mbxstatus == MBXERR_ERROR) |
| 597 | return -EIO; |
| 598 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 599 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 600 | } |
| 601 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 602 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 603 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 604 | * @phba: lpfc_hba pointer. |
| 605 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 606 | * |
| 607 | * Notes: |
| 608 | * Assumes any error from lpfc_do_offline() will be negative. |
| 609 | * Can wait up to 5 seconds for the port ring buffers count |
| 610 | * 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] | 611 | * 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] | 612 | * |
| 613 | * Returns: |
| 614 | * -EIO error posting the event |
| 615 | * zero for success |
| 616 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 617 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 618 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 619 | { |
| 620 | struct completion online_compl; |
| 621 | struct lpfc_sli_ring *pring; |
| 622 | struct lpfc_sli *psli; |
| 623 | int status = 0; |
| 624 | int cnt = 0; |
| 625 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 626 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 627 | |
| 628 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 629 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 630 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 631 | if (rc == 0) |
| 632 | return -ENOMEM; |
| 633 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 634 | wait_for_completion(&online_compl); |
| 635 | |
| 636 | if (status != 0) |
| 637 | return -EIO; |
| 638 | |
| 639 | psli = &phba->sli; |
| 640 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 641 | /* Wait a little for things to settle down, but not |
| 642 | * long enough for dev loss timeout to expire. |
| 643 | */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 644 | for (i = 0; i < psli->num_rings; i++) { |
| 645 | pring = &psli->ring[i]; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 646 | while (pring->txcmplq_cnt) { |
| 647 | msleep(10); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 648 | if (cnt++ > 500) { /* 5 secs */ |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 649 | lpfc_printf_log(phba, |
| 650 | KERN_WARNING, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 651 | "0466 Outstanding IO when " |
| 652 | "bringing Adapter offline\n"); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 653 | break; |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 659 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 660 | if (rc == 0) |
| 661 | return -ENOMEM; |
| 662 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 663 | wait_for_completion(&online_compl); |
| 664 | |
| 665 | if (status != 0) |
| 666 | return -EIO; |
| 667 | |
| 668 | return 0; |
| 669 | } |
| 670 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 671 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 672 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 673 | * @phba: lpfc_hba pointer. |
| 674 | * |
| 675 | * Description: |
| 676 | * If the port is configured to allow a reset then the hba is brought |
| 677 | * offline then online. |
| 678 | * |
| 679 | * Notes: |
| 680 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 681 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 682 | * |
| 683 | * Returns: |
| 684 | * lpfc_do_offline() return code if not zero |
| 685 | * -EIO reset not configured or error posting the event |
| 686 | * zero for success |
| 687 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 688 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 689 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 690 | { |
| 691 | struct completion online_compl; |
| 692 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 693 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 694 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 695 | if (!phba->cfg_enable_hba_reset) |
| 696 | return -EIO; |
| 697 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 698 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 699 | |
| 700 | if (status != 0) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 701 | return status; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 702 | |
| 703 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 704 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 705 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 706 | if (rc == 0) |
| 707 | return -ENOMEM; |
| 708 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 709 | wait_for_completion(&online_compl); |
| 710 | |
| 711 | if (status != 0) |
| 712 | return -EIO; |
| 713 | |
| 714 | return 0; |
| 715 | } |
| 716 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 717 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 718 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 719 | * @dev: class device that is converted into a Scsi_host. |
| 720 | * @attr: device attribute, not used. |
| 721 | * @buf: containing the string "selective". |
| 722 | * @count: unused variable. |
| 723 | * |
| 724 | * Description: |
| 725 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 726 | * is called to perform the reset. |
| 727 | * |
| 728 | * Notes: |
| 729 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 730 | * 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] | 731 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 732 | * |
| 733 | * Returns: |
| 734 | * -EINVAL if the buffer does not contain the string "selective" |
| 735 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 736 | * return value of lpfc_selective_reset() if the call fails |
| 737 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 738 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 739 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 740 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 741 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 742 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 743 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 744 | struct lpfc_hba *phba = vport->phba; |
| 745 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 746 | int status = -EINVAL; |
| 747 | |
| 748 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 749 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 750 | |
| 751 | if (status == 0) |
| 752 | return strlen(buf); |
| 753 | else |
| 754 | return status; |
| 755 | } |
| 756 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 757 | /** |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame^] | 758 | * lpfc_sli4_fw_dump_request - Request firmware to perform a firmware dump |
| 759 | * @phba: lpfc_hba pointer. |
| 760 | * |
| 761 | * Description: |
| 762 | * Request SLI4 interface type-2 device to perform a dump of firmware dump |
| 763 | * object into it's /dbg directory of the flash file system. |
| 764 | * |
| 765 | * Returns: |
| 766 | * zero for success |
| 767 | **/ |
| 768 | static ssize_t |
| 769 | lpfc_sli4_fw_dump_request(struct lpfc_hba *phba) |
| 770 | { |
| 771 | struct completion online_compl; |
| 772 | uint32_t reg_val; |
| 773 | int status = 0; |
| 774 | int rc; |
| 775 | |
| 776 | if (!phba->cfg_enable_hba_reset) |
| 777 | return -EIO; |
| 778 | |
| 779 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 780 | |
| 781 | if (status != 0) |
| 782 | return status; |
| 783 | |
| 784 | /* wait for the device to be quiesced before firmware reset */ |
| 785 | msleep(100); |
| 786 | |
| 787 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 788 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 789 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 790 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 791 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 792 | /* flush */ |
| 793 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 794 | |
| 795 | /* delay driver action following IF_TYPE_2 reset */ |
| 796 | msleep(100); |
| 797 | |
| 798 | init_completion(&online_compl); |
| 799 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
| 800 | LPFC_EVT_ONLINE); |
| 801 | if (rc == 0) |
| 802 | return -ENOMEM; |
| 803 | |
| 804 | wait_for_completion(&online_compl); |
| 805 | |
| 806 | if (status != 0) |
| 807 | return -EIO; |
| 808 | |
| 809 | return 0; |
| 810 | } |
| 811 | |
| 812 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 813 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 814 | * @dev: class device that is converted into a Scsi_host. |
| 815 | * @attr: device attribute, not used. |
| 816 | * @buf: on return contains the ascii number of nport events. |
| 817 | * |
| 818 | * Returns: size of formatted string. |
| 819 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 820 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 821 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 822 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 823 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 824 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 825 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 826 | struct lpfc_hba *phba = vport->phba; |
| 827 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 828 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 829 | } |
| 830 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 831 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 832 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 833 | * @dev: class device that is converted into a Scsi_host. |
| 834 | * @attr: device attribute, not used. |
| 835 | * @buf: on return contains the state of the adapter. |
| 836 | * |
| 837 | * Returns: size of formatted string. |
| 838 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 839 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 840 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 841 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 842 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 843 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 844 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 845 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 846 | char * state; |
| 847 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 848 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 849 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 850 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 851 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 852 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 853 | state = "offline"; |
| 854 | else |
| 855 | state = "online"; |
| 856 | |
| 857 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 858 | } |
| 859 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 860 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 861 | * 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] | 862 | * @dev: class device that is converted into a Scsi_host. |
| 863 | * @attr: device attribute, not used. |
| 864 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 865 | * @count: unused variable. |
| 866 | * |
| 867 | * Returns: |
| 868 | * -EACCES if enable hba reset not enabled |
| 869 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 870 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 871 | * buf length greater than zero indicates success |
| 872 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 873 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 874 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 875 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 876 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 877 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 878 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 879 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 880 | struct completion online_compl; |
| 881 | int status=0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 882 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 883 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 884 | if (!phba->cfg_enable_hba_reset) |
| 885 | return -EACCES; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 886 | init_completion(&online_compl); |
| 887 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 888 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 889 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 890 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 891 | if (rc == 0) |
| 892 | return -ENOMEM; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 893 | wait_for_completion(&online_compl); |
| 894 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 895 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 896 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 897 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 898 | return -EINVAL; |
| 899 | else |
| 900 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 901 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 902 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 903 | return -EINVAL; |
| 904 | else |
| 905 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame^] | 906 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
| 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 | else |
| 912 | status = lpfc_sli4_fw_dump_request(phba); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 913 | else |
| 914 | return -EINVAL; |
| 915 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 916 | if (!status) |
| 917 | return strlen(buf); |
| 918 | else |
| 919 | return -EIO; |
| 920 | } |
| 921 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 922 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 923 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 924 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 925 | * @mxri: max xri count. |
| 926 | * @axri: available xri count. |
| 927 | * @mrpi: max rpi count. |
| 928 | * @arpi: available rpi count. |
| 929 | * @mvpi: max vpi count. |
| 930 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 931 | * |
| 932 | * Description: |
| 933 | * If an integer pointer for an count is not null then the value for the |
| 934 | * count is returned. |
| 935 | * |
| 936 | * Returns: |
| 937 | * zero on error |
| 938 | * one for success |
| 939 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 940 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 941 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 942 | uint32_t *mxri, uint32_t *axri, |
| 943 | uint32_t *mrpi, uint32_t *arpi, |
| 944 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 945 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 946 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 947 | LPFC_MBOXQ_t *pmboxq; |
| 948 | MAILBOX_t *pmb; |
| 949 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 950 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 951 | |
| 952 | /* |
| 953 | * prevent udev from issuing mailbox commands until the port is |
| 954 | * configured. |
| 955 | */ |
| 956 | if (phba->link_state < LPFC_LINK_DOWN || |
| 957 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 958 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 959 | return 0; |
| 960 | |
| 961 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 962 | return 0; |
| 963 | |
| 964 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 965 | if (!pmboxq) |
| 966 | return 0; |
| 967 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 968 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 969 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 970 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 971 | pmb->mbxOwner = OWN_HOST; |
| 972 | pmboxq->context1 = NULL; |
| 973 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 974 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 975 | rc = MBX_NOT_FINISHED; |
| 976 | else |
| 977 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 978 | |
| 979 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 980 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 981 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 982 | return 0; |
| 983 | } |
| 984 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 985 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 986 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 987 | if (mrpi) |
| 988 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 989 | if (arpi) |
| 990 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 991 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 992 | if (mxri) |
| 993 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 994 | if (axri) |
| 995 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 996 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 997 | |
| 998 | /* Account for differences with SLI-3. Get vpi count from |
| 999 | * mailbox data and subtract one for max vpi value. |
| 1000 | */ |
| 1001 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1002 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1003 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1004 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1005 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1006 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1007 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1008 | } else { |
| 1009 | if (mrpi) |
| 1010 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1011 | if (arpi) |
| 1012 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1013 | if (mxri) |
| 1014 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1015 | if (axri) |
| 1016 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1017 | if (mvpi) |
| 1018 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1019 | if (avpi) |
| 1020 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1021 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1022 | |
| 1023 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1024 | return 1; |
| 1025 | } |
| 1026 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1027 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1028 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1029 | * @dev: class device that is converted into a Scsi_host. |
| 1030 | * @attr: device attribute, not used. |
| 1031 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1032 | * |
| 1033 | * Description: |
| 1034 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1035 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1036 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1037 | * must check for "Unknown" in the buffer to detect a failure. |
| 1038 | * |
| 1039 | * Returns: size of formatted string. |
| 1040 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1041 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1042 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1043 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1044 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1045 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1046 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1047 | struct lpfc_hba *phba = vport->phba; |
| 1048 | uint32_t cnt; |
| 1049 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1050 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1051 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1052 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1053 | } |
| 1054 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1055 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1056 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1057 | * @dev: class device that is converted into a Scsi_host. |
| 1058 | * @attr: device attribute, not used. |
| 1059 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1060 | * |
| 1061 | * Description: |
| 1062 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1063 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1064 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1065 | * must check for "Unknown" in the buffer to detect a failure. |
| 1066 | * |
| 1067 | * Returns: size of formatted string. |
| 1068 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1069 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1070 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1071 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1072 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1073 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1074 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1075 | struct lpfc_hba *phba = vport->phba; |
| 1076 | uint32_t cnt, acnt; |
| 1077 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1078 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1079 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1080 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1081 | } |
| 1082 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1083 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1084 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1085 | * @dev: class device that is converted into a Scsi_host. |
| 1086 | * @attr: device attribute, not used. |
| 1087 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1088 | * |
| 1089 | * Description: |
| 1090 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1091 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1092 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1093 | * must check for "Unknown" in the buffer to detect a failure. |
| 1094 | * |
| 1095 | * Returns: size of formatted string. |
| 1096 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1097 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1098 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1099 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1100 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1101 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1102 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1103 | struct lpfc_hba *phba = vport->phba; |
| 1104 | uint32_t cnt; |
| 1105 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1106 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1107 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1108 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1109 | } |
| 1110 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1111 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1112 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1113 | * @dev: class device that is converted into a Scsi_host. |
| 1114 | * @attr: device attribute, not used. |
| 1115 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1116 | * |
| 1117 | * Description: |
| 1118 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1119 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1120 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1121 | * must check for "Unknown" in the buffer to detect a failure. |
| 1122 | * |
| 1123 | * Returns: size of formatted string. |
| 1124 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1125 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1126 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1127 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1128 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1129 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1130 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1131 | struct lpfc_hba *phba = vport->phba; |
| 1132 | uint32_t cnt, acnt; |
| 1133 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1134 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1135 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1136 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1137 | } |
| 1138 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1139 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1140 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1141 | * @dev: class device that is converted into a Scsi_host. |
| 1142 | * @attr: device attribute, not used. |
| 1143 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1144 | * |
| 1145 | * Description: |
| 1146 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1147 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1148 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1149 | * must check for "Unknown" in the buffer to detect a failure. |
| 1150 | * |
| 1151 | * Returns: size of formatted string. |
| 1152 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1153 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1154 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1155 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1156 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1157 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1158 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1159 | struct lpfc_hba *phba = vport->phba; |
| 1160 | uint32_t cnt; |
| 1161 | |
| 1162 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1163 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1164 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1165 | } |
| 1166 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1167 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1168 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1169 | * @dev: class device that is converted into a Scsi_host. |
| 1170 | * @attr: device attribute, not used. |
| 1171 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1172 | * |
| 1173 | * Description: |
| 1174 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1175 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1176 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1177 | * must check for "Unknown" in the buffer to detect a failure. |
| 1178 | * |
| 1179 | * Returns: size of formatted string. |
| 1180 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1181 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1182 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1183 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1184 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1185 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1186 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1187 | struct lpfc_hba *phba = vport->phba; |
| 1188 | uint32_t cnt, acnt; |
| 1189 | |
| 1190 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1191 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1192 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1193 | } |
| 1194 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1195 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1196 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1197 | * @dev: class device that is converted into a Scsi_host. |
| 1198 | * @attr: device attribute, not used. |
| 1199 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1200 | * |
| 1201 | * Description: |
| 1202 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1203 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1204 | * the id of the vport. |
| 1205 | * |
| 1206 | * Returns: size of formatted string. |
| 1207 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1208 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1209 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1210 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1211 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1212 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1213 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1214 | struct lpfc_hba *phba = vport->phba; |
| 1215 | |
| 1216 | if (!(phba->max_vpi)) |
| 1217 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1218 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1219 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1220 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1221 | } |
| 1222 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1223 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1224 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1225 | * @dev: class device that is converted into a Scsi_host. |
| 1226 | * @attr: device attribute, not used. |
| 1227 | * @buf: on return contains the cfg_poll in hex. |
| 1228 | * |
| 1229 | * Notes: |
| 1230 | * cfg_poll should be a lpfc_polling_flags type. |
| 1231 | * |
| 1232 | * Returns: size of formatted string. |
| 1233 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1234 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1235 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1236 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1237 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1238 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1239 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1240 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1241 | |
| 1242 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1243 | } |
| 1244 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1245 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1246 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1247 | * @dev: class device that is converted into a Scsi_host. |
| 1248 | * @attr: device attribute, not used. |
| 1249 | * @buf: one or more lpfc_polling_flags values. |
| 1250 | * @count: not used. |
| 1251 | * |
| 1252 | * Notes: |
| 1253 | * buf contents converted to integer and checked for a valid value. |
| 1254 | * |
| 1255 | * Returns: |
| 1256 | * -EINVAL if the buffer connot be converted or is out of range |
| 1257 | * length of the buf on success |
| 1258 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1259 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1260 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1261 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1262 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1263 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1264 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1265 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1266 | uint32_t creg_val; |
| 1267 | uint32_t old_val; |
| 1268 | int val=0; |
| 1269 | |
| 1270 | if (!isdigit(buf[0])) |
| 1271 | return -EINVAL; |
| 1272 | |
| 1273 | if (sscanf(buf, "%i", &val) != 1) |
| 1274 | return -EINVAL; |
| 1275 | |
| 1276 | if ((val & 0x3) != val) |
| 1277 | return -EINVAL; |
| 1278 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1279 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1280 | val = 0; |
| 1281 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1282 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1283 | |
| 1284 | old_val = phba->cfg_poll; |
| 1285 | |
| 1286 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1287 | if ((val & DISABLE_FCP_RING_INT) && |
| 1288 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1289 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1290 | spin_unlock_irq(&phba->hbalock); |
| 1291 | return -EINVAL; |
| 1292 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1293 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1294 | writel(creg_val, phba->HCregaddr); |
| 1295 | readl(phba->HCregaddr); /* flush */ |
| 1296 | |
| 1297 | lpfc_poll_start_timer(phba); |
| 1298 | } |
| 1299 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1300 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1301 | return -EINVAL; |
| 1302 | } |
| 1303 | |
| 1304 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1305 | (old_val & DISABLE_FCP_RING_INT)) |
| 1306 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1307 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1308 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1309 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1310 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1311 | spin_unlock_irq(&phba->hbalock); |
| 1312 | return -EINVAL; |
| 1313 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1314 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1315 | writel(creg_val, phba->HCregaddr); |
| 1316 | readl(phba->HCregaddr); /* flush */ |
| 1317 | } |
| 1318 | |
| 1319 | phba->cfg_poll = val; |
| 1320 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1321 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1322 | |
| 1323 | return strlen(buf); |
| 1324 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1325 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1326 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1327 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1328 | * @dev: class unused variable. |
| 1329 | * @attr: device attribute, not used. |
| 1330 | * @buf: on return contains the module description text. |
| 1331 | * |
| 1332 | * Returns: size of formatted string. |
| 1333 | **/ |
| 1334 | static ssize_t |
| 1335 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1336 | char *buf) |
| 1337 | { |
| 1338 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1339 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1340 | struct lpfc_hba *phba = vport->phba; |
| 1341 | |
| 1342 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1343 | } |
| 1344 | |
| 1345 | /** |
| 1346 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1347 | * @dev: class unused variable. |
| 1348 | * @attr: device attribute, not used. |
| 1349 | * @buf: on return contains the module description text. |
| 1350 | * |
| 1351 | * Returns: size of formatted string. |
| 1352 | **/ |
| 1353 | static ssize_t |
| 1354 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1355 | char *buf) |
| 1356 | { |
| 1357 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1358 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1359 | struct lpfc_hba *phba = vport->phba; |
| 1360 | |
| 1361 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1362 | } |
| 1363 | |
| 1364 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1365 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1366 | * @dev: class converted to a Scsi_host structure. |
| 1367 | * @attr: device attribute, not used. |
| 1368 | * @buf: on return contains the formatted text. |
| 1369 | * |
| 1370 | * Returns: size of formatted string. |
| 1371 | **/ |
| 1372 | static ssize_t |
| 1373 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1374 | char *buf) |
| 1375 | { |
| 1376 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1377 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1378 | struct lpfc_hba *phba = vport->phba; |
| 1379 | |
| 1380 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1381 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1382 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1383 | "" : "Not "); |
| 1384 | } |
| 1385 | |
| 1386 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1387 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1388 | * |
| 1389 | * Description: |
| 1390 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1391 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1392 | * |
| 1393 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1394 | * @dev: class device that is converted into a Scsi_host. |
| 1395 | * @attr: device attribute, not used. |
| 1396 | * @buf: on return contains the attribute value in decimal. |
| 1397 | * |
| 1398 | * Returns: size of formatted string. |
| 1399 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1400 | #define lpfc_param_show(attr) \ |
| 1401 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1402 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1403 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1404 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1405 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1406 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1407 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1408 | uint val = 0;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1409 | val = phba->cfg_##attr;\ |
| 1410 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1411 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1412 | } |
| 1413 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1414 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1415 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1416 | * |
| 1417 | * Description: |
| 1418 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1419 | * into a function with the name lpfc_hba_queue_depth_show |
| 1420 | * |
| 1421 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1422 | * @dev: class device that is converted into a Scsi_host. |
| 1423 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1424 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1425 | * |
| 1426 | * Returns: size of formatted string. |
| 1427 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1428 | #define lpfc_param_hex_show(attr) \ |
| 1429 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1430 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1431 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1432 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1433 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1434 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1435 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1436 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1437 | val = phba->cfg_##attr;\ |
| 1438 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1439 | phba->cfg_##attr);\ |
| 1440 | } |
| 1441 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1442 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1443 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1444 | * |
| 1445 | * Description: |
| 1446 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1447 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1448 | * takes a default argument, a minimum and maximum argument. |
| 1449 | * |
| 1450 | * lpfc_##attr##_init: Initializes an attribute. |
| 1451 | * @phba: pointer the the adapter structure. |
| 1452 | * @val: integer attribute value. |
| 1453 | * |
| 1454 | * Validates the min and max values then sets the adapter config field |
| 1455 | * accordingly, or uses the default if out of range and prints an error message. |
| 1456 | * |
| 1457 | * Returns: |
| 1458 | * zero on success |
| 1459 | * -EINVAL if default used |
| 1460 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1461 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1462 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1463 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1464 | { \ |
| 1465 | if (val >= minval && val <= maxval) {\ |
| 1466 | phba->cfg_##attr = val;\ |
| 1467 | return 0;\ |
| 1468 | }\ |
| 1469 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1470 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1471 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1472 | phba->cfg_##attr = default;\ |
| 1473 | return -EINVAL;\ |
| 1474 | } |
| 1475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1476 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1477 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1478 | * |
| 1479 | * Description: |
| 1480 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1481 | * into a function with the name lpfc_hba_queue_depth_set |
| 1482 | * |
| 1483 | * lpfc_##attr##_set: Sets an attribute value. |
| 1484 | * @phba: pointer the the adapter structure. |
| 1485 | * @val: integer attribute value. |
| 1486 | * |
| 1487 | * Description: |
| 1488 | * Validates the min and max values then sets the |
| 1489 | * adapter config field if in the valid range. prints error message |
| 1490 | * and does not set the parameter if invalid. |
| 1491 | * |
| 1492 | * Returns: |
| 1493 | * zero on success |
| 1494 | * -EINVAL if val is invalid |
| 1495 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1496 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1497 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1498 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1499 | { \ |
| 1500 | if (val >= minval && val <= maxval) {\ |
| 1501 | phba->cfg_##attr = val;\ |
| 1502 | return 0;\ |
| 1503 | }\ |
| 1504 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1505 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1506 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1507 | return -EINVAL;\ |
| 1508 | } |
| 1509 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1510 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1511 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1512 | * |
| 1513 | * Description: |
| 1514 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1515 | * into a function with the name lpfc_hba_queue_depth_store. |
| 1516 | * |
| 1517 | * lpfc_##attr##_store: Set an sttribute value. |
| 1518 | * @dev: class device that is converted into a Scsi_host. |
| 1519 | * @attr: device attribute, not used. |
| 1520 | * @buf: contains the attribute value in ascii. |
| 1521 | * @count: not used. |
| 1522 | * |
| 1523 | * Description: |
| 1524 | * Convert the ascii text number to an integer, then |
| 1525 | * use the lpfc_##attr##_set function to set the value. |
| 1526 | * |
| 1527 | * Returns: |
| 1528 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1529 | * length of buffer upon success. |
| 1530 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1531 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1532 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1533 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1534 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1535 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1536 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1537 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1538 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1539 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1540 | if (!isdigit(buf[0]))\ |
| 1541 | return -EINVAL;\ |
| 1542 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1543 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1544 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 1545 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1546 | else \ |
| 1547 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1548 | } |
| 1549 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1550 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1551 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1552 | * |
| 1553 | * Description: |
| 1554 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1555 | * into a function with the name lpfc_hba_queue_depth_show |
| 1556 | * |
| 1557 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 1558 | * @dev: class device that is converted into a Scsi_host. |
| 1559 | * @attr: device attribute, not used. |
| 1560 | * @buf: on return contains the attribute value in decimal. |
| 1561 | * |
| 1562 | * Returns: length of formatted string. |
| 1563 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1564 | #define lpfc_vport_param_show(attr) \ |
| 1565 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1566 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1567 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1568 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1569 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1570 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1571 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1572 | val = vport->cfg_##attr;\ |
| 1573 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 1574 | } |
| 1575 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1576 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1577 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1578 | * |
| 1579 | * Description: |
| 1580 | * Macro that given an attr e.g. |
| 1581 | * hba_queue_depth expands into a function with the name |
| 1582 | * lpfc_hba_queue_depth_show |
| 1583 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1584 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1585 | * @dev: class device that is converted into a Scsi_host. |
| 1586 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1587 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1588 | * |
| 1589 | * Returns: length of formatted string. |
| 1590 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1591 | #define lpfc_vport_param_hex_show(attr) \ |
| 1592 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1593 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1594 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1595 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1596 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1597 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1598 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1599 | val = vport->cfg_##attr;\ |
| 1600 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 1601 | } |
| 1602 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1603 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1604 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1605 | * |
| 1606 | * Description: |
| 1607 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1608 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1609 | * takes a default argument, a minimum and maximum argument. |
| 1610 | * |
| 1611 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 1612 | * adapter config field accordingly, or uses the default if out of range |
| 1613 | * and prints an error message. |
| 1614 | * @phba: pointer the the adapter structure. |
| 1615 | * @val: integer attribute value. |
| 1616 | * |
| 1617 | * Returns: |
| 1618 | * zero on success |
| 1619 | * -EINVAL if default used |
| 1620 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1621 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 1622 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1623 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1624 | { \ |
| 1625 | if (val >= minval && val <= maxval) {\ |
| 1626 | vport->cfg_##attr = val;\ |
| 1627 | return 0;\ |
| 1628 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1629 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1630 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1631 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1632 | vport->cfg_##attr = default;\ |
| 1633 | return -EINVAL;\ |
| 1634 | } |
| 1635 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1636 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1637 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1638 | * |
| 1639 | * Description: |
| 1640 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1641 | * into a function with the name lpfc_hba_queue_depth_set |
| 1642 | * |
| 1643 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 1644 | * adapter config field if in the valid range. prints error message |
| 1645 | * and does not set the parameter if invalid. |
| 1646 | * @phba: pointer the the adapter structure. |
| 1647 | * @val: integer attribute value. |
| 1648 | * |
| 1649 | * Returns: |
| 1650 | * zero on success |
| 1651 | * -EINVAL if val is invalid |
| 1652 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1653 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 1654 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1655 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1656 | { \ |
| 1657 | if (val >= minval && val <= maxval) {\ |
| 1658 | vport->cfg_##attr = val;\ |
| 1659 | return 0;\ |
| 1660 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1661 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1662 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1663 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1664 | return -EINVAL;\ |
| 1665 | } |
| 1666 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1667 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1668 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1669 | * |
| 1670 | * Description: |
| 1671 | * Macro that given an attr e.g. hba_queue_depth |
| 1672 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 1673 | * |
| 1674 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 1675 | * use the lpfc_##attr##_set function to set the value. |
| 1676 | * @cdev: class device that is converted into a Scsi_host. |
| 1677 | * @buf: contains the attribute value in decimal. |
| 1678 | * @count: not used. |
| 1679 | * |
| 1680 | * Returns: |
| 1681 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 1682 | * length of buffer upon success. |
| 1683 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1684 | #define lpfc_vport_param_store(attr) \ |
| 1685 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1686 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 1687 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1688 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1689 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1690 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1691 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1692 | if (!isdigit(buf[0]))\ |
| 1693 | return -EINVAL;\ |
| 1694 | if (sscanf(buf, "%i", &val) != 1)\ |
| 1695 | return -EINVAL;\ |
| 1696 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 1697 | return strlen(buf);\ |
| 1698 | else \ |
| 1699 | return -EINVAL;\ |
| 1700 | } |
| 1701 | |
| 1702 | |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1703 | #define LPFC_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1704 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1705 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1706 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1707 | lpfc_param_init(name, defval, minval, maxval) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1708 | |
| 1709 | #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1710 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1711 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1712 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1713 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1714 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1715 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1716 | |
| 1717 | #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1718 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1719 | module_param(lpfc_##name, uint, S_IRUGO);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1720 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1721 | lpfc_param_show(name)\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1722 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1723 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1724 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1725 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1726 | lpfc_##name##_show, lpfc_##name##_store) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1727 | |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1728 | #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1729 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1730 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1731 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1732 | lpfc_param_hex_show(name)\ |
| 1733 | lpfc_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1734 | 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] | 1735 | |
| 1736 | #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1737 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1738 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1739 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1740 | lpfc_param_hex_show(name)\ |
| 1741 | lpfc_param_init(name, defval, minval, maxval)\ |
| 1742 | lpfc_param_set(name, defval, minval, maxval)\ |
| 1743 | lpfc_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1744 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1745 | lpfc_##name##_show, lpfc_##name##_store) |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1746 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1747 | #define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1748 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1749 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1750 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1751 | lpfc_vport_param_init(name, defval, minval, maxval) |
| 1752 | |
| 1753 | #define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1754 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1755 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1756 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1757 | lpfc_vport_param_show(name)\ |
| 1758 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1759 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1760 | |
| 1761 | #define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1762 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1763 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1764 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1765 | lpfc_vport_param_show(name)\ |
| 1766 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 1767 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 1768 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1769 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1770 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1771 | |
| 1772 | #define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1773 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1774 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1775 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1776 | lpfc_vport_param_hex_show(name)\ |
| 1777 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1778 | static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1779 | |
| 1780 | #define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1781 | static uint lpfc_##name = defval;\ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1782 | module_param(lpfc_##name, uint, S_IRUGO);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1783 | MODULE_PARM_DESC(lpfc_##name, desc);\ |
| 1784 | lpfc_vport_param_hex_show(name)\ |
| 1785 | lpfc_vport_param_init(name, defval, minval, maxval)\ |
| 1786 | lpfc_vport_param_set(name, defval, minval, maxval)\ |
| 1787 | lpfc_vport_param_store(name)\ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1788 | static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ |
| 1789 | lpfc_##name##_show, lpfc_##name##_store) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1790 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 1791 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 1792 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 1793 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 1794 | 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] | 1795 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 1796 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 1797 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 1798 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 1799 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 1800 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 1801 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 1802 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1803 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 1804 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1805 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 1806 | lpfc_option_rom_version_show, NULL); |
| 1807 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 1808 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 1809 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1810 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 1811 | 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] | 1812 | 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] | 1813 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 1814 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 1815 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 1816 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 1817 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 1818 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 1819 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 1820 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 1821 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 1822 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 1823 | 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] | 1824 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 1825 | 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] | 1826 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1827 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1828 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1829 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1830 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1831 | * 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] | 1832 | * @dev: class device that is converted into a Scsi_host. |
| 1833 | * @attr: device attribute, not used. |
| 1834 | * @buf: containing the string lpfc_soft_wwn_key. |
| 1835 | * @count: must be size of lpfc_soft_wwn_key. |
| 1836 | * |
| 1837 | * Returns: |
| 1838 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 1839 | * length of buf indicates success |
| 1840 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1841 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1842 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 1843 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1844 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1845 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1846 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1847 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1848 | unsigned int cnt = count; |
| 1849 | |
| 1850 | /* |
| 1851 | * We're doing a simple sanity check for soft_wwpn setting. |
| 1852 | * We require that the user write a specific key to enable |
| 1853 | * the soft_wwpn attribute to be settable. Once the attribute |
| 1854 | * is written, the enable key resets. If further updates are |
| 1855 | * desired, the key must be written again to re-enable the |
| 1856 | * attribute. |
| 1857 | * |
| 1858 | * The "key" is not secret - it is a hardcoded string shown |
| 1859 | * here. The intent is to protect against the random user or |
| 1860 | * application that is just writing attributes. |
| 1861 | */ |
| 1862 | |
| 1863 | /* count may include a LF at end of string */ |
| 1864 | if (buf[cnt-1] == '\n') |
| 1865 | cnt--; |
| 1866 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1867 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 1868 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1869 | return -EINVAL; |
| 1870 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1871 | phba->soft_wwn_enable = 1; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1872 | return count; |
| 1873 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1874 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 1875 | lpfc_soft_wwn_enable_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1876 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1877 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1878 | * 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] | 1879 | * @dev: class device that is converted into a Scsi_host. |
| 1880 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1881 | * @buf: on return contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1882 | * |
| 1883 | * Returns: size of formatted string. |
| 1884 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1885 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1886 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 1887 | char *buf) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1888 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1889 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1890 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1891 | struct lpfc_hba *phba = vport->phba; |
| 1892 | |
Randy Dunlap | afc071e | 2006-10-23 21:47:13 -0700 | [diff] [blame] | 1893 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 1894 | (unsigned long long)phba->cfg_soft_wwpn); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1895 | } |
| 1896 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1897 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1898 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1899 | * @dev class device that is converted into a Scsi_host. |
| 1900 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1901 | * @buf: contains the wwpn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1902 | * @count: number of wwpn bytes in buf |
| 1903 | * |
| 1904 | * Returns: |
| 1905 | * -EACCES hba reset not enabled, adapter over temp |
| 1906 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 1907 | * -EIO error taking adapter offline or online |
| 1908 | * value of count on success |
| 1909 | **/ |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1910 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1911 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 1912 | const char *buf, size_t count) |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1913 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1914 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1915 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1916 | struct lpfc_hba *phba = vport->phba; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1917 | struct completion online_compl; |
| 1918 | int stat1=0, stat2=0; |
| 1919 | unsigned int i, j, cnt=count; |
| 1920 | u8 wwpn[8]; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1921 | int rc; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1922 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1923 | if (!phba->cfg_enable_hba_reset) |
| 1924 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 1925 | spin_lock_irq(&phba->hbalock); |
| 1926 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 1927 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1928 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 1929 | } |
| 1930 | spin_unlock_irq(&phba->hbalock); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1931 | /* count may include a LF at end of string */ |
| 1932 | if (buf[cnt-1] == '\n') |
| 1933 | cnt--; |
| 1934 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1935 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1936 | ((cnt == 17) && (*buf++ != 'x')) || |
| 1937 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 1938 | return -EINVAL; |
| 1939 | |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1940 | phba->soft_wwn_enable = 0; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1941 | |
| 1942 | memset(wwpn, 0, sizeof(wwpn)); |
| 1943 | |
| 1944 | /* Validate and store the new name */ |
| 1945 | for (i=0, j=0; i < 16; i++) { |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 1946 | int value; |
| 1947 | |
| 1948 | value = hex_to_bin(*buf++); |
| 1949 | if (value >= 0) |
| 1950 | j = (j << 4) | value; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1951 | else |
| 1952 | return -EINVAL; |
| 1953 | if (i % 2) { |
| 1954 | wwpn[i/2] = j & 0xff; |
| 1955 | j = 0; |
| 1956 | } |
| 1957 | } |
| 1958 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1959 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1960 | if (phba->cfg_soft_wwnn) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1961 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1962 | |
| 1963 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 1964 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 1965 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1966 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1967 | if (stat1) |
| 1968 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1969 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 1970 | "reinit adapter - %d\n", stat1); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1971 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1972 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 1973 | LPFC_EVT_ONLINE); |
| 1974 | if (rc == 0) |
| 1975 | return -ENOMEM; |
| 1976 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1977 | wait_for_completion(&online_compl); |
| 1978 | if (stat2) |
| 1979 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1980 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 1981 | "reinit adapter - %d\n", stat2); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1982 | return (stat1 || stat2) ? -EIO : count; |
| 1983 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1984 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ |
| 1985 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 1986 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1987 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1988 | * 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] | 1989 | * @dev: class device that is converted into a Scsi_host. |
| 1990 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1991 | * @buf: on return contains the wwnn in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1992 | * |
| 1993 | * Returns: size of formatted string. |
| 1994 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1995 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1996 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 1997 | char *buf) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 1998 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1999 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2000 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2001 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2002 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2003 | } |
| 2004 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2005 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2006 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2007 | * @cdev: class device that is converted into a Scsi_host. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2008 | * @buf: contains the ww node name in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2009 | * @count: number of wwnn bytes in buf. |
| 2010 | * |
| 2011 | * Returns: |
| 2012 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2013 | * value of count on success |
| 2014 | **/ |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2015 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2016 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2017 | const char *buf, size_t count) |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2018 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2019 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2020 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2021 | unsigned int i, j, cnt=count; |
| 2022 | u8 wwnn[8]; |
| 2023 | |
| 2024 | /* count may include a LF at end of string */ |
| 2025 | if (buf[cnt-1] == '\n') |
| 2026 | cnt--; |
| 2027 | |
| 2028 | if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) || |
| 2029 | ((cnt == 17) && (*buf++ != 'x')) || |
| 2030 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2031 | return -EINVAL; |
| 2032 | |
| 2033 | /* |
| 2034 | * Allow wwnn to be set many times, as long as the enable is set. |
| 2035 | * However, once the wwpn is set, everything locks. |
| 2036 | */ |
| 2037 | |
| 2038 | memset(wwnn, 0, sizeof(wwnn)); |
| 2039 | |
| 2040 | /* Validate and store the new name */ |
| 2041 | for (i=0, j=0; i < 16; i++) { |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 2042 | int value; |
| 2043 | |
| 2044 | value = hex_to_bin(*buf++); |
| 2045 | if (value >= 0) |
| 2046 | j = (j << 4) | value; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2047 | else |
| 2048 | return -EINVAL; |
| 2049 | if (i % 2) { |
| 2050 | wwnn[i/2] = j & 0xff; |
| 2051 | j = 0; |
| 2052 | } |
| 2053 | } |
| 2054 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2055 | |
| 2056 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2057 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2058 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2059 | |
| 2060 | return count; |
| 2061 | } |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2062 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ |
| 2063 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2064 | |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2065 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2066 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2067 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2068 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 2069 | " 0 - none," |
| 2070 | " 1 - poll with interrupts enabled" |
| 2071 | " 3 - poll and disable FCP ring interrupts"); |
| 2072 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2073 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 2074 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2075 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2076 | int lpfc_sli_mode = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2077 | module_param(lpfc_sli_mode, int, S_IRUGO); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2078 | MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" |
| 2079 | " 0 - auto (SLI-3 if supported)," |
| 2080 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 2081 | " 3 - select SLI-3"); |
| 2082 | |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2083 | int lpfc_enable_npiv = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2084 | module_param(lpfc_enable_npiv, int, S_IRUGO); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 2085 | MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); |
| 2086 | lpfc_param_show(enable_npiv); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 2087 | lpfc_param_init(enable_npiv, 1, 0, 1); |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2088 | 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] | 2089 | |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2090 | int lpfc_enable_rrq; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2091 | module_param(lpfc_enable_rrq, int, S_IRUGO); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 2092 | MODULE_PARM_DESC(lpfc_enable_rrq, "Enable RRQ functionality"); |
| 2093 | lpfc_param_show(enable_rrq); |
| 2094 | lpfc_param_init(enable_rrq, 0, 0, 1); |
| 2095 | static DEVICE_ATTR(lpfc_enable_rrq, S_IRUGO, lpfc_enable_rrq_show, NULL); |
| 2096 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2097 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2098 | # lpfc_suppress_link_up: Bring link up at initialization |
| 2099 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 2100 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 2101 | # 0x2 = never bring up link |
| 2102 | # Default value is 0. |
| 2103 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2104 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 2105 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 2106 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2107 | /* |
| 2108 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 2109 | # 1 - (1024) |
| 2110 | # 2 - (2048) |
| 2111 | # 3 - (3072) |
| 2112 | # 4 - (4096) |
| 2113 | # 5 - (5120) |
| 2114 | */ |
| 2115 | static ssize_t |
| 2116 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2117 | { |
| 2118 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2119 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2120 | |
| 2121 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 2122 | } |
| 2123 | |
| 2124 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 2125 | lpfc_iocb_hw_show, NULL); |
| 2126 | static ssize_t |
| 2127 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 2128 | { |
| 2129 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2130 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2131 | |
| 2132 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2133 | phba->sli.ring[LPFC_ELS_RING].txq_max); |
| 2134 | } |
| 2135 | |
| 2136 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 2137 | lpfc_txq_hw_show, NULL); |
| 2138 | static ssize_t |
| 2139 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 2140 | char *buf) |
| 2141 | { |
| 2142 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2143 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 2144 | |
| 2145 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 2146 | phba->sli.ring[LPFC_ELS_RING].txcmplq_max); |
| 2147 | } |
| 2148 | |
| 2149 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 2150 | lpfc_txcmplq_hw_show, NULL); |
| 2151 | |
| 2152 | int lpfc_iocb_cnt = 2; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2153 | module_param(lpfc_iocb_cnt, int, S_IRUGO); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 2154 | MODULE_PARM_DESC(lpfc_iocb_cnt, |
| 2155 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
| 2156 | lpfc_param_show(iocb_cnt); |
| 2157 | lpfc_param_init(iocb_cnt, 2, 1, 5); |
| 2158 | static DEVICE_ATTR(lpfc_iocb_cnt, S_IRUGO, |
| 2159 | lpfc_iocb_cnt_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2160 | |
| 2161 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2162 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 2163 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 2164 | */ |
| 2165 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2166 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 2167 | module_param(lpfc_nodev_tmo, int, 0); |
| 2168 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 2169 | "Seconds driver will hold I/O waiting " |
| 2170 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2171 | |
| 2172 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2173 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2174 | * @dev: class converted to a Scsi_host structure. |
| 2175 | * @attr: device attribute, not used. |
| 2176 | * @buf: on return contains the dev loss timeout in decimal. |
| 2177 | * |
| 2178 | * Returns: size of formatted string. |
| 2179 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2180 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2181 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 2182 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -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; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2186 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2187 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2188 | } |
| 2189 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2190 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2191 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2192 | * @vport: lpfc vport structure pointer. |
| 2193 | * @val: contains the nodev timeout value. |
| 2194 | * |
| 2195 | * Description: |
| 2196 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 2197 | * a kernel error message is printed and zero is returned. |
| 2198 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2199 | * Otherwise nodev tmo is set to the default value. |
| 2200 | * |
| 2201 | * Returns: |
| 2202 | * zero if already set or if val is in range |
| 2203 | * -EINVAL val out of range |
| 2204 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2205 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2206 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2207 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2208 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 2209 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 2210 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2211 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2212 | "0407 Ignoring nodev_tmo module " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2213 | "parameter because devloss_tmo is " |
| 2214 | "set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2215 | return 0; |
| 2216 | } |
| 2217 | |
| 2218 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2219 | vport->cfg_nodev_tmo = val; |
| 2220 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2221 | return 0; |
| 2222 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2223 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2224 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 2225 | " %d, allowed range is [%d, %d]\n", |
| 2226 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2227 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2228 | return -EINVAL; |
| 2229 | } |
| 2230 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2231 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2232 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2233 | * @vport: lpfc vport structure pointer. |
| 2234 | * |
| 2235 | * Description: |
| 2236 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 2237 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2238 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2239 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2240 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2241 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2242 | struct lpfc_nodelist *ndlp; |
| 2243 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2244 | shost = lpfc_shost_from_vport(vport); |
| 2245 | spin_lock_irq(shost->host_lock); |
| 2246 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2247 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2248 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 2249 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 2250 | } |
| 2251 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2252 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2253 | * 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] | 2254 | * @vport: lpfc vport structure pointer. |
| 2255 | * @val: contains the tmo value. |
| 2256 | * |
| 2257 | * Description: |
| 2258 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 2259 | * then a kernel error message is printed and zero is returned. |
| 2260 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 2261 | * Otherwise nodev tmo is set to the default value. |
| 2262 | * |
| 2263 | * Returns: |
| 2264 | * zero if already set or if val is in range |
| 2265 | * -EINVAL val out of range |
| 2266 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2267 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2268 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2269 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2270 | if (vport->dev_loss_tmo_changed || |
| 2271 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2272 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2273 | "0401 Ignoring change to nodev_tmo " |
| 2274 | "because devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2275 | return 0; |
| 2276 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2277 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2278 | vport->cfg_nodev_tmo = val; |
| 2279 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2280 | /* |
| 2281 | * For compat: set the fc_host dev loss so new rports |
| 2282 | * will get the value. |
| 2283 | */ |
| 2284 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2285 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2286 | return 0; |
| 2287 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2288 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2289 | "0403 lpfc_nodev_tmo attribute cannot be set to" |
| 2290 | "%d, allowed range is [%d, %d]\n", |
| 2291 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2292 | return -EINVAL; |
| 2293 | } |
| 2294 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2295 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2296 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2297 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 2298 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2299 | |
| 2300 | /* |
| 2301 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 2302 | # disappear until the timer expires. Value range is [0,255]. Default |
| 2303 | # value is 30. |
| 2304 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2305 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2306 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 2307 | "Seconds driver will hold I/O waiting " |
| 2308 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2309 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 2310 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 2311 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2312 | |
| 2313 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2314 | * 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] | 2315 | * @vport: lpfc vport structure pointer. |
| 2316 | * @val: contains the tmo value. |
| 2317 | * |
| 2318 | * Description: |
| 2319 | * If val is in a valid range then set the vport nodev tmo, |
| 2320 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 2321 | * Else a kernel error message is printed. |
| 2322 | * |
| 2323 | * Returns: |
| 2324 | * zero if val is in range |
| 2325 | * -EINVAL val out of range |
| 2326 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2327 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2328 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2329 | { |
| 2330 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2331 | vport->cfg_nodev_tmo = val; |
| 2332 | vport->cfg_devloss_tmo = val; |
| 2333 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 2334 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2335 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2336 | return 0; |
| 2337 | } |
| 2338 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2339 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2340 | "0404 lpfc_devloss_tmo attribute cannot be set to" |
| 2341 | " %d, allowed range is [%d, %d]\n", |
| 2342 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2343 | return -EINVAL; |
| 2344 | } |
| 2345 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2346 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2347 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 2348 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 2349 | |
| 2350 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2351 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 2352 | # deluged with LOTS of information. |
| 2353 | # 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] | 2354 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2355 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2356 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2357 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2358 | |
| 2359 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 2360 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 2361 | # objects that have been registered with the nameserver after login. |
| 2362 | */ |
| 2363 | LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1, |
| 2364 | "Deregister nameserver objects before LOGO"); |
| 2365 | |
| 2366 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2367 | # lun_queue_depth: This parameter is used to limit the number of outstanding |
| 2368 | # commands per FCP LUN. Value range is [1,128]. Default value is 30. |
| 2369 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2370 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 128, |
| 2371 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2372 | |
| 2373 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 2374 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 2375 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 2376 | */ |
| 2377 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
| 2378 | "Max number of FCP commands we can queue to a specific target port"); |
| 2379 | |
| 2380 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 2381 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 2382 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 2383 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 2384 | # then maximum number of exchanges supported by the HBA is used to determine |
| 2385 | # the hba_queue_depth. |
| 2386 | */ |
| 2387 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 2388 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 2389 | |
| 2390 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2391 | # peer_port_login: This parameter allows/prevents logins |
| 2392 | # between peer ports hosted on the same physical port. |
| 2393 | # When this parameter is set 0 peer ports of same physical port |
| 2394 | # are not allowed to login to each other. |
| 2395 | # When this parameter is set 1 peer ports of same physical port |
| 2396 | # are allowed to login to each other. |
| 2397 | # Default value of this parameter is 0. |
| 2398 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2399 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 2400 | "Allow peer ports on the same physical port to login to each " |
| 2401 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2402 | |
| 2403 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2404 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2405 | # between Virtual Ports and remote initiators. |
| 2406 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 2407 | # other initiators and will attempt to PLOGI all remote ports. |
| 2408 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 2409 | # remote ports and will not attempt to PLOGI to other initiators. |
| 2410 | # This parameter does not restrict to the physical port. |
| 2411 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 2412 | # Default value of this parameter is 1. |
| 2413 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2414 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2415 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2416 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 2417 | "Restrict virtual ports login to remote initiators."); |
| 2418 | lpfc_vport_param_show(restrict_login); |
| 2419 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2420 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2421 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2422 | * @vport: lpfc vport structure pointer. |
| 2423 | * @val: contains the restrict login value. |
| 2424 | * |
| 2425 | * Description: |
| 2426 | * If val is not in a valid range then log a kernel error message and set |
| 2427 | * the vport restrict login to one. |
| 2428 | * If the port type is physical clear the restrict login flag and return. |
| 2429 | * Else set the restrict login flag to val. |
| 2430 | * |
| 2431 | * Returns: |
| 2432 | * zero if val is in range |
| 2433 | * -EINVAL val out of range |
| 2434 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2435 | static int |
| 2436 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 2437 | { |
| 2438 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2439 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2440 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2441 | "be set to %d, allowed range is [0, 1]\n", |
| 2442 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2443 | vport->cfg_restrict_login = 1; |
| 2444 | return -EINVAL; |
| 2445 | } |
| 2446 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 2447 | vport->cfg_restrict_login = 0; |
| 2448 | return 0; |
| 2449 | } |
| 2450 | vport->cfg_restrict_login = val; |
| 2451 | return 0; |
| 2452 | } |
| 2453 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2454 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2455 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2456 | * @vport: lpfc vport structure pointer. |
| 2457 | * @val: contains the restrict login value. |
| 2458 | * |
| 2459 | * Description: |
| 2460 | * If val is not in a valid range then log a kernel error message and set |
| 2461 | * the vport restrict login to one. |
| 2462 | * If the port type is physical and the val is not zero log a kernel |
| 2463 | * error message, clear the restrict login flag and return zero. |
| 2464 | * Else set the restrict login flag to val. |
| 2465 | * |
| 2466 | * Returns: |
| 2467 | * zero if val is in range |
| 2468 | * -EINVAL val out of range |
| 2469 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2470 | static int |
| 2471 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 2472 | { |
| 2473 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2474 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2475 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2476 | "be set to %d, allowed range is [0, 1]\n", |
| 2477 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2478 | vport->cfg_restrict_login = 1; |
| 2479 | return -EINVAL; |
| 2480 | } |
| 2481 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2482 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2483 | "0468 lpfc_restrict_login must be 0 for " |
| 2484 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2485 | vport->cfg_restrict_login = 0; |
| 2486 | return 0; |
| 2487 | } |
| 2488 | vport->cfg_restrict_login = val; |
| 2489 | return 0; |
| 2490 | } |
| 2491 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2492 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 2493 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2494 | |
| 2495 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2496 | # Some disk devices have a "select ID" or "select Target" capability. |
| 2497 | # From a protocol standpoint "select ID" usually means select the |
| 2498 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 2499 | # annex" which contains a table that maps a "select ID" (a number |
| 2500 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 2501 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 2502 | # ALPA. |
| 2503 | # |
| 2504 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 2505 | # cause the lpfc driver to use an inverted table, effectively |
| 2506 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 2507 | # |
| 2508 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 2509 | # and will not work across a fabric. Also this parameter will take |
| 2510 | # effect only in the case when ALPA map is not available.) |
| 2511 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2512 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 2513 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2514 | |
| 2515 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2516 | # lpfc_topology: link topology for init link |
| 2517 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 2518 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2519 | # 0x02 = attempt point-to-point mode only |
| 2520 | # 0x04 = attempt loop mode only |
| 2521 | # 0x06 = attempt point-to-point mode then loop |
| 2522 | # Set point-to-point mode if you want to run as an N_Port. |
| 2523 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 2524 | # Default value is 0. |
| 2525 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2526 | |
| 2527 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2528 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2529 | * @phba: lpfc_hba pointer. |
| 2530 | * @val: topology value. |
| 2531 | * |
| 2532 | * Description: |
| 2533 | * If val is in a valid range then set the adapter's topology field and |
| 2534 | * issue a lip; if the lip fails reset the topology to the old value. |
| 2535 | * |
| 2536 | * If the value is not in range log a kernel error message and return an error. |
| 2537 | * |
| 2538 | * Returns: |
| 2539 | * zero if val is in range and lip okay |
| 2540 | * non-zero return value from lpfc_issue_lip() |
| 2541 | * -EINVAL val out of range |
| 2542 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2543 | static ssize_t |
| 2544 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 2545 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2546 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2547 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2548 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2549 | struct lpfc_hba *phba = vport->phba; |
| 2550 | int val = 0; |
| 2551 | int nolip = 0; |
| 2552 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2553 | int err; |
| 2554 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2555 | |
| 2556 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 2557 | nolip = 1; |
| 2558 | val_buf = &buf[strlen("nolip ")]; |
| 2559 | } |
| 2560 | |
| 2561 | if (!isdigit(val_buf[0])) |
| 2562 | return -EINVAL; |
| 2563 | if (sscanf(val_buf, "%i", &val) != 1) |
| 2564 | return -EINVAL; |
| 2565 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2566 | if (val >= 0 && val <= 6) { |
| 2567 | prev_val = phba->cfg_topology; |
| 2568 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2569 | if (nolip) |
| 2570 | return strlen(buf); |
| 2571 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2572 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2573 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2574 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2575 | return -EINVAL; |
| 2576 | } else |
| 2577 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2578 | } |
| 2579 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2580 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 2581 | "allowed range is [0, 6]\n", |
| 2582 | phba->brd_no, val); |
| 2583 | return -EINVAL; |
| 2584 | } |
| 2585 | static int lpfc_topology = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2586 | module_param(lpfc_topology, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2587 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
| 2588 | lpfc_param_show(topology) |
| 2589 | lpfc_param_init(topology, 0, 0, 6) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2590 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2591 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2592 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 2593 | /** |
| 2594 | * lpfc_static_vport_show: Read callback function for |
| 2595 | * lpfc_static_vport sysfs file. |
| 2596 | * @dev: Pointer to class device object. |
| 2597 | * @attr: device attribute structure. |
| 2598 | * @buf: Data buffer. |
| 2599 | * |
| 2600 | * This function is the read call back function for |
| 2601 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 2602 | * sysfs file report the mageability of the vport. |
| 2603 | **/ |
| 2604 | static ssize_t |
| 2605 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 2606 | char *buf) |
| 2607 | { |
| 2608 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2609 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2610 | if (vport->vport_flag & STATIC_VPORT) |
| 2611 | sprintf(buf, "1\n"); |
| 2612 | else |
| 2613 | sprintf(buf, "0\n"); |
| 2614 | |
| 2615 | return strlen(buf); |
| 2616 | } |
| 2617 | |
| 2618 | /* |
| 2619 | * Sysfs attribute to control the statistical data collection. |
| 2620 | */ |
| 2621 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 2622 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2623 | |
| 2624 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2625 | * 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] | 2626 | * @dev: Pointer to class device. |
| 2627 | * @buf: Data buffer. |
| 2628 | * @count: Size of the data buffer. |
| 2629 | * |
| 2630 | * This function get called when an user write to the lpfc_stat_data_ctrl |
| 2631 | * sysfs file. This function parse the command written to the sysfs file |
| 2632 | * and take appropriate action. These commands are used for controlling |
| 2633 | * driver statistical data collection. |
| 2634 | * Following are the command this function handles. |
| 2635 | * |
| 2636 | * setbucket <bucket_type> <base> <step> |
| 2637 | * = Set the latency buckets. |
| 2638 | * destroybucket = destroy all the buckets. |
| 2639 | * start = start data collection |
| 2640 | * stop = stop data collection |
| 2641 | * reset = reset the collected data |
| 2642 | **/ |
| 2643 | static ssize_t |
| 2644 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 2645 | const char *buf, size_t count) |
| 2646 | { |
| 2647 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2648 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2649 | struct lpfc_hba *phba = vport->phba; |
| 2650 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 2651 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 2652 | unsigned long i; |
| 2653 | char *str_ptr, *token; |
| 2654 | struct lpfc_vport **vports; |
| 2655 | struct Scsi_Host *v_shost; |
| 2656 | char *bucket_type_str, *base_str, *step_str; |
| 2657 | unsigned long base, step, bucket_type; |
| 2658 | |
| 2659 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2660 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2661 | return -EINVAL; |
| 2662 | |
| 2663 | strcpy(bucket_data, buf); |
| 2664 | str_ptr = &bucket_data[0]; |
| 2665 | /* Ignore this token - this is command token */ |
| 2666 | token = strsep(&str_ptr, "\t "); |
| 2667 | if (!token) |
| 2668 | return -EINVAL; |
| 2669 | |
| 2670 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 2671 | if (!bucket_type_str) |
| 2672 | return -EINVAL; |
| 2673 | |
| 2674 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 2675 | bucket_type = LPFC_LINEAR_BUCKET; |
| 2676 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 2677 | bucket_type = LPFC_POWER2_BUCKET; |
| 2678 | else |
| 2679 | return -EINVAL; |
| 2680 | |
| 2681 | base_str = strsep(&str_ptr, "\t "); |
| 2682 | if (!base_str) |
| 2683 | return -EINVAL; |
| 2684 | base = simple_strtoul(base_str, NULL, 0); |
| 2685 | |
| 2686 | step_str = strsep(&str_ptr, "\t "); |
| 2687 | if (!step_str) |
| 2688 | return -EINVAL; |
| 2689 | step = simple_strtoul(step_str, NULL, 0); |
| 2690 | if (!step) |
| 2691 | return -EINVAL; |
| 2692 | |
| 2693 | /* Block the data collection for every vport */ |
| 2694 | vports = lpfc_create_vport_work_array(phba); |
| 2695 | if (vports == NULL) |
| 2696 | return -ENOMEM; |
| 2697 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2698 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2699 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 2700 | spin_lock_irq(v_shost->host_lock); |
| 2701 | /* Block and reset data collection */ |
| 2702 | vports[i]->stat_data_blocked = 1; |
| 2703 | if (vports[i]->stat_data_enabled) |
| 2704 | lpfc_vport_reset_stat_data(vports[i]); |
| 2705 | spin_unlock_irq(v_shost->host_lock); |
| 2706 | } |
| 2707 | |
| 2708 | /* Set the bucket attributes */ |
| 2709 | phba->bucket_type = bucket_type; |
| 2710 | phba->bucket_base = base; |
| 2711 | phba->bucket_step = step; |
| 2712 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2713 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2714 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 2715 | |
| 2716 | /* Unblock data collection */ |
| 2717 | spin_lock_irq(v_shost->host_lock); |
| 2718 | vports[i]->stat_data_blocked = 0; |
| 2719 | spin_unlock_irq(v_shost->host_lock); |
| 2720 | } |
| 2721 | lpfc_destroy_vport_work_array(phba, vports); |
| 2722 | return strlen(buf); |
| 2723 | } |
| 2724 | |
| 2725 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 2726 | vports = lpfc_create_vport_work_array(phba); |
| 2727 | if (vports == NULL) |
| 2728 | return -ENOMEM; |
| 2729 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2730 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2731 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 2732 | spin_lock_irq(shost->host_lock); |
| 2733 | vports[i]->stat_data_blocked = 1; |
| 2734 | lpfc_free_bucket(vport); |
| 2735 | vport->stat_data_enabled = 0; |
| 2736 | vports[i]->stat_data_blocked = 0; |
| 2737 | spin_unlock_irq(shost->host_lock); |
| 2738 | } |
| 2739 | lpfc_destroy_vport_work_array(phba, vports); |
| 2740 | phba->bucket_type = LPFC_NO_BUCKET; |
| 2741 | phba->bucket_base = 0; |
| 2742 | phba->bucket_step = 0; |
| 2743 | return strlen(buf); |
| 2744 | } |
| 2745 | |
| 2746 | if (!strncmp(buf, "start", strlen("start"))) { |
| 2747 | /* If no buckets configured return error */ |
| 2748 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 2749 | return -EINVAL; |
| 2750 | spin_lock_irq(shost->host_lock); |
| 2751 | if (vport->stat_data_enabled) { |
| 2752 | spin_unlock_irq(shost->host_lock); |
| 2753 | return strlen(buf); |
| 2754 | } |
| 2755 | lpfc_alloc_bucket(vport); |
| 2756 | vport->stat_data_enabled = 1; |
| 2757 | spin_unlock_irq(shost->host_lock); |
| 2758 | return strlen(buf); |
| 2759 | } |
| 2760 | |
| 2761 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 2762 | spin_lock_irq(shost->host_lock); |
| 2763 | if (vport->stat_data_enabled == 0) { |
| 2764 | spin_unlock_irq(shost->host_lock); |
| 2765 | return strlen(buf); |
| 2766 | } |
| 2767 | lpfc_free_bucket(vport); |
| 2768 | vport->stat_data_enabled = 0; |
| 2769 | spin_unlock_irq(shost->host_lock); |
| 2770 | return strlen(buf); |
| 2771 | } |
| 2772 | |
| 2773 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 2774 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 2775 | || !vport->stat_data_enabled) |
| 2776 | return strlen(buf); |
| 2777 | spin_lock_irq(shost->host_lock); |
| 2778 | vport->stat_data_blocked = 1; |
| 2779 | lpfc_vport_reset_stat_data(vport); |
| 2780 | vport->stat_data_blocked = 0; |
| 2781 | spin_unlock_irq(shost->host_lock); |
| 2782 | return strlen(buf); |
| 2783 | } |
| 2784 | return -EINVAL; |
| 2785 | } |
| 2786 | |
| 2787 | |
| 2788 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2789 | * 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] | 2790 | * @dev: Pointer to class device object. |
| 2791 | * @buf: Data buffer. |
| 2792 | * |
| 2793 | * This function is the read call back function for |
| 2794 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 2795 | * current statistical data collection state. |
| 2796 | **/ |
| 2797 | static ssize_t |
| 2798 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 2799 | char *buf) |
| 2800 | { |
| 2801 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2802 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2803 | struct lpfc_hba *phba = vport->phba; |
| 2804 | int index = 0; |
| 2805 | int i; |
| 2806 | char *bucket_type; |
| 2807 | unsigned long bucket_value; |
| 2808 | |
| 2809 | switch (phba->bucket_type) { |
| 2810 | case LPFC_LINEAR_BUCKET: |
| 2811 | bucket_type = "linear"; |
| 2812 | break; |
| 2813 | case LPFC_POWER2_BUCKET: |
| 2814 | bucket_type = "power2"; |
| 2815 | break; |
| 2816 | default: |
| 2817 | bucket_type = "No Bucket"; |
| 2818 | break; |
| 2819 | } |
| 2820 | |
| 2821 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 2822 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 2823 | " Bucket step :%d\nLatency Ranges :", |
| 2824 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 2825 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 2826 | index = strlen(buf); |
| 2827 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 2828 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 2829 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 2830 | bucket_value = phba->bucket_base + |
| 2831 | phba->bucket_step * i; |
| 2832 | else |
| 2833 | bucket_value = phba->bucket_base + |
| 2834 | (1 << i) * phba->bucket_step; |
| 2835 | |
| 2836 | if (index + 10 > PAGE_SIZE) |
| 2837 | break; |
| 2838 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 2839 | index = strlen(buf); |
| 2840 | } |
| 2841 | } |
| 2842 | sprintf(&buf[index], "\n"); |
| 2843 | return strlen(buf); |
| 2844 | } |
| 2845 | |
| 2846 | /* |
| 2847 | * Sysfs attribute to control the statistical data collection. |
| 2848 | */ |
| 2849 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 2850 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 2851 | |
| 2852 | /* |
| 2853 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 2854 | */ |
| 2855 | |
| 2856 | /* |
| 2857 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 2858 | * for each target. |
| 2859 | */ |
| 2860 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 2861 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 2862 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 2863 | |
| 2864 | |
| 2865 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2866 | * 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] | 2867 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2868 | * @kobj: Pointer to the kernel object |
| 2869 | * @bin_attr: Attribute object |
| 2870 | * @buff: Buffer pointer |
| 2871 | * @off: File offset |
| 2872 | * @count: Buffer size |
| 2873 | * |
| 2874 | * This function is the read call back function for lpfc_drvr_stat_data |
| 2875 | * sysfs file. This function export the statistical data to user |
| 2876 | * applications. |
| 2877 | **/ |
| 2878 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2879 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 2880 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2881 | char *buf, loff_t off, size_t count) |
| 2882 | { |
| 2883 | struct device *dev = container_of(kobj, struct device, |
| 2884 | kobj); |
| 2885 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2886 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2887 | struct lpfc_hba *phba = vport->phba; |
| 2888 | int i = 0, index = 0; |
| 2889 | unsigned long nport_index; |
| 2890 | struct lpfc_nodelist *ndlp = NULL; |
| 2891 | nport_index = (unsigned long)off / |
| 2892 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 2893 | |
| 2894 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 2895 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 2896 | return 0; |
| 2897 | |
| 2898 | spin_lock_irq(shost->host_lock); |
| 2899 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 2900 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 2901 | continue; |
| 2902 | |
| 2903 | if (nport_index > 0) { |
| 2904 | nport_index--; |
| 2905 | continue; |
| 2906 | } |
| 2907 | |
| 2908 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 2909 | > count) |
| 2910 | break; |
| 2911 | |
| 2912 | if (!ndlp->lat_data) |
| 2913 | continue; |
| 2914 | |
| 2915 | /* Print the WWN */ |
| 2916 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 2917 | ndlp->nlp_portname.u.wwn[0], |
| 2918 | ndlp->nlp_portname.u.wwn[1], |
| 2919 | ndlp->nlp_portname.u.wwn[2], |
| 2920 | ndlp->nlp_portname.u.wwn[3], |
| 2921 | ndlp->nlp_portname.u.wwn[4], |
| 2922 | ndlp->nlp_portname.u.wwn[5], |
| 2923 | ndlp->nlp_portname.u.wwn[6], |
| 2924 | ndlp->nlp_portname.u.wwn[7]); |
| 2925 | |
| 2926 | index = strlen(buf); |
| 2927 | |
| 2928 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 2929 | sprintf(&buf[index], "%010u,", |
| 2930 | ndlp->lat_data[i].cmd_count); |
| 2931 | index = strlen(buf); |
| 2932 | } |
| 2933 | sprintf(&buf[index], "\n"); |
| 2934 | index = strlen(buf); |
| 2935 | } |
| 2936 | spin_unlock_irq(shost->host_lock); |
| 2937 | return index; |
| 2938 | } |
| 2939 | |
| 2940 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 2941 | .attr = { |
| 2942 | .name = "lpfc_drvr_stat_data", |
| 2943 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 2944 | }, |
| 2945 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 2946 | .read = sysfs_drvr_stat_data_read, |
| 2947 | .write = NULL, |
| 2948 | }; |
| 2949 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2950 | /* |
| 2951 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 2952 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2953 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2954 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2955 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2956 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2957 | * @phba: lpfc_hba pointer. |
| 2958 | * @val: link speed value. |
| 2959 | * |
| 2960 | * Description: |
| 2961 | * If val is in a valid range then set the adapter's link speed field and |
| 2962 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 2963 | * |
| 2964 | * Notes: |
| 2965 | * If the value is not in range log a kernel error message and return an error. |
| 2966 | * |
| 2967 | * Returns: |
| 2968 | * zero if val is in range and lip okay. |
| 2969 | * non-zero return value from lpfc_issue_lip() |
| 2970 | * -EINVAL val out of range |
| 2971 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2972 | static ssize_t |
| 2973 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 2974 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2975 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2976 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2977 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2978 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2979 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2980 | int nolip = 0; |
| 2981 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 2982 | int err; |
| 2983 | uint32_t prev_val; |
| 2984 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 2985 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 2986 | nolip = 1; |
| 2987 | val_buf = &buf[strlen("nolip ")]; |
| 2988 | } |
| 2989 | |
| 2990 | if (!isdigit(val_buf[0])) |
| 2991 | return -EINVAL; |
| 2992 | if (sscanf(val_buf, "%i", &val) != 1) |
| 2993 | return -EINVAL; |
| 2994 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 2995 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 2996 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 2997 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 2998 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 2999 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
| 3000 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb))) { |
| 3001 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3002 | "2879 lpfc_link_speed attribute cannot be set " |
| 3003 | "to %d. Speed is not supported by this port.\n", |
| 3004 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3005 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3006 | } |
| 3007 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3008 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3009 | prev_val = phba->cfg_link_speed; |
| 3010 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3011 | if (nolip) |
| 3012 | return strlen(buf); |
| 3013 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3014 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3015 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3016 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3017 | return -EINVAL; |
| 3018 | } else |
| 3019 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3020 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3021 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3022 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 3023 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3024 | return -EINVAL; |
| 3025 | } |
| 3026 | |
| 3027 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3028 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3029 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 3030 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3031 | |
| 3032 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3033 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3034 | * @phba: lpfc_hba pointer. |
| 3035 | * @val: link speed value. |
| 3036 | * |
| 3037 | * Description: |
| 3038 | * If val is in a valid range then set the adapter's link speed field. |
| 3039 | * |
| 3040 | * Notes: |
| 3041 | * If the value is not in range log a kernel error message, clear the link |
| 3042 | * speed and return an error. |
| 3043 | * |
| 3044 | * Returns: |
| 3045 | * zero if val saved. |
| 3046 | * -EINVAL val out of range |
| 3047 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3048 | static int |
| 3049 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 3050 | { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3051 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 3052 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3053 | phba->cfg_link_speed = val; |
| 3054 | return 0; |
| 3055 | } |
| 3056 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3057 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3058 | "be set to %d, allowed values are " |
| 3059 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3060 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3061 | return -EINVAL; |
| 3062 | } |
| 3063 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3064 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3065 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3066 | |
| 3067 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3068 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 3069 | # 0 = aer disabled or not supported |
| 3070 | # 1 = aer supported and enabled (default) |
| 3071 | # Value range is [0,1]. Default value is 1. |
| 3072 | */ |
| 3073 | |
| 3074 | /** |
| 3075 | * lpfc_aer_support_store - Set the adapter for aer support |
| 3076 | * |
| 3077 | * @dev: class device that is converted into a Scsi_host. |
| 3078 | * @attr: device attribute, not used. |
| 3079 | * @buf: containing the string "selective". |
| 3080 | * @count: unused variable. |
| 3081 | * |
| 3082 | * Description: |
| 3083 | * If the val is 1 and currently the device's AER capability was not |
| 3084 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 3085 | * enable the device's AER capability. If the helper routine enabling |
| 3086 | * AER returns success, update the device's cfg_aer_support flag to |
| 3087 | * indicate AER is supported by the device; otherwise, if the device |
| 3088 | * AER capability is already enabled to support AER, then do nothing. |
| 3089 | * |
| 3090 | * If the val is 0 and currently the device's AER support was enabled, |
| 3091 | * invoke the kernel's disable AER helper routine. After that, update |
| 3092 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 3093 | * by the device; otherwise, if the device AER capability is already |
| 3094 | * disabled from supporting AER, then do nothing. |
| 3095 | * |
| 3096 | * Returns: |
| 3097 | * length of the buf on success if val is in range the intended mode |
| 3098 | * is supported. |
| 3099 | * -EINVAL if val out of range or intended mode is not supported. |
| 3100 | **/ |
| 3101 | static ssize_t |
| 3102 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 3103 | const char *buf, size_t count) |
| 3104 | { |
| 3105 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3106 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 3107 | struct lpfc_hba *phba = vport->phba; |
| 3108 | int val = 0, rc = -EINVAL; |
| 3109 | |
| 3110 | if (!isdigit(buf[0])) |
| 3111 | return -EINVAL; |
| 3112 | if (sscanf(buf, "%i", &val) != 1) |
| 3113 | return -EINVAL; |
| 3114 | |
| 3115 | switch (val) { |
| 3116 | case 0: |
| 3117 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 3118 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 3119 | if (!rc) { |
| 3120 | spin_lock_irq(&phba->hbalock); |
| 3121 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 3122 | spin_unlock_irq(&phba->hbalock); |
| 3123 | phba->cfg_aer_support = 0; |
| 3124 | rc = strlen(buf); |
| 3125 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3126 | rc = -EPERM; |
| 3127 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3128 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3129 | rc = strlen(buf); |
| 3130 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3131 | break; |
| 3132 | case 1: |
| 3133 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 3134 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 3135 | if (!rc) { |
| 3136 | spin_lock_irq(&phba->hbalock); |
| 3137 | phba->hba_flag |= HBA_AER_ENABLED; |
| 3138 | spin_unlock_irq(&phba->hbalock); |
| 3139 | phba->cfg_aer_support = 1; |
| 3140 | rc = strlen(buf); |
| 3141 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3142 | rc = -EPERM; |
| 3143 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3144 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3145 | rc = strlen(buf); |
| 3146 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3147 | break; |
| 3148 | default: |
| 3149 | rc = -EINVAL; |
| 3150 | break; |
| 3151 | } |
| 3152 | return rc; |
| 3153 | } |
| 3154 | |
| 3155 | static int lpfc_aer_support = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3156 | module_param(lpfc_aer_support, int, S_IRUGO); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3157 | MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support"); |
| 3158 | lpfc_param_show(aer_support) |
| 3159 | |
| 3160 | /** |
| 3161 | * lpfc_aer_support_init - Set the initial adapters aer support flag |
| 3162 | * @phba: lpfc_hba pointer. |
| 3163 | * @val: link speed value. |
| 3164 | * |
| 3165 | * Description: |
| 3166 | * If val is in a valid range [0,1], then set the adapter's initial |
| 3167 | * cfg_aer_support field. It will be up to the driver's probe_one |
| 3168 | * routine to determine whether the device's AER support can be set |
| 3169 | * or not. |
| 3170 | * |
| 3171 | * Notes: |
| 3172 | * If the value is not in range log a kernel error message, and |
| 3173 | * choose the default value of setting AER support and return. |
| 3174 | * |
| 3175 | * Returns: |
| 3176 | * zero if val saved. |
| 3177 | * -EINVAL val out of range |
| 3178 | **/ |
| 3179 | static int |
| 3180 | lpfc_aer_support_init(struct lpfc_hba *phba, int val) |
| 3181 | { |
| 3182 | if (val == 0 || val == 1) { |
| 3183 | phba->cfg_aer_support = val; |
| 3184 | return 0; |
| 3185 | } |
| 3186 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3187 | "2712 lpfc_aer_support attribute value %d out " |
| 3188 | "of range, allowed values are 0|1, setting it " |
| 3189 | "to default value of 1\n", val); |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3190 | /* By default, try to enable AER on a device */ |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3191 | phba->cfg_aer_support = 1; |
| 3192 | return -EINVAL; |
| 3193 | } |
| 3194 | |
| 3195 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 3196 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 3197 | |
| 3198 | /** |
| 3199 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 3200 | * @dev: class device that is converted into a Scsi_host. |
| 3201 | * @attr: device attribute, not used. |
| 3202 | * @buf: containing the string "selective". |
| 3203 | * @count: unused variable. |
| 3204 | * |
| 3205 | * Description: |
| 3206 | * If the @buf contains 1 and the device currently has the AER support |
| 3207 | * enabled, then invokes the kernel AER helper routine |
| 3208 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 3209 | * error status register. |
| 3210 | * |
| 3211 | * Notes: |
| 3212 | * |
| 3213 | * Returns: |
| 3214 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 3215 | * enabled with the AER support. |
| 3216 | **/ |
| 3217 | static ssize_t |
| 3218 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 3219 | const char *buf, size_t count) |
| 3220 | { |
| 3221 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3222 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3223 | struct lpfc_hba *phba = vport->phba; |
| 3224 | int val, rc = -1; |
| 3225 | |
| 3226 | if (!isdigit(buf[0])) |
| 3227 | return -EINVAL; |
| 3228 | if (sscanf(buf, "%i", &val) != 1) |
| 3229 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3230 | if (val != 1) |
| 3231 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3232 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3233 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3234 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 3235 | |
| 3236 | if (rc == 0) |
| 3237 | return strlen(buf); |
| 3238 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 3239 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3240 | } |
| 3241 | |
| 3242 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 3243 | lpfc_aer_cleanup_state); |
| 3244 | |
| 3245 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3246 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 3247 | # Value range is [2,3]. Default value is 3. |
| 3248 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3249 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 3250 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3251 | |
| 3252 | /* |
| 3253 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 3254 | # is [0,1]. Default value is 0. |
| 3255 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3256 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 3257 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3258 | |
| 3259 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3260 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 3261 | # depth. Default value is 0. When the value of this parameter is zero the |
| 3262 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 3263 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 3264 | # to limit the I/O completion time to the parameter value. |
| 3265 | # The value is set in milliseconds. |
| 3266 | */ |
| 3267 | static int lpfc_max_scsicmpl_time; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3268 | module_param(lpfc_max_scsicmpl_time, int, S_IRUGO); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3269 | MODULE_PARM_DESC(lpfc_max_scsicmpl_time, |
| 3270 | "Use command completion time to control queue depth"); |
| 3271 | lpfc_vport_param_show(max_scsicmpl_time); |
| 3272 | lpfc_vport_param_init(max_scsicmpl_time, 0, 0, 60000); |
| 3273 | static int |
| 3274 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 3275 | { |
| 3276 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3277 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 3278 | |
| 3279 | if (val == vport->cfg_max_scsicmpl_time) |
| 3280 | return 0; |
| 3281 | if ((val < 0) || (val > 60000)) |
| 3282 | return -EINVAL; |
| 3283 | vport->cfg_max_scsicmpl_time = val; |
| 3284 | |
| 3285 | spin_lock_irq(shost->host_lock); |
| 3286 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 3287 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3288 | continue; |
| 3289 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 3290 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3291 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3292 | } |
| 3293 | spin_unlock_irq(shost->host_lock); |
| 3294 | return 0; |
| 3295 | } |
| 3296 | lpfc_vport_param_store(max_scsicmpl_time); |
| 3297 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 3298 | lpfc_max_scsicmpl_time_show, |
| 3299 | lpfc_max_scsicmpl_time_store); |
| 3300 | |
| 3301 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3302 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 3303 | # range is [0,1]. Default value is 0. |
| 3304 | */ |
| 3305 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 3306 | |
| 3307 | /* |
| 3308 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 3309 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3310 | # 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] | 3311 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 3312 | # cr_delay is set to 0. |
| 3313 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 3314 | 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] | 3315 | "interrupt response is generated"); |
| 3316 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 3317 | 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] | 3318 | "interrupt response is generated"); |
| 3319 | |
| 3320 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 3321 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 3322 | # cmd/rsp IOCB entries across. |
| 3323 | # Value range is [1,2]. Default value is 1. |
| 3324 | */ |
| 3325 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 3326 | "SLI rings to spread IOCB entries across"); |
| 3327 | |
| 3328 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 3329 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 3330 | # identifies what rctl value to configure the additional ring for. |
| 3331 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 3332 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 3333 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 3334 | 255, "Identifies RCTL for additional ring configuration"); |
| 3335 | |
| 3336 | /* |
| 3337 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 3338 | # identifies what type value to configure the additional ring for. |
| 3339 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 3340 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 3341 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 3342 | 255, "Identifies TYPE for additional ring configuration"); |
| 3343 | |
| 3344 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3345 | # lpfc_fdmi_on: controls FDMI support. |
| 3346 | # 0 = no FDMI support |
| 3347 | # 1 = support FDMI without attribute of hostname |
| 3348 | # 2 = support FDMI with attribute of hostname |
| 3349 | # Value range [0,2]. Default value is 0. |
| 3350 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3351 | LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3352 | |
| 3353 | /* |
| 3354 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 3355 | # discovery). Value range is [1,64]. Default value = 32. |
| 3356 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3357 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3358 | "during discovery"); |
| 3359 | |
| 3360 | /* |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 3361 | # lpfc_max_luns: maximum allowed LUN. |
| 3362 | # Value range is [0,65535]. Default value is 255. |
| 3363 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3364 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3365 | LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3366 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3367 | /* |
| 3368 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 3369 | # Value range is [1,255], default value is 10. |
| 3370 | */ |
| 3371 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 3372 | "Milliseconds driver will wait between polling FCP ring"); |
| 3373 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3374 | /* |
| 3375 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 3376 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 3377 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3378 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 3379 | # 2 = MSI-X enabled (default) |
| 3380 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3381 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 3382 | 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] | 3383 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 3384 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3385 | /* |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 3386 | # lpfc_fcp_imax: Set the maximum number of fast-path FCP interrupts per second |
| 3387 | # |
| 3388 | # Value range is [636,651042]. Default value is 10000. |
| 3389 | */ |
| 3390 | LPFC_ATTR_R(fcp_imax, LPFC_FP_DEF_IMAX, LPFC_MIM_IMAX, LPFC_DMULT_CONST, |
| 3391 | "Set the maximum number of fast-path FCP interrupts per second"); |
| 3392 | |
| 3393 | /* |
| 3394 | # lpfc_fcp_wq_count: Set the number of fast-path FCP work queues |
| 3395 | # |
| 3396 | # Value range is [1,31]. Default value is 4. |
| 3397 | */ |
| 3398 | LPFC_ATTR_R(fcp_wq_count, LPFC_FP_WQN_DEF, LPFC_FP_WQN_MIN, LPFC_FP_WQN_MAX, |
| 3399 | "Set the number of fast-path FCP work queues, if possible"); |
| 3400 | |
| 3401 | /* |
| 3402 | # lpfc_fcp_eq_count: Set the number of fast-path FCP event queues |
| 3403 | # |
| 3404 | # Value range is [1,7]. Default value is 1. |
| 3405 | */ |
| 3406 | LPFC_ATTR_R(fcp_eq_count, LPFC_FP_EQN_DEF, LPFC_FP_EQN_MIN, LPFC_FP_EQN_MAX, |
| 3407 | "Set the number of fast-path FCP event queues, if possible"); |
| 3408 | |
| 3409 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3410 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 3411 | # 0 = HBA resets disabled |
| 3412 | # 1 = HBA resets enabled (default) |
| 3413 | # Value range is [0,1]. Default value is 1. |
| 3414 | */ |
| 3415 | 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] | 3416 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3417 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 3418 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 3419 | # 0 = HBA Heartbeat disabled |
| 3420 | # 1 = HBA Heartbeat enabled (default) |
| 3421 | # Value range is [0,1]. Default value is 1. |
| 3422 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 3423 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3424 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3425 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3426 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 3427 | # 0 = BlockGuard disabled (default) |
| 3428 | # 1 = BlockGuard enabled |
| 3429 | # Value range is [0,1]. Default value is 0. |
| 3430 | */ |
| 3431 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 3432 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 3433 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3434 | # lpfc_prot_mask: i |
| 3435 | # - Bit mask of host protection capabilities used to register with the |
| 3436 | # SCSI mid-layer |
| 3437 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 3438 | # - Allows you to ultimately specify which profiles to use |
| 3439 | # - Default will result in registering capabilities for all profiles. |
| 3440 | # |
| 3441 | */ |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 3442 | unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3443 | |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3444 | module_param(lpfc_prot_mask, uint, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3445 | MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask"); |
| 3446 | |
| 3447 | /* |
| 3448 | # lpfc_prot_guard: i |
| 3449 | # - Bit mask of protection guard types to register with the SCSI mid-layer |
| 3450 | # - Guard types are currently either 1) IP checksum 2) T10-DIF CRC |
| 3451 | # - Allows you to ultimately specify which profiles to use |
| 3452 | # - Default will result in registering capabilities for all guard types |
| 3453 | # |
| 3454 | */ |
| 3455 | unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3456 | module_param(lpfc_prot_guard, byte, S_IRUGO); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3457 | MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); |
| 3458 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 3459 | /* |
| 3460 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 3461 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 3462 | * This parameter can have value 0 or 1. |
| 3463 | * When this parameter is set to 0, no delay is added to the initial |
| 3464 | * discovery. |
| 3465 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 3466 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 3467 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 3468 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 3469 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 3470 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 3471 | * Default value is 0. |
| 3472 | */ |
| 3473 | int lpfc_delay_discovery; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3474 | module_param(lpfc_delay_discovery, int, S_IRUGO); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 3475 | MODULE_PARM_DESC(lpfc_delay_discovery, |
| 3476 | "Delay NPort discovery when Clean Address bit is cleared. " |
| 3477 | "Allowed values: 0,1."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3478 | |
| 3479 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3480 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3481 | * This value can be set to values between 64 and 256. The default value is |
| 3482 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 3483 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
| 3484 | */ |
| 3485 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 3486 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 3487 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3488 | LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_PROT_SG_SEG_CNT, |
| 3489 | LPFC_DEFAULT_PROT_SG_SEG_CNT, LPFC_MAX_PROT_SG_SEG_CNT, |
| 3490 | "Max Protection Scatter Gather Segment Count"); |
| 3491 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3492 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3493 | &dev_attr_bg_info, |
| 3494 | &dev_attr_bg_guard_err, |
| 3495 | &dev_attr_bg_apptag_err, |
| 3496 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3497 | &dev_attr_info, |
| 3498 | &dev_attr_serialnum, |
| 3499 | &dev_attr_modeldesc, |
| 3500 | &dev_attr_modelname, |
| 3501 | &dev_attr_programtype, |
| 3502 | &dev_attr_portnum, |
| 3503 | &dev_attr_fwrev, |
| 3504 | &dev_attr_hdw, |
| 3505 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 3506 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3507 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 3508 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3509 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 3510 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3511 | &dev_attr_lpfc_temp_sensor, |
| 3512 | &dev_attr_lpfc_log_verbose, |
| 3513 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3514 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3515 | &dev_attr_lpfc_hba_queue_depth, |
| 3516 | &dev_attr_lpfc_peer_port_login, |
| 3517 | &dev_attr_lpfc_nodev_tmo, |
| 3518 | &dev_attr_lpfc_devloss_tmo, |
| 3519 | &dev_attr_lpfc_fcp_class, |
| 3520 | &dev_attr_lpfc_use_adisc, |
| 3521 | &dev_attr_lpfc_ack0, |
| 3522 | &dev_attr_lpfc_topology, |
| 3523 | &dev_attr_lpfc_scan_down, |
| 3524 | &dev_attr_lpfc_link_speed, |
| 3525 | &dev_attr_lpfc_cr_delay, |
| 3526 | &dev_attr_lpfc_cr_count, |
| 3527 | &dev_attr_lpfc_multi_ring_support, |
| 3528 | &dev_attr_lpfc_multi_ring_rctl, |
| 3529 | &dev_attr_lpfc_multi_ring_type, |
| 3530 | &dev_attr_lpfc_fdmi_on, |
| 3531 | &dev_attr_lpfc_max_luns, |
| 3532 | &dev_attr_lpfc_enable_npiv, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3533 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3534 | &dev_attr_nport_evt_cnt, |
| 3535 | &dev_attr_board_mode, |
| 3536 | &dev_attr_max_vpi, |
| 3537 | &dev_attr_used_vpi, |
| 3538 | &dev_attr_max_rpi, |
| 3539 | &dev_attr_used_rpi, |
| 3540 | &dev_attr_max_xri, |
| 3541 | &dev_attr_used_xri, |
| 3542 | &dev_attr_npiv_info, |
| 3543 | &dev_attr_issue_reset, |
| 3544 | &dev_attr_lpfc_poll, |
| 3545 | &dev_attr_lpfc_poll_tmo, |
| 3546 | &dev_attr_lpfc_use_msi, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 3547 | &dev_attr_lpfc_fcp_imax, |
| 3548 | &dev_attr_lpfc_fcp_wq_count, |
| 3549 | &dev_attr_lpfc_fcp_eq_count, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3550 | &dev_attr_lpfc_enable_bg, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3551 | &dev_attr_lpfc_soft_wwnn, |
| 3552 | &dev_attr_lpfc_soft_wwpn, |
| 3553 | &dev_attr_lpfc_soft_wwn_enable, |
| 3554 | &dev_attr_lpfc_enable_hba_reset, |
| 3555 | &dev_attr_lpfc_enable_hba_heartbeat, |
| 3556 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 3557 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3558 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 3559 | &dev_attr_lpfc_prot_sg_seg_cnt, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 3560 | &dev_attr_lpfc_aer_support, |
| 3561 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3562 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3563 | &dev_attr_lpfc_iocb_cnt, |
| 3564 | &dev_attr_iocb_hw, |
| 3565 | &dev_attr_txq_hw, |
| 3566 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 3567 | &dev_attr_lpfc_fips_level, |
| 3568 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3569 | &dev_attr_lpfc_dss, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3570 | NULL, |
| 3571 | }; |
| 3572 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3573 | struct device_attribute *lpfc_vport_attrs[] = { |
| 3574 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 3575 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3576 | &dev_attr_num_discovered_ports, |
| 3577 | &dev_attr_lpfc_drvr_version, |
| 3578 | &dev_attr_lpfc_log_verbose, |
| 3579 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3580 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3581 | &dev_attr_lpfc_nodev_tmo, |
| 3582 | &dev_attr_lpfc_devloss_tmo, |
| 3583 | &dev_attr_lpfc_hba_queue_depth, |
| 3584 | &dev_attr_lpfc_peer_port_login, |
| 3585 | &dev_attr_lpfc_restrict_login, |
| 3586 | &dev_attr_lpfc_fcp_class, |
| 3587 | &dev_attr_lpfc_use_adisc, |
| 3588 | &dev_attr_lpfc_fdmi_on, |
| 3589 | &dev_attr_lpfc_max_luns, |
| 3590 | &dev_attr_nport_evt_cnt, |
| 3591 | &dev_attr_npiv_info, |
| 3592 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3593 | &dev_attr_lpfc_max_scsicmpl_time, |
| 3594 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3595 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 3596 | &dev_attr_lpfc_fips_level, |
| 3597 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3598 | NULL, |
| 3599 | }; |
| 3600 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3601 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3602 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3603 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3604 | * @kobj: kernel kobject that contains the kernel class device. |
| 3605 | * @bin_attr: kernel attributes passed to us. |
| 3606 | * @buf: contains the data to be written to the adapter IOREG space. |
| 3607 | * @off: offset into buffer to beginning of data. |
| 3608 | * @count: bytes to transfer. |
| 3609 | * |
| 3610 | * Description: |
| 3611 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 3612 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 3613 | * |
| 3614 | * Returns: |
| 3615 | * -ERANGE off and count combo out of range |
| 3616 | * -EINVAL off, count or buff address invalid |
| 3617 | * -EPERM adapter is offline |
| 3618 | * value of count, buf contents written |
| 3619 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3620 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3621 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 3622 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3623 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3624 | { |
| 3625 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3626 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3627 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3628 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3629 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3630 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 3631 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 3632 | return -EPERM; |
| 3633 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3634 | if ((off + count) > FF_REG_AREA_SIZE) |
| 3635 | return -ERANGE; |
| 3636 | |
| 3637 | if (count == 0) return 0; |
| 3638 | |
| 3639 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3640 | return -EINVAL; |
| 3641 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3642 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3643 | return -EPERM; |
| 3644 | } |
| 3645 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3646 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3647 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) |
| 3648 | writel(*((uint32_t *)(buf + buf_off)), |
| 3649 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 3650 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3651 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3652 | |
| 3653 | return count; |
| 3654 | } |
| 3655 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3656 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3657 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3658 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3659 | * @kobj: kernel kobject that contains the kernel class device. |
| 3660 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 3661 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3662 | * @off: offset into buffer to beginning of data. |
| 3663 | * @count: bytes to transfer. |
| 3664 | * |
| 3665 | * Description: |
| 3666 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 3667 | * Uses the adapter io control registers to read data into buf. |
| 3668 | * |
| 3669 | * Returns: |
| 3670 | * -ERANGE off and count combo out of range |
| 3671 | * -EINVAL off, count or buff address invalid |
| 3672 | * value of count, buf contents read |
| 3673 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3674 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3675 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 3676 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3677 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3678 | { |
| 3679 | size_t buf_off; |
| 3680 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3681 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3682 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3683 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3684 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3685 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 3686 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 3687 | return -EPERM; |
| 3688 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3689 | if (off > FF_REG_AREA_SIZE) |
| 3690 | return -ERANGE; |
| 3691 | |
| 3692 | if ((off + count) > FF_REG_AREA_SIZE) |
| 3693 | count = FF_REG_AREA_SIZE - off; |
| 3694 | |
| 3695 | if (count == 0) return 0; |
| 3696 | |
| 3697 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3698 | return -EINVAL; |
| 3699 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3700 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3701 | |
| 3702 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 3703 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 3704 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 3705 | } |
| 3706 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3707 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3708 | |
| 3709 | return count; |
| 3710 | } |
| 3711 | |
| 3712 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 3713 | .attr = { |
| 3714 | .name = "ctlreg", |
| 3715 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3716 | }, |
| 3717 | .size = 256, |
| 3718 | .read = sysfs_ctlreg_read, |
| 3719 | .write = sysfs_ctlreg_write, |
| 3720 | }; |
| 3721 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3722 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3723 | * sysfs_mbox_idle - frees the sysfs mailbox |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3724 | * @phba: lpfc_hba pointer |
| 3725 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3726 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3727 | sysfs_mbox_idle(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3728 | { |
| 3729 | phba->sysfs_mbox.state = SMBOX_IDLE; |
| 3730 | phba->sysfs_mbox.offset = 0; |
| 3731 | |
| 3732 | if (phba->sysfs_mbox.mbox) { |
| 3733 | mempool_free(phba->sysfs_mbox.mbox, |
| 3734 | phba->mbox_mem_pool); |
| 3735 | phba->sysfs_mbox.mbox = NULL; |
| 3736 | } |
| 3737 | } |
| 3738 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3739 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3740 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3741 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3742 | * @kobj: kernel kobject that contains the kernel class device. |
| 3743 | * @bin_attr: kernel attributes passed to us. |
| 3744 | * @buf: contains the data to be written to sysfs mbox. |
| 3745 | * @off: offset into buffer to beginning of data. |
| 3746 | * @count: bytes to transfer. |
| 3747 | * |
| 3748 | * Description: |
| 3749 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. |
| 3750 | * Uses the sysfs mbox to send buf contents to the adapter. |
| 3751 | * |
| 3752 | * Returns: |
| 3753 | * -ERANGE off and count combo out of range |
| 3754 | * -EINVAL off, count or buff address invalid |
| 3755 | * zero if count is zero |
| 3756 | * -EPERM adapter is offline |
| 3757 | * -ENOMEM failed to allocate memory for the mail box |
| 3758 | * -EAGAIN offset, state or mbox is NULL |
| 3759 | * count number of bytes transferred |
| 3760 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3761 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3762 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 3763 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3764 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3765 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3766 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3767 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3768 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3769 | struct lpfc_hba *phba = vport->phba; |
| 3770 | struct lpfcMboxq *mbox = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3771 | |
| 3772 | if ((count + off) > MAILBOX_CMD_SIZE) |
| 3773 | return -ERANGE; |
| 3774 | |
| 3775 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3776 | return -EINVAL; |
| 3777 | |
| 3778 | if (count == 0) |
| 3779 | return 0; |
| 3780 | |
| 3781 | if (off == 0) { |
| 3782 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 3783 | if (!mbox) |
| 3784 | return -ENOMEM; |
James Smart | fc6c12b | 2006-03-07 15:04:19 -0500 | [diff] [blame] | 3785 | memset(mbox, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3786 | } |
| 3787 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3788 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3789 | |
| 3790 | if (off == 0) { |
| 3791 | if (phba->sysfs_mbox.mbox) |
| 3792 | mempool_free(mbox, phba->mbox_mem_pool); |
| 3793 | else |
| 3794 | phba->sysfs_mbox.mbox = mbox; |
| 3795 | phba->sysfs_mbox.state = SMBOX_WRITING; |
| 3796 | } else { |
| 3797 | if (phba->sysfs_mbox.state != SMBOX_WRITING || |
| 3798 | phba->sysfs_mbox.offset != off || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3799 | phba->sysfs_mbox.mbox == NULL) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3800 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3801 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 3802 | return -EAGAIN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3803 | } |
| 3804 | } |
| 3805 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3806 | memcpy((uint8_t *) &phba->sysfs_mbox.mbox->u.mb + off, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3807 | buf, count); |
| 3808 | |
| 3809 | phba->sysfs_mbox.offset = off + count; |
| 3810 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3811 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3812 | |
| 3813 | return count; |
| 3814 | } |
| 3815 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3816 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3817 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3818 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3819 | * @kobj: kernel kobject that contains the kernel class device. |
| 3820 | * @bin_attr: kernel attributes passed to us. |
| 3821 | * @buf: contains the data to be read from sysfs mbox. |
| 3822 | * @off: offset into buffer to beginning of data. |
| 3823 | * @count: bytes to transfer. |
| 3824 | * |
| 3825 | * Description: |
| 3826 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. |
| 3827 | * Uses the sysfs mbox to receive data from to the adapter. |
| 3828 | * |
| 3829 | * Returns: |
| 3830 | * -ERANGE off greater than mailbox command size |
| 3831 | * -EINVAL off, count or buff address invalid |
| 3832 | * zero if off and count are zero |
| 3833 | * -EACCES adapter over temp |
| 3834 | * -EPERM garbage can value to catch a multitude of errors |
| 3835 | * -EAGAIN management IO not permitted, state or off error |
| 3836 | * -ETIME mailbox timeout |
| 3837 | * -ENODEV mailbox error |
| 3838 | * count number of bytes transferred |
| 3839 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3840 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3841 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 3842 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 3843 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3844 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3845 | struct device *dev = container_of(kobj, struct device, kobj); |
| 3846 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3847 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3848 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3849 | int rc; |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3850 | MAILBOX_t *pmb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3851 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3852 | if (off > MAILBOX_CMD_SIZE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3853 | return -ERANGE; |
| 3854 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3855 | if ((count + off) > MAILBOX_CMD_SIZE) |
| 3856 | count = MAILBOX_CMD_SIZE - off; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3857 | |
| 3858 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 3859 | return -EINVAL; |
| 3860 | |
| 3861 | if (off && count == 0) |
| 3862 | return 0; |
| 3863 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3864 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3865 | |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 3866 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 3867 | sysfs_mbox_idle(phba); |
| 3868 | spin_unlock_irq(&phba->hbalock); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3869 | return -EACCES; |
James Smart | 7af6705 | 2007-10-27 13:38:11 -0400 | [diff] [blame] | 3870 | } |
| 3871 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3872 | if (off == 0 && |
| 3873 | phba->sysfs_mbox.state == SMBOX_WRITING && |
| 3874 | phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3875 | pmb = &phba->sysfs_mbox.mbox->u.mb; |
| 3876 | switch (pmb->mbxCommand) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3877 | /* Offline only */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3878 | case MBX_INIT_LINK: |
| 3879 | case MBX_DOWN_LINK: |
| 3880 | case MBX_CONFIG_LINK: |
| 3881 | case MBX_CONFIG_RING: |
| 3882 | case MBX_RESET_RING: |
| 3883 | case MBX_UNREG_LOGIN: |
| 3884 | case MBX_CLEAR_LA: |
| 3885 | case MBX_DUMP_CONTEXT: |
| 3886 | case MBX_RUN_DIAGS: |
| 3887 | case MBX_RESTART: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3888 | case MBX_SET_MASK: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3889 | case MBX_SET_DEBUG: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3890 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3891 | printk(KERN_WARNING "mbox_read:Command 0x%x " |
| 3892 | "is illegal in on-line state\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3893 | pmb->mbxCommand); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3894 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3895 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3896 | return -EPERM; |
| 3897 | } |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3898 | case MBX_WRITE_NV: |
| 3899 | case MBX_WRITE_VPARMS: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3900 | case MBX_LOAD_SM: |
| 3901 | case MBX_READ_NV: |
| 3902 | case MBX_READ_CONFIG: |
| 3903 | case MBX_READ_RCONFIG: |
| 3904 | case MBX_READ_STATUS: |
| 3905 | case MBX_READ_XRI: |
| 3906 | case MBX_READ_REV: |
| 3907 | case MBX_READ_LNK_STAT: |
| 3908 | case MBX_DUMP_MEMORY: |
| 3909 | case MBX_DOWN_LOAD: |
| 3910 | case MBX_UPDATE_CFG: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 3911 | case MBX_KILL_BOARD: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3912 | case MBX_LOAD_AREA: |
| 3913 | case MBX_LOAD_EXP_ROM: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 3914 | case MBX_BEACON: |
| 3915 | case MBX_DEL_LD_ENTRY: |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3916 | case MBX_SET_VARIABLE: |
| 3917 | case MBX_WRITE_WWN: |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 3918 | case MBX_PORT_CAPABILITIES: |
| 3919 | case MBX_PORT_IOV_CONTROL: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3920 | break; |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 3921 | case MBX_SECURITY_MGMT: |
| 3922 | case MBX_AUTH_PORT: |
James Smart | 5989b8d | 2010-10-22 11:06:56 -0400 | [diff] [blame] | 3923 | if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) { |
| 3924 | printk(KERN_WARNING "mbox_read:Command 0x%x " |
| 3925 | "is not permitted\n", pmb->mbxCommand); |
| 3926 | sysfs_mbox_idle(phba); |
| 3927 | spin_unlock_irq(&phba->hbalock); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 3928 | return -EPERM; |
James Smart | 5989b8d | 2010-10-22 11:06:56 -0400 | [diff] [blame] | 3929 | } |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 3930 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3931 | case MBX_READ_SPARM64: |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3932 | case MBX_READ_TOPOLOGY: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3933 | case MBX_REG_LOGIN: |
| 3934 | case MBX_REG_LOGIN64: |
| 3935 | case MBX_CONFIG_PORT: |
| 3936 | case MBX_RUN_BIU_DIAG: |
| 3937 | printk(KERN_WARNING "mbox_read: Illegal Command 0x%x\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3938 | pmb->mbxCommand); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3939 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3940 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3941 | return -EPERM; |
| 3942 | default: |
| 3943 | printk(KERN_WARNING "mbox_read: Unknown Command 0x%x\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3944 | pmb->mbxCommand); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3945 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3946 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3947 | return -EPERM; |
| 3948 | } |
| 3949 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3950 | /* If HBA encountered an error attention, allow only DUMP |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 3951 | * or RESTART mailbox commands until the HBA is restarted. |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3952 | */ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3953 | if (phba->pport->stopped && |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3954 | pmb->mbxCommand != MBX_DUMP_MEMORY && |
| 3955 | pmb->mbxCommand != MBX_RESTART && |
| 3956 | pmb->mbxCommand != MBX_WRITE_VPARMS && |
| 3957 | pmb->mbxCommand != MBX_WRITE_WWN) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3958 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, |
| 3959 | "1259 mbox: Issued mailbox cmd " |
| 3960 | "0x%x while in stopped state.\n", |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3961 | pmb->mbxCommand); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3962 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3963 | phba->sysfs_mbox.mbox->vport = vport; |
| 3964 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3965 | /* Don't allow mailbox commands to be sent when blocked |
| 3966 | * or when in the middle of discovery |
| 3967 | */ |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 3968 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) { |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 3969 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3970 | spin_unlock_irq(&phba->hbalock); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 3971 | return -EAGAIN; |
| 3972 | } |
| 3973 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3974 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3975 | (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3976 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3977 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3978 | rc = lpfc_sli_issue_mbox (phba, |
| 3979 | phba->sysfs_mbox.mbox, |
| 3980 | MBX_POLL); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3981 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3982 | |
| 3983 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3984 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3985 | rc = lpfc_sli_issue_mbox_wait (phba, |
| 3986 | phba->sysfs_mbox.mbox, |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 3987 | lpfc_mbox_tmo_val(phba, pmb->mbxCommand) * HZ); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3988 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3989 | } |
| 3990 | |
| 3991 | if (rc != MBX_SUCCESS) { |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3992 | if (rc == MBX_TIMEOUT) { |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 3993 | phba->sysfs_mbox.mbox = NULL; |
| 3994 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3995 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3996 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 3997 | return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3998 | } |
| 3999 | phba->sysfs_mbox.state = SMBOX_READING; |
| 4000 | } |
| 4001 | else if (phba->sysfs_mbox.offset != off || |
| 4002 | phba->sysfs_mbox.state != SMBOX_READING) { |
| 4003 | printk(KERN_WARNING "mbox_read: Bad State\n"); |
| 4004 | sysfs_mbox_idle(phba); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4005 | spin_unlock_irq(&phba->hbalock); |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 4006 | return -EAGAIN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4007 | } |
| 4008 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4009 | memcpy(buf, (uint8_t *) &pmb + off, count); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4010 | |
| 4011 | phba->sysfs_mbox.offset = off + count; |
| 4012 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 4013 | if (phba->sysfs_mbox.offset == MAILBOX_CMD_SIZE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4014 | sysfs_mbox_idle(phba); |
| 4015 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4016 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4017 | |
| 4018 | return count; |
| 4019 | } |
| 4020 | |
| 4021 | static struct bin_attribute sysfs_mbox_attr = { |
| 4022 | .attr = { |
| 4023 | .name = "mbox", |
| 4024 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4025 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame^] | 4026 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4027 | .read = sysfs_mbox_read, |
| 4028 | .write = sysfs_mbox_write, |
| 4029 | }; |
| 4030 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4031 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4032 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4033 | * @vport: address of lpfc vport structure. |
| 4034 | * |
| 4035 | * Return codes: |
| 4036 | * zero on success |
| 4037 | * error return code from sysfs_create_bin_file() |
| 4038 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4039 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4040 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4041 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4042 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4043 | int error; |
| 4044 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4045 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4046 | &sysfs_drvr_stat_data_attr); |
| 4047 | |
| 4048 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 4049 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 4050 | goto out; |
| 4051 | |
| 4052 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4053 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4054 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4055 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4056 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4057 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4058 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4059 | if (error) |
| 4060 | goto out_remove_ctlreg_attr; |
| 4061 | |
| 4062 | return 0; |
| 4063 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4064 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4065 | out_remove_stat_attr: |
| 4066 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 4067 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4068 | out: |
| 4069 | return error; |
| 4070 | } |
| 4071 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4072 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4073 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4074 | * @vport: address of lpfc vport structure. |
| 4075 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4076 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4077 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4078 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4079 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4080 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 4081 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4082 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 4083 | if (vport->port_type == LPFC_NPIV_PORT) |
| 4084 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4085 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 4086 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4087 | } |
| 4088 | |
| 4089 | |
| 4090 | /* |
| 4091 | * Dynamic FC Host Attributes Support |
| 4092 | */ |
| 4093 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4094 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4095 | * 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] | 4096 | * @shost: kernel scsi host pointer. |
| 4097 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4098 | static void |
| 4099 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 4100 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4101 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4102 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4103 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4104 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4105 | } |
| 4106 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4107 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4108 | * 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] | 4109 | * @shost: kernel scsi host pointer. |
| 4110 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4111 | static void |
| 4112 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 4113 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4114 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4115 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4116 | |
| 4117 | spin_lock_irq(shost->host_lock); |
| 4118 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4119 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 4120 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 4121 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4122 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4123 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4124 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 4125 | else |
| 4126 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 4127 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4128 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4129 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 4130 | else |
| 4131 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 4132 | } |
| 4133 | } else |
| 4134 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 4135 | |
| 4136 | spin_unlock_irq(shost->host_lock); |
| 4137 | } |
| 4138 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4139 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4140 | * 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] | 4141 | * @shost: kernel scsi host pointer. |
| 4142 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4143 | static void |
| 4144 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 4145 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4146 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4147 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4148 | |
| 4149 | spin_lock_irq(shost->host_lock); |
| 4150 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4151 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4152 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 4153 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4154 | switch (phba->link_state) { |
| 4155 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4156 | case LPFC_LINK_DOWN: |
| 4157 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 4158 | break; |
| 4159 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4160 | case LPFC_CLEAR_LA: |
| 4161 | case LPFC_HBA_READY: |
| 4162 | /* Links up, beyond this port_type reports state */ |
| 4163 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
| 4164 | break; |
| 4165 | case LPFC_HBA_ERROR: |
| 4166 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 4167 | break; |
| 4168 | default: |
| 4169 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 4170 | break; |
| 4171 | } |
| 4172 | } |
| 4173 | |
| 4174 | spin_unlock_irq(shost->host_lock); |
| 4175 | } |
| 4176 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4177 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4178 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4179 | * @shost: kernel scsi host pointer. |
| 4180 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4181 | static void |
| 4182 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 4183 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4184 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4185 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4186 | |
| 4187 | spin_lock_irq(shost->host_lock); |
| 4188 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4189 | if (lpfc_is_link_up(phba)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4190 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4191 | case LPFC_LINK_SPEED_1GHZ: |
| 4192 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4193 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4194 | case LPFC_LINK_SPEED_2GHZ: |
| 4195 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4196 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4197 | case LPFC_LINK_SPEED_4GHZ: |
| 4198 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4199 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4200 | case LPFC_LINK_SPEED_8GHZ: |
| 4201 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 4202 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4203 | case LPFC_LINK_SPEED_10GHZ: |
| 4204 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4205 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4206 | case LPFC_LINK_SPEED_16GHZ: |
| 4207 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 4208 | break; |
| 4209 | default: |
| 4210 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4211 | break; |
| 4212 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4213 | } else |
| 4214 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4215 | |
| 4216 | spin_unlock_irq(shost->host_lock); |
| 4217 | } |
| 4218 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4219 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4220 | * 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] | 4221 | * @shost: kernel scsi host pointer. |
| 4222 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4223 | static void |
| 4224 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 4225 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4226 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4227 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 4228 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4229 | |
| 4230 | spin_lock_irq(shost->host_lock); |
| 4231 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4232 | if ((vport->fc_flag & FC_FABRIC) || |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4233 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4234 | (vport->fc_flag & FC_PUBLIC_LOOP))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 4235 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4236 | else |
| 4237 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4238 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4239 | |
| 4240 | spin_unlock_irq(shost->host_lock); |
| 4241 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 4242 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4243 | } |
| 4244 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4245 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4246 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4247 | * @shost: kernel scsi host pointer. |
| 4248 | * |
| 4249 | * Notes: |
| 4250 | * NULL on error for link down, no mbox pool, sli2 active, |
| 4251 | * management not allowed, memory allocation error, or mbox error. |
| 4252 | * |
| 4253 | * Returns: |
| 4254 | * NULL for error |
| 4255 | * address of the adapter host statistics |
| 4256 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4257 | static struct fc_host_statistics * |
| 4258 | lpfc_get_stats(struct Scsi_Host *shost) |
| 4259 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4260 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4261 | struct lpfc_hba *phba = vport->phba; |
| 4262 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 4263 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4264 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4265 | LPFC_MBOXQ_t *pmboxq; |
| 4266 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4267 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4268 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4269 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4270 | /* |
| 4271 | * prevent udev from issuing mailbox commands until the port is |
| 4272 | * configured. |
| 4273 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4274 | if (phba->link_state < LPFC_LINK_DOWN || |
| 4275 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4276 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4277 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4278 | |
| 4279 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 4280 | return NULL; |
| 4281 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4282 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 4283 | if (!pmboxq) |
| 4284 | return NULL; |
| 4285 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 4286 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4287 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4288 | pmb->mbxCommand = MBX_READ_STATUS; |
| 4289 | pmb->mbxOwner = OWN_HOST; |
| 4290 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4291 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4292 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 4293 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4294 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4295 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4296 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4297 | |
| 4298 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4299 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4300 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4301 | return NULL; |
| 4302 | } |
| 4303 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 4304 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 4305 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4306 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
| 4307 | hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); |
| 4308 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
| 4309 | hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256); |
| 4310 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4311 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4312 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 4313 | pmb->mbxOwner = OWN_HOST; |
| 4314 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4315 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4316 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 4317 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4318 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 4319 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4320 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4321 | |
| 4322 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4323 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4324 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4325 | return NULL; |
| 4326 | } |
| 4327 | |
| 4328 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 4329 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 4330 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 4331 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 4332 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 4333 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 4334 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 4335 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4336 | hs->link_failure_count -= lso->link_failure_count; |
| 4337 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 4338 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 4339 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 4340 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 4341 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 4342 | hs->error_frames -= lso->error_frames; |
| 4343 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4344 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 4345 | hs->lip_count = -1; |
| 4346 | hs->nos_count = (phba->link_events >> 1); |
| 4347 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4348 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4349 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4350 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4351 | hs->nos_count = -1; |
| 4352 | } else { |
| 4353 | hs->lip_count = -1; |
| 4354 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4355 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4356 | } |
| 4357 | |
| 4358 | hs->dumped_frames = -1; |
| 4359 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4360 | seconds = get_seconds(); |
| 4361 | if (seconds < psli->stats_start) |
| 4362 | hs->seconds_since_last_reset = seconds + |
| 4363 | ((unsigned long)-1 - psli->stats_start); |
| 4364 | else |
| 4365 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4366 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 4367 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 4368 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4369 | return hs; |
| 4370 | } |
| 4371 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4372 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4373 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4374 | * @shost: kernel scsi host pointer. |
| 4375 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4376 | static void |
| 4377 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 4378 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4379 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4380 | struct lpfc_hba *phba = vport->phba; |
| 4381 | struct lpfc_sli *psli = &phba->sli; |
| 4382 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4383 | LPFC_MBOXQ_t *pmboxq; |
| 4384 | MAILBOX_t *pmb; |
| 4385 | int rc = 0; |
| 4386 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4387 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 4388 | return; |
| 4389 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4390 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 4391 | if (!pmboxq) |
| 4392 | return; |
| 4393 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 4394 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4395 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4396 | pmb->mbxCommand = MBX_READ_STATUS; |
| 4397 | pmb->mbxOwner = OWN_HOST; |
| 4398 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 4399 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4400 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4401 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4402 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4403 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4404 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 4405 | else |
| 4406 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4407 | |
| 4408 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4409 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4410 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 4411 | return; |
| 4412 | } |
| 4413 | |
| 4414 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 4415 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 4416 | pmb->mbxOwner = OWN_HOST; |
| 4417 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4418 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4419 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4420 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4421 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4422 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 4423 | else |
| 4424 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 4425 | |
| 4426 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4427 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4428 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 4429 | return; |
| 4430 | } |
| 4431 | |
| 4432 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 4433 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 4434 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 4435 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 4436 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 4437 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 4438 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4439 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 4440 | lso->link_events = (phba->link_events >> 1); |
| 4441 | else |
| 4442 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4443 | |
| 4444 | psli->stats_start = get_seconds(); |
| 4445 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 4446 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 4447 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4448 | return; |
| 4449 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4450 | |
| 4451 | /* |
| 4452 | * The LPFC driver treats linkdown handling as target loss events so there |
| 4453 | * are no sysfs handlers for link_down_tmo. |
| 4454 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4455 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4456 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4457 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4458 | * @starget: kernel scsi target pointer. |
| 4459 | * |
| 4460 | * Returns: |
| 4461 | * address of the node list if found |
| 4462 | * NULL target not found |
| 4463 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4464 | static struct lpfc_nodelist * |
| 4465 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4466 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4467 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 4468 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4469 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4470 | |
| 4471 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4472 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4473 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4474 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 4475 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4476 | starget->id == ndlp->nlp_sid) { |
| 4477 | spin_unlock_irq(shost->host_lock); |
| 4478 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4479 | } |
| 4480 | } |
| 4481 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4482 | return NULL; |
| 4483 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4484 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4485 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4486 | * 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] | 4487 | * @starget: kernel scsi target pointer. |
| 4488 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4489 | static void |
| 4490 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 4491 | { |
| 4492 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 4493 | |
| 4494 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4495 | } |
| 4496 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4497 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4498 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4499 | * @starget: kernel scsi target pointer. |
| 4500 | * |
| 4501 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 4502 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4503 | static void |
| 4504 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 4505 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4506 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4507 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4508 | fc_starget_node_name(starget) = |
| 4509 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4510 | } |
| 4511 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4512 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4513 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4514 | * @starget: kernel scsi target pointer. |
| 4515 | * |
| 4516 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 4517 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4518 | static void |
| 4519 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 4520 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4521 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4522 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4523 | fc_starget_port_name(starget) = |
| 4524 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4525 | } |
| 4526 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4527 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4528 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4529 | * @rport: fc rport address. |
| 4530 | * @timeout: new value for dev loss tmo. |
| 4531 | * |
| 4532 | * Description: |
| 4533 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 4534 | * dev_loss_tmo to one. |
| 4535 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4536 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4537 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 4538 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4539 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 4540 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4541 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 4542 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4543 | } |
| 4544 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4545 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4546 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4547 | * |
| 4548 | * Description: |
| 4549 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 4550 | * |
| 4551 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 4552 | * @cdev: class converted to an fc_rport. |
| 4553 | * @buf: on return contains the target_field or zero. |
| 4554 | * |
| 4555 | * Returns: size of formatted string. |
| 4556 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4557 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 4558 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4559 | lpfc_show_rport_##field (struct device *dev, \ |
| 4560 | struct device_attribute *attr, \ |
| 4561 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4562 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4563 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4564 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 4565 | return snprintf(buf, sz, format_string, \ |
| 4566 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 4567 | } |
| 4568 | |
| 4569 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 4570 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 4571 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 4572 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4573 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4574 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4575 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 4576 | * |
| 4577 | * Description: |
| 4578 | * This function is called by the transport after the @fc_vport's symbolic name |
| 4579 | * 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] | 4580 | * 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] | 4581 | **/ |
| 4582 | static void |
| 4583 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 4584 | { |
| 4585 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 4586 | |
| 4587 | if (vport->port_state == LPFC_VPORT_READY) |
| 4588 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 4589 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4590 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4591 | /** |
| 4592 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 4593 | * @phba: Pointer to lpfc_hba struct. |
| 4594 | * |
| 4595 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 4596 | * 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] | 4597 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4598 | * before hba port or vport created. |
| 4599 | **/ |
| 4600 | static void |
| 4601 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 4602 | { |
| 4603 | phba->cfg_log_verbose = verbose; |
| 4604 | } |
| 4605 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4606 | struct fc_function_template lpfc_transport_functions = { |
| 4607 | /* fixed attributes the driver supports */ |
| 4608 | .show_host_node_name = 1, |
| 4609 | .show_host_port_name = 1, |
| 4610 | .show_host_supported_classes = 1, |
| 4611 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4612 | .show_host_supported_speeds = 1, |
| 4613 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4614 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4615 | |
| 4616 | /* dynamic attributes the driver supports */ |
| 4617 | .get_host_port_id = lpfc_get_host_port_id, |
| 4618 | .show_host_port_id = 1, |
| 4619 | |
| 4620 | .get_host_port_type = lpfc_get_host_port_type, |
| 4621 | .show_host_port_type = 1, |
| 4622 | |
| 4623 | .get_host_port_state = lpfc_get_host_port_state, |
| 4624 | .show_host_port_state = 1, |
| 4625 | |
| 4626 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 4627 | .show_host_active_fc4s = 1, |
| 4628 | |
| 4629 | .get_host_speed = lpfc_get_host_speed, |
| 4630 | .show_host_speed = 1, |
| 4631 | |
| 4632 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 4633 | .show_host_fabric_name = 1, |
| 4634 | |
| 4635 | /* |
| 4636 | * The LPFC driver treats linkdown handling as target loss events |
| 4637 | * so there are no sysfs handlers for link_down_tmo. |
| 4638 | */ |
| 4639 | |
| 4640 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 4641 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4642 | |
| 4643 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 4644 | .show_rport_maxframe_size = 1, |
| 4645 | .show_rport_supported_classes = 1, |
| 4646 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4647 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 4648 | .show_rport_dev_loss_tmo = 1, |
| 4649 | |
| 4650 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 4651 | .show_starget_port_id = 1, |
| 4652 | |
| 4653 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 4654 | .show_starget_node_name = 1, |
| 4655 | |
| 4656 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 4657 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 4658 | |
| 4659 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 4660 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 4661 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4662 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4663 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4664 | |
| 4665 | .vport_disable = lpfc_vport_disable, |
| 4666 | |
| 4667 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 4668 | |
| 4669 | .bsg_request = lpfc_bsg_request, |
| 4670 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4671 | }; |
| 4672 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 4673 | struct fc_function_template lpfc_vport_transport_functions = { |
| 4674 | /* fixed attributes the driver supports */ |
| 4675 | .show_host_node_name = 1, |
| 4676 | .show_host_port_name = 1, |
| 4677 | .show_host_supported_classes = 1, |
| 4678 | .show_host_supported_fc4s = 1, |
| 4679 | .show_host_supported_speeds = 1, |
| 4680 | .show_host_maxframe_size = 1, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4681 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 4682 | |
| 4683 | /* dynamic attributes the driver supports */ |
| 4684 | .get_host_port_id = lpfc_get_host_port_id, |
| 4685 | .show_host_port_id = 1, |
| 4686 | |
| 4687 | .get_host_port_type = lpfc_get_host_port_type, |
| 4688 | .show_host_port_type = 1, |
| 4689 | |
| 4690 | .get_host_port_state = lpfc_get_host_port_state, |
| 4691 | .show_host_port_state = 1, |
| 4692 | |
| 4693 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 4694 | .show_host_active_fc4s = 1, |
| 4695 | |
| 4696 | .get_host_speed = lpfc_get_host_speed, |
| 4697 | .show_host_speed = 1, |
| 4698 | |
| 4699 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 4700 | .show_host_fabric_name = 1, |
| 4701 | |
| 4702 | /* |
| 4703 | * The LPFC driver treats linkdown handling as target loss events |
| 4704 | * so there are no sysfs handlers for link_down_tmo. |
| 4705 | */ |
| 4706 | |
| 4707 | .get_fc_host_stats = lpfc_get_stats, |
| 4708 | .reset_fc_host_stats = lpfc_reset_stats, |
| 4709 | |
| 4710 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 4711 | .show_rport_maxframe_size = 1, |
| 4712 | .show_rport_supported_classes = 1, |
| 4713 | |
| 4714 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 4715 | .show_rport_dev_loss_tmo = 1, |
| 4716 | |
| 4717 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 4718 | .show_starget_port_id = 1, |
| 4719 | |
| 4720 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 4721 | .show_starget_node_name = 1, |
| 4722 | |
| 4723 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 4724 | .show_starget_port_name = 1, |
| 4725 | |
| 4726 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 4727 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 4728 | |
| 4729 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 4730 | |
| 4731 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 4732 | }; |
| 4733 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4734 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4735 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4736 | * @phba: lpfc_hba pointer. |
| 4737 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4738 | void |
| 4739 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 4740 | { |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 4741 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 4742 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4743 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4744 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 4745 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 4746 | lpfc_ack0_init(phba, lpfc_ack0); |
| 4747 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 4748 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4749 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 4750 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4751 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4752 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 4753 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
| 4754 | lpfc_fcp_wq_count_init(phba, lpfc_fcp_wq_count); |
| 4755 | lpfc_fcp_eq_count_init(phba, lpfc_fcp_eq_count); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4756 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 4757 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4758 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 4759 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 4760 | phba->cfg_poll = 0; |
| 4761 | else |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4762 | phba->cfg_poll = lpfc_poll; |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 4763 | phba->cfg_soft_wwnn = 0L; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 4764 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4765 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4766 | lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4767 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4768 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4769 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 4770 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 4771 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4772 | phba->cfg_enable_dss = 1; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4773 | return; |
| 4774 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 4775 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4776 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4777 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4778 | * @vport: lpfc_vport pointer. |
| 4779 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4780 | void |
| 4781 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 4782 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4783 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4784 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4785 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4786 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 4787 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 4788 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 4789 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 4790 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 4791 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4792 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4793 | lpfc_fdmi_on_init(vport, lpfc_fdmi_on); |
| 4794 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 4795 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 4796 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 4797 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4798 | return; |
| 4799 | } |