| 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 | 67073c6 | 2021-03-01 09:18:21 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term * |
James Smart | 3e21d1c | 2018-05-04 20:37:59 -0700 | [diff] [blame] | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
James Smart | 5061157 | 2016-03-31 14:12:34 -0700 | [diff] [blame] | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * EMULEX and SLI are trademarks of Emulex. * |
James Smart | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 8 | * www.broadcom.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 9 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 10 | * * |
| 11 | * 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] | 12 | * modify it under the terms of version 2 of the GNU General * |
| 13 | * Public License as published by the Free Software Foundation. * |
| 14 | * This program is distributed in the hope that it will be useful. * |
| 15 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 16 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 18 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 19 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 20 | * more details, a copy of which can be found in the file COPYING * |
| 21 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | *******************************************************************/ |
| 23 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 24 | #include <linux/ctype.h> |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 25 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 26 | #include <linux/pci.h> |
| 27 | #include <linux/interrupt.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 28 | #include <linux/module.h> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 29 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 31 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 32 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 33 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | #include <scsi/scsi_device.h> |
| 35 | #include <scsi/scsi_host.h> |
| 36 | #include <scsi/scsi_tcq.h> |
| 37 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 38 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 39 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 40 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 41 | #include "lpfc_hw.h" |
| 42 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 43 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 44 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 45 | #include "lpfc_disc.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 46 | #include "lpfc.h" |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 47 | #include "lpfc_scsi.h" |
| 48 | #include "lpfc_nvme.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 49 | #include "lpfc_logmsg.h" |
| 50 | #include "lpfc_version.h" |
| 51 | #include "lpfc_compat.h" |
| 52 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 53 | #include "lpfc_vport.h" |
James Smart | 93dd191 | 2016-07-06 12:36:10 -0700 | [diff] [blame] | 54 | #include "lpfc_attr.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 55 | |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 56 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 57 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 58 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 59 | |
James Smart | 74a7baa | 2021-08-16 09:28:58 -0700 | [diff] [blame] | 60 | #define LPFC_MAX_INFO_TMP_LEN 100 |
| 61 | #define LPFC_INFO_MORE_STR "\nCould be more info...\n" |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 62 | /* |
| 63 | * Write key size should be multiple of 4. If write key is changed |
| 64 | * make sure that library write key is also changed. |
| 65 | */ |
| 66 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 67 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 68 | |
Bart Van Assche | a73cb81 | 2019-03-28 11:06:19 -0700 | [diff] [blame] | 69 | const char *const trunk_errmsg[] = { /* map errcode */ |
| 70 | "", /* There is no such error code at index 0*/ |
| 71 | "link negotiated speed does not match existing" |
| 72 | " trunk - link was \"low\" speed", |
| 73 | "link negotiated speed does not match" |
| 74 | " existing trunk - link was \"middle\" speed", |
| 75 | "link negotiated speed does not match existing" |
| 76 | " trunk - link was \"high\" speed", |
| 77 | "Attached to non-trunking port - F_Port", |
| 78 | "Attached to non-trunking port - N_Port", |
| 79 | "FLOGI response timeout", |
| 80 | "non-FLOGI frame received", |
| 81 | "Invalid FLOGI response", |
| 82 | "Trunking initialization protocol", |
| 83 | "Trunk peer device mismatch", |
| 84 | }; |
| 85 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 86 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 87 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 88 | * @incr: integer to convert. |
| 89 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 90 | * |
| 91 | * Description: |
| 92 | * JEDEC Joint Electron Device Engineering Council. |
| 93 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 94 | * character string. The string is then terminated with a NULL in byte 9. |
| 95 | * Hex 0-9 becomes ascii '0' to '9'. |
| 96 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 97 | * |
| 98 | * Notes: |
| 99 | * Coded for 32 bit integers only. |
| 100 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 101 | static void |
| 102 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 103 | { |
| 104 | int i, j; |
| 105 | for (i = 0; i < 8; i++) { |
| 106 | j = (incr & 0xf); |
| 107 | if (j <= 9) |
| 108 | hdw[7 - i] = 0x30 + j; |
| 109 | else |
| 110 | hdw[7 - i] = 0x61 + j - 10; |
| 111 | incr = (incr >> 4); |
| 112 | } |
| 113 | hdw[8] = 0; |
| 114 | return; |
| 115 | } |
| 116 | |
James Smart | 74a7baa | 2021-08-16 09:28:58 -0700 | [diff] [blame] | 117 | static ssize_t |
| 118 | lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr, |
| 119 | char *buf) |
| 120 | { |
| 121 | struct Scsi_Host *shost = class_to_shost(dev); |
| 122 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 123 | struct lpfc_hba *phba = vport->phba; |
| 124 | struct lpfc_cgn_info *cp = NULL; |
| 125 | struct lpfc_cgn_stat *cgs; |
| 126 | int len = 0; |
| 127 | int cpu; |
| 128 | u64 rcv, total; |
| 129 | char tmp[LPFC_MAX_INFO_TMP_LEN] = {0}; |
| 130 | |
| 131 | if (phba->cgn_i) |
| 132 | cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; |
| 133 | |
| 134 | scnprintf(tmp, sizeof(tmp), |
| 135 | "Congestion Mgmt Info: E2Eattr %d Ver %d " |
| 136 | "CMF %d cnt %d\n", |
| 137 | phba->sli4_hba.pc_sli4_params.mi_ver, |
| 138 | cp ? cp->cgn_info_version : 0, |
| 139 | phba->sli4_hba.pc_sli4_params.cmf, phba->cmf_timer_cnt); |
| 140 | |
| 141 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 142 | goto buffer_done; |
| 143 | |
| 144 | if (!phba->sli4_hba.pc_sli4_params.cmf) |
| 145 | goto buffer_done; |
| 146 | |
| 147 | switch (phba->cgn_init_reg_signal) { |
| 148 | case EDC_CG_SIG_WARN_ONLY: |
| 149 | scnprintf(tmp, sizeof(tmp), |
| 150 | "Register: Init: Signal:WARN "); |
| 151 | break; |
| 152 | case EDC_CG_SIG_WARN_ALARM: |
| 153 | scnprintf(tmp, sizeof(tmp), |
| 154 | "Register: Init: Signal:WARN|ALARM "); |
| 155 | break; |
| 156 | default: |
| 157 | scnprintf(tmp, sizeof(tmp), |
| 158 | "Register: Init: Signal:NONE "); |
| 159 | break; |
| 160 | } |
| 161 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 162 | goto buffer_done; |
| 163 | |
| 164 | switch (phba->cgn_init_reg_fpin) { |
| 165 | case LPFC_CGN_FPIN_WARN: |
| 166 | scnprintf(tmp, sizeof(tmp), |
| 167 | "FPIN:WARN\n"); |
| 168 | break; |
| 169 | case LPFC_CGN_FPIN_ALARM: |
| 170 | scnprintf(tmp, sizeof(tmp), |
| 171 | "FPIN:ALARM\n"); |
| 172 | break; |
| 173 | case LPFC_CGN_FPIN_BOTH: |
| 174 | scnprintf(tmp, sizeof(tmp), |
| 175 | "FPIN:WARN|ALARM\n"); |
| 176 | break; |
| 177 | default: |
| 178 | scnprintf(tmp, sizeof(tmp), |
| 179 | "FPIN:NONE\n"); |
| 180 | break; |
| 181 | } |
| 182 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 183 | goto buffer_done; |
| 184 | |
| 185 | switch (phba->cgn_reg_signal) { |
| 186 | case EDC_CG_SIG_WARN_ONLY: |
| 187 | scnprintf(tmp, sizeof(tmp), |
| 188 | " Current: Signal:WARN "); |
| 189 | break; |
| 190 | case EDC_CG_SIG_WARN_ALARM: |
| 191 | scnprintf(tmp, sizeof(tmp), |
| 192 | " Current: Signal:WARN|ALARM "); |
| 193 | break; |
| 194 | default: |
| 195 | scnprintf(tmp, sizeof(tmp), |
| 196 | " Current: Signal:NONE "); |
| 197 | break; |
| 198 | } |
| 199 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 200 | goto buffer_done; |
| 201 | |
| 202 | switch (phba->cgn_reg_fpin) { |
| 203 | case LPFC_CGN_FPIN_WARN: |
| 204 | scnprintf(tmp, sizeof(tmp), |
| 205 | "FPIN:WARN ACQEcnt:%d\n", phba->cgn_acqe_cnt); |
| 206 | break; |
| 207 | case LPFC_CGN_FPIN_ALARM: |
| 208 | scnprintf(tmp, sizeof(tmp), |
| 209 | "FPIN:ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt); |
| 210 | break; |
| 211 | case LPFC_CGN_FPIN_BOTH: |
| 212 | scnprintf(tmp, sizeof(tmp), |
| 213 | "FPIN:WARN|ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt); |
| 214 | break; |
| 215 | default: |
| 216 | scnprintf(tmp, sizeof(tmp), |
| 217 | "FPIN:NONE ACQEcnt:%d\n", phba->cgn_acqe_cnt); |
| 218 | break; |
| 219 | } |
| 220 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 221 | goto buffer_done; |
| 222 | |
| 223 | if (phba->cmf_active_mode != phba->cgn_p.cgn_param_mode) { |
| 224 | switch (phba->cmf_active_mode) { |
| 225 | case LPFC_CFG_OFF: |
| 226 | scnprintf(tmp, sizeof(tmp), "Active: Mode:Off\n"); |
| 227 | break; |
| 228 | case LPFC_CFG_MANAGED: |
| 229 | scnprintf(tmp, sizeof(tmp), "Active: Mode:Managed\n"); |
| 230 | break; |
| 231 | case LPFC_CFG_MONITOR: |
| 232 | scnprintf(tmp, sizeof(tmp), "Active: Mode:Monitor\n"); |
| 233 | break; |
| 234 | default: |
| 235 | scnprintf(tmp, sizeof(tmp), "Active: Mode:Unknown\n"); |
| 236 | } |
| 237 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 238 | goto buffer_done; |
| 239 | } |
| 240 | |
| 241 | switch (phba->cgn_p.cgn_param_mode) { |
| 242 | case LPFC_CFG_OFF: |
| 243 | scnprintf(tmp, sizeof(tmp), "Config: Mode:Off "); |
| 244 | break; |
| 245 | case LPFC_CFG_MANAGED: |
| 246 | scnprintf(tmp, sizeof(tmp), "Config: Mode:Managed "); |
| 247 | break; |
| 248 | case LPFC_CFG_MONITOR: |
| 249 | scnprintf(tmp, sizeof(tmp), "Config: Mode:Monitor "); |
| 250 | break; |
| 251 | default: |
| 252 | scnprintf(tmp, sizeof(tmp), "Config: Mode:Unknown "); |
| 253 | } |
| 254 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 255 | goto buffer_done; |
| 256 | |
| 257 | total = 0; |
| 258 | rcv = 0; |
| 259 | for_each_present_cpu(cpu) { |
| 260 | cgs = per_cpu_ptr(phba->cmf_stat, cpu); |
| 261 | total += atomic64_read(&cgs->total_bytes); |
| 262 | rcv += atomic64_read(&cgs->rcv_bytes); |
| 263 | } |
| 264 | |
| 265 | scnprintf(tmp, sizeof(tmp), |
| 266 | "IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n", |
| 267 | atomic_read(&phba->cmf_busy), |
| 268 | phba->cmf_active_info, rcv, total); |
| 269 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 270 | goto buffer_done; |
| 271 | |
| 272 | scnprintf(tmp, sizeof(tmp), |
| 273 | "Port_speed:%d Link_byte_cnt:%ld " |
| 274 | "Max_byte_per_interval:%ld\n", |
| 275 | lpfc_sli_port_speed_get(phba), |
| 276 | (unsigned long)phba->cmf_link_byte_count, |
| 277 | (unsigned long)phba->cmf_max_bytes_per_interval); |
| 278 | strlcat(buf, tmp, PAGE_SIZE); |
| 279 | |
| 280 | buffer_done: |
| 281 | len = strnlen(buf, PAGE_SIZE); |
| 282 | |
| 283 | if (unlikely(len >= (PAGE_SIZE - 1))) { |
| 284 | lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT, |
| 285 | "6312 Catching potential buffer " |
| 286 | "overflow > PAGE_SIZE = %lu bytes\n", |
| 287 | PAGE_SIZE); |
Arnd Bergmann | a38923f2d | 2021-09-20 11:56:22 +0200 | [diff] [blame] | 288 | strscpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_INFO_MORE_STR), |
| 289 | LPFC_INFO_MORE_STR, sizeof(LPFC_INFO_MORE_STR) + 1); |
James Smart | 74a7baa | 2021-08-16 09:28:58 -0700 | [diff] [blame] | 290 | } |
| 291 | return len; |
| 292 | } |
| 293 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 294 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 295 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 296 | * @dev: class unused variable. |
| 297 | * @attr: device attribute, not used. |
| 298 | * @buf: on return contains the module description text. |
| 299 | * |
| 300 | * Returns: size of formatted string. |
| 301 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 302 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 303 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 304 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 305 | { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 306 | return scnprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 307 | } |
| 308 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 309 | /** |
| 310 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 311 | * @dev: class unused variable. |
| 312 | * @attr: device attribute, not used. |
| 313 | * @buf: on return contains the module description text. |
| 314 | * |
| 315 | * Returns: size of formatted string. |
| 316 | **/ |
| 317 | static ssize_t |
| 318 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 319 | char *buf) |
| 320 | { |
| 321 | struct Scsi_Host *shost = class_to_shost(dev); |
| 322 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 323 | struct lpfc_hba *phba = vport->phba; |
| 324 | |
| 325 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 326 | return scnprintf(buf, PAGE_SIZE, "1\n"); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 327 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 328 | return scnprintf(buf, PAGE_SIZE, "0\n"); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 329 | } |
| 330 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 331 | static ssize_t |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 332 | lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, |
| 333 | char *buf) |
| 334 | { |
| 335 | struct Scsi_Host *shost = class_to_shost(dev); |
| 336 | struct lpfc_vport *vport = shost_priv(shost); |
| 337 | struct lpfc_hba *phba = vport->phba; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 338 | struct lpfc_nvmet_tgtport *tgtp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 339 | struct nvme_fc_local_port *localport; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 340 | struct lpfc_nvme_lport *lport; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 341 | struct lpfc_nvme_rport *rport; |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 342 | struct lpfc_nodelist *ndlp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 343 | struct nvme_fc_remote_port *nrport; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 344 | struct lpfc_fc4_ctrl_stat *cstat; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 345 | uint64_t data1, data2, data3; |
| 346 | uint64_t totin, totout, tot; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 347 | char *statep; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 348 | int i; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 349 | int len = 0; |
James Smart | 74a7baa | 2021-08-16 09:28:58 -0700 | [diff] [blame] | 350 | char tmp[LPFC_MAX_INFO_TMP_LEN] = {0}; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 351 | |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 352 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 353 | len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 354 | return len; |
| 355 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 356 | if (phba->nvmet_support) { |
| 357 | if (!phba->targetport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 358 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 359 | "NVME Target: x%llx is not allocated\n", |
| 360 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 361 | return len; |
| 362 | } |
| 363 | /* Port state is only one of two values for now. */ |
| 364 | if (phba->targetport->port_id) |
| 365 | statep = "REGISTERED"; |
| 366 | else |
| 367 | statep = "INIT"; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 368 | scnprintf(tmp, sizeof(tmp), |
| 369 | "NVME Target Enabled State %s\n", |
| 370 | statep); |
| 371 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 372 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 373 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 374 | scnprintf(tmp, sizeof(tmp), |
| 375 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 376 | "NVME Target: lpfc", |
| 377 | phba->brd_no, |
| 378 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 379 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 380 | phba->targetport->port_id); |
| 381 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 382 | goto buffer_done; |
| 383 | |
| 384 | if (strlcat(buf, "\nNVME Target: Statistics\n", PAGE_SIZE) |
| 385 | >= PAGE_SIZE) |
| 386 | goto buffer_done; |
| 387 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 388 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 389 | scnprintf(tmp, sizeof(tmp), |
| 390 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 391 | atomic_read(&tgtp->rcv_ls_req_in), |
| 392 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 393 | atomic_read(&tgtp->xmt_ls_abort)); |
| 394 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 395 | goto buffer_done; |
| 396 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 397 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 398 | atomic_read(&tgtp->rcv_ls_req_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 399 | scnprintf(tmp, sizeof(tmp), |
| 400 | "Rcv LS: in %08x != out %08x\n", |
| 401 | atomic_read(&tgtp->rcv_ls_req_in), |
| 402 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 403 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 404 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 405 | } |
| 406 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 407 | scnprintf(tmp, sizeof(tmp), |
| 408 | "LS: Xmt %08x Drop %08x Cmpl %08x\n", |
| 409 | atomic_read(&tgtp->xmt_ls_rsp), |
| 410 | atomic_read(&tgtp->xmt_ls_drop), |
| 411 | atomic_read(&tgtp->xmt_ls_rsp_cmpl)); |
| 412 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 413 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 414 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 415 | scnprintf(tmp, sizeof(tmp), |
| 416 | "LS: RSP Abort %08x xb %08x Err %08x\n", |
| 417 | atomic_read(&tgtp->xmt_ls_rsp_aborted), |
| 418 | atomic_read(&tgtp->xmt_ls_rsp_xb_set), |
| 419 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 420 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 421 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 422 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 423 | scnprintf(tmp, sizeof(tmp), |
| 424 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 425 | "Drop %08x\n", |
| 426 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 427 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
| 428 | atomic_read(&tgtp->xmt_fcp_release), |
| 429 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 430 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 431 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 432 | |
| 433 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 434 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 435 | scnprintf(tmp, sizeof(tmp), |
| 436 | "Rcv FCP: in %08x != out %08x\n", |
| 437 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 438 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 439 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 440 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 441 | } |
| 442 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 443 | scnprintf(tmp, sizeof(tmp), |
| 444 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " |
| 445 | "drop %08x\n", |
| 446 | atomic_read(&tgtp->xmt_fcp_read), |
| 447 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 448 | atomic_read(&tgtp->xmt_fcp_write), |
| 449 | atomic_read(&tgtp->xmt_fcp_rsp), |
| 450 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 451 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 452 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 453 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 454 | scnprintf(tmp, sizeof(tmp), |
| 455 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 456 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 457 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 458 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 459 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 460 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 461 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 462 | scnprintf(tmp, sizeof(tmp), |
| 463 | "FCP Rsp Abort: %08x xb %08x xricqe %08x\n", |
| 464 | atomic_read(&tgtp->xmt_fcp_rsp_aborted), |
| 465 | atomic_read(&tgtp->xmt_fcp_rsp_xb_set), |
| 466 | atomic_read(&tgtp->xmt_fcp_xri_abort_cqe)); |
| 467 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 468 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 469 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 470 | scnprintf(tmp, sizeof(tmp), |
| 471 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 472 | atomic_read(&tgtp->xmt_fcp_abort), |
| 473 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 474 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 475 | goto buffer_done; |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 476 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 477 | scnprintf(tmp, sizeof(tmp), |
| 478 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n", |
| 479 | atomic_read(&tgtp->xmt_abort_sol), |
| 480 | atomic_read(&tgtp->xmt_abort_unsol), |
| 481 | atomic_read(&tgtp->xmt_abort_rsp), |
| 482 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
| 483 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 484 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 485 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 486 | scnprintf(tmp, sizeof(tmp), |
| 487 | "DELAY: ctx %08x fod %08x wqfull %08x\n", |
| 488 | atomic_read(&tgtp->defer_ctx), |
| 489 | atomic_read(&tgtp->defer_fod), |
| 490 | atomic_read(&tgtp->defer_wqfull)); |
| 491 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 492 | goto buffer_done; |
James Smart | 411de51 | 2018-01-30 15:58:52 -0800 | [diff] [blame] | 493 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 494 | /* Calculate outstanding IOs */ |
| 495 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 496 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 497 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 498 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 499 | scnprintf(tmp, sizeof(tmp), |
| 500 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 501 | "CTX Outstanding %08llx\n\n", |
| 502 | phba->sli4_hba.nvmet_xri_cnt, |
| 503 | phba->sli4_hba.nvmet_io_wait_cnt, |
| 504 | phba->sli4_hba.nvmet_io_wait_total, |
| 505 | tot); |
| 506 | strlcat(buf, tmp, PAGE_SIZE); |
| 507 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 508 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 509 | |
| 510 | localport = vport->localport; |
| 511 | if (!localport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 512 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 513 | "NVME Initiator x%llx is not allocated\n", |
| 514 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 515 | return len; |
| 516 | } |
Colin Ian King | 5c665ae | 2017-12-22 00:28:52 +0000 | [diff] [blame] | 517 | lport = (struct lpfc_nvme_lport *)localport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 518 | if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE) |
| 519 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 520 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 521 | scnprintf(tmp, sizeof(tmp), |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 522 | "XRI Dist lpfc%d Total %d IO %d ELS %d\n", |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 523 | phba->brd_no, |
| 524 | phba->sli4_hba.max_cfg_param.max_xri, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 525 | phba->sli4_hba.io_xri_max, |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 526 | lpfc_sli4_get_els_iocb_cnt(phba)); |
| 527 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 528 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 529 | |
| 530 | /* Port state is only one of two values for now. */ |
| 531 | if (localport->port_id) |
| 532 | statep = "ONLINE"; |
| 533 | else |
| 534 | statep = "UNKNOWN "; |
| 535 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 536 | scnprintf(tmp, sizeof(tmp), |
| 537 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 538 | "NVME LPORT lpfc", |
| 539 | phba->brd_no, |
| 540 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 541 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 542 | localport->port_id, statep); |
| 543 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 544 | goto buffer_done; |
| 545 | |
| 546 | spin_lock_irq(shost->host_lock); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 547 | |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 548 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 549 | nrport = NULL; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 550 | spin_lock(&ndlp->lock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 551 | rport = lpfc_ndlp_get_nrport(ndlp); |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 552 | if (rport) |
| 553 | nrport = rport->remoteport; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 554 | spin_unlock(&ndlp->lock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 555 | if (!nrport) |
| 556 | continue; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 557 | |
| 558 | /* Port state is only one of two values for now. */ |
| 559 | switch (nrport->port_state) { |
| 560 | case FC_OBJSTATE_ONLINE: |
| 561 | statep = "ONLINE"; |
| 562 | break; |
| 563 | case FC_OBJSTATE_UNKNOWN: |
| 564 | statep = "UNKNOWN "; |
| 565 | break; |
| 566 | default: |
| 567 | statep = "UNSUPPORTED"; |
| 568 | break; |
| 569 | } |
| 570 | |
| 571 | /* Tab in to show lport ownership. */ |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 572 | if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 573 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 574 | if (phba->brd_no >= 10) { |
| 575 | if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 576 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 577 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 578 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 579 | scnprintf(tmp, sizeof(tmp), "WWPN x%llx ", |
| 580 | nrport->port_name); |
| 581 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 582 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 583 | |
| 584 | scnprintf(tmp, sizeof(tmp), "WWNN x%llx ", |
| 585 | nrport->node_name); |
| 586 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 587 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 588 | |
| 589 | scnprintf(tmp, sizeof(tmp), "DID x%06x ", |
| 590 | nrport->port_id); |
| 591 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 592 | goto unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 593 | |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 594 | /* An NVME rport can have multiple roles. */ |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 595 | if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) { |
| 596 | if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 597 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 598 | } |
| 599 | if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) { |
| 600 | if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 601 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 602 | } |
| 603 | if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) { |
| 604 | if (strlcat(buf, "DISCSRVC ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 605 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 606 | } |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 607 | if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | |
| 608 | FC_PORT_ROLE_NVME_TARGET | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 609 | FC_PORT_ROLE_NVME_DISCOVERY)) { |
| 610 | scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x", |
| 611 | nrport->port_role); |
| 612 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 613 | goto unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 614 | } |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 615 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 616 | scnprintf(tmp, sizeof(tmp), "%s\n", statep); |
| 617 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 618 | goto unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 619 | } |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 620 | spin_unlock_irq(shost->host_lock); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 621 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 622 | if (!lport) |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 623 | goto buffer_done; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 624 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 625 | if (strlcat(buf, "\nNVME Statistics\n", PAGE_SIZE) >= PAGE_SIZE) |
| 626 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 627 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 628 | scnprintf(tmp, sizeof(tmp), |
| 629 | "LS: Xmt %010x Cmpl %010x Abort %08x\n", |
| 630 | atomic_read(&lport->fc4NvmeLsRequests), |
| 631 | atomic_read(&lport->fc4NvmeLsCmpls), |
| 632 | atomic_read(&lport->xmt_ls_abort)); |
| 633 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 634 | goto buffer_done; |
| 635 | |
| 636 | scnprintf(tmp, sizeof(tmp), |
| 637 | "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n", |
| 638 | atomic_read(&lport->xmt_ls_err), |
| 639 | atomic_read(&lport->cmpl_ls_xb), |
| 640 | atomic_read(&lport->cmpl_ls_err)); |
| 641 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 642 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 643 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 644 | totin = 0; |
| 645 | totout = 0; |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 646 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 647 | cstat = &phba->sli4_hba.hdwq[i].nvme_cstat; |
| 648 | tot = cstat->io_cmpls; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 649 | totin += tot; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 650 | data1 = cstat->input_requests; |
| 651 | data2 = cstat->output_requests; |
| 652 | data3 = cstat->control_requests; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 653 | totout += (data1 + data2 + data3); |
| 654 | } |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 655 | scnprintf(tmp, sizeof(tmp), |
| 656 | "Total FCP Cmpl %016llx Issue %016llx " |
| 657 | "OutIO %016llx\n", |
| 658 | totin, totout, totout - totin); |
| 659 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 660 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 661 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 662 | scnprintf(tmp, sizeof(tmp), |
| 663 | "\tabort %08x noxri %08x nondlp %08x qdepth %08x " |
| 664 | "wqerr %08x err %08x\n", |
| 665 | atomic_read(&lport->xmt_fcp_abort), |
| 666 | atomic_read(&lport->xmt_fcp_noxri), |
| 667 | atomic_read(&lport->xmt_fcp_bad_ndlp), |
| 668 | atomic_read(&lport->xmt_fcp_qdepth), |
James Smart | 3bfab8a | 2021-04-11 18:31:23 -0700 | [diff] [blame] | 669 | atomic_read(&lport->xmt_fcp_wqerr), |
| 670 | atomic_read(&lport->xmt_fcp_err)); |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 671 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 672 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 673 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 674 | scnprintf(tmp, sizeof(tmp), |
| 675 | "FCP CMPL: xb %08x Err %08x\n", |
| 676 | atomic_read(&lport->cmpl_fcp_xb), |
| 677 | atomic_read(&lport->cmpl_fcp_err)); |
| 678 | strlcat(buf, tmp, PAGE_SIZE); |
| 679 | |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 680 | /* host_lock is already unlocked. */ |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 681 | goto buffer_done; |
| 682 | |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 683 | unlock_buf_done: |
| 684 | spin_unlock_irq(shost->host_lock); |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 685 | |
| 686 | buffer_done: |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 687 | len = strnlen(buf, PAGE_SIZE); |
| 688 | |
| 689 | if (unlikely(len >= (PAGE_SIZE - 1))) { |
| 690 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME, |
| 691 | "6314 Catching potential buffer " |
| 692 | "overflow > PAGE_SIZE = %lu bytes\n", |
| 693 | PAGE_SIZE); |
James Smart | 74a7baa | 2021-08-16 09:28:58 -0700 | [diff] [blame] | 694 | strscpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_INFO_MORE_STR), |
| 695 | LPFC_INFO_MORE_STR, |
| 696 | sizeof(LPFC_INFO_MORE_STR) + 1); |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 697 | } |
| 698 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 699 | return len; |
| 700 | } |
| 701 | |
| 702 | static ssize_t |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 703 | lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr, |
| 704 | char *buf) |
| 705 | { |
| 706 | struct Scsi_Host *shost = class_to_shost(dev); |
| 707 | struct lpfc_vport *vport = shost_priv(shost); |
| 708 | struct lpfc_hba *phba = vport->phba; |
| 709 | int len; |
| 710 | struct lpfc_fc4_ctrl_stat *cstat; |
| 711 | u64 data1, data2, data3; |
| 712 | u64 tot, totin, totout; |
| 713 | int i; |
| 714 | char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0}; |
| 715 | |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 716 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) || |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 717 | (phba->sli_rev != LPFC_SLI_REV4)) |
| 718 | return 0; |
| 719 | |
| 720 | scnprintf(buf, PAGE_SIZE, "SCSI HDWQ Statistics\n"); |
| 721 | |
| 722 | totin = 0; |
| 723 | totout = 0; |
| 724 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
| 725 | cstat = &phba->sli4_hba.hdwq[i].scsi_cstat; |
| 726 | tot = cstat->io_cmpls; |
| 727 | totin += tot; |
| 728 | data1 = cstat->input_requests; |
| 729 | data2 = cstat->output_requests; |
| 730 | data3 = cstat->control_requests; |
| 731 | totout += (data1 + data2 + data3); |
| 732 | |
| 733 | scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx " |
| 734 | "IO %016llx ", i, data1, data2, data3); |
| 735 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 736 | goto buffer_done; |
| 737 | |
| 738 | scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n", |
| 739 | tot, ((data1 + data2 + data3) - tot)); |
| 740 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 741 | goto buffer_done; |
| 742 | } |
| 743 | scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx " |
| 744 | "OutIO %016llx\n", totin, totout, totout - totin); |
| 745 | strlcat(buf, tmp, PAGE_SIZE); |
| 746 | |
| 747 | buffer_done: |
| 748 | len = strnlen(buf, PAGE_SIZE); |
| 749 | |
| 750 | return len; |
| 751 | } |
| 752 | |
| 753 | static ssize_t |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 754 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 755 | char *buf) |
| 756 | { |
| 757 | struct Scsi_Host *shost = class_to_shost(dev); |
| 758 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 759 | struct lpfc_hba *phba = vport->phba; |
| 760 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 761 | if (phba->cfg_enable_bg) { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 762 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 763 | return scnprintf(buf, PAGE_SIZE, |
| 764 | "BlockGuard Enabled\n"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 765 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 766 | return scnprintf(buf, PAGE_SIZE, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 767 | "BlockGuard Not Supported\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 768 | } else |
| 769 | return scnprintf(buf, PAGE_SIZE, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 770 | "BlockGuard Disabled\n"); |
| 771 | } |
| 772 | |
| 773 | static ssize_t |
| 774 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 775 | char *buf) |
| 776 | { |
| 777 | struct Scsi_Host *shost = class_to_shost(dev); |
| 778 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 779 | struct lpfc_hba *phba = vport->phba; |
| 780 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 781 | return scnprintf(buf, PAGE_SIZE, "%llu\n", |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 782 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | static ssize_t |
| 786 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 787 | char *buf) |
| 788 | { |
| 789 | struct Scsi_Host *shost = class_to_shost(dev); |
| 790 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 791 | struct lpfc_hba *phba = vport->phba; |
| 792 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 793 | return scnprintf(buf, PAGE_SIZE, "%llu\n", |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 794 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | static ssize_t |
| 798 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 799 | char *buf) |
| 800 | { |
| 801 | struct Scsi_Host *shost = class_to_shost(dev); |
| 802 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 803 | struct lpfc_hba *phba = vport->phba; |
| 804 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 805 | return scnprintf(buf, PAGE_SIZE, "%llu\n", |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 806 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 807 | } |
| 808 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 809 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 810 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 811 | * @dev: class converted to a Scsi_host structure. |
| 812 | * @attr: device attribute, not used. |
| 813 | * @buf: on return contains the formatted text from lpfc_info(). |
| 814 | * |
| 815 | * Returns: size of formatted string. |
| 816 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 817 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 818 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 819 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 820 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 821 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 822 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 823 | return scnprintf(buf, PAGE_SIZE, "%s\n", lpfc_info(host)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 824 | } |
| 825 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 826 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 827 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 828 | * @dev: class converted to a Scsi_host structure. |
| 829 | * @attr: device attribute, not used. |
| 830 | * @buf: on return contains the formatted text serial number. |
| 831 | * |
| 832 | * Returns: size of formatted string. |
| 833 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 834 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 835 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 836 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 837 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 838 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 839 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 840 | struct lpfc_hba *phba = vport->phba; |
| 841 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 842 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->SerialNumber); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 843 | } |
| 844 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 845 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 846 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 847 | * @dev: class converted to a Scsi_host structure. |
| 848 | * @attr: device attribute, not used. |
| 849 | * @buf: on return contains the formatted support level. |
| 850 | * |
| 851 | * Description: |
| 852 | * Returns a number indicating the temperature sensor level currently |
| 853 | * supported, zero or one in ascii. |
| 854 | * |
| 855 | * Returns: size of formatted string. |
| 856 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 857 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 858 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 859 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 860 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 861 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 862 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 863 | struct lpfc_hba *phba = vport->phba; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 864 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->temp_sensor_support); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 865 | } |
| 866 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 867 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 868 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 869 | * @dev: class converted to a Scsi_host structure. |
| 870 | * @attr: device attribute, not used. |
| 871 | * @buf: on return contains the scsi vpd model description. |
| 872 | * |
| 873 | * Returns: size of formatted string. |
| 874 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 875 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 876 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 877 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 878 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 879 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 880 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 881 | struct lpfc_hba *phba = vport->phba; |
| 882 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 883 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelDesc); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 884 | } |
| 885 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 886 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 887 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 888 | * @dev: class converted to a Scsi_host structure. |
| 889 | * @attr: device attribute, not used. |
| 890 | * @buf: on return contains the scsi vpd model name. |
| 891 | * |
| 892 | * Returns: size of formatted string. |
| 893 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 894 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 895 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 896 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 897 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 898 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 899 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 900 | struct lpfc_hba *phba = vport->phba; |
| 901 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 902 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelName); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 903 | } |
| 904 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 905 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 906 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 907 | * @dev: class converted to a Scsi_host structure. |
| 908 | * @attr: device attribute, not used. |
| 909 | * @buf: on return contains the scsi vpd program type. |
| 910 | * |
| 911 | * Returns: size of formatted string. |
| 912 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 913 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 914 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 915 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 916 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 917 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 918 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 919 | struct lpfc_hba *phba = vport->phba; |
| 920 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 921 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ProgramType); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 922 | } |
| 923 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 924 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 925 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 926 | * @dev: class converted to a Scsi_host structure. |
| 927 | * @attr: device attribute, not used. |
| 928 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 929 | * |
| 930 | * Returns: size of formatted string. |
| 931 | **/ |
| 932 | static ssize_t |
| 933 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 934 | { |
| 935 | struct Scsi_Host *shost = class_to_shost(dev); |
| 936 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 937 | struct lpfc_hba *phba = vport->phba; |
| 938 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 939 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 940 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 941 | } |
| 942 | |
| 943 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 944 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 945 | * @dev: class converted to a Scsi_host structure. |
| 946 | * @attr: device attribute, not used. |
| 947 | * @buf: on return contains scsi vpd program type. |
| 948 | * |
| 949 | * Returns: size of formatted string. |
| 950 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 951 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 952 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 953 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 954 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 955 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 956 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 957 | struct lpfc_hba *phba = vport->phba; |
| 958 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 959 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->Port); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 960 | } |
| 961 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 962 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 963 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 964 | * @dev: class converted to a Scsi_host structure. |
| 965 | * @attr: device attribute, not used. |
| 966 | * @buf: on return contains the scsi vpd program type. |
| 967 | * |
| 968 | * Returns: size of formatted string. |
| 969 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 970 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 971 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 972 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 973 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 974 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 975 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 976 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 977 | uint32_t if_type; |
| 978 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 979 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 980 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 981 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 982 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 983 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 984 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 985 | |
| 986 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 987 | len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 988 | fwrev, phba->sli_rev); |
| 989 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 990 | len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 991 | fwrev, phba->sli_rev, if_type, sli_family); |
| 992 | |
| 993 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 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_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 998 | * @dev: class converted to a Scsi_host structure. |
| 999 | * @attr: device attribute, not used. |
| 1000 | * @buf: on return contains the scsi vpd program type. |
| 1001 | * |
| 1002 | * Returns: size of formatted string. |
| 1003 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1004 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1005 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1006 | { |
| 1007 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1008 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1009 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1010 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1011 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1012 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1013 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
James Smart | ec76242 | 2019-08-14 16:57:07 -0700 | [diff] [blame] | 1014 | return scnprintf(buf, PAGE_SIZE, "%s %08x %08x\n", hdw, |
| 1015 | vp->rev.smRev, vp->rev.smFwRev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1016 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1017 | |
| 1018 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1019 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1020 | * @dev: class converted to a Scsi_host structure. |
| 1021 | * @attr: device attribute, not used. |
| 1022 | * @buf: on return contains the ROM and FCode ascii strings. |
| 1023 | * |
| 1024 | * Returns: size of formatted string. |
| 1025 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1026 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1027 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 1028 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1029 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1030 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1031 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1032 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 1033 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1034 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 1035 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1036 | return scnprintf(buf, PAGE_SIZE, "%s\n", |
| 1037 | phba->OptionROMVersion); |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 1038 | |
| 1039 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1040 | return scnprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1041 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1042 | |
| 1043 | /** |
Lee Jones | a3dbf51 | 2021-03-12 09:47:12 +0000 | [diff] [blame] | 1044 | * lpfc_link_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1045 | * @dev: class converted to a Scsi_host structure. |
| 1046 | * @attr: device attribute, not used. |
| 1047 | * @buf: on return contains text describing the state of the link. |
| 1048 | * |
| 1049 | * Notes: |
| 1050 | * The switch statement has no default so zero will be returned. |
| 1051 | * |
| 1052 | * Returns: size of formatted string. |
| 1053 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1054 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 1055 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 1056 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1057 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1058 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1059 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1060 | struct lpfc_hba *phba = vport->phba; |
| 1061 | int len = 0; |
| 1062 | |
| 1063 | switch (phba->link_state) { |
| 1064 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1065 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1066 | case LPFC_INIT_START: |
| 1067 | case LPFC_INIT_MBX_CMDS: |
| 1068 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1069 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 1070 | if (phba->hba_flag & LINK_DISABLED) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1071 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 1072 | "Link Down - User disabled\n"); |
| 1073 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1074 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 1075 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1076 | break; |
| 1077 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1078 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1079 | case LPFC_HBA_READY: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1080 | len += scnprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1081 | |
| 1082 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1083 | case LPFC_LOCAL_CFG_LINK: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1084 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1085 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1086 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1087 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1088 | case LPFC_FLOGI: |
| 1089 | case LPFC_FABRIC_CFG_LINK: |
| 1090 | case LPFC_NS_REG: |
| 1091 | case LPFC_NS_QRY: |
| 1092 | case LPFC_BUILD_DISC_LIST: |
| 1093 | case LPFC_DISC_AUTH: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1094 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1095 | "Discovery\n"); |
| 1096 | break; |
| 1097 | case LPFC_VPORT_READY: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1098 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 1099 | "Ready\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1100 | break; |
| 1101 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1102 | case LPFC_VPORT_FAILED: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1103 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 1104 | "Failed\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1105 | break; |
| 1106 | |
| 1107 | case LPFC_VPORT_UNKNOWN: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1108 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1109 | "Unknown\n"); |
| 1110 | break; |
| 1111 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 1112 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1113 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 1114 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1115 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1116 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1117 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1118 | " Public Loop\n"); |
| 1119 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1120 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1121 | " Private Loop\n"); |
| 1122 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1123 | if (vport->fc_flag & FC_FABRIC) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1124 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1125 | " Fabric\n"); |
| 1126 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1127 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1128 | " Point-2-Point\n"); |
| 1129 | } |
| 1130 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1131 | |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1132 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 1133 | ((bf_get(lpfc_sli_intf_if_type, |
| 1134 | &phba->sli4_hba.sli_intf) == |
| 1135 | LPFC_SLI_INTF_IF_TYPE_6))) { |
| 1136 | struct lpfc_trunk_link link = phba->trunk_link; |
| 1137 | |
| 1138 | if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1139 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1140 | "Trunk port 0: Link %s %s\n", |
| 1141 | (link.link0.state == LPFC_LINK_UP) ? |
| 1142 | "Up" : "Down. ", |
| 1143 | trunk_errmsg[link.link0.fault]); |
| 1144 | |
| 1145 | if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1146 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1147 | "Trunk port 1: Link %s %s\n", |
| 1148 | (link.link1.state == LPFC_LINK_UP) ? |
| 1149 | "Up" : "Down. ", |
| 1150 | trunk_errmsg[link.link1.fault]); |
| 1151 | |
| 1152 | if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1153 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1154 | "Trunk port 2: Link %s %s\n", |
| 1155 | (link.link2.state == LPFC_LINK_UP) ? |
| 1156 | "Up" : "Down. ", |
| 1157 | trunk_errmsg[link.link2.fault]); |
| 1158 | |
| 1159 | if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1160 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1161 | "Trunk port 3: Link %s %s\n", |
| 1162 | (link.link3.state == LPFC_LINK_UP) ? |
| 1163 | "Up" : "Down. ", |
| 1164 | trunk_errmsg[link.link3.fault]); |
| 1165 | |
| 1166 | } |
| 1167 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1168 | return len; |
| 1169 | } |
| 1170 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1171 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1172 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 1173 | * @dev: class unused variable. |
| 1174 | * @attr: device attribute, not used. |
| 1175 | * @buf: on return contains the module description text. |
| 1176 | * |
| 1177 | * Returns: size of formatted string. |
| 1178 | **/ |
| 1179 | static ssize_t |
| 1180 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 1181 | char *buf) |
| 1182 | { |
| 1183 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1184 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1185 | struct lpfc_hba *phba = vport->phba; |
| 1186 | |
| 1187 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1188 | return scnprintf(buf, PAGE_SIZE, "fc\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1189 | |
| 1190 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 1191 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1192 | return scnprintf(buf, PAGE_SIZE, "fcoe\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1193 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1194 | return scnprintf(buf, PAGE_SIZE, "fc\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1195 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1196 | return scnprintf(buf, PAGE_SIZE, "unknown\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1200 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 1201 | * (OAS) is supported. |
| 1202 | * @dev: class unused variable. |
| 1203 | * @attr: device attribute, not used. |
| 1204 | * @buf: on return contains the module description text. |
| 1205 | * |
| 1206 | * Returns: size of formatted string. |
| 1207 | **/ |
| 1208 | static ssize_t |
| 1209 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 1210 | char *buf) |
| 1211 | { |
| 1212 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1213 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 1214 | struct lpfc_hba *phba = vport->phba; |
| 1215 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1216 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1217 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 1218 | } |
| 1219 | |
| 1220 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1221 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 1222 | * @dev: class device that is converted into a Scsi_host. |
| 1223 | * @attr: device attribute, not used. |
| 1224 | * @buf: one or more lpfc_polling_flags values. |
| 1225 | * @count: not used. |
| 1226 | * |
| 1227 | * Returns: |
| 1228 | * -EINVAL if the buffer is not "up" or "down" |
| 1229 | * return from link state change function if non-zero |
| 1230 | * length of the buf on success |
| 1231 | **/ |
| 1232 | static ssize_t |
| 1233 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 1234 | const char *buf, size_t count) |
| 1235 | { |
| 1236 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1237 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1238 | struct lpfc_hba *phba = vport->phba; |
| 1239 | |
| 1240 | int status = -EINVAL; |
| 1241 | |
| 1242 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 1243 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1244 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1245 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 1246 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1247 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1248 | |
| 1249 | if (status == 0) |
| 1250 | return strlen(buf); |
| 1251 | else |
| 1252 | return status; |
| 1253 | } |
| 1254 | |
| 1255 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1256 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1257 | * @dev: class device that is converted into a Scsi_host. |
| 1258 | * @attr: device attribute, not used. |
| 1259 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 1260 | * |
| 1261 | * Description: |
| 1262 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 1263 | * vport counts. |
| 1264 | * |
| 1265 | * Returns: size of formatted string. |
| 1266 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1267 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1268 | lpfc_num_discovered_ports_show(struct device *dev, |
| 1269 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1270 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1271 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1272 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1273 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1274 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1275 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1276 | } |
| 1277 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1278 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1279 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1280 | * @shost: Scsi_Host pointer. |
| 1281 | * |
| 1282 | * Description: |
| 1283 | * Bring the link down gracefully then re-init the link. The firmware will |
| 1284 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 1285 | * |
| 1286 | * Returns: |
| 1287 | * -EPERM port offline or management commands are being blocked |
| 1288 | * -ENOMEM cannot allocate memory for the mailbox command |
| 1289 | * -EIO error sending the mailbox command |
| 1290 | * zero for success |
| 1291 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1292 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1293 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1294 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1295 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1296 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1297 | LPFC_MBOXQ_t *pmboxq; |
| 1298 | int mbxstatus = MBXERR_ERROR; |
| 1299 | |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1300 | /* |
| 1301 | * If the link is offline, disabled or BLOCK_MGMT_IO |
| 1302 | * it doesn't make any sense to allow issue_lip |
| 1303 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1304 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1305 | (phba->hba_flag & LINK_DISABLED) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 1306 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1307 | return -EPERM; |
| 1308 | |
| 1309 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 1310 | |
| 1311 | if (!pmboxq) |
| 1312 | return -ENOMEM; |
| 1313 | |
| 1314 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1315 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 1316 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1317 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 1318 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1319 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1320 | if ((mbxstatus == MBX_SUCCESS) && |
| 1321 | (pmboxq->u.mb.mbxStatus == 0 || |
| 1322 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1323 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1324 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 1325 | phba->cfg_link_speed); |
| 1326 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 1327 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 1328 | if ((mbxstatus == MBX_SUCCESS) && |
| 1329 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 1330 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 1331 | "2859 SLI authentication is required " |
| 1332 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1333 | } |
| 1334 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 1335 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1336 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1337 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1338 | |
| 1339 | if (mbxstatus == MBXERR_ERROR) |
| 1340 | return -EIO; |
| 1341 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1342 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1343 | } |
| 1344 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1345 | int |
| 1346 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 1347 | { |
| 1348 | int cnt = 0; |
| 1349 | |
| 1350 | spin_lock_irq(lock); |
| 1351 | while (!list_empty(q)) { |
| 1352 | spin_unlock_irq(lock); |
| 1353 | msleep(20); |
| 1354 | if (cnt++ > 250) { /* 5 secs */ |
| 1355 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
James Smart | 3bfab8a | 2021-04-11 18:31:23 -0700 | [diff] [blame] | 1356 | "0466 Outstanding IO when " |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1357 | "bringing Adapter offline\n"); |
| 1358 | return 0; |
| 1359 | } |
| 1360 | spin_lock_irq(lock); |
| 1361 | } |
| 1362 | spin_unlock_irq(lock); |
| 1363 | return 1; |
| 1364 | } |
| 1365 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1366 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1367 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1368 | * @phba: lpfc_hba pointer. |
| 1369 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 1370 | * |
| 1371 | * Notes: |
| 1372 | * Assumes any error from lpfc_do_offline() will be negative. |
| 1373 | * Can wait up to 5 seconds for the port ring buffers count |
| 1374 | * 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] | 1375 | * 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] | 1376 | * |
| 1377 | * Returns: |
| 1378 | * -EIO error posting the event |
| 1379 | * zero for success |
| 1380 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1381 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1382 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 1383 | { |
| 1384 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1385 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1386 | struct lpfc_sli_ring *pring; |
| 1387 | struct lpfc_sli *psli; |
| 1388 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1389 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1390 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1391 | |
| 1392 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1393 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1394 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1395 | if (rc == 0) |
| 1396 | return -ENOMEM; |
| 1397 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1398 | wait_for_completion(&online_compl); |
| 1399 | |
| 1400 | if (status != 0) |
| 1401 | return -EIO; |
| 1402 | |
| 1403 | psli = &phba->sli; |
| 1404 | |
James Smart | 4645f7b | 2019-03-12 16:30:14 -0700 | [diff] [blame] | 1405 | /* |
| 1406 | * If freeing the queues have already started, don't access them. |
| 1407 | * Otherwise set FREE_WAIT to indicate that queues are being used |
| 1408 | * to hold the freeing process until we finish. |
| 1409 | */ |
| 1410 | spin_lock_irq(&phba->hbalock); |
| 1411 | if (!(psli->sli_flag & LPFC_QUEUE_FREE_INIT)) { |
| 1412 | psli->sli_flag |= LPFC_QUEUE_FREE_WAIT; |
| 1413 | } else { |
| 1414 | spin_unlock_irq(&phba->hbalock); |
| 1415 | goto skip_wait; |
| 1416 | } |
| 1417 | spin_unlock_irq(&phba->hbalock); |
| 1418 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1419 | /* Wait a little for things to settle down, but not |
| 1420 | * long enough for dev loss timeout to expire. |
| 1421 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1422 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 1423 | for (i = 0; i < psli->num_rings; i++) { |
| 1424 | pring = &psli->sli3_ring[i]; |
| 1425 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1426 | &phba->hbalock)) |
| 1427 | goto out; |
| 1428 | } |
| 1429 | } else { |
| 1430 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 1431 | pring = qp->pring; |
| 1432 | if (!pring) |
| 1433 | continue; |
| 1434 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1435 | &pring->ring_lock)) |
| 1436 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1437 | } |
| 1438 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1439 | out: |
James Smart | 4645f7b | 2019-03-12 16:30:14 -0700 | [diff] [blame] | 1440 | spin_lock_irq(&phba->hbalock); |
| 1441 | psli->sli_flag &= ~LPFC_QUEUE_FREE_WAIT; |
| 1442 | spin_unlock_irq(&phba->hbalock); |
| 1443 | |
| 1444 | skip_wait: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1445 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1446 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 1447 | if (rc == 0) |
| 1448 | return -ENOMEM; |
| 1449 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1450 | wait_for_completion(&online_compl); |
| 1451 | |
| 1452 | if (status != 0) |
| 1453 | return -EIO; |
| 1454 | |
| 1455 | return 0; |
| 1456 | } |
| 1457 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1458 | /** |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1459 | * lpfc_reset_pci_bus - resets PCI bridge controller's secondary bus of an HBA |
| 1460 | * @phba: lpfc_hba pointer. |
| 1461 | * |
| 1462 | * Description: |
| 1463 | * Issues a PCI secondary bus reset for the phba->pcidev. |
| 1464 | * |
| 1465 | * Notes: |
| 1466 | * First walks the bus_list to ensure only PCI devices with Emulex |
| 1467 | * vendor id, device ids that support hot reset, only one occurrence |
| 1468 | * of function 0, and all ports on the bus are in offline mode to ensure the |
| 1469 | * hot reset only affects one valid HBA. |
| 1470 | * |
| 1471 | * Returns: |
| 1472 | * -ENOTSUPP, cfg_enable_hba_reset must be of value 2 |
| 1473 | * -ENODEV, NULL ptr to pcidev |
| 1474 | * -EBADSLT, detected invalid device |
| 1475 | * -EBUSY, port is not in offline state |
| 1476 | * 0, successful |
| 1477 | */ |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 1478 | static int |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1479 | lpfc_reset_pci_bus(struct lpfc_hba *phba) |
| 1480 | { |
| 1481 | struct pci_dev *pdev = phba->pcidev; |
| 1482 | struct Scsi_Host *shost = NULL; |
| 1483 | struct lpfc_hba *phba_other = NULL; |
| 1484 | struct pci_dev *ptr = NULL; |
| 1485 | int res; |
| 1486 | |
| 1487 | if (phba->cfg_enable_hba_reset != 2) |
| 1488 | return -ENOTSUPP; |
| 1489 | |
| 1490 | if (!pdev) { |
| 1491 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "8345 pdev NULL!\n"); |
| 1492 | return -ENODEV; |
| 1493 | } |
| 1494 | |
| 1495 | res = lpfc_check_pci_resettable(phba); |
| 1496 | if (res) |
| 1497 | return res; |
| 1498 | |
| 1499 | /* Walk the list of devices on the pci_dev's bus */ |
| 1500 | list_for_each_entry(ptr, &pdev->bus->devices, bus_list) { |
| 1501 | /* Check port is offline */ |
| 1502 | shost = pci_get_drvdata(ptr); |
| 1503 | if (shost) { |
| 1504 | phba_other = |
| 1505 | ((struct lpfc_vport *)shost->hostdata)->phba; |
| 1506 | if (!(phba_other->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1507 | lpfc_printf_log(phba_other, KERN_INFO, LOG_INIT, |
| 1508 | "8349 WWPN = 0x%02x%02x%02x%02x" |
| 1509 | "%02x%02x%02x%02x is not " |
| 1510 | "offline!\n", |
| 1511 | phba_other->wwpn[0], |
| 1512 | phba_other->wwpn[1], |
| 1513 | phba_other->wwpn[2], |
| 1514 | phba_other->wwpn[3], |
| 1515 | phba_other->wwpn[4], |
| 1516 | phba_other->wwpn[5], |
| 1517 | phba_other->wwpn[6], |
| 1518 | phba_other->wwpn[7]); |
| 1519 | return -EBUSY; |
| 1520 | } |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | /* Issue PCI bus reset */ |
| 1525 | res = pci_reset_bus(pdev); |
| 1526 | if (res) { |
| 1527 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1528 | "8350 PCI reset bus failed: %d\n", res); |
| 1529 | } |
| 1530 | |
| 1531 | return res; |
| 1532 | } |
| 1533 | |
| 1534 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1535 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1536 | * @phba: lpfc_hba pointer. |
| 1537 | * |
| 1538 | * Description: |
| 1539 | * If the port is configured to allow a reset then the hba is brought |
| 1540 | * offline then online. |
| 1541 | * |
| 1542 | * Notes: |
| 1543 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1544 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1545 | * |
| 1546 | * Returns: |
| 1547 | * lpfc_do_offline() return code if not zero |
| 1548 | * -EIO reset not configured or error posting the event |
| 1549 | * zero for success |
| 1550 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1551 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1552 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1553 | { |
| 1554 | struct completion online_compl; |
| 1555 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1556 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1557 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1558 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1559 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1560 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1561 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1562 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1563 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1564 | if (status != 0) |
| 1565 | return status; |
| 1566 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1567 | |
| 1568 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1569 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1570 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1571 | if (rc == 0) |
| 1572 | return -ENOMEM; |
| 1573 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1574 | wait_for_completion(&online_compl); |
| 1575 | |
| 1576 | if (status != 0) |
| 1577 | return -EIO; |
| 1578 | |
| 1579 | return 0; |
| 1580 | } |
| 1581 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1582 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1583 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1584 | * @dev: class device that is converted into a Scsi_host. |
| 1585 | * @attr: device attribute, not used. |
| 1586 | * @buf: containing the string "selective". |
| 1587 | * @count: unused variable. |
| 1588 | * |
| 1589 | * Description: |
| 1590 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1591 | * is called to perform the reset. |
| 1592 | * |
| 1593 | * Notes: |
| 1594 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1595 | * If lpfc_selective_reset() returns zero then the length of the buffer |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 1596 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1597 | * |
| 1598 | * Returns: |
| 1599 | * -EINVAL if the buffer does not contain the string "selective" |
| 1600 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1601 | * return value of lpfc_selective_reset() if the call fails |
| 1602 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1603 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1604 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1605 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1606 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1607 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1608 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1609 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1610 | int status = -EINVAL; |
| 1611 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1612 | if (!phba->cfg_enable_hba_reset) |
| 1613 | return -EACCES; |
| 1614 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1615 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1616 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1617 | |
| 1618 | if (status == 0) |
| 1619 | return strlen(buf); |
| 1620 | else |
| 1621 | return status; |
| 1622 | } |
| 1623 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1624 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1625 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1626 | * @phba: lpfc_hba pointer. |
| 1627 | * |
| 1628 | * Description: |
| 1629 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1630 | * the readyness after performing a firmware reset. |
| 1631 | * |
| 1632 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1633 | * zero for success, -EPERM when port does not have privilege to perform the |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1634 | * reset, -EIO when port timeout from recovering from the reset. |
| 1635 | * |
| 1636 | * Note: |
| 1637 | * As the caller will interpret the return code by value, be careful in making |
| 1638 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1639 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1640 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1641 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1642 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1643 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1644 | int i; |
| 1645 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1646 | msleep(100); |
James Smart | b7b95fb | 2019-09-21 20:58:49 -0700 | [diff] [blame] | 1647 | if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1648 | &portstat_reg.word0)) |
| 1649 | return -EIO; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1650 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1651 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1652 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1653 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1654 | return -EPERM; |
| 1655 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1656 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1657 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1658 | msleep(10); |
James Smart | b7b95fb | 2019-09-21 20:58:49 -0700 | [diff] [blame] | 1659 | if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1660 | &portstat_reg.word0)) |
| 1661 | continue; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1662 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1663 | continue; |
| 1664 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1665 | continue; |
| 1666 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1667 | continue; |
| 1668 | break; |
| 1669 | } |
| 1670 | |
| 1671 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1672 | return 0; |
| 1673 | else |
| 1674 | return -EIO; |
| 1675 | } |
| 1676 | |
| 1677 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1678 | * lpfc_sli4_pdev_reg_request - Request physical dev to perform a register acc |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1679 | * @phba: lpfc_hba pointer. |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 1680 | * @opcode: The sli4 config command opcode. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1681 | * |
| 1682 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1683 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1684 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1685 | * |
| 1686 | * Returns: |
| 1687 | * zero for success |
| 1688 | **/ |
| 1689 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1690 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1691 | { |
| 1692 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1693 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1694 | uint32_t before_fc_flag; |
| 1695 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1696 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1697 | int status = 0, rc = 0; |
| 1698 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1699 | |
| 1700 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1701 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1702 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1703 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame] | 1704 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1705 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1706 | return -EPERM; |
| 1707 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1708 | /* Keep state if we need to restore back */ |
| 1709 | before_fc_flag = phba->pport->fc_flag; |
| 1710 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1711 | |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1712 | if (opcode == LPFC_FW_DUMP) { |
| 1713 | init_completion(&online_compl); |
| 1714 | phba->fw_dump_cmpl = &online_compl; |
| 1715 | } else { |
| 1716 | /* Disable SR-IOV virtual functions if enabled */ |
| 1717 | if (phba->cfg_sriov_nr_virtfn) { |
| 1718 | pci_disable_sriov(pdev); |
| 1719 | phba->cfg_sriov_nr_virtfn = 0; |
| 1720 | } |
| 1721 | |
| 1722 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1723 | |
| 1724 | if (status != 0) |
| 1725 | return status; |
| 1726 | |
| 1727 | /* wait for the device to be quiesced before firmware reset */ |
| 1728 | msleep(100); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1729 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1730 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1731 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1732 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1733 | |
| 1734 | if (opcode == LPFC_FW_DUMP) |
| 1735 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1736 | else if (opcode == LPFC_FW_RESET) |
| 1737 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1738 | else if (opcode == LPFC_DV_RESET) |
| 1739 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1740 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1741 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1742 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1743 | /* flush */ |
| 1744 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1745 | |
| 1746 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1747 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1748 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1749 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1750 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1751 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1752 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1753 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1754 | } else if (rc == -EIO) { |
| 1755 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1756 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1757 | "3153 Fail to perform the requested " |
| 1758 | "access: x%x\n", reg_val); |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1759 | if (phba->fw_dump_cmpl) |
| 1760 | phba->fw_dump_cmpl = NULL; |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1761 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1762 | } |
| 1763 | |
| 1764 | /* keep the original port state */ |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1765 | if (before_fc_flag & FC_OFFLINE_MODE) { |
| 1766 | if (phba->fw_dump_cmpl) |
| 1767 | phba->fw_dump_cmpl = NULL; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1768 | goto out; |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1769 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1770 | |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1771 | /* Firmware dump will trigger an HA_ERATT event, and |
| 1772 | * lpfc_handle_eratt_s4 routine already handles bringing the port back |
| 1773 | * online. |
| 1774 | */ |
| 1775 | if (opcode == LPFC_FW_DUMP) { |
| 1776 | wait_for_completion(phba->fw_dump_cmpl); |
| 1777 | } else { |
| 1778 | init_completion(&online_compl); |
| 1779 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1780 | LPFC_EVT_ONLINE); |
| 1781 | if (!job_posted) |
| 1782 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1783 | |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1784 | wait_for_completion(&online_compl); |
| 1785 | } |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1786 | out: |
| 1787 | /* in any case, restore the virtual functions enabled as before */ |
| 1788 | if (sriov_nr_virtfn) { |
James Smart | 7dd2e2a | 2021-12-03 16:26:40 -0800 | [diff] [blame] | 1789 | /* If fw_dump was performed, first disable to clean up */ |
| 1790 | if (opcode == LPFC_FW_DUMP) { |
| 1791 | pci_disable_sriov(pdev); |
| 1792 | phba->cfg_sriov_nr_virtfn = 0; |
| 1793 | } |
| 1794 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1795 | sriov_err = |
| 1796 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1797 | if (!sriov_err) |
| 1798 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1799 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1800 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1801 | /* return proper error code */ |
| 1802 | if (!rc) { |
| 1803 | if (!job_posted) |
| 1804 | rc = -ENOMEM; |
| 1805 | else if (status) |
| 1806 | rc = -EIO; |
| 1807 | } |
| 1808 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1809 | } |
| 1810 | |
| 1811 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1812 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1813 | * @dev: class device that is converted into a Scsi_host. |
| 1814 | * @attr: device attribute, not used. |
| 1815 | * @buf: on return contains the ascii number of nport events. |
| 1816 | * |
| 1817 | * Returns: size of formatted string. |
| 1818 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1819 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1820 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1821 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1822 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1823 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1824 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1825 | struct lpfc_hba *phba = vport->phba; |
| 1826 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1827 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1828 | } |
| 1829 | |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 1830 | static int |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1831 | lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out) |
| 1832 | { |
| 1833 | LPFC_MBOXQ_t *mbox = NULL; |
| 1834 | unsigned long val = 0; |
Saurav Girepunje | 2c7fb46 | 2019-10-24 08:27:29 +0530 | [diff] [blame] | 1835 | char *pval = NULL; |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1836 | int rc = 0; |
| 1837 | |
| 1838 | if (!strncmp("enable", buff_out, |
| 1839 | strlen("enable"))) { |
| 1840 | pval = buff_out + strlen("enable") + 1; |
| 1841 | rc = kstrtoul(pval, 0, &val); |
| 1842 | if (rc) |
| 1843 | return rc; /* Invalid number */ |
| 1844 | } else if (!strncmp("disable", buff_out, |
| 1845 | strlen("disable"))) { |
| 1846 | val = 0; |
| 1847 | } else { |
| 1848 | return -EINVAL; /* Invalid command */ |
| 1849 | } |
| 1850 | |
| 1851 | switch (val) { |
| 1852 | case 0: |
| 1853 | val = 0x0; /* Disable */ |
| 1854 | break; |
| 1855 | case 2: |
| 1856 | val = 0x1; /* Enable two port trunk */ |
| 1857 | break; |
| 1858 | case 4: |
| 1859 | val = 0x2; /* Enable four port trunk */ |
| 1860 | break; |
| 1861 | default: |
| 1862 | return -EINVAL; |
| 1863 | } |
| 1864 | |
| 1865 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1866 | "0070 Set trunk mode with val %ld ", val); |
| 1867 | |
| 1868 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1869 | if (!mbox) |
| 1870 | return -ENOMEM; |
| 1871 | |
| 1872 | lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE, |
| 1873 | LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE, |
| 1874 | 12, LPFC_SLI4_MBX_EMBED); |
| 1875 | |
| 1876 | bf_set(lpfc_mbx_set_trunk_mode, |
| 1877 | &mbox->u.mqe.un.set_trunk_mode, |
| 1878 | val); |
| 1879 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); |
| 1880 | if (rc) |
| 1881 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1882 | "0071 Set trunk mode failed with status: %d", |
| 1883 | rc); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 1884 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1885 | |
| 1886 | return 0; |
| 1887 | } |
| 1888 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1889 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1890 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1891 | * @dev: class device that is converted into a Scsi_host. |
| 1892 | * @attr: device attribute, not used. |
| 1893 | * @buf: on return contains the state of the adapter. |
| 1894 | * |
| 1895 | * Returns: size of formatted string. |
| 1896 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1897 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1898 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1899 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1900 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1901 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1902 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1903 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1904 | char * state; |
| 1905 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1906 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1907 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1908 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1909 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1910 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1911 | state = "offline"; |
| 1912 | else |
| 1913 | state = "online"; |
| 1914 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1915 | return scnprintf(buf, PAGE_SIZE, "%s\n", state); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1916 | } |
| 1917 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1918 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1919 | * 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] | 1920 | * @dev: class device that is converted into a Scsi_host. |
| 1921 | * @attr: device attribute, not used. |
| 1922 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1923 | * @count: unused variable. |
| 1924 | * |
| 1925 | * Returns: |
| 1926 | * -EACCES if enable hba reset not enabled |
| 1927 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1928 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1929 | * buf length greater than zero indicates success |
| 1930 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1931 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1932 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1933 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1934 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1935 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1936 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1937 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1938 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1939 | char *board_mode_str = NULL; |
| 1940 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1941 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1942 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1943 | if (!phba->cfg_enable_hba_reset) { |
| 1944 | status = -EACCES; |
| 1945 | goto board_mode_out; |
| 1946 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1947 | |
| 1948 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1949 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1950 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1951 | init_completion(&online_compl); |
| 1952 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1953 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1954 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1955 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1956 | if (rc == 0) { |
| 1957 | status = -ENOMEM; |
| 1958 | goto board_mode_out; |
| 1959 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1960 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1961 | if (status) |
| 1962 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1963 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1964 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1965 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1966 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1967 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1968 | else |
| 1969 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1970 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1971 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1972 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1973 | else |
| 1974 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1975 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1976 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1977 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1978 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1979 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1980 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1981 | else if (strncmp(buf, "pci_bus_reset", sizeof("pci_bus_reset") - 1) |
| 1982 | == 0) |
| 1983 | status = lpfc_reset_pci_bus(phba); |
James Smart | a22d73b | 2021-01-04 10:02:38 -0800 | [diff] [blame] | 1984 | else if (strncmp(buf, "heartbeat", sizeof("heartbeat") - 1) == 0) |
| 1985 | lpfc_issue_hb_tmo(phba); |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1986 | else if (strncmp(buf, "trunk", sizeof("trunk") - 1) == 0) |
| 1987 | status = lpfc_set_trunking(phba, (char *)buf + sizeof("trunk")); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1988 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1989 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1990 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1991 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1992 | if (!status) |
| 1993 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1994 | else { |
| 1995 | board_mode_str = strchr(buf, '\n'); |
| 1996 | if (board_mode_str) |
| 1997 | *board_mode_str = '\0'; |
| 1998 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1999 | "3097 Failed \"%s\", status(%d), " |
| 2000 | "fc_flag(x%x)\n", |
| 2001 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 2002 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2003 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 2004 | } |
| 2005 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2006 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2007 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2008 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2009 | * @mxri: max xri count. |
| 2010 | * @axri: available xri count. |
| 2011 | * @mrpi: max rpi count. |
| 2012 | * @arpi: available rpi count. |
| 2013 | * @mvpi: max vpi count. |
| 2014 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2015 | * |
| 2016 | * Description: |
| 2017 | * If an integer pointer for an count is not null then the value for the |
| 2018 | * count is returned. |
| 2019 | * |
| 2020 | * Returns: |
| 2021 | * zero on error |
| 2022 | * one for success |
| 2023 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 2024 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2025 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 2026 | uint32_t *mxri, uint32_t *axri, |
| 2027 | uint32_t *mrpi, uint32_t *arpi, |
| 2028 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2029 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 2030 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2031 | LPFC_MBOXQ_t *pmboxq; |
| 2032 | MAILBOX_t *pmb; |
| 2033 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2034 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2035 | |
| 2036 | /* |
| 2037 | * prevent udev from issuing mailbox commands until the port is |
| 2038 | * configured. |
| 2039 | */ |
| 2040 | if (phba->link_state < LPFC_LINK_DOWN || |
| 2041 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2042 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2043 | return 0; |
| 2044 | |
| 2045 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 2046 | return 0; |
| 2047 | |
| 2048 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 2049 | if (!pmboxq) |
| 2050 | return 0; |
| 2051 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 2052 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 2053 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2054 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 2055 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 2056 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2057 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 2058 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2059 | rc = MBX_NOT_FINISHED; |
| 2060 | else |
| 2061 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 2062 | |
| 2063 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2064 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2065 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 2066 | return 0; |
| 2067 | } |
| 2068 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 2069 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 2070 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 2071 | if (mrpi) |
| 2072 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 2073 | if (arpi) |
| 2074 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 2075 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 2076 | if (mxri) |
| 2077 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 2078 | if (axri) |
| 2079 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 2080 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2081 | |
| 2082 | /* Account for differences with SLI-3. Get vpi count from |
| 2083 | * mailbox data and subtract one for max vpi value. |
| 2084 | */ |
| 2085 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 2086 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 2087 | |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 2088 | /* Limit the max we support */ |
| 2089 | if (max_vpi > LPFC_MAX_VPI) |
| 2090 | max_vpi = LPFC_MAX_VPI; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 2091 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2092 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 2093 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 2094 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 2095 | } else { |
| 2096 | if (mrpi) |
| 2097 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 2098 | if (arpi) |
| 2099 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 2100 | if (mxri) |
| 2101 | *mxri = pmb->un.varRdConfig.max_xri; |
| 2102 | if (axri) |
| 2103 | *axri = pmb->un.varRdConfig.avail_xri; |
| 2104 | if (mvpi) |
| 2105 | *mvpi = pmb->un.varRdConfig.max_vpi; |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 2106 | if (avpi) { |
| 2107 | /* avail_vpi is only valid if link is up and ready */ |
| 2108 | if (phba->link_state == LPFC_HBA_READY) |
| 2109 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 2110 | else |
| 2111 | *avpi = pmb->un.varRdConfig.max_vpi; |
| 2112 | } |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 2113 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2114 | |
| 2115 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 2116 | return 1; |
| 2117 | } |
| 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_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2121 | * @dev: class device that is converted into a Scsi_host. |
| 2122 | * @attr: device attribute, not used. |
| 2123 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 2124 | * |
| 2125 | * Description: |
| 2126 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 2127 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2128 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2129 | * must check for "Unknown" in the buffer to detect a failure. |
| 2130 | * |
| 2131 | * Returns: size of formatted string. |
| 2132 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2133 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2134 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 2135 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2136 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2137 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2138 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2139 | struct lpfc_hba *phba = vport->phba; |
| 2140 | uint32_t cnt; |
| 2141 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2142 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2143 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2144 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2145 | } |
| 2146 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2147 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2148 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2149 | * @dev: class device that is converted into a Scsi_host. |
| 2150 | * @attr: device attribute, not used. |
| 2151 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 2152 | * |
| 2153 | * Description: |
| 2154 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 2155 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2156 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2157 | * must check for "Unknown" in the buffer to detect a failure. |
| 2158 | * |
| 2159 | * Returns: size of formatted string. |
| 2160 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2161 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2162 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 2163 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2164 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2165 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2166 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2167 | struct lpfc_hba *phba = vport->phba; |
| 2168 | uint32_t cnt, acnt; |
| 2169 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2170 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2171 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2172 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2173 | } |
| 2174 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2175 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2176 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2177 | * @dev: class device that is converted into a Scsi_host. |
| 2178 | * @attr: device attribute, not used. |
| 2179 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 2180 | * |
| 2181 | * Description: |
| 2182 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 2183 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2184 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2185 | * must check for "Unknown" in the buffer to detect a failure. |
| 2186 | * |
| 2187 | * Returns: size of formatted string. |
| 2188 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2189 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2190 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 2191 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2192 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2193 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2194 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2195 | struct lpfc_hba *phba = vport->phba; |
| 2196 | uint32_t cnt; |
| 2197 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2198 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2199 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2200 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2201 | } |
| 2202 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2203 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2204 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2205 | * @dev: class device that is converted into a Scsi_host. |
| 2206 | * @attr: device attribute, not used. |
| 2207 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 2208 | * |
| 2209 | * Description: |
| 2210 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 2211 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2212 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2213 | * must check for "Unknown" in the buffer to detect a failure. |
| 2214 | * |
| 2215 | * Returns: size of formatted string. |
| 2216 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2217 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2218 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 2219 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2220 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2221 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2222 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2223 | struct lpfc_hba *phba = vport->phba; |
| 2224 | uint32_t cnt, acnt; |
| 2225 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2226 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2227 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2228 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2229 | } |
| 2230 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2231 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2232 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2233 | * @dev: class device that is converted into a Scsi_host. |
| 2234 | * @attr: device attribute, not used. |
| 2235 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 2236 | * |
| 2237 | * Description: |
| 2238 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 2239 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2240 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2241 | * must check for "Unknown" in the buffer to detect a failure. |
| 2242 | * |
| 2243 | * Returns: size of formatted string. |
| 2244 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2245 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2246 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 2247 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2248 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2249 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2250 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2251 | struct lpfc_hba *phba = vport->phba; |
| 2252 | uint32_t cnt; |
| 2253 | |
| 2254 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2255 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2256 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2257 | } |
| 2258 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2259 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2260 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2261 | * @dev: class device that is converted into a Scsi_host. |
| 2262 | * @attr: device attribute, not used. |
| 2263 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 2264 | * |
| 2265 | * Description: |
| 2266 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 2267 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2268 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2269 | * must check for "Unknown" in the buffer to detect a failure. |
| 2270 | * |
| 2271 | * Returns: size of formatted string. |
| 2272 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2273 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2274 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 2275 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2276 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2277 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2278 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2279 | struct lpfc_hba *phba = vport->phba; |
| 2280 | uint32_t cnt, acnt; |
| 2281 | |
| 2282 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2283 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2284 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2285 | } |
| 2286 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2287 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2288 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2289 | * @dev: class device that is converted into a Scsi_host. |
| 2290 | * @attr: device attribute, not used. |
| 2291 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 2292 | * |
| 2293 | * Description: |
| 2294 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 2295 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 2296 | * the id of the vport. |
| 2297 | * |
| 2298 | * Returns: size of formatted string. |
| 2299 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2300 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2301 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 2302 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2303 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2304 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2305 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2306 | struct lpfc_hba *phba = vport->phba; |
| 2307 | |
| 2308 | if (!(phba->max_vpi)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2309 | return scnprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2310 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2311 | return scnprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 2312 | return scnprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2313 | } |
| 2314 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2315 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2316 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2317 | * @dev: class device that is converted into a Scsi_host. |
| 2318 | * @attr: device attribute, not used. |
| 2319 | * @buf: on return contains the cfg_poll in hex. |
| 2320 | * |
| 2321 | * Notes: |
| 2322 | * cfg_poll should be a lpfc_polling_flags type. |
| 2323 | * |
| 2324 | * Returns: size of formatted string. |
| 2325 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 2326 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2327 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 2328 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2329 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2330 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2331 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2332 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2333 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2334 | return scnprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2335 | } |
| 2336 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2337 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2338 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2339 | * @dev: class device that is converted into a Scsi_host. |
| 2340 | * @attr: device attribute, not used. |
| 2341 | * @buf: one or more lpfc_polling_flags values. |
| 2342 | * @count: not used. |
| 2343 | * |
| 2344 | * Notes: |
| 2345 | * buf contents converted to integer and checked for a valid value. |
| 2346 | * |
| 2347 | * Returns: |
| 2348 | * -EINVAL if the buffer connot be converted or is out of range |
| 2349 | * length of the buf on success |
| 2350 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2351 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2352 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 2353 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2354 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2355 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2356 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2357 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2358 | uint32_t creg_val; |
| 2359 | uint32_t old_val; |
| 2360 | int val=0; |
| 2361 | |
| 2362 | if (!isdigit(buf[0])) |
| 2363 | return -EINVAL; |
| 2364 | |
| 2365 | if (sscanf(buf, "%i", &val) != 1) |
| 2366 | return -EINVAL; |
| 2367 | |
| 2368 | if ((val & 0x3) != val) |
| 2369 | return -EINVAL; |
| 2370 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 2371 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 2372 | val = 0; |
| 2373 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2374 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2375 | "3051 lpfc_poll changed from %d to %d\n", |
| 2376 | phba->cfg_poll, val); |
| 2377 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2378 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2379 | |
| 2380 | old_val = phba->cfg_poll; |
| 2381 | |
| 2382 | if (val & ENABLE_FCP_RING_POLLING) { |
| 2383 | if ((val & DISABLE_FCP_RING_INT) && |
| 2384 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2385 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2386 | spin_unlock_irq(&phba->hbalock); |
| 2387 | return -EINVAL; |
| 2388 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2389 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 2390 | writel(creg_val, phba->HCregaddr); |
| 2391 | readl(phba->HCregaddr); /* flush */ |
| 2392 | |
| 2393 | lpfc_poll_start_timer(phba); |
| 2394 | } |
| 2395 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2396 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2397 | return -EINVAL; |
| 2398 | } |
| 2399 | |
| 2400 | if (!(val & DISABLE_FCP_RING_INT) && |
| 2401 | (old_val & DISABLE_FCP_RING_INT)) |
| 2402 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2403 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2404 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2405 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2406 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2407 | spin_unlock_irq(&phba->hbalock); |
| 2408 | return -EINVAL; |
| 2409 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2410 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 2411 | writel(creg_val, phba->HCregaddr); |
| 2412 | readl(phba->HCregaddr); /* flush */ |
| 2413 | } |
| 2414 | |
| 2415 | phba->cfg_poll = val; |
| 2416 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2417 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2418 | |
| 2419 | return strlen(buf); |
| 2420 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2421 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2422 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2423 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 2424 | * @dev: class converted to a Scsi_host structure. |
| 2425 | * @attr: device attribute, not used. |
| 2426 | * @buf: on return contains the formatted support level. |
| 2427 | * |
| 2428 | * Description: |
| 2429 | * Returns the maximum number of virtual functions a physical function can |
| 2430 | * support, 0 will be returned if called on virtual function. |
| 2431 | * |
| 2432 | * Returns: size of formatted string. |
| 2433 | **/ |
| 2434 | static ssize_t |
| 2435 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 2436 | struct device_attribute *attr, |
| 2437 | char *buf) |
| 2438 | { |
| 2439 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2440 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2441 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2442 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2443 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2444 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2445 | return scnprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2446 | } |
| 2447 | |
| 2448 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2449 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 2450 | * @phba: pointer the the adapter structure. |
| 2451 | * @val: integer attribute value. |
| 2452 | * |
| 2453 | * Description: |
| 2454 | * Validates the min and max values then sets the |
| 2455 | * adapter config field if in the valid range. prints error message |
| 2456 | * and does not set the parameter if invalid. |
| 2457 | * |
| 2458 | * Returns: |
| 2459 | * zero on success |
| 2460 | * -EINVAL if val is invalid |
| 2461 | */ |
| 2462 | static ssize_t |
| 2463 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 2464 | { |
| 2465 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 2466 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 5b1f508 | 2021-04-11 18:31:25 -0700 | [diff] [blame] | 2467 | "3068 lpfc_enable_bbcr changed from %d to " |
| 2468 | "%d\n", phba->cfg_enable_bbcr, val); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2469 | phba->cfg_enable_bbcr = val; |
| 2470 | return 0; |
| 2471 | } |
| 2472 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 5b1f508 | 2021-04-11 18:31:25 -0700 | [diff] [blame] | 2473 | "0451 lpfc_enable_bbcr cannot set to %d, range is 0, " |
| 2474 | "1\n", val); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2475 | return -EINVAL; |
| 2476 | } |
| 2477 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2478 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2479 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2480 | * |
| 2481 | * Description: |
| 2482 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2483 | * into a function with the name lpfc_hba_queue_depth_show. |
| 2484 | * |
| 2485 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 2486 | * @dev: class device that is converted into a Scsi_host. |
| 2487 | * @attr: device attribute, not used. |
| 2488 | * @buf: on return contains the attribute value in decimal. |
| 2489 | * |
| 2490 | * Returns: size of formatted string. |
| 2491 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2492 | #define lpfc_param_show(attr) \ |
| 2493 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2494 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2495 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2496 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2497 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2498 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2499 | struct lpfc_hba *phba = vport->phba;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2500 | return scnprintf(buf, PAGE_SIZE, "%d\n",\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2501 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2502 | } |
| 2503 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2504 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2505 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2506 | * |
| 2507 | * Description: |
| 2508 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2509 | * into a function with the name lpfc_hba_queue_depth_show |
| 2510 | * |
| 2511 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 2512 | * @dev: class device that is converted into a Scsi_host. |
| 2513 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2514 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2515 | * |
| 2516 | * Returns: size of formatted string. |
| 2517 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2518 | #define lpfc_param_hex_show(attr) \ |
| 2519 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2520 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2521 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2522 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2523 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2524 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2525 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2526 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2527 | val = phba->cfg_##attr;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2528 | return scnprintf(buf, PAGE_SIZE, "%#x\n",\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2529 | phba->cfg_##attr);\ |
| 2530 | } |
| 2531 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2532 | /* |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 2533 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2534 | * |
| 2535 | * Description: |
| 2536 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2537 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2538 | * takes a default argument, a minimum and maximum argument. |
| 2539 | * |
| 2540 | * lpfc_##attr##_init: Initializes an attribute. |
| 2541 | * @phba: pointer the the adapter structure. |
| 2542 | * @val: integer attribute value. |
| 2543 | * |
| 2544 | * Validates the min and max values then sets the adapter config field |
| 2545 | * accordingly, or uses the default if out of range and prints an error message. |
| 2546 | * |
| 2547 | * Returns: |
| 2548 | * zero on success |
| 2549 | * -EINVAL if default used |
| 2550 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2551 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 2552 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2553 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2554 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2555 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2556 | phba->cfg_##attr = val;\ |
| 2557 | return 0;\ |
| 2558 | }\ |
| 2559 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2560 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2561 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2562 | phba->cfg_##attr = default;\ |
| 2563 | return -EINVAL;\ |
| 2564 | } |
| 2565 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2566 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2567 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2568 | * |
| 2569 | * Description: |
| 2570 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2571 | * into a function with the name lpfc_hba_queue_depth_set |
| 2572 | * |
| 2573 | * lpfc_##attr##_set: Sets an attribute value. |
| 2574 | * @phba: pointer the the adapter structure. |
| 2575 | * @val: integer attribute value. |
| 2576 | * |
| 2577 | * Description: |
| 2578 | * Validates the min and max values then sets the |
| 2579 | * adapter config field if in the valid range. prints error message |
| 2580 | * and does not set the parameter if invalid. |
| 2581 | * |
| 2582 | * Returns: |
| 2583 | * zero on success |
| 2584 | * -EINVAL if val is invalid |
| 2585 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2586 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2587 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2588 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2589 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2590 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2591 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2592 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2593 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2594 | phba->cfg_##attr = val;\ |
| 2595 | return 0;\ |
| 2596 | }\ |
| 2597 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2598 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2599 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2600 | return -EINVAL;\ |
| 2601 | } |
| 2602 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2603 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2604 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2605 | * |
| 2606 | * Description: |
| 2607 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2608 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2609 | * |
| 2610 | * lpfc_##attr##_store: Set an sttribute value. |
| 2611 | * @dev: class device that is converted into a Scsi_host. |
| 2612 | * @attr: device attribute, not used. |
| 2613 | * @buf: contains the attribute value in ascii. |
| 2614 | * @count: not used. |
| 2615 | * |
| 2616 | * Description: |
| 2617 | * Convert the ascii text number to an integer, then |
| 2618 | * use the lpfc_##attr##_set function to set the value. |
| 2619 | * |
| 2620 | * Returns: |
| 2621 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2622 | * length of buffer upon success. |
| 2623 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2624 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2625 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2626 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2627 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2628 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2629 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2630 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2631 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2632 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2633 | if (!isdigit(buf[0]))\ |
| 2634 | return -EINVAL;\ |
| 2635 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2636 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2637 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2638 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2639 | else \ |
| 2640 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2641 | } |
| 2642 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2643 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2644 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2645 | * |
| 2646 | * Description: |
| 2647 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2648 | * into a function with the name lpfc_hba_queue_depth_show |
| 2649 | * |
| 2650 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2651 | * @dev: class device that is converted into a Scsi_host. |
| 2652 | * @attr: device attribute, not used. |
| 2653 | * @buf: on return contains the attribute value in decimal. |
| 2654 | * |
| 2655 | * Returns: length of formatted string. |
| 2656 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2657 | #define lpfc_vport_param_show(attr) \ |
| 2658 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2659 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2660 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2661 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2662 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2663 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2664 | return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2665 | } |
| 2666 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2667 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2668 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2669 | * |
| 2670 | * Description: |
| 2671 | * Macro that given an attr e.g. |
| 2672 | * hba_queue_depth expands into a function with the name |
| 2673 | * lpfc_hba_queue_depth_show |
| 2674 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2675 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2676 | * @dev: class device that is converted into a Scsi_host. |
| 2677 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2678 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2679 | * |
| 2680 | * Returns: length of formatted string. |
| 2681 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2682 | #define lpfc_vport_param_hex_show(attr) \ |
| 2683 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2684 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2685 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2686 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2687 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2688 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2689 | return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2690 | } |
| 2691 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2692 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2693 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2694 | * |
| 2695 | * Description: |
| 2696 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2697 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2698 | * takes a default argument, a minimum and maximum argument. |
| 2699 | * |
| 2700 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2701 | * adapter config field accordingly, or uses the default if out of range |
| 2702 | * and prints an error message. |
| 2703 | * @phba: pointer the the adapter structure. |
| 2704 | * @val: integer attribute value. |
| 2705 | * |
| 2706 | * Returns: |
| 2707 | * zero on success |
| 2708 | * -EINVAL if default used |
| 2709 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2710 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2711 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2712 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2713 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2714 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2715 | vport->cfg_##attr = val;\ |
| 2716 | return 0;\ |
| 2717 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2718 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2719 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2720 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2721 | vport->cfg_##attr = default;\ |
| 2722 | return -EINVAL;\ |
| 2723 | } |
| 2724 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2725 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2726 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2727 | * |
| 2728 | * Description: |
| 2729 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2730 | * into a function with the name lpfc_hba_queue_depth_set |
| 2731 | * |
| 2732 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2733 | * adapter config field if in the valid range. prints error message |
| 2734 | * and does not set the parameter if invalid. |
| 2735 | * @phba: pointer the the adapter structure. |
| 2736 | * @val: integer attribute value. |
| 2737 | * |
| 2738 | * Returns: |
| 2739 | * zero on success |
| 2740 | * -EINVAL if val is invalid |
| 2741 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2742 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2743 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2744 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2745 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2746 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2747 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2748 | "3053 lpfc_" #attr \ |
| 2749 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2750 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2751 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2752 | vport->cfg_##attr = val;\ |
| 2753 | return 0;\ |
| 2754 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2755 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2756 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2757 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2758 | return -EINVAL;\ |
| 2759 | } |
| 2760 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 2761 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2762 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2763 | * |
| 2764 | * Description: |
| 2765 | * Macro that given an attr e.g. hba_queue_depth |
| 2766 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2767 | * |
| 2768 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2769 | * use the lpfc_##attr##_set function to set the value. |
| 2770 | * @cdev: class device that is converted into a Scsi_host. |
| 2771 | * @buf: contains the attribute value in decimal. |
| 2772 | * @count: not used. |
| 2773 | * |
| 2774 | * Returns: |
| 2775 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2776 | * length of buffer upon success. |
| 2777 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2778 | #define lpfc_vport_param_store(attr) \ |
| 2779 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2780 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2781 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2782 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2783 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2784 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2785 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2786 | if (!isdigit(buf[0]))\ |
| 2787 | return -EINVAL;\ |
| 2788 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2789 | return -EINVAL;\ |
| 2790 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2791 | return strlen(buf);\ |
| 2792 | else \ |
| 2793 | return -EINVAL;\ |
| 2794 | } |
| 2795 | |
| 2796 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2797 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 2798 | static DEVICE_ATTR(scsi_stat, 0444, lpfc_scsi_stat_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2799 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2800 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2801 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2802 | 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] | 2803 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2804 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2805 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2806 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2807 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2808 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2809 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2810 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2811 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2812 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2813 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2814 | lpfc_option_rom_version_show, NULL); |
| 2815 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2816 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2817 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2818 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2819 | static DEVICE_ATTR_RO(lpfc_drvr_version); |
| 2820 | static DEVICE_ATTR_RO(lpfc_enable_fip); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2821 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2822 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2823 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2824 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2825 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2826 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2827 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2828 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2829 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2830 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2831 | static DEVICE_ATTR_RO(lpfc_temp_sensor); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2832 | static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2833 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2834 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2835 | NULL); |
James Smart | 74a7baa | 2021-08-16 09:28:58 -0700 | [diff] [blame] | 2836 | static DEVICE_ATTR(cmf_info, 0444, lpfc_cmf_info_show, NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2837 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2838 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2839 | #define WWN_SZ 8 |
| 2840 | /** |
| 2841 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2842 | * @buf: WWN string. |
| 2843 | * @cnt: Length of string. |
| 2844 | * @wwn: Array to receive converted wwn value. |
| 2845 | * |
| 2846 | * Returns: |
| 2847 | * -EINVAL if the buffer does not contain a valid wwn |
| 2848 | * 0 success |
| 2849 | **/ |
| 2850 | static size_t |
| 2851 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2852 | { |
| 2853 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2854 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2855 | /* Count may include a LF at end of string */ |
| 2856 | if (buf[cnt-1] == '\n') |
| 2857 | cnt--; |
| 2858 | |
| 2859 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2860 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2861 | return -EINVAL; |
| 2862 | |
| 2863 | memset(wwn, 0, WWN_SZ); |
| 2864 | |
| 2865 | /* Validate and store the new name */ |
| 2866 | for (i = 0, j = 0; i < 16; i++) { |
| 2867 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2868 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2869 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2870 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2871 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2872 | j = ((j << 4) | (*buf++ - '0')); |
| 2873 | else |
| 2874 | return -EINVAL; |
| 2875 | if (i % 2) { |
| 2876 | wwn[i/2] = j & 0xff; |
| 2877 | j = 0; |
| 2878 | } |
| 2879 | } |
| 2880 | return 0; |
| 2881 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2882 | /** |
| 2883 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2884 | * @dev: class device that is converted into a Scsi_host. |
| 2885 | * @attr: device attribute, not used. |
| 2886 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2887 | * @count: must be size of lpfc_soft_wwn_key. |
| 2888 | * |
| 2889 | * Returns: |
| 2890 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2891 | * length of buf indicates success |
| 2892 | **/ |
| 2893 | static ssize_t |
| 2894 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2895 | const char *buf, size_t count) |
| 2896 | { |
| 2897 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2898 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2899 | struct lpfc_hba *phba = vport->phba; |
| 2900 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2901 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2902 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2903 | |
| 2904 | /* |
| 2905 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2906 | * We require that the user write a specific key to enable |
| 2907 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2908 | * is written, the enable key resets. If further updates are |
| 2909 | * desired, the key must be written again to re-enable the |
| 2910 | * attribute. |
| 2911 | * |
| 2912 | * The "key" is not secret - it is a hardcoded string shown |
| 2913 | * here. The intent is to protect against the random user or |
| 2914 | * application that is just writing attributes. |
| 2915 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2916 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2917 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 5b1f508 | 2021-04-11 18:31:25 -0700 | [diff] [blame] | 2918 | "0051 lpfc soft wwpn can not be enabled: " |
| 2919 | "fawwpn is enabled\n"); |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2920 | return -EINVAL; |
| 2921 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2922 | |
| 2923 | /* count may include a LF at end of string */ |
| 2924 | if (buf[cnt-1] == '\n') |
| 2925 | cnt--; |
| 2926 | |
| 2927 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2928 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2929 | return -EINVAL; |
| 2930 | |
| 2931 | phba->soft_wwn_enable = 1; |
| 2932 | |
| 2933 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2934 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2935 | phba->brd_no); |
| 2936 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2937 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2938 | |
| 2939 | return count; |
| 2940 | } |
Joe Perches | 6cbaefb | 2017-12-19 10:15:09 -0800 | [diff] [blame] | 2941 | static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2942 | |
| 2943 | /** |
| 2944 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2945 | * @dev: class device that is converted into a Scsi_host. |
| 2946 | * @attr: device attribute, not used. |
| 2947 | * @buf: on return contains the wwpn in hexadecimal. |
| 2948 | * |
| 2949 | * Returns: size of formatted string. |
| 2950 | **/ |
| 2951 | static ssize_t |
| 2952 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2953 | char *buf) |
| 2954 | { |
| 2955 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2956 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2957 | struct lpfc_hba *phba = vport->phba; |
| 2958 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2959 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2960 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2961 | } |
| 2962 | |
| 2963 | /** |
| 2964 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 2965 | * @dev: class device that is converted into a Scsi_host. |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2966 | * @attr: device attribute, not used. |
| 2967 | * @buf: contains the wwpn in hexadecimal. |
| 2968 | * @count: number of wwpn bytes in buf |
| 2969 | * |
| 2970 | * Returns: |
| 2971 | * -EACCES hba reset not enabled, adapter over temp |
| 2972 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2973 | * -EIO error taking adapter offline or online |
| 2974 | * value of count on success |
| 2975 | **/ |
| 2976 | static ssize_t |
| 2977 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2978 | const char *buf, size_t count) |
| 2979 | { |
| 2980 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2981 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2982 | struct lpfc_hba *phba = vport->phba; |
| 2983 | struct completion online_compl; |
| 2984 | int stat1 = 0, stat2 = 0; |
| 2985 | unsigned int cnt = count; |
| 2986 | u8 wwpn[WWN_SZ]; |
| 2987 | int rc; |
| 2988 | |
| 2989 | if (!phba->cfg_enable_hba_reset) |
| 2990 | return -EACCES; |
| 2991 | spin_lock_irq(&phba->hbalock); |
| 2992 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2993 | spin_unlock_irq(&phba->hbalock); |
| 2994 | return -EACCES; |
| 2995 | } |
| 2996 | spin_unlock_irq(&phba->hbalock); |
| 2997 | /* count may include a LF at end of string */ |
| 2998 | if (buf[cnt-1] == '\n') |
| 2999 | cnt--; |
| 3000 | |
| 3001 | if (!phba->soft_wwn_enable) |
| 3002 | return -EINVAL; |
| 3003 | |
| 3004 | /* lock setting wwpn, wwnn down */ |
| 3005 | phba->soft_wwn_enable = 0; |
| 3006 | |
| 3007 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 3008 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 3009 | /* not able to set wwpn, unlock it */ |
| 3010 | phba->soft_wwn_enable = 1; |
| 3011 | return rc; |
| 3012 | } |
| 3013 | |
| 3014 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 3015 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 3016 | if (phba->cfg_soft_wwnn) |
| 3017 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 3018 | |
| 3019 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 3020 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 3021 | |
| 3022 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 3023 | if (stat1) |
| 3024 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3025 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 3026 | "reinit adapter - %d\n", stat1); |
| 3027 | init_completion(&online_compl); |
| 3028 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 3029 | LPFC_EVT_ONLINE); |
| 3030 | if (rc == 0) |
| 3031 | return -ENOMEM; |
| 3032 | |
| 3033 | wait_for_completion(&online_compl); |
| 3034 | if (stat2) |
| 3035 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3036 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 3037 | "reinit adapter - %d\n", stat2); |
| 3038 | return (stat1 || stat2) ? -EIO : count; |
| 3039 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3040 | static DEVICE_ATTR_RW(lpfc_soft_wwpn); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 3041 | |
| 3042 | /** |
| 3043 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 3044 | * @dev: class device that is converted into a Scsi_host. |
| 3045 | * @attr: device attribute, not used. |
| 3046 | * @buf: on return contains the wwnn in hexadecimal. |
| 3047 | * |
| 3048 | * Returns: size of formatted string. |
| 3049 | **/ |
| 3050 | static ssize_t |
| 3051 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 3052 | char *buf) |
| 3053 | { |
| 3054 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3055 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3056 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 3057 | (unsigned long long)phba->cfg_soft_wwnn); |
| 3058 | } |
| 3059 | |
| 3060 | /** |
| 3061 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 3062 | * @dev: class device that is converted into a Scsi_host. |
| 3063 | * @attr: device attribute, not used. |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 3064 | * @buf: contains the ww node name in hexadecimal. |
| 3065 | * @count: number of wwnn bytes in buf. |
| 3066 | * |
| 3067 | * Returns: |
| 3068 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 3069 | * value of count on success |
| 3070 | **/ |
| 3071 | static ssize_t |
| 3072 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 3073 | const char *buf, size_t count) |
| 3074 | { |
| 3075 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3076 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3077 | unsigned int cnt = count; |
| 3078 | u8 wwnn[WWN_SZ]; |
| 3079 | int rc; |
| 3080 | |
| 3081 | /* count may include a LF at end of string */ |
| 3082 | if (buf[cnt-1] == '\n') |
| 3083 | cnt--; |
| 3084 | |
| 3085 | if (!phba->soft_wwn_enable) |
| 3086 | return -EINVAL; |
| 3087 | |
| 3088 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 3089 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 3090 | /* Allow wwnn to be set many times, as long as the enable |
| 3091 | * is set. However, once the wwpn is set, everything locks. |
| 3092 | */ |
| 3093 | return rc; |
| 3094 | } |
| 3095 | |
| 3096 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 3097 | |
| 3098 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 3099 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 3100 | "setting of the soft_wwpn\n", phba->brd_no); |
| 3101 | |
| 3102 | return count; |
| 3103 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3104 | static DEVICE_ATTR_RW(lpfc_soft_wwnn); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 3105 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3106 | /** |
| 3107 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 3108 | * Optimized Access Storage (OAS) operations. |
| 3109 | * @dev: class device that is converted into a Scsi_host. |
| 3110 | * @attr: device attribute, not used. |
| 3111 | * @buf: buffer for passing information. |
| 3112 | * |
| 3113 | * Returns: |
| 3114 | * value of count |
| 3115 | **/ |
| 3116 | static ssize_t |
| 3117 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 3118 | char *buf) |
| 3119 | { |
| 3120 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3121 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3122 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3123 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3124 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 3125 | } |
| 3126 | |
| 3127 | /** |
| 3128 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 3129 | * Optimized Access Storage (OAS) operations. |
| 3130 | * @dev: class device that is converted into a Scsi_host. |
| 3131 | * @attr: device attribute, not used. |
| 3132 | * @buf: buffer for passing information. |
| 3133 | * @count: Size of the data buffer. |
| 3134 | * |
| 3135 | * Returns: |
| 3136 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3137 | * -EPERM oas is not supported by hba |
| 3138 | * value of count on success |
| 3139 | **/ |
| 3140 | static ssize_t |
| 3141 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 3142 | const char *buf, size_t count) |
| 3143 | { |
| 3144 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3145 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3146 | unsigned int cnt = count; |
| 3147 | uint8_t wwpn[WWN_SZ]; |
| 3148 | int rc; |
| 3149 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3150 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3151 | return -EPERM; |
| 3152 | |
| 3153 | /* count may include a LF at end of string */ |
| 3154 | if (buf[cnt-1] == '\n') |
| 3155 | cnt--; |
| 3156 | |
| 3157 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 3158 | if (rc) |
| 3159 | return rc; |
| 3160 | |
| 3161 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3162 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3163 | if (wwn_to_u64(wwpn) == 0) |
| 3164 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 3165 | else |
| 3166 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 3167 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 3168 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3169 | return count; |
| 3170 | } |
| 3171 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 3172 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 3173 | |
| 3174 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3175 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 3176 | * Optimized Access Storage (OAS) operations. |
| 3177 | * @dev: class device that is converted into a Scsi_host. |
| 3178 | * @attr: device attribute, not used. |
| 3179 | * @buf: buffer for passing information. |
| 3180 | * |
| 3181 | * Returns: |
| 3182 | * value of count |
| 3183 | **/ |
| 3184 | static ssize_t |
| 3185 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 3186 | char *buf) |
| 3187 | { |
| 3188 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3189 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3190 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3191 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3192 | } |
| 3193 | |
| 3194 | /** |
| 3195 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 3196 | * Optimized Access Storage (OAS) operations. |
| 3197 | * @dev: class device that is converted into a Scsi_host. |
| 3198 | * @attr: device attribute, not used. |
| 3199 | * @buf: buffer for passing information. |
| 3200 | * @count: Size of the data buffer. |
| 3201 | * |
| 3202 | * Returns: |
| 3203 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3204 | * -EPERM oas is not supported by hba |
| 3205 | * value of count on success |
| 3206 | **/ |
| 3207 | static ssize_t |
| 3208 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 3209 | const char *buf, size_t count) |
| 3210 | { |
| 3211 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3212 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3213 | unsigned int cnt = count; |
| 3214 | unsigned long val; |
| 3215 | int ret; |
| 3216 | |
| 3217 | if (!phba->cfg_fof) |
| 3218 | return -EPERM; |
| 3219 | |
| 3220 | /* count may include a LF at end of string */ |
| 3221 | if (buf[cnt-1] == '\n') |
| 3222 | cnt--; |
| 3223 | |
| 3224 | ret = kstrtoul(buf, 0, &val); |
| 3225 | if (ret || (val > 0x7f)) |
| 3226 | return -EINVAL; |
| 3227 | |
| 3228 | if (val) |
| 3229 | phba->cfg_oas_priority = (uint8_t)val; |
| 3230 | else |
| 3231 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 3232 | return count; |
| 3233 | } |
| 3234 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 3235 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 3236 | |
| 3237 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3238 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 3239 | * for Optimized Access Storage (OAS) operations. |
| 3240 | * @dev: class device that is converted into a Scsi_host. |
| 3241 | * @attr: device attribute, not used. |
| 3242 | * @buf: buffer for passing information. |
| 3243 | * |
| 3244 | * Returns: |
| 3245 | * value of count on success |
| 3246 | **/ |
| 3247 | static ssize_t |
| 3248 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 3249 | char *buf) |
| 3250 | { |
| 3251 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3252 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3253 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3254 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3255 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 3256 | } |
| 3257 | |
| 3258 | /** |
| 3259 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 3260 | * for Optimized Access Storage (OAS) operations. |
| 3261 | * @dev: class device that is converted into a Scsi_host. |
| 3262 | * @attr: device attribute, not used. |
| 3263 | * @buf: buffer for passing information. |
| 3264 | * @count: Size of the data buffer. |
| 3265 | * |
| 3266 | * Returns: |
| 3267 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3268 | * -EPERM oas is not supported by hba |
| 3269 | * value of count on success |
| 3270 | **/ |
| 3271 | static ssize_t |
| 3272 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 3273 | const char *buf, size_t count) |
| 3274 | { |
| 3275 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3276 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3277 | unsigned int cnt = count; |
| 3278 | uint8_t wwpn[WWN_SZ]; |
| 3279 | int rc; |
| 3280 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3281 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3282 | return -EPERM; |
| 3283 | |
| 3284 | /* count may include a LF at end of string */ |
| 3285 | if (buf[cnt-1] == '\n') |
| 3286 | cnt--; |
| 3287 | |
| 3288 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 3289 | if (rc) |
| 3290 | return rc; |
| 3291 | |
| 3292 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3293 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3294 | if (wwn_to_u64(wwpn) == 0) |
| 3295 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 3296 | else |
| 3297 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 3298 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3299 | if (phba->cfg_oas_priority == 0) |
| 3300 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3301 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3302 | return count; |
| 3303 | } |
| 3304 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 3305 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 3306 | |
| 3307 | /** |
| 3308 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 3309 | * of whether luns will be enabled or disabled |
| 3310 | * for Optimized Access Storage (OAS) operations. |
| 3311 | * @dev: class device that is converted into a Scsi_host. |
| 3312 | * @attr: device attribute, not used. |
| 3313 | * @buf: buffer for passing information. |
| 3314 | * |
| 3315 | * Returns: |
| 3316 | * size of formatted string. |
| 3317 | **/ |
| 3318 | static ssize_t |
| 3319 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 3320 | char *buf) |
| 3321 | { |
| 3322 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3323 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3324 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3325 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3326 | } |
| 3327 | |
| 3328 | /** |
| 3329 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 3330 | * of whether luns will be enabled or disabled |
| 3331 | * for Optimized Access Storage (OAS) operations. |
| 3332 | * @dev: class device that is converted into a Scsi_host. |
| 3333 | * @attr: device attribute, not used. |
| 3334 | * @buf: buffer for passing information. |
| 3335 | * @count: Size of the data buffer. |
| 3336 | * |
| 3337 | * Returns: |
| 3338 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3339 | * -EPERM oas is not supported by hba |
| 3340 | * value of count on success |
| 3341 | **/ |
| 3342 | static ssize_t |
| 3343 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 3344 | const char *buf, size_t count) |
| 3345 | { |
| 3346 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3347 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3348 | int val = 0; |
| 3349 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3350 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3351 | return -EPERM; |
| 3352 | |
| 3353 | if (!isdigit(buf[0])) |
| 3354 | return -EINVAL; |
| 3355 | |
| 3356 | if (sscanf(buf, "%i", &val) != 1) |
| 3357 | return -EINVAL; |
| 3358 | |
| 3359 | if ((val != 0) && (val != 1)) |
| 3360 | return -EINVAL; |
| 3361 | |
| 3362 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3363 | return strlen(buf); |
| 3364 | } |
| 3365 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 3366 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 3367 | |
| 3368 | /** |
| 3369 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 3370 | * Storage (OAS) lun returned by the |
| 3371 | * lpfc_oas_lun_show function. |
| 3372 | * @dev: class device that is converted into a Scsi_host. |
| 3373 | * @attr: device attribute, not used. |
| 3374 | * @buf: buffer for passing information. |
| 3375 | * |
| 3376 | * Returns: |
| 3377 | * size of formatted string. |
| 3378 | **/ |
| 3379 | static ssize_t |
| 3380 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 3381 | char *buf) |
| 3382 | { |
| 3383 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3384 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3385 | |
| 3386 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 3387 | return -EFAULT; |
| 3388 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3389 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3390 | } |
| 3391 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 3392 | lpfc_oas_lun_status_show, NULL); |
| 3393 | |
| 3394 | |
| 3395 | /** |
| 3396 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 3397 | * (OAS) operations. |
| 3398 | * @phba: lpfc_hba pointer. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 3399 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 3400 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3401 | * @lun: the fc lun for setting oas state. |
| 3402 | * @oas_state: the oas state to be set to the lun. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 3403 | * @pri: priority |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3404 | * |
| 3405 | * Returns: |
| 3406 | * SUCCESS : 0 |
| 3407 | * -EPERM OAS is not enabled or not supported by this port. |
| 3408 | * |
| 3409 | */ |
| 3410 | static size_t |
| 3411 | lpfc_oas_lun_state_set(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3412 | uint8_t tgt_wwpn[], uint64_t lun, |
| 3413 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3414 | { |
| 3415 | |
| 3416 | int rc = 0; |
| 3417 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3418 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3419 | return -EPERM; |
| 3420 | |
| 3421 | if (oas_state) { |
| 3422 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3423 | (struct lpfc_name *)tgt_wwpn, |
| 3424 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3425 | rc = -ENOMEM; |
| 3426 | } else { |
| 3427 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3428 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3429 | } |
| 3430 | return rc; |
| 3431 | |
| 3432 | } |
| 3433 | |
| 3434 | /** |
| 3435 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 3436 | * Access Storage (OAS) operations. |
| 3437 | * @phba: lpfc_hba pointer. |
| 3438 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 3439 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 3440 | * @lun_status: status of the lun returned lun |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 3441 | * @lun_pri: priority of the lun returned lun |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3442 | * |
| 3443 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 3444 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 3445 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 3446 | * |
| 3447 | * Return: |
| 3448 | * lun that is OAS enabled for the vport/target |
| 3449 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 3450 | */ |
| 3451 | static uint64_t |
| 3452 | lpfc_oas_lun_get_next(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3453 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 3454 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3455 | { |
| 3456 | uint64_t found_lun; |
| 3457 | |
| 3458 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 3459 | return NOT_OAS_ENABLED_LUN; |
| 3460 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 3461 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 3462 | (struct lpfc_name *) |
| 3463 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 3464 | &phba->sli4_hba.oas_next_lun, |
| 3465 | (struct lpfc_name *)vpt_wwpn, |
| 3466 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3467 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3468 | return found_lun; |
| 3469 | else |
| 3470 | return NOT_OAS_ENABLED_LUN; |
| 3471 | } |
| 3472 | |
| 3473 | /** |
| 3474 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 3475 | * @phba: lpfc_hba pointer. |
| 3476 | * @vpt_wwpn: vport wwpn by reference. |
| 3477 | * @tgt_wwpn: target wwpn by reference. |
| 3478 | * @lun: the fc lun for setting oas state. |
| 3479 | * @oas_state: the oas state to be set to the oas_lun. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 3480 | * @pri: priority |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3481 | * |
| 3482 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 3483 | * a lun for OAS operations. |
| 3484 | * |
| 3485 | * Return: |
| 3486 | * SUCCESS: 0 |
| 3487 | * -ENOMEM: failed to enable an lun for OAS operations |
| 3488 | * -EPERM: OAS is not enabled |
| 3489 | */ |
| 3490 | static ssize_t |
| 3491 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 3492 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3493 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3494 | { |
| 3495 | |
| 3496 | int rc; |
| 3497 | |
| 3498 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3499 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3500 | return rc; |
| 3501 | } |
| 3502 | |
| 3503 | /** |
| 3504 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 3505 | * @dev: class device that is converted into a Scsi_host. |
| 3506 | * @attr: device attribute, not used. |
| 3507 | * @buf: buffer for passing information. |
| 3508 | * |
| 3509 | * This routine returns a lun enabled for OAS each time the function |
| 3510 | * is called. |
| 3511 | * |
| 3512 | * Returns: |
| 3513 | * SUCCESS: size of formatted string. |
| 3514 | * -EFAULT: target or vport wwpn was not set properly. |
| 3515 | * -EPERM: oas is not enabled. |
| 3516 | **/ |
| 3517 | static ssize_t |
| 3518 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 3519 | char *buf) |
| 3520 | { |
| 3521 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3522 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3523 | |
| 3524 | uint64_t oas_lun; |
| 3525 | int len = 0; |
| 3526 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3527 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3528 | return -EPERM; |
| 3529 | |
| 3530 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3531 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 3532 | return -EFAULT; |
| 3533 | |
| 3534 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3535 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 3536 | return -EFAULT; |
| 3537 | |
| 3538 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 3539 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3540 | &phba->cfg_oas_lun_status, |
| 3541 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3542 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 3543 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 3544 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3545 | len += scnprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3546 | |
| 3547 | return len; |
| 3548 | } |
| 3549 | |
| 3550 | /** |
| 3551 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 3552 | * @dev: class device that is converted into a Scsi_host. |
| 3553 | * @attr: device attribute, not used. |
| 3554 | * @buf: buffer for passing information. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 3555 | * @count: size of the formatting string |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3556 | * |
| 3557 | * This function sets the OAS state for lun. Before this function is called, |
| 3558 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3559 | * |
| 3560 | * Returns: |
| 3561 | * SUCCESS: size of formatted string. |
| 3562 | * -EFAULT: target or vport wwpn was not set properly. |
| 3563 | * -EPERM: oas is not enabled. |
| 3564 | * size of formatted string. |
| 3565 | **/ |
| 3566 | static ssize_t |
| 3567 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3568 | const char *buf, size_t count) |
| 3569 | { |
| 3570 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3571 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3572 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3573 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3574 | ssize_t rc; |
| 3575 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3576 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3577 | return -EPERM; |
| 3578 | |
| 3579 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3580 | return -EFAULT; |
| 3581 | |
| 3582 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3583 | return -EFAULT; |
| 3584 | |
| 3585 | if (!isdigit(buf[0])) |
| 3586 | return -EINVAL; |
| 3587 | |
| 3588 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3589 | return -EINVAL; |
| 3590 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3591 | pri = phba->cfg_oas_priority; |
| 3592 | if (pri == 0) |
| 3593 | pri = phba->cfg_XLanePriority; |
| 3594 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3595 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3596 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3597 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3598 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3599 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3600 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3601 | |
| 3602 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3603 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3604 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3605 | if (rc) |
| 3606 | return rc; |
| 3607 | |
| 3608 | return count; |
| 3609 | } |
| 3610 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3611 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3612 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3613 | int lpfc_enable_nvmet_cnt; |
| 3614 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3615 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3616 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3617 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3618 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3619 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3620 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3621 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3622 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3623 | " 0 - none," |
| 3624 | " 1 - poll with interrupts enabled" |
| 3625 | " 3 - poll and disable FCP ring interrupts"); |
| 3626 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3627 | static DEVICE_ATTR_RW(lpfc_poll); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3628 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3629 | int lpfc_no_hba_reset_cnt; |
| 3630 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3631 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3632 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3633 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3634 | |
James Smart | d2f2547 | 2021-01-04 10:02:27 -0800 | [diff] [blame] | 3635 | LPFC_ATTR(sli_mode, 3, 3, 3, |
| 3636 | "SLI mode selector: 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3637 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3638 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3639 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3640 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3641 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3642 | "FCF Fast failover=1 Priority failover=2"); |
| 3643 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3644 | /* |
James Smart | 3e49af9 | 2021-05-14 12:55:57 -0700 | [diff] [blame] | 3645 | * lpfc_fcp_wait_abts_rsp: Modifies criteria for reporting completion of |
| 3646 | * aborted IO. |
| 3647 | * The range is [0,1]. Default value is 0 |
| 3648 | * 0, IO completes after ABTS issued (default). |
| 3649 | * 1, IO completes after receipt of ABTS response or timeout. |
| 3650 | */ |
| 3651 | LPFC_ATTR_R(fcp_wait_abts_rsp, 0, 0, 1, "Wait for FCP ABTS completion"); |
| 3652 | |
| 3653 | /* |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3654 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3655 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3656 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3657 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3658 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3659 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3660 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3661 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3662 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3663 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3664 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3665 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3666 | # 0x2 = never bring up link |
| 3667 | # Default value is 0. |
| 3668 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3669 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3670 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3671 | "Suppress Link Up at initialization"); |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 3672 | |
| 3673 | static ssize_t |
| 3674 | lpfc_pls_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3675 | { |
| 3676 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3677 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3678 | |
| 3679 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
| 3680 | phba->sli4_hba.pc_sli4_params.pls); |
| 3681 | } |
| 3682 | static DEVICE_ATTR(pls, 0444, |
| 3683 | lpfc_pls_show, NULL); |
| 3684 | |
| 3685 | static ssize_t |
| 3686 | lpfc_pt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3687 | { |
| 3688 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3689 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3690 | |
| 3691 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
| 3692 | (phba->hba_flag & HBA_PERSISTENT_TOPO) ? 1 : 0); |
| 3693 | } |
| 3694 | static DEVICE_ATTR(pt, 0444, |
| 3695 | lpfc_pt_show, NULL); |
| 3696 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3697 | /* |
| 3698 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3699 | # 1 - (1024) |
| 3700 | # 2 - (2048) |
| 3701 | # 3 - (3072) |
| 3702 | # 4 - (4096) |
| 3703 | # 5 - (5120) |
| 3704 | */ |
| 3705 | static ssize_t |
| 3706 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3707 | { |
| 3708 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3709 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3710 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3711 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3712 | } |
| 3713 | |
| 3714 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3715 | lpfc_iocb_hw_show, NULL); |
| 3716 | static ssize_t |
| 3717 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3718 | { |
| 3719 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3720 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3721 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3722 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3723 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3724 | pring ? pring->txq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3725 | } |
| 3726 | |
| 3727 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3728 | lpfc_txq_hw_show, NULL); |
| 3729 | static ssize_t |
| 3730 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3731 | char *buf) |
| 3732 | { |
| 3733 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3734 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3735 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3736 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3737 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3738 | pring ? pring->txcmplq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3739 | } |
| 3740 | |
| 3741 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3742 | lpfc_txcmplq_hw_show, NULL); |
| 3743 | |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3744 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3745 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3746 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3747 | */ |
| 3748 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3749 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3750 | module_param(lpfc_nodev_tmo, int, 0); |
| 3751 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3752 | "Seconds driver will hold I/O waiting " |
| 3753 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3754 | |
| 3755 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3756 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3757 | * @dev: class converted to a Scsi_host structure. |
| 3758 | * @attr: device attribute, not used. |
| 3759 | * @buf: on return contains the dev loss timeout in decimal. |
| 3760 | * |
| 3761 | * Returns: size of formatted string. |
| 3762 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3763 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3764 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3765 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3766 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3767 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3768 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3769 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3770 | return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3771 | } |
| 3772 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3773 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3774 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3775 | * @vport: lpfc vport structure pointer. |
| 3776 | * @val: contains the nodev timeout value. |
| 3777 | * |
| 3778 | * Description: |
| 3779 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3780 | * a kernel error message is printed and zero is returned. |
| 3781 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3782 | * Otherwise nodev tmo is set to the default value. |
| 3783 | * |
| 3784 | * Returns: |
| 3785 | * zero if already set or if val is in range |
| 3786 | * -EINVAL val out of range |
| 3787 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3788 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3789 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3790 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3791 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3792 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3793 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3794 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3795 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3796 | "parameter because lpfc_devloss_tmo " |
| 3797 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3798 | return 0; |
| 3799 | } |
| 3800 | |
| 3801 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3802 | vport->cfg_nodev_tmo = val; |
| 3803 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3804 | return 0; |
| 3805 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3806 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3807 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3808 | " %d, allowed range is [%d, %d]\n", |
| 3809 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3810 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3811 | return -EINVAL; |
| 3812 | } |
| 3813 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3814 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3815 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3816 | * @vport: lpfc vport structure pointer. |
| 3817 | * |
| 3818 | * Description: |
| 3819 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3820 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3821 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3822 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3823 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3824 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3825 | struct lpfc_nodelist *ndlp; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3826 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3827 | struct lpfc_nvme_rport *rport; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3828 | struct nvme_fc_remote_port *remoteport = NULL; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3829 | #endif |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3830 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3831 | shost = lpfc_shost_from_vport(vport); |
| 3832 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3833 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3834 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3835 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3836 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 3837 | spin_lock(&ndlp->lock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3838 | rport = lpfc_ndlp_get_nrport(ndlp); |
| 3839 | if (rport) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3840 | remoteport = rport->remoteport; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 3841 | spin_unlock(&ndlp->lock); |
James Smart | 07f5099 | 2019-08-14 16:56:45 -0700 | [diff] [blame] | 3842 | if (rport && remoteport) |
| 3843 | nvme_fc_set_remoteport_devloss(remoteport, |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3844 | vport->cfg_devloss_tmo); |
| 3845 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3846 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3847 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3848 | } |
| 3849 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3850 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3851 | * 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] | 3852 | * @vport: lpfc vport structure pointer. |
| 3853 | * @val: contains the tmo value. |
| 3854 | * |
| 3855 | * Description: |
| 3856 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3857 | * then a kernel error message is printed and zero is returned. |
| 3858 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3859 | * Otherwise nodev tmo is set to the default value. |
| 3860 | * |
| 3861 | * Returns: |
| 3862 | * zero if already set or if val is in range |
| 3863 | * -EINVAL val out of range |
| 3864 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3865 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3866 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3867 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3868 | if (vport->dev_loss_tmo_changed || |
| 3869 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3870 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3871 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3872 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3873 | return 0; |
| 3874 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3875 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3876 | vport->cfg_nodev_tmo = val; |
| 3877 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3878 | /* |
| 3879 | * For compat: set the fc_host dev loss so new rports |
| 3880 | * will get the value. |
| 3881 | */ |
| 3882 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3883 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3884 | return 0; |
| 3885 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3886 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3887 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3888 | "%d, allowed range is [%d, %d]\n", |
| 3889 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3890 | return -EINVAL; |
| 3891 | } |
| 3892 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3893 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3894 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3895 | static DEVICE_ATTR_RW(lpfc_nodev_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3896 | |
| 3897 | /* |
| 3898 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3899 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3900 | # value is 30. |
| 3901 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3902 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3903 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3904 | "Seconds driver will hold I/O waiting " |
| 3905 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3906 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3907 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3908 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3909 | |
| 3910 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3911 | * 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] | 3912 | * @vport: lpfc vport structure pointer. |
| 3913 | * @val: contains the tmo value. |
| 3914 | * |
| 3915 | * Description: |
| 3916 | * If val is in a valid range then set the vport nodev tmo, |
| 3917 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3918 | * Else a kernel error message is printed. |
| 3919 | * |
| 3920 | * Returns: |
| 3921 | * zero if val is in range |
| 3922 | * -EINVAL val out of range |
| 3923 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3924 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3925 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3926 | { |
| 3927 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3928 | vport->cfg_nodev_tmo = val; |
| 3929 | vport->cfg_devloss_tmo = val; |
| 3930 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3931 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3932 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3933 | return 0; |
| 3934 | } |
| 3935 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3936 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3937 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3938 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3939 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3940 | return -EINVAL; |
| 3941 | } |
| 3942 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3943 | lpfc_vport_param_store(devloss_tmo) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3944 | static DEVICE_ATTR_RW(lpfc_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3945 | |
| 3946 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3947 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3948 | * lpfc_suppress_rsp = 0 Disable |
| 3949 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3950 | * |
| 3951 | */ |
| 3952 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3953 | "Enable suppress rsp feature is firmware supports it"); |
| 3954 | |
| 3955 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3956 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3957 | * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3958 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3959 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3960 | * |
| 3961 | */ |
| 3962 | LPFC_ATTR_R(nvmet_mrq, |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3963 | LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3964 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3965 | |
| 3966 | /* |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 3967 | * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post |
| 3968 | * to each NVMET RQ. Range 64 to 2048, default is 512. |
| 3969 | */ |
| 3970 | LPFC_ATTR_R(nvmet_mrq_post, |
| 3971 | LPFC_NVMET_RQE_DEF_POST, LPFC_NVMET_RQE_MIN_POST, |
| 3972 | LPFC_NVMET_RQE_DEF_COUNT, |
| 3973 | "Specify number of RQ buffers to initially post"); |
| 3974 | |
| 3975 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3976 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3977 | * Supported Values: 1 - register just FCP |
| 3978 | * 3 - register both FCP and NVME |
James Smart | b1684a0 | 2019-01-28 11:14:36 -0800 | [diff] [blame] | 3979 | * Supported values are [1,3]. Default value is 3 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3980 | */ |
James Smart | b1684a0 | 2019-01-28 11:14:36 -0800 | [diff] [blame] | 3981 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_BOTH, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3982 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3983 | "Enable FC4 Protocol support - FCP / NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3984 | |
| 3985 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3986 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3987 | # deluged with LOTS of information. |
| 3988 | # 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] | 3989 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3990 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3991 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3992 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3993 | |
| 3994 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3995 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3996 | # objects that have been registered with the nameserver after login. |
| 3997 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3998 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3999 | "Deregister nameserver objects before LOGO"); |
| 4000 | |
| 4001 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4002 | # lun_queue_depth: This parameter is used to limit the number of outstanding |
Dick Kennedy | 763a18c | 2020-03-23 09:19:35 -0700 | [diff] [blame] | 4003 | # commands per FCP LUN. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4004 | */ |
Dick Kennedy | 763a18c | 2020-03-23 09:19:35 -0700 | [diff] [blame] | 4005 | LPFC_VPORT_ATTR_R(lun_queue_depth, 64, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4006 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4007 | |
| 4008 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4009 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 4010 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 4011 | */ |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 4012 | static uint lpfc_tgt_queue_depth = LPFC_MAX_TGT_QDEPTH; |
| 4013 | module_param(lpfc_tgt_queue_depth, uint, 0444); |
| 4014 | MODULE_PARM_DESC(lpfc_tgt_queue_depth, "Set max Target queue depth"); |
| 4015 | lpfc_vport_param_show(tgt_queue_depth); |
| 4016 | lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH, |
| 4017 | LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH); |
| 4018 | |
| 4019 | /** |
Lee Jones | a3dbf51 | 2021-03-12 09:47:12 +0000 | [diff] [blame] | 4020 | * lpfc_tgt_queue_depth_set: Sets an attribute value. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 4021 | * @vport: lpfc vport structure pointer. |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 4022 | * @val: integer attribute value. |
| 4023 | * |
| 4024 | * Description: Sets the parameter to the new value. |
| 4025 | * |
| 4026 | * Returns: |
| 4027 | * zero on success |
| 4028 | * -EINVAL if val is invalid |
| 4029 | */ |
| 4030 | static int |
| 4031 | lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val) |
| 4032 | { |
| 4033 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4034 | struct lpfc_nodelist *ndlp; |
| 4035 | |
| 4036 | if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH)) |
| 4037 | return -EINVAL; |
| 4038 | |
| 4039 | if (val == vport->cfg_tgt_queue_depth) |
| 4040 | return 0; |
| 4041 | |
| 4042 | spin_lock_irq(shost->host_lock); |
| 4043 | vport->cfg_tgt_queue_depth = val; |
| 4044 | |
| 4045 | /* Next loop thru nodelist and change cmd_qdepth */ |
| 4046 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
| 4047 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
| 4048 | |
| 4049 | spin_unlock_irq(shost->host_lock); |
| 4050 | return 0; |
| 4051 | } |
| 4052 | |
| 4053 | lpfc_vport_param_store(tgt_queue_depth); |
| 4054 | static DEVICE_ATTR_RW(lpfc_tgt_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4055 | |
| 4056 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 4057 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 4058 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 4059 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 4060 | # then maximum number of exchanges supported by the HBA is used to determine |
| 4061 | # the hba_queue_depth. |
| 4062 | */ |
| 4063 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 4064 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 4065 | |
| 4066 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4067 | # peer_port_login: This parameter allows/prevents logins |
| 4068 | # between peer ports hosted on the same physical port. |
| 4069 | # When this parameter is set 0 peer ports of same physical port |
| 4070 | # are not allowed to login to each other. |
| 4071 | # When this parameter is set 1 peer ports of same physical port |
| 4072 | # are allowed to login to each other. |
| 4073 | # Default value of this parameter is 0. |
| 4074 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4075 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 4076 | "Allow peer ports on the same physical port to login to each " |
| 4077 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4078 | |
| 4079 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4080 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4081 | # between Virtual Ports and remote initiators. |
| 4082 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 4083 | # other initiators and will attempt to PLOGI all remote ports. |
| 4084 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 4085 | # remote ports and will not attempt to PLOGI to other initiators. |
| 4086 | # This parameter does not restrict to the physical port. |
| 4087 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 4088 | # Default value of this parameter is 1. |
| 4089 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4090 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4091 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4092 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 4093 | "Restrict virtual ports login to remote initiators."); |
| 4094 | lpfc_vport_param_show(restrict_login); |
| 4095 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4096 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4097 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4098 | * @vport: lpfc vport structure pointer. |
| 4099 | * @val: contains the restrict login value. |
| 4100 | * |
| 4101 | * Description: |
| 4102 | * If val is not in a valid range then log a kernel error message and set |
| 4103 | * the vport restrict login to one. |
| 4104 | * If the port type is physical clear the restrict login flag and return. |
| 4105 | * Else set the restrict login flag to val. |
| 4106 | * |
| 4107 | * Returns: |
| 4108 | * zero if val is in range |
| 4109 | * -EINVAL val out of range |
| 4110 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4111 | static int |
| 4112 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 4113 | { |
| 4114 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4115 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4116 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4117 | "be set to %d, allowed range is [0, 1]\n", |
| 4118 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4119 | vport->cfg_restrict_login = 1; |
| 4120 | return -EINVAL; |
| 4121 | } |
| 4122 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 4123 | vport->cfg_restrict_login = 0; |
| 4124 | return 0; |
| 4125 | } |
| 4126 | vport->cfg_restrict_login = val; |
| 4127 | return 0; |
| 4128 | } |
| 4129 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4130 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4131 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4132 | * @vport: lpfc vport structure pointer. |
| 4133 | * @val: contains the restrict login value. |
| 4134 | * |
| 4135 | * Description: |
| 4136 | * If val is not in a valid range then log a kernel error message and set |
| 4137 | * the vport restrict login to one. |
| 4138 | * If the port type is physical and the val is not zero log a kernel |
| 4139 | * error message, clear the restrict login flag and return zero. |
| 4140 | * Else set the restrict login flag to val. |
| 4141 | * |
| 4142 | * Returns: |
| 4143 | * zero if val is in range |
| 4144 | * -EINVAL val out of range |
| 4145 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4146 | static int |
| 4147 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 4148 | { |
| 4149 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4150 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4151 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4152 | "be set to %d, allowed range is [0, 1]\n", |
| 4153 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4154 | vport->cfg_restrict_login = 1; |
| 4155 | return -EINVAL; |
| 4156 | } |
| 4157 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4158 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4159 | "0468 lpfc_restrict_login must be 0 for " |
| 4160 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4161 | vport->cfg_restrict_login = 0; |
| 4162 | return 0; |
| 4163 | } |
| 4164 | vport->cfg_restrict_login = val; |
| 4165 | return 0; |
| 4166 | } |
| 4167 | lpfc_vport_param_store(restrict_login); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4168 | static DEVICE_ATTR_RW(lpfc_restrict_login); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4169 | |
| 4170 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4171 | # Some disk devices have a "select ID" or "select Target" capability. |
| 4172 | # From a protocol standpoint "select ID" usually means select the |
| 4173 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 4174 | # annex" which contains a table that maps a "select ID" (a number |
| 4175 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 4176 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 4177 | # ALPA. |
| 4178 | # |
| 4179 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 4180 | # cause the lpfc driver to use an inverted table, effectively |
| 4181 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 4182 | # |
| 4183 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 4184 | # and will not work across a fabric. Also this parameter will take |
| 4185 | # effect only in the case when ALPA map is not available.) |
| 4186 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4187 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 4188 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4189 | |
| 4190 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4191 | # lpfc_topology: link topology for init link |
| 4192 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 4193 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4194 | # 0x02 = attempt point-to-point mode only |
| 4195 | # 0x04 = attempt loop mode only |
| 4196 | # 0x06 = attempt point-to-point mode then loop |
| 4197 | # Set point-to-point mode if you want to run as an N_Port. |
| 4198 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 4199 | # Default value is 0. |
| 4200 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 4201 | LPFC_ATTR(topology, 0, 0, 6, |
| 4202 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4203 | |
| 4204 | /** |
Lee Jones | a3dbf51 | 2021-03-12 09:47:12 +0000 | [diff] [blame] | 4205 | * lpfc_topology_store - Set the adapters topology field |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 4206 | * @dev: class device that is converted into a scsi_host. |
| 4207 | * @attr:device attribute, not used. |
| 4208 | * @buf: buffer for passing information. |
| 4209 | * @count: size of the data buffer. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4210 | * |
| 4211 | * Description: |
| 4212 | * If val is in a valid range then set the adapter's topology field and |
| 4213 | * issue a lip; if the lip fails reset the topology to the old value. |
| 4214 | * |
| 4215 | * If the value is not in range log a kernel error message and return an error. |
| 4216 | * |
| 4217 | * Returns: |
| 4218 | * zero if val is in range and lip okay |
| 4219 | * non-zero return value from lpfc_issue_lip() |
| 4220 | * -EINVAL val out of range |
| 4221 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4222 | static ssize_t |
| 4223 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 4224 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4225 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4226 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4227 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4228 | struct lpfc_hba *phba = vport->phba; |
| 4229 | int val = 0; |
| 4230 | int nolip = 0; |
| 4231 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4232 | int err; |
| 4233 | uint32_t prev_val; |
James Smart | f6c5e6c | 2021-07-22 15:17:18 -0700 | [diff] [blame] | 4234 | u8 sli_family, if_type; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4235 | |
| 4236 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4237 | nolip = 1; |
| 4238 | val_buf = &buf[strlen("nolip ")]; |
| 4239 | } |
| 4240 | |
| 4241 | if (!isdigit(val_buf[0])) |
| 4242 | return -EINVAL; |
| 4243 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4244 | return -EINVAL; |
| 4245 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4246 | if (val >= 0 && val <= 6) { |
| 4247 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4248 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 4249 | val == 4) { |
| 4250 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4251 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4252 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4253 | return -EINVAL; |
| 4254 | } |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 4255 | /* |
| 4256 | * The 'topology' is not a configurable parameter if : |
| 4257 | * - persistent topology enabled |
James Smart | f6c5e6c | 2021-07-22 15:17:18 -0700 | [diff] [blame] | 4258 | * - ASIC_GEN_NUM >= 0xC, with no private loop support |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 4259 | */ |
James Smart | f6c5e6c | 2021-07-22 15:17:18 -0700 | [diff] [blame] | 4260 | sli_family = bf_get(lpfc_sli_intf_sli_family, |
| 4261 | &phba->sli4_hba.sli_intf); |
| 4262 | if_type = bf_get(lpfc_sli_intf_if_type, |
| 4263 | &phba->sli4_hba.sli_intf); |
James Smart | a052ce8 | 2019-12-18 15:58:04 -0800 | [diff] [blame] | 4264 | if ((phba->hba_flag & HBA_PERSISTENT_TOPO || |
James Smart | f6c5e6c | 2021-07-22 15:17:18 -0700 | [diff] [blame] | 4265 | (!phba->sli4_hba.pc_sli4_params.pls && |
| 4266 | (sli_family == LPFC_SLI_INTF_FAMILY_G6 || |
| 4267 | if_type == LPFC_SLI_INTF_IF_TYPE_6))) && |
James Smart | f6978f4 | 2019-05-21 17:48:57 -0700 | [diff] [blame] | 4268 | val == 4) { |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4269 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | f6978f4 | 2019-05-21 17:48:57 -0700 | [diff] [blame] | 4270 | "3114 Loop mode not supported\n"); |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4271 | return -EINVAL; |
| 4272 | } |
| 4273 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4274 | if (nolip) |
| 4275 | return strlen(buf); |
| 4276 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4277 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4278 | "3054 lpfc_topology changed from %d to %d\n", |
| 4279 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 4280 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 4281 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4282 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4283 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4284 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4285 | return -EINVAL; |
| 4286 | } else |
| 4287 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4288 | } |
| 4289 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4290 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 4291 | "allowed range is [0, 6]\n", |
| 4292 | phba->brd_no, val); |
| 4293 | return -EINVAL; |
| 4294 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 4295 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4296 | lpfc_param_show(topology) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4297 | static DEVICE_ATTR_RW(lpfc_topology); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4298 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4299 | /** |
| 4300 | * lpfc_static_vport_show: Read callback function for |
| 4301 | * lpfc_static_vport sysfs file. |
| 4302 | * @dev: Pointer to class device object. |
| 4303 | * @attr: device attribute structure. |
| 4304 | * @buf: Data buffer. |
| 4305 | * |
| 4306 | * This function is the read call back function for |
| 4307 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 4308 | * sysfs file report the mageability of the vport. |
| 4309 | **/ |
| 4310 | static ssize_t |
| 4311 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 4312 | char *buf) |
| 4313 | { |
| 4314 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4315 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4316 | if (vport->vport_flag & STATIC_VPORT) |
| 4317 | sprintf(buf, "1\n"); |
| 4318 | else |
| 4319 | sprintf(buf, "0\n"); |
| 4320 | |
| 4321 | return strlen(buf); |
| 4322 | } |
| 4323 | |
| 4324 | /* |
| 4325 | * Sysfs attribute to control the statistical data collection. |
| 4326 | */ |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 4327 | static DEVICE_ATTR_RO(lpfc_static_vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4328 | |
| 4329 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4330 | * 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] | 4331 | * @dev: Pointer to class device. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 4332 | * @attr: Unused. |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4333 | * @buf: Data buffer. |
| 4334 | * @count: Size of the data buffer. |
| 4335 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 4336 | * This function get called when a user write to the lpfc_stat_data_ctrl |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4337 | * sysfs file. This function parse the command written to the sysfs file |
| 4338 | * and take appropriate action. These commands are used for controlling |
| 4339 | * driver statistical data collection. |
| 4340 | * Following are the command this function handles. |
| 4341 | * |
| 4342 | * setbucket <bucket_type> <base> <step> |
| 4343 | * = Set the latency buckets. |
| 4344 | * destroybucket = destroy all the buckets. |
| 4345 | * start = start data collection |
| 4346 | * stop = stop data collection |
| 4347 | * reset = reset the collected data |
| 4348 | **/ |
| 4349 | static ssize_t |
| 4350 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 4351 | const char *buf, size_t count) |
| 4352 | { |
| 4353 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4354 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4355 | struct lpfc_hba *phba = vport->phba; |
| 4356 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 4357 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 4358 | unsigned long i; |
| 4359 | char *str_ptr, *token; |
| 4360 | struct lpfc_vport **vports; |
| 4361 | struct Scsi_Host *v_shost; |
| 4362 | char *bucket_type_str, *base_str, *step_str; |
| 4363 | unsigned long base, step, bucket_type; |
| 4364 | |
| 4365 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4366 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4367 | return -EINVAL; |
| 4368 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 4369 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4370 | str_ptr = &bucket_data[0]; |
| 4371 | /* Ignore this token - this is command token */ |
| 4372 | token = strsep(&str_ptr, "\t "); |
| 4373 | if (!token) |
| 4374 | return -EINVAL; |
| 4375 | |
| 4376 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 4377 | if (!bucket_type_str) |
| 4378 | return -EINVAL; |
| 4379 | |
| 4380 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 4381 | bucket_type = LPFC_LINEAR_BUCKET; |
| 4382 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 4383 | bucket_type = LPFC_POWER2_BUCKET; |
| 4384 | else |
| 4385 | return -EINVAL; |
| 4386 | |
| 4387 | base_str = strsep(&str_ptr, "\t "); |
| 4388 | if (!base_str) |
| 4389 | return -EINVAL; |
| 4390 | base = simple_strtoul(base_str, NULL, 0); |
| 4391 | |
| 4392 | step_str = strsep(&str_ptr, "\t "); |
| 4393 | if (!step_str) |
| 4394 | return -EINVAL; |
| 4395 | step = simple_strtoul(step_str, NULL, 0); |
| 4396 | if (!step) |
| 4397 | return -EINVAL; |
| 4398 | |
| 4399 | /* Block the data collection for every vport */ |
| 4400 | vports = lpfc_create_vport_work_array(phba); |
| 4401 | if (vports == NULL) |
| 4402 | return -ENOMEM; |
| 4403 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4404 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4405 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4406 | spin_lock_irq(v_shost->host_lock); |
| 4407 | /* Block and reset data collection */ |
| 4408 | vports[i]->stat_data_blocked = 1; |
| 4409 | if (vports[i]->stat_data_enabled) |
| 4410 | lpfc_vport_reset_stat_data(vports[i]); |
| 4411 | spin_unlock_irq(v_shost->host_lock); |
| 4412 | } |
| 4413 | |
| 4414 | /* Set the bucket attributes */ |
| 4415 | phba->bucket_type = bucket_type; |
| 4416 | phba->bucket_base = base; |
| 4417 | phba->bucket_step = step; |
| 4418 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4419 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4420 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4421 | |
| 4422 | /* Unblock data collection */ |
| 4423 | spin_lock_irq(v_shost->host_lock); |
| 4424 | vports[i]->stat_data_blocked = 0; |
| 4425 | spin_unlock_irq(v_shost->host_lock); |
| 4426 | } |
| 4427 | lpfc_destroy_vport_work_array(phba, vports); |
| 4428 | return strlen(buf); |
| 4429 | } |
| 4430 | |
| 4431 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 4432 | vports = lpfc_create_vport_work_array(phba); |
| 4433 | if (vports == NULL) |
| 4434 | return -ENOMEM; |
| 4435 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4436 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4437 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4438 | spin_lock_irq(shost->host_lock); |
| 4439 | vports[i]->stat_data_blocked = 1; |
| 4440 | lpfc_free_bucket(vport); |
| 4441 | vport->stat_data_enabled = 0; |
| 4442 | vports[i]->stat_data_blocked = 0; |
| 4443 | spin_unlock_irq(shost->host_lock); |
| 4444 | } |
| 4445 | lpfc_destroy_vport_work_array(phba, vports); |
| 4446 | phba->bucket_type = LPFC_NO_BUCKET; |
| 4447 | phba->bucket_base = 0; |
| 4448 | phba->bucket_step = 0; |
| 4449 | return strlen(buf); |
| 4450 | } |
| 4451 | |
| 4452 | if (!strncmp(buf, "start", strlen("start"))) { |
| 4453 | /* If no buckets configured return error */ |
| 4454 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 4455 | return -EINVAL; |
| 4456 | spin_lock_irq(shost->host_lock); |
| 4457 | if (vport->stat_data_enabled) { |
| 4458 | spin_unlock_irq(shost->host_lock); |
| 4459 | return strlen(buf); |
| 4460 | } |
| 4461 | lpfc_alloc_bucket(vport); |
| 4462 | vport->stat_data_enabled = 1; |
| 4463 | spin_unlock_irq(shost->host_lock); |
| 4464 | return strlen(buf); |
| 4465 | } |
| 4466 | |
| 4467 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 4468 | spin_lock_irq(shost->host_lock); |
| 4469 | if (vport->stat_data_enabled == 0) { |
| 4470 | spin_unlock_irq(shost->host_lock); |
| 4471 | return strlen(buf); |
| 4472 | } |
| 4473 | lpfc_free_bucket(vport); |
| 4474 | vport->stat_data_enabled = 0; |
| 4475 | spin_unlock_irq(shost->host_lock); |
| 4476 | return strlen(buf); |
| 4477 | } |
| 4478 | |
| 4479 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 4480 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 4481 | || !vport->stat_data_enabled) |
| 4482 | return strlen(buf); |
| 4483 | spin_lock_irq(shost->host_lock); |
| 4484 | vport->stat_data_blocked = 1; |
| 4485 | lpfc_vport_reset_stat_data(vport); |
| 4486 | vport->stat_data_blocked = 0; |
| 4487 | spin_unlock_irq(shost->host_lock); |
| 4488 | return strlen(buf); |
| 4489 | } |
| 4490 | return -EINVAL; |
| 4491 | } |
| 4492 | |
| 4493 | |
| 4494 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4495 | * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 4496 | * @dev: Pointer to class device. |
| 4497 | * @attr: Unused. |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4498 | * @buf: Data buffer. |
| 4499 | * |
| 4500 | * This function is the read call back function for |
| 4501 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 4502 | * current statistical data collection state. |
| 4503 | **/ |
| 4504 | static ssize_t |
| 4505 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 4506 | char *buf) |
| 4507 | { |
| 4508 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4509 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4510 | struct lpfc_hba *phba = vport->phba; |
| 4511 | int index = 0; |
| 4512 | int i; |
| 4513 | char *bucket_type; |
| 4514 | unsigned long bucket_value; |
| 4515 | |
| 4516 | switch (phba->bucket_type) { |
| 4517 | case LPFC_LINEAR_BUCKET: |
| 4518 | bucket_type = "linear"; |
| 4519 | break; |
| 4520 | case LPFC_POWER2_BUCKET: |
| 4521 | bucket_type = "power2"; |
| 4522 | break; |
| 4523 | default: |
| 4524 | bucket_type = "No Bucket"; |
| 4525 | break; |
| 4526 | } |
| 4527 | |
| 4528 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 4529 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 4530 | " Bucket step :%d\nLatency Ranges :", |
| 4531 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 4532 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 4533 | index = strlen(buf); |
| 4534 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 4535 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4536 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 4537 | bucket_value = phba->bucket_base + |
| 4538 | phba->bucket_step * i; |
| 4539 | else |
| 4540 | bucket_value = phba->bucket_base + |
| 4541 | (1 << i) * phba->bucket_step; |
| 4542 | |
| 4543 | if (index + 10 > PAGE_SIZE) |
| 4544 | break; |
| 4545 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 4546 | index = strlen(buf); |
| 4547 | } |
| 4548 | } |
| 4549 | sprintf(&buf[index], "\n"); |
| 4550 | return strlen(buf); |
| 4551 | } |
| 4552 | |
| 4553 | /* |
| 4554 | * Sysfs attribute to control the statistical data collection. |
| 4555 | */ |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4556 | static DEVICE_ATTR_RW(lpfc_stat_data_ctrl); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4557 | |
| 4558 | /* |
| 4559 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 4560 | */ |
| 4561 | |
| 4562 | /* |
| 4563 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 4564 | * for each target. |
| 4565 | */ |
| 4566 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 4567 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 4568 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 4569 | |
| 4570 | |
| 4571 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4572 | * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4573 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4574 | * @kobj: Pointer to the kernel object |
| 4575 | * @bin_attr: Attribute object |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 4576 | * @buf: Buffer pointer |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4577 | * @off: File offset |
| 4578 | * @count: Buffer size |
| 4579 | * |
| 4580 | * This function is the read call back function for lpfc_drvr_stat_data |
| 4581 | * sysfs file. This function export the statistical data to user |
| 4582 | * applications. |
| 4583 | **/ |
| 4584 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4585 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 4586 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4587 | char *buf, loff_t off, size_t count) |
| 4588 | { |
| 4589 | struct device *dev = container_of(kobj, struct device, |
| 4590 | kobj); |
| 4591 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4592 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4593 | struct lpfc_hba *phba = vport->phba; |
| 4594 | int i = 0, index = 0; |
| 4595 | unsigned long nport_index; |
| 4596 | struct lpfc_nodelist *ndlp = NULL; |
| 4597 | nport_index = (unsigned long)off / |
| 4598 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 4599 | |
| 4600 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 4601 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 4602 | return 0; |
| 4603 | |
| 4604 | spin_lock_irq(shost->host_lock); |
| 4605 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 4606 | if (!ndlp->lat_data) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4607 | continue; |
| 4608 | |
| 4609 | if (nport_index > 0) { |
| 4610 | nport_index--; |
| 4611 | continue; |
| 4612 | } |
| 4613 | |
| 4614 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 4615 | > count) |
| 4616 | break; |
| 4617 | |
| 4618 | if (!ndlp->lat_data) |
| 4619 | continue; |
| 4620 | |
| 4621 | /* Print the WWN */ |
| 4622 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 4623 | ndlp->nlp_portname.u.wwn[0], |
| 4624 | ndlp->nlp_portname.u.wwn[1], |
| 4625 | ndlp->nlp_portname.u.wwn[2], |
| 4626 | ndlp->nlp_portname.u.wwn[3], |
| 4627 | ndlp->nlp_portname.u.wwn[4], |
| 4628 | ndlp->nlp_portname.u.wwn[5], |
| 4629 | ndlp->nlp_portname.u.wwn[6], |
| 4630 | ndlp->nlp_portname.u.wwn[7]); |
| 4631 | |
| 4632 | index = strlen(buf); |
| 4633 | |
| 4634 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4635 | sprintf(&buf[index], "%010u,", |
| 4636 | ndlp->lat_data[i].cmd_count); |
| 4637 | index = strlen(buf); |
| 4638 | } |
| 4639 | sprintf(&buf[index], "\n"); |
| 4640 | index = strlen(buf); |
| 4641 | } |
| 4642 | spin_unlock_irq(shost->host_lock); |
| 4643 | return index; |
| 4644 | } |
| 4645 | |
| 4646 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4647 | .attr = { |
| 4648 | .name = "lpfc_drvr_stat_data", |
| 4649 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4650 | }, |
| 4651 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4652 | .read = sysfs_drvr_stat_data_read, |
| 4653 | .write = NULL, |
| 4654 | }; |
| 4655 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4656 | /* |
| 4657 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4658 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4659 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4660 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4661 | /** |
Lee Jones | a3dbf51 | 2021-03-12 09:47:12 +0000 | [diff] [blame] | 4662 | * lpfc_link_speed_store - Set the adapters link speed |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 4663 | * @dev: Pointer to class device. |
| 4664 | * @attr: Unused. |
| 4665 | * @buf: Data buffer. |
| 4666 | * @count: Size of the data buffer. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4667 | * |
| 4668 | * Description: |
| 4669 | * If val is in a valid range then set the adapter's link speed field and |
| 4670 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4671 | * |
| 4672 | * Notes: |
| 4673 | * If the value is not in range log a kernel error message and return an error. |
| 4674 | * |
| 4675 | * Returns: |
| 4676 | * zero if val is in range and lip okay. |
| 4677 | * non-zero return value from lpfc_issue_lip() |
| 4678 | * -EINVAL val out of range |
| 4679 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4680 | static ssize_t |
| 4681 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4682 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4683 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4684 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4685 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4686 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4687 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4688 | int nolip = 0; |
| 4689 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4690 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4691 | uint32_t prev_val, if_type; |
| 4692 | |
| 4693 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame] | 4694 | if (if_type >= LPFC_SLI_INTF_IF_TYPE_2 && |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4695 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4696 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4697 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4698 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4699 | nolip = 1; |
| 4700 | val_buf = &buf[strlen("nolip ")]; |
| 4701 | } |
| 4702 | |
| 4703 | if (!isdigit(val_buf[0])) |
| 4704 | return -EINVAL; |
| 4705 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4706 | return -EINVAL; |
| 4707 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4708 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4709 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4710 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4711 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4712 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4713 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4714 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4715 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4716 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4717 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4718 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) || |
| 4719 | ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4720 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4721 | "2879 lpfc_link_speed attribute cannot be set " |
| 4722 | "to %d. Speed is not supported by this port.\n", |
| 4723 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4724 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4725 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4726 | if (val >= LPFC_USER_LINK_SPEED_16G && |
| 4727 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4728 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4729 | "3112 lpfc_link_speed attribute cannot be set " |
| 4730 | "to %d. Speed is not supported in loop mode.\n", |
| 4731 | val); |
| 4732 | return -EINVAL; |
| 4733 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4734 | |
| 4735 | switch (val) { |
| 4736 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4737 | case LPFC_USER_LINK_SPEED_1G: |
| 4738 | case LPFC_USER_LINK_SPEED_2G: |
| 4739 | case LPFC_USER_LINK_SPEED_4G: |
| 4740 | case LPFC_USER_LINK_SPEED_8G: |
| 4741 | case LPFC_USER_LINK_SPEED_16G: |
| 4742 | case LPFC_USER_LINK_SPEED_32G: |
| 4743 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4744 | prev_val = phba->cfg_link_speed; |
| 4745 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4746 | if (nolip) |
| 4747 | return strlen(buf); |
| 4748 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4749 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4750 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4751 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4752 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4753 | } |
| 4754 | return strlen(buf); |
| 4755 | default: |
| 4756 | break; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4757 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4758 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4759 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4760 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4761 | "allowed values are [%s]\n", |
| 4762 | val, LPFC_LINK_SPEED_STRING); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4763 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4764 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4765 | } |
| 4766 | |
| 4767 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4768 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4769 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4770 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4771 | |
| 4772 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4773 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4774 | * @phba: lpfc_hba pointer. |
| 4775 | * @val: link speed value. |
| 4776 | * |
| 4777 | * Description: |
| 4778 | * If val is in a valid range then set the adapter's link speed field. |
| 4779 | * |
| 4780 | * Notes: |
| 4781 | * If the value is not in range log a kernel error message, clear the link |
| 4782 | * speed and return an error. |
| 4783 | * |
| 4784 | * Returns: |
| 4785 | * zero if val saved. |
| 4786 | * -EINVAL val out of range |
| 4787 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4788 | static int |
| 4789 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4790 | { |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4791 | if (val >= LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4792 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4793 | "3111 lpfc_link_speed of %d cannot " |
| 4794 | "support loop mode, setting topology to default.\n", |
| 4795 | val); |
| 4796 | phba->cfg_topology = 0; |
| 4797 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4798 | |
| 4799 | switch (val) { |
| 4800 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4801 | case LPFC_USER_LINK_SPEED_1G: |
| 4802 | case LPFC_USER_LINK_SPEED_2G: |
| 4803 | case LPFC_USER_LINK_SPEED_4G: |
| 4804 | case LPFC_USER_LINK_SPEED_8G: |
| 4805 | case LPFC_USER_LINK_SPEED_16G: |
| 4806 | case LPFC_USER_LINK_SPEED_32G: |
| 4807 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4808 | phba->cfg_link_speed = val; |
| 4809 | return 0; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4810 | default: |
| 4811 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4812 | "0405 lpfc_link_speed attribute cannot " |
| 4813 | "be set to %d, allowed values are " |
| 4814 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
| 4815 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
| 4816 | return -EINVAL; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4817 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4818 | } |
| 4819 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4820 | static DEVICE_ATTR_RW(lpfc_link_speed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4821 | |
| 4822 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4823 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4824 | # 0 = aer disabled or not supported |
| 4825 | # 1 = aer supported and enabled (default) |
| 4826 | # Value range is [0,1]. Default value is 1. |
| 4827 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4828 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4829 | "Enable PCIe device AER support"); |
| 4830 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4831 | |
| 4832 | /** |
| 4833 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4834 | * |
| 4835 | * @dev: class device that is converted into a Scsi_host. |
| 4836 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4837 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4838 | * @count: unused variable. |
| 4839 | * |
| 4840 | * Description: |
| 4841 | * If the val is 1 and currently the device's AER capability was not |
| 4842 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4843 | * enable the device's AER capability. If the helper routine enabling |
| 4844 | * AER returns success, update the device's cfg_aer_support flag to |
| 4845 | * indicate AER is supported by the device; otherwise, if the device |
| 4846 | * AER capability is already enabled to support AER, then do nothing. |
| 4847 | * |
| 4848 | * If the val is 0 and currently the device's AER support was enabled, |
| 4849 | * invoke the kernel's disable AER helper routine. After that, update |
| 4850 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4851 | * by the device; otherwise, if the device AER capability is already |
| 4852 | * disabled from supporting AER, then do nothing. |
| 4853 | * |
| 4854 | * Returns: |
| 4855 | * length of the buf on success if val is in range the intended mode |
| 4856 | * is supported. |
| 4857 | * -EINVAL if val out of range or intended mode is not supported. |
| 4858 | **/ |
| 4859 | static ssize_t |
| 4860 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4861 | const char *buf, size_t count) |
| 4862 | { |
| 4863 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4864 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4865 | struct lpfc_hba *phba = vport->phba; |
| 4866 | int val = 0, rc = -EINVAL; |
| 4867 | |
| 4868 | if (!isdigit(buf[0])) |
| 4869 | return -EINVAL; |
| 4870 | if (sscanf(buf, "%i", &val) != 1) |
| 4871 | return -EINVAL; |
| 4872 | |
| 4873 | switch (val) { |
| 4874 | case 0: |
| 4875 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4876 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4877 | if (!rc) { |
| 4878 | spin_lock_irq(&phba->hbalock); |
| 4879 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4880 | spin_unlock_irq(&phba->hbalock); |
| 4881 | phba->cfg_aer_support = 0; |
| 4882 | rc = strlen(buf); |
| 4883 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4884 | rc = -EPERM; |
| 4885 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4886 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4887 | rc = strlen(buf); |
| 4888 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4889 | break; |
| 4890 | case 1: |
| 4891 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4892 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4893 | if (!rc) { |
| 4894 | spin_lock_irq(&phba->hbalock); |
| 4895 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4896 | spin_unlock_irq(&phba->hbalock); |
| 4897 | phba->cfg_aer_support = 1; |
| 4898 | rc = strlen(buf); |
| 4899 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4900 | rc = -EPERM; |
| 4901 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4902 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4903 | rc = strlen(buf); |
| 4904 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4905 | break; |
| 4906 | default: |
| 4907 | rc = -EINVAL; |
| 4908 | break; |
| 4909 | } |
| 4910 | return rc; |
| 4911 | } |
| 4912 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4913 | static DEVICE_ATTR_RW(lpfc_aer_support); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4914 | |
| 4915 | /** |
| 4916 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4917 | * @dev: class device that is converted into a Scsi_host. |
| 4918 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4919 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4920 | * @count: unused variable. |
| 4921 | * |
| 4922 | * Description: |
| 4923 | * If the @buf contains 1 and the device currently has the AER support |
| 4924 | * enabled, then invokes the kernel AER helper routine |
Kuppuswamy Sathyanarayanan | 894020f | 2020-03-23 17:26:08 -0700 | [diff] [blame] | 4925 | * pci_aer_clear_nonfatal_status() to clean up the uncorrectable |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4926 | * error status register. |
| 4927 | * |
| 4928 | * Notes: |
| 4929 | * |
| 4930 | * Returns: |
| 4931 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4932 | * enabled with the AER support. |
| 4933 | **/ |
| 4934 | static ssize_t |
| 4935 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4936 | const char *buf, size_t count) |
| 4937 | { |
| 4938 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4939 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4940 | struct lpfc_hba *phba = vport->phba; |
| 4941 | int val, rc = -1; |
| 4942 | |
| 4943 | if (!isdigit(buf[0])) |
| 4944 | return -EINVAL; |
| 4945 | if (sscanf(buf, "%i", &val) != 1) |
| 4946 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4947 | if (val != 1) |
| 4948 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4949 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4950 | if (phba->hba_flag & HBA_AER_ENABLED) |
Kuppuswamy Sathyanarayanan | 894020f | 2020-03-23 17:26:08 -0700 | [diff] [blame] | 4951 | rc = pci_aer_clear_nonfatal_status(phba->pcidev); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4952 | |
| 4953 | if (rc == 0) |
| 4954 | return strlen(buf); |
| 4955 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4956 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4957 | } |
| 4958 | |
| 4959 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4960 | lpfc_aer_cleanup_state); |
| 4961 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4962 | /** |
| 4963 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4964 | * |
| 4965 | * @dev: class device that is converted into a Scsi_host. |
| 4966 | * @attr: device attribute, not used. |
| 4967 | * @buf: containing the string the number of vfs to be enabled. |
| 4968 | * @count: unused variable. |
| 4969 | * |
| 4970 | * Description: |
| 4971 | * When this api is called either through user sysfs, the driver shall |
| 4972 | * try to enable or disable SR-IOV virtual functions according to the |
| 4973 | * following: |
| 4974 | * |
| 4975 | * If zero virtual function has been enabled to the physical function, |
| 4976 | * the driver shall invoke the pci enable virtual function api trying |
| 4977 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4978 | * than the maximum supported, the maximum virtual function number will |
| 4979 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4980 | * be used for invoking the api. If the api call returned success, the |
| 4981 | * actual number of virtual functions enabled will be set to the driver |
| 4982 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4983 | * cfg_sriov_nr_virtfn remains zero. |
| 4984 | * |
| 4985 | * If none-zero virtual functions have already been enabled to the |
| 4986 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4987 | * -EINVAL will be returned and the driver does nothing; |
| 4988 | * |
| 4989 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4990 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4991 | * disabling virtual function api shall be invoded to disable all the |
| 4992 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4993 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4994 | * nothing. |
| 4995 | * |
| 4996 | * Returns: |
| 4997 | * length of the buf on success if val is in range the intended mode |
| 4998 | * is supported. |
| 4999 | * -EINVAL if val out of range or intended mode is not supported. |
| 5000 | **/ |
| 5001 | static ssize_t |
| 5002 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 5003 | const char *buf, size_t count) |
| 5004 | { |
| 5005 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5006 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5007 | struct lpfc_hba *phba = vport->phba; |
| 5008 | struct pci_dev *pdev = phba->pcidev; |
| 5009 | int val = 0, rc = -EINVAL; |
| 5010 | |
| 5011 | /* Sanity check on user data */ |
| 5012 | if (!isdigit(buf[0])) |
| 5013 | return -EINVAL; |
| 5014 | if (sscanf(buf, "%i", &val) != 1) |
| 5015 | return -EINVAL; |
| 5016 | if (val < 0) |
| 5017 | return -EINVAL; |
| 5018 | |
| 5019 | /* Request disabling virtual functions */ |
| 5020 | if (val == 0) { |
| 5021 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 5022 | pci_disable_sriov(pdev); |
| 5023 | phba->cfg_sriov_nr_virtfn = 0; |
| 5024 | } |
| 5025 | return strlen(buf); |
| 5026 | } |
| 5027 | |
| 5028 | /* Request enabling virtual functions */ |
| 5029 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 5030 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 5031 | "3018 There are %d virtual functions " |
| 5032 | "enabled on physical function.\n", |
| 5033 | phba->cfg_sriov_nr_virtfn); |
| 5034 | return -EEXIST; |
| 5035 | } |
| 5036 | |
| 5037 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 5038 | phba->cfg_sriov_nr_virtfn = val; |
| 5039 | else { |
| 5040 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 5041 | "3019 Enabling %d virtual functions is not " |
| 5042 | "allowed.\n", val); |
| 5043 | return -EINVAL; |
| 5044 | } |
| 5045 | |
| 5046 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 5047 | if (rc) { |
| 5048 | phba->cfg_sriov_nr_virtfn = 0; |
| 5049 | rc = -EPERM; |
| 5050 | } else |
| 5051 | rc = strlen(buf); |
| 5052 | |
| 5053 | return rc; |
| 5054 | } |
| 5055 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 5056 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 5057 | "Enable PCIe device SR-IOV virtual fn"); |
| 5058 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5059 | lpfc_param_show(sriov_nr_virtfn) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5060 | static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5061 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5062 | /** |
Lee Jones | a3dbf51 | 2021-03-12 09:47:12 +0000 | [diff] [blame] | 5063 | * lpfc_request_firmware_upgrade_store - Request for Linux generic firmware upgrade |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5064 | * |
| 5065 | * @dev: class device that is converted into a Scsi_host. |
| 5066 | * @attr: device attribute, not used. |
| 5067 | * @buf: containing the string the number of vfs to be enabled. |
| 5068 | * @count: unused variable. |
| 5069 | * |
| 5070 | * Description: |
| 5071 | * |
| 5072 | * Returns: |
| 5073 | * length of the buf on success if val is in range the intended mode |
| 5074 | * is supported. |
| 5075 | * -EINVAL if val out of range or intended mode is not supported. |
| 5076 | **/ |
| 5077 | static ssize_t |
| 5078 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 5079 | struct device_attribute *attr, |
| 5080 | const char *buf, size_t count) |
| 5081 | { |
| 5082 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5083 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5084 | struct lpfc_hba *phba = vport->phba; |
Colin Ian King | 6e27a86 | 2020-05-07 21:31:11 +0100 | [diff] [blame] | 5085 | int val = 0, rc; |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5086 | |
| 5087 | /* Sanity check on user data */ |
| 5088 | if (!isdigit(buf[0])) |
| 5089 | return -EINVAL; |
| 5090 | if (sscanf(buf, "%i", &val) != 1) |
| 5091 | return -EINVAL; |
| 5092 | if (val != 1) |
| 5093 | return -EINVAL; |
| 5094 | |
| 5095 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 5096 | if (rc) |
| 5097 | rc = -EPERM; |
| 5098 | else |
| 5099 | rc = strlen(buf); |
| 5100 | return rc; |
| 5101 | } |
| 5102 | |
| 5103 | static int lpfc_req_fw_upgrade; |
| 5104 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 5105 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 5106 | lpfc_param_show(request_firmware_upgrade) |
| 5107 | |
| 5108 | /** |
| 5109 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 5110 | * @phba: lpfc_hba pointer. |
| 5111 | * @val: 0 or 1. |
| 5112 | * |
| 5113 | * Description: |
| 5114 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 5115 | * |
| 5116 | * Returns: |
| 5117 | * zero if val saved. |
| 5118 | * -EINVAL val out of range |
| 5119 | **/ |
| 5120 | static int |
| 5121 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 5122 | { |
| 5123 | if (val >= 0 && val <= 1) { |
| 5124 | phba->cfg_request_firmware_upgrade = val; |
| 5125 | return 0; |
| 5126 | } |
| 5127 | return -EINVAL; |
| 5128 | } |
| 5129 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 5130 | lpfc_request_firmware_upgrade_show, |
| 5131 | lpfc_request_firmware_upgrade_store); |
| 5132 | |
| 5133 | /** |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 5134 | * lpfc_force_rscn_store |
| 5135 | * |
| 5136 | * @dev: class device that is converted into a Scsi_host. |
| 5137 | * @attr: device attribute, not used. |
| 5138 | * @buf: unused string |
| 5139 | * @count: unused variable. |
| 5140 | * |
| 5141 | * Description: |
| 5142 | * Force the switch to send a RSCN to all other NPorts in our zone |
| 5143 | * If we are direct connect pt2pt, build the RSCN command ourself |
| 5144 | * and send to the other NPort. Not supported for private loop. |
| 5145 | * |
| 5146 | * Returns: |
| 5147 | * 0 - on success |
| 5148 | * -EIO - if command is not sent |
| 5149 | **/ |
| 5150 | static ssize_t |
| 5151 | lpfc_force_rscn_store(struct device *dev, struct device_attribute *attr, |
| 5152 | const char *buf, size_t count) |
| 5153 | { |
| 5154 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5155 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5156 | int i; |
| 5157 | |
| 5158 | i = lpfc_issue_els_rscn(vport, 0); |
| 5159 | if (i) |
| 5160 | return -EIO; |
| 5161 | return strlen(buf); |
| 5162 | } |
| 5163 | |
| 5164 | /* |
| 5165 | * lpfc_force_rscn: Force an RSCN to be sent to all remote NPorts |
| 5166 | * connected to the HBA. |
| 5167 | * |
| 5168 | * Value range is any ascii value |
| 5169 | */ |
| 5170 | static int lpfc_force_rscn; |
| 5171 | module_param(lpfc_force_rscn, int, 0644); |
| 5172 | MODULE_PARM_DESC(lpfc_force_rscn, |
| 5173 | "Force an RSCN to be sent to all remote NPorts"); |
| 5174 | lpfc_param_show(force_rscn) |
| 5175 | |
| 5176 | /** |
| 5177 | * lpfc_force_rscn_init - Force an RSCN to be sent to all remote NPorts |
| 5178 | * @phba: lpfc_hba pointer. |
| 5179 | * @val: unused value. |
| 5180 | * |
| 5181 | * Returns: |
| 5182 | * zero if val saved. |
| 5183 | **/ |
| 5184 | static int |
| 5185 | lpfc_force_rscn_init(struct lpfc_hba *phba, int val) |
| 5186 | { |
| 5187 | return 0; |
| 5188 | } |
| 5189 | static DEVICE_ATTR_RW(lpfc_force_rscn); |
| 5190 | |
| 5191 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5192 | * lpfc_fcp_imax_store |
| 5193 | * |
| 5194 | * @dev: class device that is converted into a Scsi_host. |
| 5195 | * @attr: device attribute, not used. |
| 5196 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 5197 | * @count: unused variable. |
| 5198 | * |
| 5199 | * Description: |
| 5200 | * If val is in a valid range [636,651042], then set the adapter's |
| 5201 | * maximum number of fast-path FCP interrupts per second. |
| 5202 | * |
| 5203 | * Returns: |
| 5204 | * length of the buf on success if val is in range the intended mode |
| 5205 | * is supported. |
| 5206 | * -EINVAL if val out of range or intended mode is not supported. |
| 5207 | **/ |
| 5208 | static ssize_t |
| 5209 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 5210 | const char *buf, size_t count) |
| 5211 | { |
| 5212 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5213 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5214 | struct lpfc_hba *phba = vport->phba; |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5215 | struct lpfc_eq_intr_info *eqi; |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5216 | uint32_t usdelay; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5217 | int val = 0, i; |
| 5218 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5219 | /* fcp_imax is only valid for SLI4 */ |
| 5220 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5221 | return -EINVAL; |
| 5222 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5223 | /* Sanity check on user data */ |
| 5224 | if (!isdigit(buf[0])) |
| 5225 | return -EINVAL; |
| 5226 | if (sscanf(buf, "%i", &val) != 1) |
| 5227 | return -EINVAL; |
| 5228 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5229 | /* |
| 5230 | * Value range for the HBA is [5000,5000000] |
| 5231 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5232 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5233 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5234 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5235 | return -EINVAL; |
| 5236 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5237 | phba->cfg_auto_imax = (val) ? 0 : 1; |
| 5238 | if (phba->cfg_fcp_imax && !val) { |
| 5239 | queue_delayed_work(phba->wq, &phba->eq_delay_work, |
| 5240 | msecs_to_jiffies(LPFC_EQ_DELAY_MSECS)); |
| 5241 | |
| 5242 | for_each_present_cpu(i) { |
| 5243 | eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); |
| 5244 | eqi->icnt = 0; |
| 5245 | } |
| 5246 | } |
| 5247 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5248 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 5249 | |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5250 | if (phba->cfg_fcp_imax) |
| 5251 | usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; |
| 5252 | else |
| 5253 | usdelay = 0; |
| 5254 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5255 | for (i = 0; i < phba->cfg_irq_chann; i += LPFC_MAX_EQ_DELAY_EQID_CNT) |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5256 | lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT, |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5257 | usdelay); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5258 | |
| 5259 | return strlen(buf); |
| 5260 | } |
| 5261 | |
| 5262 | /* |
| 5263 | # lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5264 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5265 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5266 | # Value range is [5,000 to 5,000,000]. Default value is 50,000. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5267 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5268 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5269 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 5270 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5271 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5272 | lpfc_param_show(fcp_imax) |
| 5273 | |
| 5274 | /** |
| 5275 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 5276 | * @phba: lpfc_hba pointer. |
| 5277 | * @val: link speed value. |
| 5278 | * |
| 5279 | * Description: |
| 5280 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 5281 | * maximum number of fast-path FCP interrupts per second. |
| 5282 | * |
| 5283 | * Returns: |
| 5284 | * zero if val saved. |
| 5285 | * -EINVAL val out of range |
| 5286 | **/ |
| 5287 | static int |
| 5288 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 5289 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5290 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5291 | phba->cfg_fcp_imax = 0; |
| 5292 | return 0; |
| 5293 | } |
| 5294 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5295 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 5296 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5297 | phba->cfg_fcp_imax = val; |
| 5298 | return 0; |
| 5299 | } |
| 5300 | |
| 5301 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5302 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 5303 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5304 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5305 | |
| 5306 | return 0; |
| 5307 | } |
| 5308 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5309 | static DEVICE_ATTR_RW(lpfc_fcp_imax); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5310 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5311 | /** |
| 5312 | * lpfc_cq_max_proc_limit_store |
| 5313 | * |
| 5314 | * @dev: class device that is converted into a Scsi_host. |
| 5315 | * @attr: device attribute, not used. |
| 5316 | * @buf: string with the cq max processing limit of cqes |
| 5317 | * @count: unused variable. |
| 5318 | * |
| 5319 | * Description: |
| 5320 | * If val is in a valid range, then set value on each cq |
| 5321 | * |
| 5322 | * Returns: |
| 5323 | * The length of the buf: if successful |
| 5324 | * -ERANGE: if val is not in the valid range |
| 5325 | * -EINVAL: if bad value format or intended mode is not supported. |
| 5326 | **/ |
| 5327 | static ssize_t |
| 5328 | lpfc_cq_max_proc_limit_store(struct device *dev, struct device_attribute *attr, |
| 5329 | const char *buf, size_t count) |
| 5330 | { |
| 5331 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5332 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5333 | struct lpfc_hba *phba = vport->phba; |
| 5334 | struct lpfc_queue *eq, *cq; |
| 5335 | unsigned long val; |
| 5336 | int i; |
| 5337 | |
| 5338 | /* cq_max_proc_limit is only valid for SLI4 */ |
| 5339 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5340 | return -EINVAL; |
| 5341 | |
| 5342 | /* Sanity check on user data */ |
| 5343 | if (!isdigit(buf[0])) |
| 5344 | return -EINVAL; |
| 5345 | if (kstrtoul(buf, 0, &val)) |
| 5346 | return -EINVAL; |
| 5347 | |
| 5348 | if (val < LPFC_CQ_MIN_PROC_LIMIT || val > LPFC_CQ_MAX_PROC_LIMIT) |
| 5349 | return -ERANGE; |
| 5350 | |
| 5351 | phba->cfg_cq_max_proc_limit = (uint32_t)val; |
| 5352 | |
| 5353 | /* set the values on the cq's */ |
| 5354 | for (i = 0; i < phba->cfg_irq_chann; i++) { |
James Smart | 657add4 | 2019-05-21 17:49:06 -0700 | [diff] [blame] | 5355 | /* Get the EQ corresponding to the IRQ vector */ |
| 5356 | eq = phba->sli4_hba.hba_eq_hdl[i].eq; |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5357 | if (!eq) |
| 5358 | continue; |
| 5359 | |
| 5360 | list_for_each_entry(cq, &eq->child_list, list) |
| 5361 | cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, |
| 5362 | cq->entry_count); |
| 5363 | } |
| 5364 | |
| 5365 | return strlen(buf); |
| 5366 | } |
| 5367 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5368 | /* |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5369 | * lpfc_cq_max_proc_limit: The maximum number CQE entries processed in an |
| 5370 | * itteration of CQ processing. |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5371 | */ |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5372 | static int lpfc_cq_max_proc_limit = LPFC_CQ_DEF_MAX_PROC_LIMIT; |
| 5373 | module_param(lpfc_cq_max_proc_limit, int, 0644); |
| 5374 | MODULE_PARM_DESC(lpfc_cq_max_proc_limit, |
| 5375 | "Set the maximum number CQEs processed in an iteration of " |
| 5376 | "CQ processing"); |
| 5377 | lpfc_param_show(cq_max_proc_limit) |
| 5378 | |
| 5379 | /* |
| 5380 | * lpfc_cq_poll_threshold: Set the threshold of CQE completions in a |
| 5381 | * single handler call which should request a polled completion rather |
| 5382 | * than re-enabling interrupts. |
| 5383 | */ |
| 5384 | LPFC_ATTR_RW(cq_poll_threshold, LPFC_CQ_DEF_THRESHOLD_TO_POLL, |
| 5385 | LPFC_CQ_MIN_THRESHOLD_TO_POLL, |
| 5386 | LPFC_CQ_MAX_THRESHOLD_TO_POLL, |
| 5387 | "CQE Processing Threshold to enable Polling"); |
| 5388 | |
| 5389 | /** |
| 5390 | * lpfc_cq_max_proc_limit_init - Set the initial cq max_proc_limit |
| 5391 | * @phba: lpfc_hba pointer. |
| 5392 | * @val: entry limit |
| 5393 | * |
| 5394 | * Description: |
| 5395 | * If val is in a valid range, then initialize the adapter's maximum |
| 5396 | * value. |
| 5397 | * |
| 5398 | * Returns: |
| 5399 | * Always returns 0 for success, even if value not always set to |
| 5400 | * requested value. If value out of range or not supported, will fall |
| 5401 | * back to default. |
| 5402 | **/ |
| 5403 | static int |
| 5404 | lpfc_cq_max_proc_limit_init(struct lpfc_hba *phba, int val) |
| 5405 | { |
| 5406 | phba->cfg_cq_max_proc_limit = LPFC_CQ_DEF_MAX_PROC_LIMIT; |
| 5407 | |
| 5408 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5409 | return 0; |
| 5410 | |
| 5411 | if (val >= LPFC_CQ_MIN_PROC_LIMIT && val <= LPFC_CQ_MAX_PROC_LIMIT) { |
| 5412 | phba->cfg_cq_max_proc_limit = val; |
| 5413 | return 0; |
| 5414 | } |
| 5415 | |
| 5416 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 5b1f508 | 2021-04-11 18:31:25 -0700 | [diff] [blame] | 5417 | "0371 lpfc_cq_max_proc_limit: %d out of range, using " |
| 5418 | "default\n", |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5419 | phba->cfg_cq_max_proc_limit); |
| 5420 | |
| 5421 | return 0; |
| 5422 | } |
| 5423 | |
| 5424 | static DEVICE_ATTR_RW(lpfc_cq_max_proc_limit); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5425 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5426 | /** |
Lee Jones | a3dbf51 | 2021-03-12 09:47:12 +0000 | [diff] [blame] | 5427 | * lpfc_fcp_cpu_map_show - Display current driver CPU affinity |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5428 | * @dev: class converted to a Scsi_host structure. |
| 5429 | * @attr: device attribute, not used. |
| 5430 | * @buf: on return contains text describing the state of the link. |
| 5431 | * |
| 5432 | * Returns: size of formatted string. |
| 5433 | **/ |
| 5434 | static ssize_t |
| 5435 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 5436 | char *buf) |
| 5437 | { |
| 5438 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5439 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5440 | struct lpfc_hba *phba = vport->phba; |
| 5441 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5442 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5443 | |
| 5444 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 5445 | (phba->intr_type != MSIX)) |
| 5446 | return len; |
| 5447 | |
| 5448 | switch (phba->cfg_fcp_cpu_map) { |
| 5449 | case 0: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5450 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5451 | "fcp_cpu_map: No mapping (%d)\n", |
| 5452 | phba->cfg_fcp_cpu_map); |
| 5453 | return len; |
| 5454 | case 1: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5455 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5456 | "fcp_cpu_map: HBA centric mapping (%d): " |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5457 | "%d of %d CPUs online from %d possible CPUs\n", |
| 5458 | phba->cfg_fcp_cpu_map, num_online_cpus(), |
| 5459 | num_present_cpus(), |
| 5460 | phba->sli4_hba.num_possible_cpu); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5461 | break; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5462 | } |
| 5463 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5464 | while (phba->sli4_hba.curr_disp_cpu < |
| 5465 | phba->sli4_hba.num_possible_cpu) { |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5466 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 5467 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5468 | if (!cpu_present(phba->sli4_hba.curr_disp_cpu)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5469 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5470 | "CPU %02d not present\n", |
| 5471 | phba->sli4_hba.curr_disp_cpu); |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5472 | else if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5473 | if (cpup->hdwq == LPFC_VECTOR_MAP_EMPTY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5474 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5475 | buf + len, PAGE_SIZE - len, |
| 5476 | "CPU %02d hdwq None " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5477 | "physid %d coreid %d ht %d ua %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5478 | phba->sli4_hba.curr_disp_cpu, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5479 | cpup->phys_id, cpup->core_id, |
| 5480 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5481 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5482 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5483 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5484 | buf + len, PAGE_SIZE - len, |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5485 | "CPU %02d EQ None hdwq %04d " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5486 | "physid %d coreid %d ht %d ua %d\n", |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5487 | phba->sli4_hba.curr_disp_cpu, |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5488 | cpup->hdwq, cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5489 | cpup->core_id, |
| 5490 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5491 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5492 | } else { |
| 5493 | if (cpup->hdwq == LPFC_VECTOR_MAP_EMPTY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5494 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5495 | buf + len, PAGE_SIZE - len, |
| 5496 | "CPU %02d hdwq None " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5497 | "physid %d coreid %d ht %d ua %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5498 | phba->sli4_hba.curr_disp_cpu, |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5499 | cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5500 | cpup->core_id, |
| 5501 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5502 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN), |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5503 | lpfc_get_irq(cpup->eq)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5504 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5505 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5506 | buf + len, PAGE_SIZE - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5507 | "CPU %02d EQ %04d hdwq %04d " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5508 | "physid %d coreid %d ht %d ua %d IRQ %d\n", |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5509 | phba->sli4_hba.curr_disp_cpu, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5510 | cpup->eq, cpup->hdwq, cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5511 | cpup->core_id, |
| 5512 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5513 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN), |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5514 | lpfc_get_irq(cpup->eq)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5515 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5516 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5517 | phba->sli4_hba.curr_disp_cpu++; |
| 5518 | |
| 5519 | /* display max number of CPUs keeping some margin */ |
| 5520 | if (phba->sli4_hba.curr_disp_cpu < |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5521 | phba->sli4_hba.num_possible_cpu && |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5522 | (len >= (PAGE_SIZE - 64))) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5523 | len += scnprintf(buf + len, |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5524 | PAGE_SIZE - len, "more...\n"); |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5525 | break; |
| 5526 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5527 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5528 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5529 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_possible_cpu) |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5530 | phba->sli4_hba.curr_disp_cpu = 0; |
| 5531 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5532 | return len; |
| 5533 | } |
| 5534 | |
| 5535 | /** |
| 5536 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 5537 | * @dev: class device that is converted into a Scsi_host. |
| 5538 | * @attr: device attribute, not used. |
| 5539 | * @buf: one or more lpfc_polling_flags values. |
| 5540 | * @count: not used. |
| 5541 | * |
| 5542 | * Returns: |
| 5543 | * -EINVAL - Not implemented yet. |
| 5544 | **/ |
| 5545 | static ssize_t |
| 5546 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 5547 | const char *buf, size_t count) |
| 5548 | { |
Ye Bin | 37fa429 | 2020-09-16 10:28:59 +0800 | [diff] [blame] | 5549 | return -EINVAL; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5550 | } |
| 5551 | |
| 5552 | /* |
| 5553 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 5554 | # for the HBA. |
| 5555 | # |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5556 | # Value range is [0 to 1]. Default value is LPFC_HBA_CPU_MAP (1). |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5557 | # 0 - Do not affinitze IRQ vectors |
| 5558 | # 1 - Affintize HBA vectors with respect to each HBA |
| 5559 | # (start with CPU0 for each HBA) |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5560 | # This also defines how Hardware Queues are mapped to specific CPUs. |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5561 | */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5562 | static int lpfc_fcp_cpu_map = LPFC_HBA_CPU_MAP; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5563 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 5564 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 5565 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 5566 | |
| 5567 | /** |
| 5568 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 5569 | * @phba: lpfc_hba pointer. |
| 5570 | * @val: link speed value. |
| 5571 | * |
| 5572 | * Description: |
| 5573 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 5574 | * MSIX vectors. |
| 5575 | * |
| 5576 | * Returns: |
| 5577 | * zero if val saved. |
| 5578 | * -EINVAL val out of range |
| 5579 | **/ |
| 5580 | static int |
| 5581 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 5582 | { |
| 5583 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5584 | phba->cfg_fcp_cpu_map = 0; |
| 5585 | return 0; |
| 5586 | } |
| 5587 | |
| 5588 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 5589 | phba->cfg_fcp_cpu_map = val; |
| 5590 | return 0; |
| 5591 | } |
| 5592 | |
| 5593 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5594 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 5595 | "default\n", val); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5596 | phba->cfg_fcp_cpu_map = LPFC_HBA_CPU_MAP; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5597 | |
| 5598 | return 0; |
| 5599 | } |
| 5600 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5601 | static DEVICE_ATTR_RW(lpfc_fcp_cpu_map); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5602 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5603 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5604 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 5605 | # Value range is [2,3]. Default value is 3. |
| 5606 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5607 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 5608 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5609 | |
| 5610 | /* |
| 5611 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
James Smart | 816bd88 | 2021-07-07 11:43:45 -0700 | [diff] [blame] | 5612 | # is [0,1]. Default value is 1. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5613 | */ |
James Smart | 816bd88 | 2021-07-07 11:43:45 -0700 | [diff] [blame] | 5614 | LPFC_VPORT_ATTR_RW(use_adisc, 1, 0, 1, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5615 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5616 | |
| 5617 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5618 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 5619 | # that support first burst. |
| 5620 | # Value range is [0,65536]. Default value is 0. |
| 5621 | */ |
| 5622 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 5623 | "First burst size for Targets that support first burst"); |
| 5624 | |
| 5625 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5626 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 5627 | * When the driver is configured as an NVME target, this value is |
| 5628 | * communicated to the NVME initiator in the PRLI response. It is |
| 5629 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 5630 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5631 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5632 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5633 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5634 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 5635 | "NVME Target mode first burst size in 512B increments."); |
| 5636 | |
| 5637 | /* |
| 5638 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 5639 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 5640 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
James Smart | db197bc | 2019-08-14 16:57:03 -0700 | [diff] [blame] | 5641 | * processed by the initiator for subsequent NVME FCP IO. |
| 5642 | * Currently, this feature is not supported on the NVME target |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5643 | * Value range is [0,1]. Default value is 0 (disabled). |
| 5644 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5645 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
James Smart | db197bc | 2019-08-14 16:57:03 -0700 | [diff] [blame] | 5646 | "Enable First Burst feature for NVME Initiator."); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5647 | |
| 5648 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5649 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 5650 | # depth. Default value is 0. When the value of this parameter is zero the |
| 5651 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 5652 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 5653 | # to limit the I/O completion time to the parameter value. |
| 5654 | # The value is set in milliseconds. |
| 5655 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5656 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5657 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5658 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5659 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5660 | static int |
| 5661 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 5662 | { |
| 5663 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5664 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 5665 | |
| 5666 | if (val == vport->cfg_max_scsicmpl_time) |
| 5667 | return 0; |
| 5668 | if ((val < 0) || (val > 60000)) |
| 5669 | return -EINVAL; |
| 5670 | vport->cfg_max_scsicmpl_time = val; |
| 5671 | |
| 5672 | spin_lock_irq(shost->host_lock); |
| 5673 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5674 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 5675 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5676 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5677 | } |
| 5678 | spin_unlock_irq(shost->host_lock); |
| 5679 | return 0; |
| 5680 | } |
| 5681 | lpfc_vport_param_store(max_scsicmpl_time); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5682 | static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5683 | |
| 5684 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5685 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 5686 | # range is [0,1]. Default value is 0. |
| 5687 | */ |
| 5688 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 5689 | |
| 5690 | /* |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 5691 | # lpfc_xri_rebalancing: enable or disable XRI rebalancing feature |
| 5692 | # range is [0,1]. Default value is 1. |
| 5693 | */ |
| 5694 | LPFC_ATTR_R(xri_rebalancing, 1, 0, 1, "Enable/Disable XRI rebalancing"); |
| 5695 | |
| 5696 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5697 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 5698 | * range is [0,1]. Default value is 0. |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5699 | * For [0], FCP commands are issued to Work Queues based on upper layer |
| 5700 | * hardware queue index. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5701 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 5702 | * current CPU. |
| 5703 | * |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5704 | * LPFC_FCP_SCHED_BY_HDWQ == 0 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5705 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 5706 | * |
| 5707 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 5708 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 5709 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 5710 | * through WQs will be used. |
| 5711 | */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5712 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_BY_CPU, |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5713 | LPFC_FCP_SCHED_BY_HDWQ, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5714 | LPFC_FCP_SCHED_BY_CPU, |
| 5715 | "Determine scheduling algorithm for " |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5716 | "issuing commands [0] - Hardware Queue, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5717 | |
| 5718 | /* |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 5719 | * lpfc_ns_query: Determine algrithmn for NameServer queries after RSCN |
| 5720 | * range is [0,1]. Default value is 0. |
| 5721 | * For [0], GID_FT is used for NameServer queries after RSCN (default) |
| 5722 | * For [1], GID_PT is used for NameServer queries after RSCN |
| 5723 | * |
| 5724 | */ |
| 5725 | LPFC_ATTR_RW(ns_query, LPFC_NS_QUERY_GID_FT, |
| 5726 | LPFC_NS_QUERY_GID_FT, LPFC_NS_QUERY_GID_PT, |
| 5727 | "Determine algorithm NameServer queries after RSCN " |
| 5728 | "[0] - GID_FT, [1] - GID_PT"); |
| 5729 | |
| 5730 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5731 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 5732 | # range is [0,1]. Default value is 0. |
| 5733 | # For [0], bus reset issues target reset to ALL devices |
| 5734 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 5735 | */ |
| 5736 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 5737 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 5738 | |
| 5739 | |
| 5740 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5741 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 5742 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5743 | # 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] | 5744 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 5745 | # cr_delay is set to 0. |
| 5746 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5747 | 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] | 5748 | "interrupt response is generated"); |
| 5749 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5750 | 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] | 5751 | "interrupt response is generated"); |
| 5752 | |
| 5753 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5754 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 5755 | # cmd/rsp IOCB entries across. |
| 5756 | # Value range is [1,2]. Default value is 1. |
| 5757 | */ |
| 5758 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 5759 | "SLI rings to spread IOCB entries across"); |
| 5760 | |
| 5761 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5762 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 5763 | # identifies what rctl value to configure the additional ring for. |
| 5764 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 5765 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5766 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5767 | 255, "Identifies RCTL for additional ring configuration"); |
| 5768 | |
| 5769 | /* |
| 5770 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 5771 | # identifies what type value to configure the additional ring for. |
| 5772 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 5773 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5774 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5775 | 255, "Identifies TYPE for additional ring configuration"); |
| 5776 | |
| 5777 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5778 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 5779 | # 0 = SmartSAN functionality disabled (default) |
| 5780 | # 1 = SmartSAN functionality enabled |
| 5781 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 5782 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5783 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5784 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 5785 | |
| 5786 | /* |
| 5787 | # lpfc_fdmi_on: Controls FDMI support. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5788 | # 0 No FDMI support |
| 5789 | # 1 Traditional FDMI support (default) |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 5790 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 5791 | # however, if that fails, it will fallback to FDMI-1. |
| 5792 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 5793 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 5794 | # lpfc_fdmi_on. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5795 | # Value range [0,1]. Default value is 1. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5796 | */ |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5797 | LPFC_ATTR_R(fdmi_on, 1, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5798 | |
| 5799 | /* |
| 5800 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 5801 | # discovery). Value range is [1,64]. Default value = 32. |
| 5802 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5803 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5804 | "during discovery"); |
| 5805 | |
| 5806 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 5807 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 5808 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 5809 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 5810 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 5811 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 5812 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 5813 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 5814 | # on a target can take minutes of wall clock time. Additionally, |
| 5815 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 5816 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 5817 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 5818 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 5819 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 5820 | # devices present, when in fact, there is only 1. |
| 5821 | # A customer that is aware of their target behaviors, and the results as |
| 5822 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 5823 | # As mentioned, this value is not used by the lpfc driver, only the |
| 5824 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 5825 | # Value range is [0,65535]. Default value is 255. |
| 5826 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5827 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 5828 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5829 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5830 | /* |
| 5831 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 5832 | # Value range is [1,255], default value is 10. |
| 5833 | */ |
| 5834 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 5835 | "Milliseconds driver will wait between polling FCP ring"); |
| 5836 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5837 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5838 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 5839 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 5840 | */ |
| 5841 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 5842 | "Maximum time to wait for task management commands to complete"); |
| 5843 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5844 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 5845 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5846 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5847 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5848 | # 2 = MSI-X enabled (default) |
| 5849 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5850 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5851 | LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or " |
James Smart | db2378e | 2008-02-08 18:49:51 -0500 | [diff] [blame] | 5852 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5853 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5854 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5855 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5856 | * |
| 5857 | * 0 = NVME OAS disabled |
| 5858 | * 1 = NVME OAS enabled |
| 5859 | * |
| 5860 | * Value range is [0,1]. Default value is 0. |
| 5861 | */ |
| 5862 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 5863 | "Use OAS bit on NVME IOs"); |
| 5864 | |
| 5865 | /* |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5866 | * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs |
| 5867 | * |
| 5868 | * 0 = Put NVME Command in SGL |
| 5869 | * 1 = Embed NVME Command in WQE (unless G7) |
| 5870 | * 2 = Embed NVME Command in WQE (force) |
| 5871 | * |
| 5872 | * Value range is [0,2]. Default value is 1. |
| 5873 | */ |
| 5874 | LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2, |
| 5875 | "Embed NVME Command in WQE"); |
| 5876 | |
| 5877 | /* |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5878 | * lpfc_fcp_mq_threshold: Set the maximum number of Hardware Queues |
| 5879 | * the driver will advertise it supports to the SCSI layer. |
| 5880 | * |
| 5881 | * 0 = Set nr_hw_queues by the number of CPUs or HW queues. |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5882 | * 1,256 = Manually specify nr_hw_queue value to be advertised, |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5883 | * |
James Smart | 0622800 | 2019-08-27 14:28:23 -0700 | [diff] [blame] | 5884 | * Value range is [0,256]. Default value is 8. |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5885 | */ |
| 5886 | LPFC_ATTR_R(fcp_mq_threshold, LPFC_FCP_MQ_THRESHOLD_DEF, |
| 5887 | LPFC_FCP_MQ_THRESHOLD_MIN, LPFC_FCP_MQ_THRESHOLD_MAX, |
| 5888 | "Set the number of SCSI Queues advertised"); |
| 5889 | |
| 5890 | /* |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5891 | * lpfc_hdw_queue: Set the number of Hardware Queues the driver |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5892 | * will advertise it supports to the NVME and SCSI layers. This also |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5893 | * will map to the number of CQ/WQ pairs the driver will create. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5894 | * |
| 5895 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5896 | * hardware queue. The administrative queue will always map to WQ 0 |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5897 | * A hardware IO queue maps (qidx) to a specific driver CQ/WQ. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5898 | * |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5899 | * 0 = Configure the number of hdw queues to the number of active CPUs. |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5900 | * 1,256 = Manually specify how many hdw queues to use. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5901 | * |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5902 | * Value range is [0,256]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5903 | */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5904 | LPFC_ATTR_R(hdw_queue, |
| 5905 | LPFC_HBA_HDWQ_DEF, |
| 5906 | LPFC_HBA_HDWQ_MIN, LPFC_HBA_HDWQ_MAX, |
| 5907 | "Set the number of I/O Hardware Queues"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5908 | |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 5909 | #if IS_ENABLED(CONFIG_X86) |
| 5910 | /** |
| 5911 | * lpfc_cpumask_irq_mode_init - initalizes cpumask of phba based on |
| 5912 | * irq_chann_mode |
| 5913 | * @phba: Pointer to HBA context object. |
| 5914 | **/ |
| 5915 | static void |
| 5916 | lpfc_cpumask_irq_mode_init(struct lpfc_hba *phba) |
| 5917 | { |
| 5918 | unsigned int cpu, first_cpu, numa_node = NUMA_NO_NODE; |
| 5919 | const struct cpumask *sibling_mask; |
| 5920 | struct cpumask *aff_mask = &phba->sli4_hba.irq_aff_mask; |
| 5921 | |
| 5922 | cpumask_clear(aff_mask); |
| 5923 | |
| 5924 | if (phba->irq_chann_mode == NUMA_MODE) { |
| 5925 | /* Check if we're a NUMA architecture */ |
| 5926 | numa_node = dev_to_node(&phba->pcidev->dev); |
| 5927 | if (numa_node == NUMA_NO_NODE) { |
| 5928 | phba->irq_chann_mode = NORMAL_MODE; |
| 5929 | return; |
| 5930 | } |
| 5931 | } |
| 5932 | |
| 5933 | for_each_possible_cpu(cpu) { |
| 5934 | switch (phba->irq_chann_mode) { |
| 5935 | case NUMA_MODE: |
| 5936 | if (cpu_to_node(cpu) == numa_node) |
| 5937 | cpumask_set_cpu(cpu, aff_mask); |
| 5938 | break; |
| 5939 | case NHT_MODE: |
| 5940 | sibling_mask = topology_sibling_cpumask(cpu); |
| 5941 | first_cpu = cpumask_first(sibling_mask); |
| 5942 | if (first_cpu < nr_cpu_ids) |
| 5943 | cpumask_set_cpu(first_cpu, aff_mask); |
| 5944 | break; |
| 5945 | default: |
| 5946 | break; |
| 5947 | } |
| 5948 | } |
| 5949 | } |
| 5950 | #endif |
| 5951 | |
| 5952 | static void |
| 5953 | lpfc_assign_default_irq_chann(struct lpfc_hba *phba) |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5954 | { |
| 5955 | #if IS_ENABLED(CONFIG_X86) |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 5956 | switch (boot_cpu_data.x86_vendor) { |
| 5957 | case X86_VENDOR_AMD: |
| 5958 | /* If AMD architecture, then default is NUMA_MODE */ |
| 5959 | phba->irq_chann_mode = NUMA_MODE; |
| 5960 | break; |
| 5961 | case X86_VENDOR_INTEL: |
| 5962 | /* If Intel architecture, then default is no hyperthread mode */ |
| 5963 | phba->irq_chann_mode = NHT_MODE; |
| 5964 | break; |
| 5965 | default: |
| 5966 | phba->irq_chann_mode = NORMAL_MODE; |
| 5967 | break; |
| 5968 | } |
| 5969 | lpfc_cpumask_irq_mode_init(phba); |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5970 | #else |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 5971 | phba->irq_chann_mode = NORMAL_MODE; |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5972 | #endif |
| 5973 | } |
| 5974 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5975 | /* |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5976 | * lpfc_irq_chann: Set the number of IRQ vectors that are available |
| 5977 | * for Hardware Queues to utilize. This also will map to the number |
| 5978 | * of EQ / MSI-X vectors the driver will create. This should never be |
| 5979 | * more than the number of Hardware Queues |
| 5980 | * |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5981 | * 0 = Configure number of IRQ Channels to: |
| 5982 | * if AMD architecture, number of CPUs on HBA's NUMA node |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 5983 | * if Intel architecture, number of physical CPUs. |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5984 | * otherwise, number of active CPUs. |
| 5985 | * [1,256] = Manually specify how many IRQ Channels to use. |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5986 | * |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5987 | * Value range is [0,256]. Default value is [0]. |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5988 | */ |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5989 | static uint lpfc_irq_chann = LPFC_IRQ_CHANN_DEF; |
| 5990 | module_param(lpfc_irq_chann, uint, 0444); |
| 5991 | MODULE_PARM_DESC(lpfc_irq_chann, "Set number of interrupt vectors to allocate"); |
| 5992 | |
| 5993 | /* lpfc_irq_chann_init - Set the hba irq_chann initial value |
| 5994 | * @phba: lpfc_hba pointer. |
| 5995 | * @val: contains the initial value |
| 5996 | * |
| 5997 | * Description: |
| 5998 | * Validates the initial value is within range and assigns it to the |
| 5999 | * adapter. If not in range, an error message is posted and the |
| 6000 | * default value is assigned. |
| 6001 | * |
| 6002 | * Returns: |
| 6003 | * zero if value is in range and is set |
| 6004 | * -EINVAL if value was out of range |
| 6005 | **/ |
| 6006 | static int |
| 6007 | lpfc_irq_chann_init(struct lpfc_hba *phba, uint32_t val) |
| 6008 | { |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6009 | const struct cpumask *aff_mask; |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6010 | |
| 6011 | if (phba->cfg_use_msi != 2) { |
| 6012 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 6013 | "8532 use_msi = %u ignoring cfg_irq_numa\n", |
| 6014 | phba->cfg_use_msi); |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6015 | phba->irq_chann_mode = NORMAL_MODE; |
| 6016 | phba->cfg_irq_chann = LPFC_IRQ_CHANN_DEF; |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6017 | return 0; |
| 6018 | } |
| 6019 | |
| 6020 | /* Check if default setting was passed */ |
James Smart | d3de0d1 | 2021-04-11 18:31:21 -0700 | [diff] [blame] | 6021 | if (val == LPFC_IRQ_CHANN_DEF && |
| 6022 | phba->cfg_hdw_queue == LPFC_HBA_HDWQ_DEF && |
| 6023 | phba->sli_rev == LPFC_SLI_REV4) |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6024 | lpfc_assign_default_irq_chann(phba); |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6025 | |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6026 | if (phba->irq_chann_mode != NORMAL_MODE) { |
| 6027 | aff_mask = &phba->sli4_hba.irq_aff_mask; |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6028 | |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6029 | if (cpumask_empty(aff_mask)) { |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6030 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6031 | "8533 Could not identify CPUS for " |
| 6032 | "mode %d, ignoring\n", |
| 6033 | phba->irq_chann_mode); |
| 6034 | phba->irq_chann_mode = NORMAL_MODE; |
| 6035 | phba->cfg_irq_chann = LPFC_IRQ_CHANN_DEF; |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6036 | } else { |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6037 | phba->cfg_irq_chann = cpumask_weight(aff_mask); |
| 6038 | |
| 6039 | /* If no hyperthread mode, then set hdwq count to |
| 6040 | * aff_mask weight as well |
| 6041 | */ |
| 6042 | if (phba->irq_chann_mode == NHT_MODE) |
| 6043 | phba->cfg_hdw_queue = phba->cfg_irq_chann; |
| 6044 | |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6045 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 6046 | "8543 lpfc_irq_chann set to %u " |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6047 | "(mode: %d)\n", phba->cfg_irq_chann, |
| 6048 | phba->irq_chann_mode); |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6049 | } |
| 6050 | } else { |
| 6051 | if (val > LPFC_IRQ_CHANN_MAX) { |
| 6052 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 6053 | "8545 lpfc_irq_chann attribute cannot " |
| 6054 | "be set to %u, allowed range is " |
| 6055 | "[%u,%u]\n", |
| 6056 | val, |
| 6057 | LPFC_IRQ_CHANN_MIN, |
| 6058 | LPFC_IRQ_CHANN_MAX); |
Dick Kennedy | 3048e3e | 2020-05-01 14:43:06 -0700 | [diff] [blame] | 6059 | phba->cfg_irq_chann = LPFC_IRQ_CHANN_DEF; |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6060 | return -EINVAL; |
| 6061 | } |
James Smart | d3de0d1 | 2021-04-11 18:31:21 -0700 | [diff] [blame] | 6062 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 6063 | phba->cfg_irq_chann = val; |
| 6064 | } else { |
| 6065 | phba->cfg_irq_chann = 2; |
| 6066 | phba->cfg_hdw_queue = 1; |
| 6067 | } |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 6068 | } |
| 6069 | |
| 6070 | return 0; |
| 6071 | } |
| 6072 | |
| 6073 | /** |
| 6074 | * lpfc_irq_chann_show - Display value of irq_chann |
| 6075 | * @dev: class converted to a Scsi_host structure. |
| 6076 | * @attr: device attribute, not used. |
| 6077 | * @buf: on return contains a string with the list sizes |
| 6078 | * |
| 6079 | * Returns: size of formatted string. |
| 6080 | **/ |
| 6081 | static ssize_t |
| 6082 | lpfc_irq_chann_show(struct device *dev, struct device_attribute *attr, |
| 6083 | char *buf) |
| 6084 | { |
| 6085 | struct Scsi_Host *shost = class_to_shost(dev); |
| 6086 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 6087 | struct lpfc_hba *phba = vport->phba; |
| 6088 | |
| 6089 | return scnprintf(buf, PAGE_SIZE, "%u\n", phba->cfg_irq_chann); |
| 6090 | } |
| 6091 | |
| 6092 | static DEVICE_ATTR_RO(lpfc_irq_chann); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 6093 | |
| 6094 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6095 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 6096 | # 0 = HBA resets disabled |
| 6097 | # 1 = HBA resets enabled (default) |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 6098 | # 2 = HBA reset via PCI bus reset enabled |
| 6099 | # Value range is [0,2]. Default value is 1. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6100 | */ |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 6101 | LPFC_ATTR_RW(enable_hba_reset, 1, 0, 2, "Enable HBA resets from the driver."); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 6102 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6103 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 6104 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6105 | # 0 = HBA Heartbeat disabled |
| 6106 | # 1 = HBA Heartbeat enabled (default) |
| 6107 | # Value range is [0,1]. Default value is 1. |
| 6108 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 6109 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6110 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6111 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6112 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 6113 | # 0x0 Express Lane Feature disabled |
| 6114 | # 0x1 Express Lane Feature enabled |
| 6115 | # Value range is [0,1]. Default value is 0. |
| 6116 | */ |
| 6117 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 6118 | |
| 6119 | /* |
| 6120 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 6121 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 6122 | # Value range is [0x0,0x7f]. Default value is 0 |
| 6123 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 6124 | LPFC_ATTR_RW(XLanePriority, 0, 0x0, 0x7f, "CS_CTL for Express Lane Feature."); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6125 | |
| 6126 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6127 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 6128 | # 0 = BlockGuard disabled (default) |
| 6129 | # 1 = BlockGuard enabled |
| 6130 | # Value range is [0,1]. Default value is 0. |
| 6131 | */ |
| 6132 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 6133 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6134 | /* |
James Smart | 3bfab8a | 2021-04-11 18:31:23 -0700 | [diff] [blame] | 6135 | # lpfc_prot_mask: |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6136 | # - Bit mask of host protection capabilities used to register with the |
| 6137 | # SCSI mid-layer |
| 6138 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 6139 | # - Allows you to ultimately specify which profiles to use |
| 6140 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 6141 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 6142 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 6143 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 6144 | # HBA supports DIX Type 0: Host to HBA protection only |
| 6145 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 6146 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6147 | # |
| 6148 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6149 | LPFC_ATTR(prot_mask, |
| 6150 | (SHOST_DIF_TYPE1_PROTECTION | |
| 6151 | SHOST_DIX_TYPE0_PROTECTION | |
| 6152 | SHOST_DIX_TYPE1_PROTECTION), |
| 6153 | 0, |
| 6154 | (SHOST_DIF_TYPE1_PROTECTION | |
| 6155 | SHOST_DIX_TYPE0_PROTECTION | |
| 6156 | SHOST_DIX_TYPE1_PROTECTION), |
| 6157 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6158 | |
| 6159 | /* |
James Smart | 3bfab8a | 2021-04-11 18:31:23 -0700 | [diff] [blame] | 6160 | # lpfc_prot_guard: |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6161 | # - Bit mask of protection guard types to register with the SCSI mid-layer |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 6162 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6163 | # - Allows you to ultimately specify which profiles to use |
| 6164 | # - Default will result in registering capabilities for all guard types |
| 6165 | # |
| 6166 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6167 | LPFC_ATTR(prot_guard, |
| 6168 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 6169 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6170 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 6171 | /* |
| 6172 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 6173 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 6174 | * This parameter can have value 0 or 1. |
| 6175 | * When this parameter is set to 0, no delay is added to the initial |
| 6176 | * discovery. |
| 6177 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 6178 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 6179 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 6180 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 6181 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 6182 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 6183 | * Default value is 0. |
| 6184 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 6185 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 6186 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6187 | |
| 6188 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6189 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 6190 | * This value can be set to values between 64 and 4096. The default value |
| 6191 | * is 64, but may be increased to allow for larger Max I/O sizes. The scsi |
| 6192 | * and nvme layers will allow I/O sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 6193 | * Because of the additional overhead involved in setting up T10-DIF, |
| 6194 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 6195 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6196 | */ |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 6197 | static uint lpfc_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 6198 | module_param(lpfc_sg_seg_cnt, uint, 0444); |
| 6199 | MODULE_PARM_DESC(lpfc_sg_seg_cnt, "Max Scatter Gather Segment Count"); |
| 6200 | |
| 6201 | /** |
| 6202 | * lpfc_sg_seg_cnt_show - Display the scatter/gather list sizes |
| 6203 | * configured for the adapter |
| 6204 | * @dev: class converted to a Scsi_host structure. |
| 6205 | * @attr: device attribute, not used. |
| 6206 | * @buf: on return contains a string with the list sizes |
| 6207 | * |
| 6208 | * Returns: size of formatted string. |
| 6209 | **/ |
| 6210 | static ssize_t |
| 6211 | lpfc_sg_seg_cnt_show(struct device *dev, struct device_attribute *attr, |
| 6212 | char *buf) |
| 6213 | { |
| 6214 | struct Scsi_Host *shost = class_to_shost(dev); |
| 6215 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 6216 | struct lpfc_hba *phba = vport->phba; |
| 6217 | int len; |
| 6218 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 6219 | len = scnprintf(buf, PAGE_SIZE, "SGL sz: %d total SGEs: %d\n", |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 6220 | phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt); |
| 6221 | |
Dan Carpenter | 6dacc37 | 2021-09-16 16:23:31 +0300 | [diff] [blame] | 6222 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 6223 | "Cfg: %d SCSI: %d NVME: %d\n", |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 6224 | phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt, |
| 6225 | phba->cfg_nvme_seg_cnt); |
| 6226 | return len; |
| 6227 | } |
| 6228 | |
| 6229 | static DEVICE_ATTR_RO(lpfc_sg_seg_cnt); |
| 6230 | |
| 6231 | /** |
| 6232 | * lpfc_sg_seg_cnt_init - Set the hba sg_seg_cnt initial value |
| 6233 | * @phba: lpfc_hba pointer. |
| 6234 | * @val: contains the initial value |
| 6235 | * |
| 6236 | * Description: |
| 6237 | * Validates the initial value is within range and assigns it to the |
| 6238 | * adapter. If not in range, an error message is posted and the |
| 6239 | * default value is assigned. |
| 6240 | * |
| 6241 | * Returns: |
| 6242 | * zero if value is in range and is set |
| 6243 | * -EINVAL if value was out of range |
| 6244 | **/ |
| 6245 | static int |
| 6246 | lpfc_sg_seg_cnt_init(struct lpfc_hba *phba, int val) |
| 6247 | { |
| 6248 | if (val >= LPFC_MIN_SG_SEG_CNT && val <= LPFC_MAX_SG_SEG_CNT) { |
| 6249 | phba->cfg_sg_seg_cnt = val; |
| 6250 | return 0; |
| 6251 | } |
| 6252 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 5b1f508 | 2021-04-11 18:31:25 -0700 | [diff] [blame] | 6253 | "0409 lpfc_sg_seg_cnt attribute cannot be set to %d, " |
| 6254 | "allowed range is [%d, %d]\n", |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 6255 | val, LPFC_MIN_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT); |
| 6256 | phba->cfg_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 6257 | return -EINVAL; |
| 6258 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6259 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 6260 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6261 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 6262 | * 0 = MDS Diagnostics disabled (default) |
| 6263 | * 1 = MDS Diagnostics enabled |
| 6264 | * Value range is [0,1]. Default value is 0. |
| 6265 | */ |
James Smart | e62245d | 2019-08-14 16:57:08 -0700 | [diff] [blame] | 6266 | LPFC_ATTR_RW(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6267 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6268 | /* |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6269 | * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size |
| 6270 | * 0 = Disable firmware logging (default) |
| 6271 | * [1-4] = Multiple of 1/4th Mb of host memory for FW logging |
| 6272 | * Value range [0..4]. Default value is 0 |
| 6273 | */ |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 6274 | LPFC_ATTR(ras_fwlog_buffsize, 0, 0, 4, "Host memory for FW logging"); |
| 6275 | lpfc_param_show(ras_fwlog_buffsize); |
| 6276 | |
| 6277 | static ssize_t |
| 6278 | lpfc_ras_fwlog_buffsize_set(struct lpfc_hba *phba, uint val) |
| 6279 | { |
| 6280 | int ret = 0; |
| 6281 | enum ras_state state; |
| 6282 | |
| 6283 | if (!lpfc_rangecheck(val, 0, 4)) |
| 6284 | return -EINVAL; |
| 6285 | |
| 6286 | if (phba->cfg_ras_fwlog_buffsize == val) |
| 6287 | return 0; |
| 6288 | |
James Smart | dda5bdf | 2019-11-04 16:57:02 -0800 | [diff] [blame] | 6289 | if (phba->cfg_ras_fwlog_func != PCI_FUNC(phba->pcidev->devfn)) |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 6290 | return -EINVAL; |
| 6291 | |
| 6292 | spin_lock_irq(&phba->hbalock); |
| 6293 | state = phba->ras_fwlog.state; |
| 6294 | spin_unlock_irq(&phba->hbalock); |
| 6295 | |
| 6296 | if (state == REG_INPROGRESS) { |
| 6297 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "6147 RAS Logging " |
| 6298 | "registration is in progress\n"); |
| 6299 | return -EBUSY; |
| 6300 | } |
| 6301 | |
| 6302 | /* For disable logging: stop the logs and free the DMA. |
| 6303 | * For ras_fwlog_buffsize size change we still need to free and |
| 6304 | * reallocate the DMA in lpfc_sli4_ras_fwlog_init. |
| 6305 | */ |
| 6306 | phba->cfg_ras_fwlog_buffsize = val; |
| 6307 | if (state == ACTIVE) { |
| 6308 | lpfc_ras_stop_fwlog(phba); |
| 6309 | lpfc_sli4_ras_dma_free(phba); |
| 6310 | } |
| 6311 | |
| 6312 | lpfc_sli4_ras_init(phba); |
| 6313 | if (phba->ras_fwlog.ras_enabled) |
| 6314 | ret = lpfc_sli4_ras_fwlog_init(phba, phba->cfg_ras_fwlog_level, |
| 6315 | LPFC_RAS_ENABLE_LOGGING); |
| 6316 | return ret; |
| 6317 | } |
| 6318 | |
| 6319 | lpfc_param_store(ras_fwlog_buffsize); |
| 6320 | static DEVICE_ATTR_RW(lpfc_ras_fwlog_buffsize); |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6321 | |
| 6322 | /* |
| 6323 | * lpfc_ras_fwlog_level: Firmware logging verbosity level |
| 6324 | * Valid only if firmware logging is enabled |
| 6325 | * 0(Least Verbosity) 4 (most verbosity) |
| 6326 | * Value range is [0..4]. Default value is 0 |
| 6327 | */ |
| 6328 | LPFC_ATTR_RW(ras_fwlog_level, 0, 0, 4, "Firmware Logging Level"); |
| 6329 | |
| 6330 | /* |
| 6331 | * lpfc_ras_fwlog_func: Firmware logging enabled on function number |
| 6332 | * Default function which has RAS support : 0 |
| 6333 | * Value Range is [0..7]. |
| 6334 | * FW logging is a global action and enablement is via a specific |
| 6335 | * port. |
| 6336 | */ |
| 6337 | LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function"); |
| 6338 | |
| 6339 | /* |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6340 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 6341 | * 0 = BB Credit Recovery disabled |
| 6342 | * 1 = BB Credit Recovery enabled (default) |
| 6343 | * Value range is [0,1]. Default value is 1. |
| 6344 | */ |
| 6345 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 6346 | |
James Smart | 9064aeb | 2021-08-16 09:28:50 -0700 | [diff] [blame] | 6347 | /* Signaling module parameters */ |
| 6348 | int lpfc_fabric_cgn_frequency = 100; /* 100 ms default */ |
| 6349 | module_param(lpfc_fabric_cgn_frequency, int, 0444); |
| 6350 | MODULE_PARM_DESC(lpfc_fabric_cgn_frequency, "Congestion signaling fabric freq"); |
| 6351 | |
| 6352 | int lpfc_acqe_cgn_frequency = 10; /* 10 sec default */ |
| 6353 | module_param(lpfc_acqe_cgn_frequency, int, 0444); |
| 6354 | MODULE_PARM_DESC(lpfc_acqe_cgn_frequency, "Congestion signaling ACQE freq"); |
| 6355 | |
| 6356 | int lpfc_use_cgn_signal = 1; /* 0 - only use FPINs, 1 - Use signals if avail */ |
| 6357 | module_param(lpfc_use_cgn_signal, int, 0444); |
| 6358 | MODULE_PARM_DESC(lpfc_use_cgn_signal, "Use Congestion signaling if available"); |
| 6359 | |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 6360 | /* |
| 6361 | * lpfc_enable_dpp: Enable DPP on G7 |
| 6362 | * 0 = DPP on G7 disabled |
| 6363 | * 1 = DPP on G7 enabled (default) |
| 6364 | * Value range is [0,1]. Default value is 1. |
| 6365 | */ |
| 6366 | LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); |
| 6367 | |
James Smart | 8aaa7bc | 2020-10-20 13:27:17 -0700 | [diff] [blame] | 6368 | /* |
| 6369 | * lpfc_enable_mi: Enable FDMI MIB |
| 6370 | * 0 = disabled |
| 6371 | * 1 = enabled (default) |
| 6372 | * Value range is [0,1]. |
| 6373 | */ |
| 6374 | LPFC_ATTR_R(enable_mi, 1, 0, 1, "Enable MI"); |
| 6375 | |
Gaurav Srivastava | 7ba2272 | 2021-06-08 10:05:48 +0530 | [diff] [blame] | 6376 | /* |
| 6377 | * lpfc_max_vmid: Maximum number of VMs to be tagged. This is valid only if |
| 6378 | * either vmid_app_header or vmid_priority_tagging is enabled. |
| 6379 | * 4 - 255 = vmid support enabled for 4-255 VMs |
| 6380 | * Value range is [4,255]. |
| 6381 | */ |
| 6382 | LPFC_ATTR_RW(max_vmid, LPFC_MIN_VMID, LPFC_MIN_VMID, LPFC_MAX_VMID, |
| 6383 | "Maximum number of VMs supported"); |
| 6384 | |
| 6385 | /* |
| 6386 | * lpfc_vmid_inactivity_timeout: Inactivity timeout duration in hours |
| 6387 | * 0 = Timeout is disabled |
| 6388 | * Value range is [0,24]. |
| 6389 | */ |
| 6390 | LPFC_ATTR_RW(vmid_inactivity_timeout, 4, 0, 24, |
| 6391 | "Inactivity timeout in hours"); |
| 6392 | |
| 6393 | /* |
| 6394 | * lpfc_vmid_app_header: Enable App Header VMID support |
| 6395 | * 0 = Support is disabled (default) |
| 6396 | * 1 = Support is enabled |
| 6397 | * Value range is [0,1]. |
| 6398 | */ |
| 6399 | LPFC_ATTR_RW(vmid_app_header, LPFC_VMID_APP_HEADER_DISABLE, |
| 6400 | LPFC_VMID_APP_HEADER_DISABLE, LPFC_VMID_APP_HEADER_ENABLE, |
| 6401 | "Enable App Header VMID support"); |
| 6402 | |
| 6403 | /* |
| 6404 | * lpfc_vmid_priority_tagging: Enable Priority Tagging VMID support |
| 6405 | * 0 = Support is disabled (default) |
| 6406 | * 1 = Allow supported targets only |
| 6407 | * 2 = Allow all targets |
| 6408 | * Value range is [0,2]. |
| 6409 | */ |
| 6410 | LPFC_ATTR_RW(vmid_priority_tagging, LPFC_VMID_PRIO_TAG_DISABLE, |
| 6411 | LPFC_VMID_PRIO_TAG_DISABLE, |
| 6412 | LPFC_VMID_PRIO_TAG_ALL_TARGETS, |
| 6413 | "Enable Priority Tagging VMID support"); |
| 6414 | |
Bart Van Assche | 08adfa7 | 2021-10-12 16:35:39 -0700 | [diff] [blame] | 6415 | static struct attribute *lpfc_hba_attrs[] = { |
| 6416 | &dev_attr_nvme_info.attr, |
| 6417 | &dev_attr_scsi_stat.attr, |
| 6418 | &dev_attr_bg_info.attr, |
| 6419 | &dev_attr_bg_guard_err.attr, |
| 6420 | &dev_attr_bg_apptag_err.attr, |
| 6421 | &dev_attr_bg_reftag_err.attr, |
| 6422 | &dev_attr_info.attr, |
| 6423 | &dev_attr_serialnum.attr, |
| 6424 | &dev_attr_modeldesc.attr, |
| 6425 | &dev_attr_modelname.attr, |
| 6426 | &dev_attr_programtype.attr, |
| 6427 | &dev_attr_portnum.attr, |
| 6428 | &dev_attr_fwrev.attr, |
| 6429 | &dev_attr_hdw.attr, |
| 6430 | &dev_attr_option_rom_version.attr, |
| 6431 | &dev_attr_link_state.attr, |
| 6432 | &dev_attr_num_discovered_ports.attr, |
| 6433 | &dev_attr_menlo_mgmt_mode.attr, |
| 6434 | &dev_attr_lpfc_drvr_version.attr, |
| 6435 | &dev_attr_lpfc_enable_fip.attr, |
| 6436 | &dev_attr_lpfc_temp_sensor.attr, |
| 6437 | &dev_attr_lpfc_log_verbose.attr, |
| 6438 | &dev_attr_lpfc_lun_queue_depth.attr, |
| 6439 | &dev_attr_lpfc_tgt_queue_depth.attr, |
| 6440 | &dev_attr_lpfc_hba_queue_depth.attr, |
| 6441 | &dev_attr_lpfc_peer_port_login.attr, |
| 6442 | &dev_attr_lpfc_nodev_tmo.attr, |
| 6443 | &dev_attr_lpfc_devloss_tmo.attr, |
| 6444 | &dev_attr_lpfc_enable_fc4_type.attr, |
| 6445 | &dev_attr_lpfc_fcp_class.attr, |
| 6446 | &dev_attr_lpfc_use_adisc.attr, |
| 6447 | &dev_attr_lpfc_first_burst_size.attr, |
| 6448 | &dev_attr_lpfc_ack0.attr, |
| 6449 | &dev_attr_lpfc_xri_rebalancing.attr, |
| 6450 | &dev_attr_lpfc_topology.attr, |
| 6451 | &dev_attr_lpfc_scan_down.attr, |
| 6452 | &dev_attr_lpfc_link_speed.attr, |
| 6453 | &dev_attr_lpfc_fcp_io_sched.attr, |
| 6454 | &dev_attr_lpfc_ns_query.attr, |
| 6455 | &dev_attr_lpfc_fcp2_no_tgt_reset.attr, |
| 6456 | &dev_attr_lpfc_cr_delay.attr, |
| 6457 | &dev_attr_lpfc_cr_count.attr, |
| 6458 | &dev_attr_lpfc_multi_ring_support.attr, |
| 6459 | &dev_attr_lpfc_multi_ring_rctl.attr, |
| 6460 | &dev_attr_lpfc_multi_ring_type.attr, |
| 6461 | &dev_attr_lpfc_fdmi_on.attr, |
| 6462 | &dev_attr_lpfc_enable_SmartSAN.attr, |
| 6463 | &dev_attr_lpfc_max_luns.attr, |
| 6464 | &dev_attr_lpfc_enable_npiv.attr, |
| 6465 | &dev_attr_lpfc_fcf_failover_policy.attr, |
| 6466 | &dev_attr_lpfc_enable_rrq.attr, |
| 6467 | &dev_attr_lpfc_fcp_wait_abts_rsp.attr, |
| 6468 | &dev_attr_nport_evt_cnt.attr, |
| 6469 | &dev_attr_board_mode.attr, |
| 6470 | &dev_attr_max_vpi.attr, |
| 6471 | &dev_attr_used_vpi.attr, |
| 6472 | &dev_attr_max_rpi.attr, |
| 6473 | &dev_attr_used_rpi.attr, |
| 6474 | &dev_attr_max_xri.attr, |
| 6475 | &dev_attr_used_xri.attr, |
| 6476 | &dev_attr_npiv_info.attr, |
| 6477 | &dev_attr_issue_reset.attr, |
| 6478 | &dev_attr_lpfc_poll.attr, |
| 6479 | &dev_attr_lpfc_poll_tmo.attr, |
| 6480 | &dev_attr_lpfc_task_mgmt_tmo.attr, |
| 6481 | &dev_attr_lpfc_use_msi.attr, |
| 6482 | &dev_attr_lpfc_nvme_oas.attr, |
| 6483 | &dev_attr_lpfc_nvme_embed_cmd.attr, |
| 6484 | &dev_attr_lpfc_fcp_imax.attr, |
| 6485 | &dev_attr_lpfc_force_rscn.attr, |
| 6486 | &dev_attr_lpfc_cq_poll_threshold.attr, |
| 6487 | &dev_attr_lpfc_cq_max_proc_limit.attr, |
| 6488 | &dev_attr_lpfc_fcp_cpu_map.attr, |
| 6489 | &dev_attr_lpfc_fcp_mq_threshold.attr, |
| 6490 | &dev_attr_lpfc_hdw_queue.attr, |
| 6491 | &dev_attr_lpfc_irq_chann.attr, |
| 6492 | &dev_attr_lpfc_suppress_rsp.attr, |
| 6493 | &dev_attr_lpfc_nvmet_mrq.attr, |
| 6494 | &dev_attr_lpfc_nvmet_mrq_post.attr, |
| 6495 | &dev_attr_lpfc_nvme_enable_fb.attr, |
| 6496 | &dev_attr_lpfc_nvmet_fb_size.attr, |
| 6497 | &dev_attr_lpfc_enable_bg.attr, |
| 6498 | &dev_attr_lpfc_soft_wwnn.attr, |
| 6499 | &dev_attr_lpfc_soft_wwpn.attr, |
| 6500 | &dev_attr_lpfc_soft_wwn_enable.attr, |
| 6501 | &dev_attr_lpfc_enable_hba_reset.attr, |
| 6502 | &dev_attr_lpfc_enable_hba_heartbeat.attr, |
| 6503 | &dev_attr_lpfc_EnableXLane.attr, |
| 6504 | &dev_attr_lpfc_XLanePriority.attr, |
| 6505 | &dev_attr_lpfc_xlane_lun.attr, |
| 6506 | &dev_attr_lpfc_xlane_tgt.attr, |
| 6507 | &dev_attr_lpfc_xlane_vpt.attr, |
| 6508 | &dev_attr_lpfc_xlane_lun_state.attr, |
| 6509 | &dev_attr_lpfc_xlane_lun_status.attr, |
| 6510 | &dev_attr_lpfc_xlane_priority.attr, |
| 6511 | &dev_attr_lpfc_sg_seg_cnt.attr, |
| 6512 | &dev_attr_lpfc_max_scsicmpl_time.attr, |
| 6513 | &dev_attr_lpfc_stat_data_ctrl.attr, |
| 6514 | &dev_attr_lpfc_aer_support.attr, |
| 6515 | &dev_attr_lpfc_aer_state_cleanup.attr, |
| 6516 | &dev_attr_lpfc_sriov_nr_virtfn.attr, |
| 6517 | &dev_attr_lpfc_req_fw_upgrade.attr, |
| 6518 | &dev_attr_lpfc_suppress_link_up.attr, |
| 6519 | &dev_attr_iocb_hw.attr, |
| 6520 | &dev_attr_pls.attr, |
| 6521 | &dev_attr_pt.attr, |
| 6522 | &dev_attr_txq_hw.attr, |
| 6523 | &dev_attr_txcmplq_hw.attr, |
| 6524 | &dev_attr_lpfc_sriov_hw_max_virtfn.attr, |
| 6525 | &dev_attr_protocol.attr, |
| 6526 | &dev_attr_lpfc_xlane_supported.attr, |
| 6527 | &dev_attr_lpfc_enable_mds_diags.attr, |
| 6528 | &dev_attr_lpfc_ras_fwlog_buffsize.attr, |
| 6529 | &dev_attr_lpfc_ras_fwlog_level.attr, |
| 6530 | &dev_attr_lpfc_ras_fwlog_func.attr, |
| 6531 | &dev_attr_lpfc_enable_bbcr.attr, |
| 6532 | &dev_attr_lpfc_enable_dpp.attr, |
| 6533 | &dev_attr_lpfc_enable_mi.attr, |
| 6534 | &dev_attr_cmf_info.attr, |
| 6535 | &dev_attr_lpfc_max_vmid.attr, |
| 6536 | &dev_attr_lpfc_vmid_inactivity_timeout.attr, |
| 6537 | &dev_attr_lpfc_vmid_app_header.attr, |
| 6538 | &dev_attr_lpfc_vmid_priority_tagging.attr, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6539 | NULL, |
| 6540 | }; |
| 6541 | |
Bart Van Assche | 08adfa7 | 2021-10-12 16:35:39 -0700 | [diff] [blame] | 6542 | static const struct attribute_group lpfc_hba_attr_group = { |
| 6543 | .attrs = lpfc_hba_attrs |
| 6544 | }; |
| 6545 | |
| 6546 | const struct attribute_group *lpfc_hba_groups[] = { |
| 6547 | &lpfc_hba_attr_group, |
| 6548 | NULL |
| 6549 | }; |
| 6550 | |
| 6551 | static struct attribute *lpfc_vport_attrs[] = { |
| 6552 | &dev_attr_info.attr, |
| 6553 | &dev_attr_link_state.attr, |
| 6554 | &dev_attr_num_discovered_ports.attr, |
| 6555 | &dev_attr_lpfc_drvr_version.attr, |
| 6556 | &dev_attr_lpfc_log_verbose.attr, |
| 6557 | &dev_attr_lpfc_lun_queue_depth.attr, |
| 6558 | &dev_attr_lpfc_tgt_queue_depth.attr, |
| 6559 | &dev_attr_lpfc_nodev_tmo.attr, |
| 6560 | &dev_attr_lpfc_devloss_tmo.attr, |
| 6561 | &dev_attr_lpfc_hba_queue_depth.attr, |
| 6562 | &dev_attr_lpfc_peer_port_login.attr, |
| 6563 | &dev_attr_lpfc_restrict_login.attr, |
| 6564 | &dev_attr_lpfc_fcp_class.attr, |
| 6565 | &dev_attr_lpfc_use_adisc.attr, |
| 6566 | &dev_attr_lpfc_first_burst_size.attr, |
| 6567 | &dev_attr_lpfc_max_luns.attr, |
| 6568 | &dev_attr_nport_evt_cnt.attr, |
| 6569 | &dev_attr_npiv_info.attr, |
| 6570 | &dev_attr_lpfc_enable_da_id.attr, |
| 6571 | &dev_attr_lpfc_max_scsicmpl_time.attr, |
| 6572 | &dev_attr_lpfc_stat_data_ctrl.attr, |
| 6573 | &dev_attr_lpfc_static_vport.attr, |
| 6574 | &dev_attr_cmf_info.attr, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6575 | NULL, |
| 6576 | }; |
| 6577 | |
Bart Van Assche | 08adfa7 | 2021-10-12 16:35:39 -0700 | [diff] [blame] | 6578 | static const struct attribute_group lpfc_vport_attr_group = { |
| 6579 | .attrs = lpfc_vport_attrs |
| 6580 | }; |
| 6581 | |
| 6582 | const struct attribute_group *lpfc_vport_groups[] = { |
| 6583 | &lpfc_vport_attr_group, |
| 6584 | NULL |
| 6585 | }; |
| 6586 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6587 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6588 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6589 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6590 | * @kobj: kernel kobject that contains the kernel class device. |
| 6591 | * @bin_attr: kernel attributes passed to us. |
| 6592 | * @buf: contains the data to be written to the adapter IOREG space. |
| 6593 | * @off: offset into buffer to beginning of data. |
| 6594 | * @count: bytes to transfer. |
| 6595 | * |
| 6596 | * Description: |
| 6597 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 6598 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 6599 | * |
| 6600 | * Returns: |
| 6601 | * -ERANGE off and count combo out of range |
| 6602 | * -EINVAL off, count or buff address invalid |
| 6603 | * -EPERM adapter is offline |
| 6604 | * value of count, buf contents written |
| 6605 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6606 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6607 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 6608 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6609 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6610 | { |
| 6611 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6612 | struct device *dev = container_of(kobj, struct device, kobj); |
| 6613 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6614 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6615 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6616 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6617 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 6618 | return -EPERM; |
| 6619 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6620 | if ((off + count) > FF_REG_AREA_SIZE) |
| 6621 | return -ERANGE; |
| 6622 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6623 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 6624 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6625 | |
| 6626 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 6627 | return -EINVAL; |
| 6628 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6629 | /* This is to protect HBA registers from accidental writes. */ |
| 6630 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 6631 | return -EINVAL; |
| 6632 | |
| 6633 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6634 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6635 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6636 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6637 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 6638 | buf_off += sizeof(uint32_t)) |
| 6639 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6640 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 6641 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6642 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6643 | |
| 6644 | return count; |
| 6645 | } |
| 6646 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6647 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6648 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6649 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6650 | * @kobj: kernel kobject that contains the kernel class device. |
| 6651 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 6652 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6653 | * @off: offset into buffer to beginning of data. |
| 6654 | * @count: bytes to transfer. |
| 6655 | * |
| 6656 | * Description: |
| 6657 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 6658 | * Uses the adapter io control registers to read data into buf. |
| 6659 | * |
| 6660 | * Returns: |
| 6661 | * -ERANGE off and count combo out of range |
| 6662 | * -EINVAL off, count or buff address invalid |
| 6663 | * value of count, buf contents read |
| 6664 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6665 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6666 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 6667 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6668 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6669 | { |
| 6670 | size_t buf_off; |
| 6671 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6672 | struct device *dev = container_of(kobj, struct device, kobj); |
| 6673 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6674 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6675 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6676 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6677 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 6678 | return -EPERM; |
| 6679 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6680 | if (off > FF_REG_AREA_SIZE) |
| 6681 | return -ERANGE; |
| 6682 | |
| 6683 | if ((off + count) > FF_REG_AREA_SIZE) |
| 6684 | count = FF_REG_AREA_SIZE - off; |
| 6685 | |
| 6686 | if (count == 0) return 0; |
| 6687 | |
| 6688 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 6689 | return -EINVAL; |
| 6690 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6691 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6692 | |
| 6693 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 6694 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 6695 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 6696 | } |
| 6697 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6698 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6699 | |
| 6700 | return count; |
| 6701 | } |
| 6702 | |
| 6703 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 6704 | .attr = { |
| 6705 | .name = "ctlreg", |
| 6706 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6707 | }, |
| 6708 | .size = 256, |
| 6709 | .read = sysfs_ctlreg_read, |
| 6710 | .write = sysfs_ctlreg_write, |
| 6711 | }; |
| 6712 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6713 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6714 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6715 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6716 | * @kobj: kernel kobject that contains the kernel class device. |
| 6717 | * @bin_attr: kernel attributes passed to us. |
| 6718 | * @buf: contains the data to be written to sysfs mbox. |
| 6719 | * @off: offset into buffer to beginning of data. |
| 6720 | * @count: bytes to transfer. |
| 6721 | * |
| 6722 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6723 | * Deprecated function. All mailbox access from user space is performed via the |
| 6724 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6725 | * |
| 6726 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6727 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6728 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6729 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6730 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 6731 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6732 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6733 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6734 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6735 | } |
| 6736 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6737 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6738 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6739 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6740 | * @kobj: kernel kobject that contains the kernel class device. |
| 6741 | * @bin_attr: kernel attributes passed to us. |
| 6742 | * @buf: contains the data to be read from sysfs mbox. |
| 6743 | * @off: offset into buffer to beginning of data. |
| 6744 | * @count: bytes to transfer. |
| 6745 | * |
| 6746 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6747 | * Deprecated function. All mailbox access from user space is performed via the |
| 6748 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6749 | * |
| 6750 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6751 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6752 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6753 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6754 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 6755 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6756 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6757 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6758 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6759 | } |
| 6760 | |
| 6761 | static struct bin_attribute sysfs_mbox_attr = { |
| 6762 | .attr = { |
| 6763 | .name = "mbox", |
| 6764 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6765 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 6766 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6767 | .read = sysfs_mbox_read, |
| 6768 | .write = sysfs_mbox_write, |
| 6769 | }; |
| 6770 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6771 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6772 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6773 | * @vport: address of lpfc vport structure. |
| 6774 | * |
| 6775 | * Return codes: |
| 6776 | * zero on success |
| 6777 | * error return code from sysfs_create_bin_file() |
| 6778 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6779 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6780 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6781 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6782 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6783 | int error; |
| 6784 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6785 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6786 | &sysfs_drvr_stat_data_attr); |
| 6787 | |
| 6788 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 6789 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 6790 | goto out; |
| 6791 | |
| 6792 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6793 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6794 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6795 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6796 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6797 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6798 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6799 | if (error) |
| 6800 | goto out_remove_ctlreg_attr; |
| 6801 | |
| 6802 | return 0; |
| 6803 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6804 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6805 | out_remove_stat_attr: |
| 6806 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 6807 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6808 | out: |
| 6809 | return error; |
| 6810 | } |
| 6811 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6812 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6813 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6814 | * @vport: address of lpfc vport structure. |
| 6815 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6816 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6817 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6818 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6819 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6820 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 6821 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6822 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 6823 | if (vport->port_type == LPFC_NPIV_PORT) |
| 6824 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6825 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 6826 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6827 | } |
| 6828 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6829 | /* |
| 6830 | * Dynamic FC Host Attributes Support |
| 6831 | */ |
| 6832 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6833 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6834 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 6835 | * @shost: kernel scsi host pointer. |
| 6836 | **/ |
| 6837 | static void |
| 6838 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 6839 | { |
| 6840 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 6841 | |
| 6842 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 6843 | sizeof fc_host_symbolic_name(shost)); |
| 6844 | } |
| 6845 | |
| 6846 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6847 | * 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] | 6848 | * @shost: kernel scsi host pointer. |
| 6849 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6850 | static void |
| 6851 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 6852 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6853 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6854 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6855 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6856 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6857 | } |
| 6858 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6859 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6860 | * 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] | 6861 | * @shost: kernel scsi host pointer. |
| 6862 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6863 | static void |
| 6864 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 6865 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6866 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6867 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6868 | |
| 6869 | spin_lock_irq(shost->host_lock); |
| 6870 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6871 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 6872 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 6873 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6874 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6875 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6876 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 6877 | else |
| 6878 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 6879 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6880 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6881 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 6882 | else |
| 6883 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 6884 | } |
| 6885 | } else |
| 6886 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 6887 | |
| 6888 | spin_unlock_irq(shost->host_lock); |
| 6889 | } |
| 6890 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6891 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6892 | * 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] | 6893 | * @shost: kernel scsi host pointer. |
| 6894 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6895 | static void |
| 6896 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 6897 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6898 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6899 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6900 | |
| 6901 | spin_lock_irq(shost->host_lock); |
| 6902 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6903 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6904 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 6905 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6906 | switch (phba->link_state) { |
| 6907 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6908 | case LPFC_LINK_DOWN: |
| 6909 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 6910 | break; |
| 6911 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6912 | case LPFC_CLEAR_LA: |
| 6913 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6914 | /* Links up, reports port state accordingly */ |
| 6915 | if (vport->port_state < LPFC_VPORT_READY) |
| 6916 | fc_host_port_state(shost) = |
| 6917 | FC_PORTSTATE_BYPASSED; |
| 6918 | else |
| 6919 | fc_host_port_state(shost) = |
| 6920 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6921 | break; |
| 6922 | case LPFC_HBA_ERROR: |
| 6923 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 6924 | break; |
| 6925 | default: |
| 6926 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 6927 | break; |
| 6928 | } |
| 6929 | } |
| 6930 | |
| 6931 | spin_unlock_irq(shost->host_lock); |
| 6932 | } |
| 6933 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6934 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6935 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6936 | * @shost: kernel scsi host pointer. |
| 6937 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6938 | static void |
| 6939 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 6940 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6941 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6942 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6943 | |
| 6944 | spin_lock_irq(shost->host_lock); |
| 6945 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 6946 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6947 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6948 | case LPFC_LINK_SPEED_1GHZ: |
| 6949 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6950 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6951 | case LPFC_LINK_SPEED_2GHZ: |
| 6952 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6953 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6954 | case LPFC_LINK_SPEED_4GHZ: |
| 6955 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6956 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6957 | case LPFC_LINK_SPEED_8GHZ: |
| 6958 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 6959 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6960 | case LPFC_LINK_SPEED_10GHZ: |
| 6961 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6962 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6963 | case LPFC_LINK_SPEED_16GHZ: |
| 6964 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 6965 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 6966 | case LPFC_LINK_SPEED_32GHZ: |
| 6967 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 6968 | break; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 6969 | case LPFC_LINK_SPEED_64GHZ: |
| 6970 | fc_host_speed(shost) = FC_PORTSPEED_64GBIT; |
| 6971 | break; |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 6972 | case LPFC_LINK_SPEED_128GHZ: |
| 6973 | fc_host_speed(shost) = FC_PORTSPEED_128GBIT; |
| 6974 | break; |
James Smart | bfc4778 | 2021-07-22 15:17:19 -0700 | [diff] [blame] | 6975 | case LPFC_LINK_SPEED_256GHZ: |
| 6976 | fc_host_speed(shost) = FC_PORTSPEED_256GBIT; |
| 6977 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6978 | default: |
| 6979 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6980 | break; |
| 6981 | } |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame] | 6982 | } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) { |
| 6983 | switch (phba->fc_linkspeed) { |
Dick Kennedy | a1e4d3d | 2020-08-03 14:02:22 -0700 | [diff] [blame] | 6984 | case LPFC_ASYNC_LINK_SPEED_1GBPS: |
| 6985 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| 6986 | break; |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame] | 6987 | case LPFC_ASYNC_LINK_SPEED_10GBPS: |
| 6988 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
| 6989 | break; |
Dick Kennedy | a1e4d3d | 2020-08-03 14:02:22 -0700 | [diff] [blame] | 6990 | case LPFC_ASYNC_LINK_SPEED_20GBPS: |
| 6991 | fc_host_speed(shost) = FC_PORTSPEED_20GBIT; |
| 6992 | break; |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame] | 6993 | case LPFC_ASYNC_LINK_SPEED_25GBPS: |
| 6994 | fc_host_speed(shost) = FC_PORTSPEED_25GBIT; |
| 6995 | break; |
| 6996 | case LPFC_ASYNC_LINK_SPEED_40GBPS: |
| 6997 | fc_host_speed(shost) = FC_PORTSPEED_40GBIT; |
| 6998 | break; |
| 6999 | case LPFC_ASYNC_LINK_SPEED_100GBPS: |
| 7000 | fc_host_speed(shost) = FC_PORTSPEED_100GBIT; |
| 7001 | break; |
| 7002 | default: |
| 7003 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| 7004 | break; |
| 7005 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7006 | } else |
| 7007 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7008 | |
| 7009 | spin_unlock_irq(shost->host_lock); |
| 7010 | } |
| 7011 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7012 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7013 | * 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] | 7014 | * @shost: kernel scsi host pointer. |
| 7015 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7016 | static void |
| 7017 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 7018 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7019 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 7020 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 7021 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7022 | |
| 7023 | spin_lock_irq(shost->host_lock); |
| 7024 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 7025 | if ((vport->port_state > LPFC_FLOGI) && |
| 7026 | ((vport->fc_flag & FC_FABRIC) || |
| 7027 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 7028 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 7029 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7030 | else |
| 7031 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7032 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7033 | |
| 7034 | spin_unlock_irq(shost->host_lock); |
| 7035 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 7036 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7037 | } |
| 7038 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7039 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7040 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7041 | * @shost: kernel scsi host pointer. |
| 7042 | * |
| 7043 | * Notes: |
| 7044 | * NULL on error for link down, no mbox pool, sli2 active, |
| 7045 | * management not allowed, memory allocation error, or mbox error. |
| 7046 | * |
| 7047 | * Returns: |
| 7048 | * NULL for error |
| 7049 | * address of the adapter host statistics |
| 7050 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7051 | static struct fc_host_statistics * |
| 7052 | lpfc_get_stats(struct Scsi_Host *shost) |
| 7053 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7054 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 7055 | struct lpfc_hba *phba = vport->phba; |
| 7056 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 7057 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7058 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7059 | LPFC_MBOXQ_t *pmboxq; |
| 7060 | MAILBOX_t *pmb; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 7061 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7062 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7063 | /* |
| 7064 | * prevent udev from issuing mailbox commands until the port is |
| 7065 | * configured. |
| 7066 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7067 | if (phba->link_state < LPFC_LINK_DOWN || |
| 7068 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 7069 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7070 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7071 | |
| 7072 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 7073 | return NULL; |
| 7074 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7075 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 7076 | if (!pmboxq) |
| 7077 | return NULL; |
| 7078 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 7079 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 7080 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7081 | pmb->mbxCommand = MBX_READ_STATUS; |
| 7082 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 7083 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7084 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7085 | |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7086 | if (vport->fc_flag & FC_OFFLINE_MODE) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7087 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7088 | if (rc != MBX_SUCCESS) { |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 7089 | mempool_free(pmboxq, phba->mbox_mem_pool); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7090 | return NULL; |
| 7091 | } |
| 7092 | } else { |
| 7093 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 7094 | if (rc != MBX_SUCCESS) { |
| 7095 | if (rc != MBX_TIMEOUT) |
| 7096 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7097 | return NULL; |
| 7098 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7099 | } |
| 7100 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 7101 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 7102 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7103 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 7104 | /* |
| 7105 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 7106 | * converted to words |
| 7107 | */ |
| 7108 | hs->tx_words = (uint64_t) |
| 7109 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 7110 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7111 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 7112 | hs->rx_words = (uint64_t) |
| 7113 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 7114 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7115 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 7116 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7117 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 7118 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 7119 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7120 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7121 | |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7122 | if (vport->fc_flag & FC_OFFLINE_MODE) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7123 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7124 | if (rc != MBX_SUCCESS) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7125 | mempool_free(pmboxq, phba->mbox_mem_pool); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7126 | return NULL; |
| 7127 | } |
| 7128 | } else { |
| 7129 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 7130 | if (rc != MBX_SUCCESS) { |
| 7131 | if (rc != MBX_TIMEOUT) |
| 7132 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7133 | return NULL; |
| 7134 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7135 | } |
| 7136 | |
| 7137 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 7138 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 7139 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 7140 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 7141 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 7142 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 7143 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 7144 | |
James Smart | 9064aeb | 2021-08-16 09:28:50 -0700 | [diff] [blame] | 7145 | hs->cn_sig_warn = atomic64_read(&phba->cgn_acqe_stat.warn); |
| 7146 | hs->cn_sig_alarm = atomic64_read(&phba->cgn_acqe_stat.alarm); |
| 7147 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7148 | hs->link_failure_count -= lso->link_failure_count; |
| 7149 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 7150 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 7151 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 7152 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 7153 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 7154 | hs->error_frames -= lso->error_frames; |
| 7155 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7156 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 7157 | hs->lip_count = -1; |
| 7158 | hs->nos_count = (phba->link_events >> 1); |
| 7159 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7160 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7161 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7162 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7163 | hs->nos_count = -1; |
| 7164 | } else { |
| 7165 | hs->lip_count = -1; |
| 7166 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7167 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7168 | } |
| 7169 | |
| 7170 | hs->dumped_frames = -1; |
| 7171 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 7172 | hs->seconds_since_last_reset = ktime_get_seconds() - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7173 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 7174 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7175 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7176 | return hs; |
| 7177 | } |
| 7178 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7179 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7180 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7181 | * @shost: kernel scsi host pointer. |
| 7182 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7183 | static void |
| 7184 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 7185 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7186 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 7187 | struct lpfc_hba *phba = vport->phba; |
| 7188 | struct lpfc_sli *psli = &phba->sli; |
| 7189 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7190 | LPFC_MBOXQ_t *pmboxq; |
| 7191 | MAILBOX_t *pmb; |
| 7192 | int rc = 0; |
| 7193 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7194 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 7195 | return; |
| 7196 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7197 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 7198 | if (!pmboxq) |
| 7199 | return; |
| 7200 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 7201 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 7202 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7203 | pmb->mbxCommand = MBX_READ_STATUS; |
| 7204 | pmb->mbxOwner = OWN_HOST; |
| 7205 | pmb->un.varWords[0] = 0x1; /* reset request */ |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 7206 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7207 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7208 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7209 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7210 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) { |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7211 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7212 | if (rc != MBX_SUCCESS) { |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7213 | mempool_free(pmboxq, phba->mbox_mem_pool); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7214 | return; |
| 7215 | } |
| 7216 | } else { |
| 7217 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 7218 | if (rc != MBX_SUCCESS) { |
| 7219 | if (rc != MBX_TIMEOUT) |
| 7220 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7221 | return; |
| 7222 | } |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7223 | } |
| 7224 | |
| 7225 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 7226 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 7227 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 7228 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7229 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7230 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7231 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7232 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) { |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7233 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7234 | if (rc != MBX_SUCCESS) { |
| 7235 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7236 | return; |
| 7237 | } |
| 7238 | } else { |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7239 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
James Smart | 304ee43 | 2021-04-11 18:31:17 -0700 | [diff] [blame] | 7240 | if (rc != MBX_SUCCESS) { |
| 7241 | if (rc != MBX_TIMEOUT) |
| 7242 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7243 | return; |
| 7244 | } |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7245 | } |
| 7246 | |
| 7247 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 7248 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 7249 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 7250 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 7251 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 7252 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 7253 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7254 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 7255 | lso->link_events = (phba->link_events >> 1); |
| 7256 | else |
| 7257 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7258 | |
James Smart | 9064aeb | 2021-08-16 09:28:50 -0700 | [diff] [blame] | 7259 | atomic64_set(&phba->cgn_acqe_stat.warn, 0); |
| 7260 | atomic64_set(&phba->cgn_acqe_stat.alarm, 0); |
| 7261 | |
| 7262 | memset(&shost_to_fc_host(shost)->fpin_stats, 0, |
| 7263 | sizeof(shost_to_fc_host(shost)->fpin_stats)); |
| 7264 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 7265 | psli->stats_start = ktime_get_seconds(); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7266 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 7267 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 7268 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7269 | return; |
| 7270 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7271 | |
| 7272 | /* |
| 7273 | * The LPFC driver treats linkdown handling as target loss events so there |
| 7274 | * are no sysfs handlers for link_down_tmo. |
| 7275 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7276 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7277 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7278 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7279 | * @starget: kernel scsi target pointer. |
| 7280 | * |
| 7281 | * Returns: |
| 7282 | * address of the node list if found |
| 7283 | * NULL target not found |
| 7284 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7285 | static struct lpfc_nodelist * |
| 7286 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7287 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7288 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 7289 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7290 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7291 | |
| 7292 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7293 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7294 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 7295 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7296 | starget->id == ndlp->nlp_sid) { |
| 7297 | spin_unlock_irq(shost->host_lock); |
| 7298 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7299 | } |
| 7300 | } |
| 7301 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7302 | return NULL; |
| 7303 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7304 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7305 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7306 | * 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] | 7307 | * @starget: kernel scsi target pointer. |
| 7308 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7309 | static void |
| 7310 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 7311 | { |
| 7312 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 7313 | |
| 7314 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7315 | } |
| 7316 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7317 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7318 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7319 | * @starget: kernel scsi target pointer. |
| 7320 | * |
| 7321 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 7322 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7323 | static void |
| 7324 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 7325 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7326 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7327 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7328 | fc_starget_node_name(starget) = |
| 7329 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7330 | } |
| 7331 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7332 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7333 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7334 | * @starget: kernel scsi target pointer. |
| 7335 | * |
| 7336 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 7337 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7338 | static void |
| 7339 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 7340 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7341 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7342 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7343 | fc_starget_port_name(starget) = |
| 7344 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7345 | } |
| 7346 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7347 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7348 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7349 | * @rport: fc rport address. |
| 7350 | * @timeout: new value for dev loss tmo. |
| 7351 | * |
| 7352 | * Description: |
| 7353 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 7354 | * dev_loss_tmo to one. |
| 7355 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7356 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7357 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 7358 | { |
James Smart | a643c6d | 2019-08-14 16:56:48 -0700 | [diff] [blame] | 7359 | struct lpfc_rport_data *rdata = rport->dd_data; |
| 7360 | struct lpfc_nodelist *ndlp = rdata->pnode; |
| 7361 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 7362 | struct lpfc_nvme_rport *nrport = NULL; |
| 7363 | #endif |
| 7364 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7365 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 7366 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7367 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 7368 | rport->dev_loss_tmo = 1; |
James Smart | a643c6d | 2019-08-14 16:56:48 -0700 | [diff] [blame] | 7369 | |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 7370 | if (!ndlp) { |
James Smart | a643c6d | 2019-08-14 16:56:48 -0700 | [diff] [blame] | 7371 | dev_info(&rport->dev, "Cannot find remote node to " |
| 7372 | "set rport dev loss tmo, port_id x%x\n", |
| 7373 | rport->port_id); |
| 7374 | return; |
| 7375 | } |
| 7376 | |
| 7377 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 7378 | nrport = lpfc_ndlp_get_nrport(ndlp); |
| 7379 | |
| 7380 | if (nrport && nrport->remoteport) |
| 7381 | nvme_fc_set_remoteport_devloss(nrport->remoteport, |
| 7382 | rport->dev_loss_tmo); |
| 7383 | #endif |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7384 | } |
| 7385 | |
Lee Jones | 9176ad2 | 2020-11-02 14:23:44 +0000 | [diff] [blame] | 7386 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7387 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7388 | * |
| 7389 | * Description: |
| 7390 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 7391 | * |
| 7392 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 7393 | * @cdev: class converted to an fc_rport. |
| 7394 | * @buf: on return contains the target_field or zero. |
| 7395 | * |
| 7396 | * Returns: size of formatted string. |
| 7397 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7398 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 7399 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 7400 | lpfc_show_rport_##field (struct device *dev, \ |
| 7401 | struct device_attribute *attr, \ |
| 7402 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7403 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 7404 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7405 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 7406 | return scnprintf(buf, sz, format_string, \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7407 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 7408 | } |
| 7409 | |
| 7410 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 7411 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 7412 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 7413 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7414 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7415 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7416 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 7417 | * |
| 7418 | * Description: |
| 7419 | * This function is called by the transport after the @fc_vport's symbolic name |
| 7420 | * has been changed. This function re-registers the symbolic name with the |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7421 | * switch to propagate the change into the fabric if the vport is active. |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7422 | **/ |
| 7423 | static void |
| 7424 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 7425 | { |
| 7426 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 7427 | |
| 7428 | if (vport->port_state == LPFC_VPORT_READY) |
| 7429 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 7430 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7431 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 7432 | /** |
| 7433 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 7434 | * @phba: Pointer to lpfc_hba struct. |
Lee Jones | a738bd9 | 2020-11-02 14:23:45 +0000 | [diff] [blame] | 7435 | * @verbose: Verbose level to set. |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 7436 | * |
| 7437 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 7438 | * module lpfc_log_verbose into the @phba cfg_log_verbose for use with |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 7439 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 7440 | * before hba port or vport created. |
| 7441 | **/ |
| 7442 | static void |
| 7443 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 7444 | { |
| 7445 | phba->cfg_log_verbose = verbose; |
| 7446 | } |
| 7447 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7448 | struct fc_function_template lpfc_transport_functions = { |
| 7449 | /* fixed attributes the driver supports */ |
| 7450 | .show_host_node_name = 1, |
| 7451 | .show_host_port_name = 1, |
| 7452 | .show_host_supported_classes = 1, |
| 7453 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7454 | .show_host_supported_speeds = 1, |
| 7455 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 7456 | |
| 7457 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7458 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7459 | |
| 7460 | /* dynamic attributes the driver supports */ |
| 7461 | .get_host_port_id = lpfc_get_host_port_id, |
| 7462 | .show_host_port_id = 1, |
| 7463 | |
| 7464 | .get_host_port_type = lpfc_get_host_port_type, |
| 7465 | .show_host_port_type = 1, |
| 7466 | |
| 7467 | .get_host_port_state = lpfc_get_host_port_state, |
| 7468 | .show_host_port_state = 1, |
| 7469 | |
| 7470 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 7471 | .show_host_active_fc4s = 1, |
| 7472 | |
| 7473 | .get_host_speed = lpfc_get_host_speed, |
| 7474 | .show_host_speed = 1, |
| 7475 | |
| 7476 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 7477 | .show_host_fabric_name = 1, |
| 7478 | |
| 7479 | /* |
| 7480 | * The LPFC driver treats linkdown handling as target loss events |
| 7481 | * so there are no sysfs handlers for link_down_tmo. |
| 7482 | */ |
| 7483 | |
| 7484 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7485 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7486 | |
| 7487 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 7488 | .show_rport_maxframe_size = 1, |
| 7489 | .show_rport_supported_classes = 1, |
| 7490 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7491 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 7492 | .show_rport_dev_loss_tmo = 1, |
| 7493 | |
| 7494 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 7495 | .show_starget_port_id = 1, |
| 7496 | |
| 7497 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 7498 | .show_starget_node_name = 1, |
| 7499 | |
| 7500 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 7501 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 7502 | |
| 7503 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 7504 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 7505 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7506 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7507 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7508 | |
| 7509 | .vport_disable = lpfc_vport_disable, |
| 7510 | |
| 7511 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 7512 | |
| 7513 | .bsg_request = lpfc_bsg_request, |
| 7514 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7515 | }; |
| 7516 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7517 | struct fc_function_template lpfc_vport_transport_functions = { |
| 7518 | /* fixed attributes the driver supports */ |
| 7519 | .show_host_node_name = 1, |
| 7520 | .show_host_port_name = 1, |
| 7521 | .show_host_supported_classes = 1, |
| 7522 | .show_host_supported_fc4s = 1, |
| 7523 | .show_host_supported_speeds = 1, |
| 7524 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 7525 | |
| 7526 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7527 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7528 | |
| 7529 | /* dynamic attributes the driver supports */ |
| 7530 | .get_host_port_id = lpfc_get_host_port_id, |
| 7531 | .show_host_port_id = 1, |
| 7532 | |
| 7533 | .get_host_port_type = lpfc_get_host_port_type, |
| 7534 | .show_host_port_type = 1, |
| 7535 | |
| 7536 | .get_host_port_state = lpfc_get_host_port_state, |
| 7537 | .show_host_port_state = 1, |
| 7538 | |
| 7539 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 7540 | .show_host_active_fc4s = 1, |
| 7541 | |
| 7542 | .get_host_speed = lpfc_get_host_speed, |
| 7543 | .show_host_speed = 1, |
| 7544 | |
| 7545 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 7546 | .show_host_fabric_name = 1, |
| 7547 | |
| 7548 | /* |
| 7549 | * The LPFC driver treats linkdown handling as target loss events |
| 7550 | * so there are no sysfs handlers for link_down_tmo. |
| 7551 | */ |
| 7552 | |
| 7553 | .get_fc_host_stats = lpfc_get_stats, |
| 7554 | .reset_fc_host_stats = lpfc_reset_stats, |
| 7555 | |
| 7556 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 7557 | .show_rport_maxframe_size = 1, |
| 7558 | .show_rport_supported_classes = 1, |
| 7559 | |
| 7560 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 7561 | .show_rport_dev_loss_tmo = 1, |
| 7562 | |
| 7563 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 7564 | .show_starget_port_id = 1, |
| 7565 | |
| 7566 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 7567 | .show_starget_node_name = 1, |
| 7568 | |
| 7569 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 7570 | .show_starget_port_name = 1, |
| 7571 | |
| 7572 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 7573 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 7574 | |
| 7575 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7576 | |
| 7577 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7578 | }; |
| 7579 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7580 | /** |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7581 | * lpfc_get_hba_function_mode - Used to determine the HBA function in FCoE |
| 7582 | * Mode |
| 7583 | * @phba: lpfc_hba pointer. |
| 7584 | **/ |
| 7585 | static void |
| 7586 | lpfc_get_hba_function_mode(struct lpfc_hba *phba) |
| 7587 | { |
James Smart | 412e737 | 2019-09-21 20:59:04 -0700 | [diff] [blame] | 7588 | /* If the adapter supports FCoE mode */ |
| 7589 | switch (phba->pcidev->device) { |
| 7590 | case PCI_DEVICE_ID_SKYHAWK: |
| 7591 | case PCI_DEVICE_ID_SKYHAWK_VF: |
| 7592 | case PCI_DEVICE_ID_LANCER_FCOE: |
| 7593 | case PCI_DEVICE_ID_LANCER_FCOE_VF: |
| 7594 | case PCI_DEVICE_ID_ZEPHYR_DCSP: |
| 7595 | case PCI_DEVICE_ID_HORNET: |
| 7596 | case PCI_DEVICE_ID_TIGERSHARK: |
| 7597 | case PCI_DEVICE_ID_TOMCAT: |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7598 | phba->hba_flag |= HBA_FCOE_MODE; |
James Smart | 412e737 | 2019-09-21 20:59:04 -0700 | [diff] [blame] | 7599 | break; |
| 7600 | default: |
| 7601 | /* for others, clear the flag */ |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7602 | phba->hba_flag &= ~HBA_FCOE_MODE; |
James Smart | 412e737 | 2019-09-21 20:59:04 -0700 | [diff] [blame] | 7603 | } |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7604 | } |
| 7605 | |
| 7606 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7607 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7608 | * @phba: lpfc_hba pointer. |
| 7609 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7610 | void |
| 7611 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 7612 | { |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 7613 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 7614 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 7615 | lpfc_ns_query_init(phba, lpfc_ns_query); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 7616 | lpfc_fcp2_no_tgt_reset_init(phba, lpfc_fcp2_no_tgt_reset); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7617 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 7618 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 7619 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 7620 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 7621 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7622 | lpfc_ack0_init(phba, lpfc_ack0); |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 7623 | lpfc_xri_rebalancing_init(phba, lpfc_xri_rebalancing); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7624 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7625 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 7626 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 7627 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 7628 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 7629 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 7630 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 3e49af9 | 2021-05-14 12:55:57 -0700 | [diff] [blame] | 7631 | lpfc_fcp_wait_abts_rsp_init(phba, lpfc_fcp_wait_abts_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7632 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 7633 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 7634 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7635 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 7636 | lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 7637 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 7638 | lpfc_force_rscn_init(phba, lpfc_force_rscn); |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 7639 | lpfc_cq_poll_threshold_init(phba, lpfc_cq_poll_threshold); |
| 7640 | lpfc_cq_max_proc_limit_init(phba, lpfc_cq_max_proc_limit); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 7641 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 7642 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 7643 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 7644 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7645 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
Gaurav Srivastava | 7ba2272 | 2021-06-08 10:05:48 +0530 | [diff] [blame] | 7646 | /* VMID Inits */ |
| 7647 | lpfc_max_vmid_init(phba, lpfc_max_vmid); |
| 7648 | lpfc_vmid_inactivity_timeout_init(phba, lpfc_vmid_inactivity_timeout); |
| 7649 | lpfc_vmid_app_header_init(phba, lpfc_vmid_app_header); |
| 7650 | lpfc_vmid_priority_tagging_init(phba, lpfc_vmid_priority_tagging); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7651 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 7652 | phba->cfg_EnableXLane = 0; |
| 7653 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 7654 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7655 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 7656 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 7657 | phba->cfg_oas_lun_state = 0; |
| 7658 | phba->cfg_oas_lun_status = 0; |
| 7659 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 7660 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 7661 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 7662 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 7663 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 7664 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7665 | phba->cfg_poll = 0; |
| 7666 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7667 | phba->cfg_poll = lpfc_poll; |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7668 | |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7669 | /* Get the function mode */ |
| 7670 | lpfc_get_hba_function_mode(phba); |
| 7671 | |
| 7672 | /* BlockGuard allowed for FC only. */ |
| 7673 | if (phba->cfg_enable_bg && phba->hba_flag & HBA_FCOE_MODE) { |
| 7674 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 7675 | "0581 BlockGuard feature not supported\n"); |
| 7676 | /* If set, clear the BlockGuard support param */ |
| 7677 | phba->cfg_enable_bg = 0; |
| 7678 | } else if (phba->cfg_enable_bg) { |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7679 | phba->sli3_options |= LPFC_SLI3_BG_ENABLED; |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7680 | } |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7681 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7682 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7683 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7684 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7685 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 7686 | lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7687 | |
| 7688 | /* Initialize first burst. Target vs Initiator are different. */ |
| 7689 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7690 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 7691 | lpfc_fcp_mq_threshold_init(phba, lpfc_fcp_mq_threshold); |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7692 | lpfc_hdw_queue_init(phba, lpfc_hdw_queue); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7693 | lpfc_irq_chann_init(phba, lpfc_irq_chann); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 7694 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 7695 | lpfc_enable_dpp_init(phba, lpfc_enable_dpp); |
James Smart | 8aaa7bc | 2020-10-20 13:27:17 -0700 | [diff] [blame] | 7696 | lpfc_enable_mi_init(phba, lpfc_enable_mi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7697 | |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 7698 | phba->cgn_p.cgn_param_mode = LPFC_CFG_OFF; |
James Smart | 9064aeb | 2021-08-16 09:28:50 -0700 | [diff] [blame] | 7699 | phba->cmf_active_mode = LPFC_CFG_OFF; |
| 7700 | if (lpfc_fabric_cgn_frequency > EDC_CG_SIGFREQ_CNT_MAX || |
| 7701 | lpfc_fabric_cgn_frequency < EDC_CG_SIGFREQ_CNT_MIN) |
| 7702 | lpfc_fabric_cgn_frequency = 100; /* 100 ms default */ |
| 7703 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7704 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 7705 | /* NVME only supported on SLI4 */ |
| 7706 | phba->nvmet_support = 0; |
James Smart | 982ab12 | 2019-03-12 16:30:10 -0700 | [diff] [blame] | 7707 | phba->cfg_nvmet_mrq = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7708 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 7709 | phba->cfg_enable_bbcr = 0; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 7710 | phba->cfg_xri_rebalancing = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7711 | } else { |
| 7712 | /* We MUST have FCP support */ |
| 7713 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 7714 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 7715 | } |
| 7716 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 7717 | phba->cfg_auto_imax = (phba->cfg_fcp_imax) ? 0 : 1; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 7718 | |
James Smart | 06b6fa38 | 2018-07-31 17:23:24 -0700 | [diff] [blame] | 7719 | phba->cfg_enable_pbde = 0; |
| 7720 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7721 | /* A value of 0 means use the number of CPUs found in the system */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7722 | if (phba->cfg_hdw_queue == 0) |
| 7723 | phba->cfg_hdw_queue = phba->sli4_hba.num_present_cpu; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7724 | if (phba->cfg_irq_chann == 0) |
| 7725 | phba->cfg_irq_chann = phba->sli4_hba.num_present_cpu; |
James Smart | d3de0d1 | 2021-04-11 18:31:21 -0700 | [diff] [blame] | 7726 | if (phba->cfg_irq_chann > phba->cfg_hdw_queue && |
| 7727 | phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7728 | phba->cfg_irq_chann = phba->cfg_hdw_queue; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7729 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 7730 | phba->cfg_soft_wwnn = 0L; |
| 7731 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 7732 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 7733 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 7734 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 7735 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 7736 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 7737 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 7738 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 7739 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 7740 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 7741 | lpfc_ras_fwlog_buffsize_init(phba, lpfc_ras_fwlog_buffsize); |
| 7742 | lpfc_ras_fwlog_level_init(phba, lpfc_ras_fwlog_level); |
| 7743 | lpfc_ras_fwlog_func_init(phba, lpfc_ras_fwlog_func); |
| 7744 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7745 | return; |
| 7746 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 7747 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7748 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7749 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 7750 | * dependencies between protocols and roles. |
| 7751 | * @phba: lpfc_hba pointer. |
| 7752 | **/ |
| 7753 | void |
| 7754 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 7755 | { |
Dick Kennedy | 9e3e365 | 2020-08-03 14:02:23 -0700 | [diff] [blame] | 7756 | int logit = 0; |
| 7757 | |
| 7758 | if (phba->cfg_hdw_queue > phba->sli4_hba.num_present_cpu) { |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7759 | phba->cfg_hdw_queue = phba->sli4_hba.num_present_cpu; |
Dick Kennedy | 9e3e365 | 2020-08-03 14:02:23 -0700 | [diff] [blame] | 7760 | logit = 1; |
| 7761 | } |
| 7762 | if (phba->cfg_irq_chann > phba->sli4_hba.num_present_cpu) { |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7763 | phba->cfg_irq_chann = phba->sli4_hba.num_present_cpu; |
Dick Kennedy | 9e3e365 | 2020-08-03 14:02:23 -0700 | [diff] [blame] | 7764 | logit = 1; |
| 7765 | } |
| 7766 | if (phba->cfg_irq_chann > phba->cfg_hdw_queue) { |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7767 | phba->cfg_irq_chann = phba->cfg_hdw_queue; |
Dick Kennedy | 9e3e365 | 2020-08-03 14:02:23 -0700 | [diff] [blame] | 7768 | logit = 1; |
| 7769 | } |
| 7770 | if (logit) |
| 7771 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 7772 | "2006 Reducing Queues - CPU limitation: " |
| 7773 | "IRQ %d HDWQ %d\n", |
| 7774 | phba->cfg_irq_chann, |
| 7775 | phba->cfg_hdw_queue); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7776 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7777 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 7778 | phba->nvmet_support) { |
| 7779 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7780 | |
| 7781 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 7782 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 7783 | "NVME Target PRLI ACC enable_fb ", |
| 7784 | phba->cfg_nvme_enable_fb, |
| 7785 | phba->cfg_nvmet_fb_size, |
| 7786 | LPFC_NVMET_FB_SZ_MAX); |
| 7787 | |
| 7788 | if (phba->cfg_nvme_enable_fb == 0) |
| 7789 | phba->cfg_nvmet_fb_size = 0; |
| 7790 | else { |
| 7791 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 7792 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 7793 | } |
| 7794 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7795 | if (!phba->cfg_nvmet_mrq) |
James Smart | 97a9ed3 | 2019-10-18 14:18:17 -0700 | [diff] [blame] | 7796 | phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7797 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7798 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
James Smart | 97a9ed3 | 2019-10-18 14:18:17 -0700 | [diff] [blame] | 7799 | if (phba->cfg_nvmet_mrq > phba->cfg_hdw_queue) { |
| 7800 | phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7801 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 7802 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 7803 | phba->cfg_nvmet_mrq); |
| 7804 | } |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7805 | if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) |
| 7806 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; |
| 7807 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7808 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7809 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 7810 | phba->nvmet_support = 0; |
James Smart | 982ab12 | 2019-03-12 16:30:10 -0700 | [diff] [blame] | 7811 | phba->cfg_nvmet_mrq = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7812 | phba->cfg_nvmet_fb_size = 0; |
| 7813 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7814 | } |
| 7815 | |
| 7816 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7817 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7818 | * @vport: lpfc_vport pointer. |
| 7819 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7820 | void |
| 7821 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 7822 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7823 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7824 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 7825 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7826 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 7827 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 7828 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 7829 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 7830 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 7831 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 7832 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 7833 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7834 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 7835 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 7836 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 7837 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7838 | return; |
| 7839 | } |