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