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