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