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