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