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