| 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 | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017 Broadcom. All Rights Reserved. The term * |
| 5 | * “Broadcom” refers to Broadcom Limited 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 | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 40 | #include <linux/nvme-fc-driver.h> |
| 41 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 42 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 43 | #include "lpfc_hw.h" |
| 44 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 45 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 46 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 47 | #include "lpfc_disc.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 48 | #include "lpfc.h" |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 49 | #include "lpfc_scsi.h" |
| 50 | #include "lpfc_nvme.h" |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 51 | #include "lpfc_nvmet.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 52 | #include "lpfc_logmsg.h" |
| 53 | #include "lpfc_version.h" |
| 54 | #include "lpfc_compat.h" |
| 55 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 56 | #include "lpfc_vport.h" |
James Smart | 93dd191 | 2016-07-06 12:36:10 -0700 | [diff] [blame] | 57 | #include "lpfc_attr.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 58 | |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 59 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 60 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 61 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 62 | |
James Smart | 61f3d4b | 2017-05-15 15:20:41 -0700 | [diff] [blame] | 63 | #define LPFC_DEF_MRQ_POST 512 |
| 64 | #define LPFC_MIN_MRQ_POST 512 |
| 65 | #define LPFC_MAX_MRQ_POST 2048 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 66 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 67 | /* |
| 68 | * Write key size should be multiple of 4. If write key is changed |
| 69 | * make sure that library write key is also changed. |
| 70 | */ |
| 71 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 72 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 73 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 74 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 75 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 76 | * @incr: integer to convert. |
| 77 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 78 | * |
| 79 | * Description: |
| 80 | * JEDEC Joint Electron Device Engineering Council. |
| 81 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 82 | * character string. The string is then terminated with a NULL in byte 9. |
| 83 | * Hex 0-9 becomes ascii '0' to '9'. |
| 84 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 85 | * |
| 86 | * Notes: |
| 87 | * Coded for 32 bit integers only. |
| 88 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 89 | static void |
| 90 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 91 | { |
| 92 | int i, j; |
| 93 | for (i = 0; i < 8; i++) { |
| 94 | j = (incr & 0xf); |
| 95 | if (j <= 9) |
| 96 | hdw[7 - i] = 0x30 + j; |
| 97 | else |
| 98 | hdw[7 - i] = 0x61 + j - 10; |
| 99 | incr = (incr >> 4); |
| 100 | } |
| 101 | hdw[8] = 0; |
| 102 | return; |
| 103 | } |
| 104 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 105 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 106 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 107 | * @dev: class unused variable. |
| 108 | * @attr: device attribute, not used. |
| 109 | * @buf: on return contains the module description text. |
| 110 | * |
| 111 | * Returns: size of formatted string. |
| 112 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 113 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 114 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 115 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 116 | { |
| 117 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 118 | } |
| 119 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 120 | /** |
| 121 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 122 | * @dev: class unused variable. |
| 123 | * @attr: device attribute, not used. |
| 124 | * @buf: on return contains the module description text. |
| 125 | * |
| 126 | * Returns: size of formatted string. |
| 127 | **/ |
| 128 | static ssize_t |
| 129 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 130 | char *buf) |
| 131 | { |
| 132 | struct Scsi_Host *shost = class_to_shost(dev); |
| 133 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 134 | struct lpfc_hba *phba = vport->phba; |
| 135 | |
| 136 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 137 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 138 | else |
| 139 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 140 | } |
| 141 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 142 | static ssize_t |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 143 | lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, |
| 144 | char *buf) |
| 145 | { |
| 146 | struct Scsi_Host *shost = class_to_shost(dev); |
| 147 | struct lpfc_vport *vport = shost_priv(shost); |
| 148 | struct lpfc_hba *phba = vport->phba; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 149 | struct lpfc_nvmet_tgtport *tgtp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 150 | struct nvme_fc_local_port *localport; |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 151 | struct lpfc_nodelist *ndlp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 152 | struct nvme_fc_remote_port *nrport; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 153 | uint64_t data1, data2, data3, tot; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 154 | char *statep; |
| 155 | int len = 0; |
| 156 | |
| 157 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
| 158 | len += snprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
| 159 | return len; |
| 160 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 161 | if (phba->nvmet_support) { |
| 162 | if (!phba->targetport) { |
| 163 | len = snprintf(buf, PAGE_SIZE, |
| 164 | "NVME Target: x%llx is not allocated\n", |
| 165 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 166 | return len; |
| 167 | } |
| 168 | /* Port state is only one of two values for now. */ |
| 169 | if (phba->targetport->port_id) |
| 170 | statep = "REGISTERED"; |
| 171 | else |
| 172 | statep = "INIT"; |
| 173 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | b4fd681 | 2017-06-15 22:56:42 -0700 | [diff] [blame] | 174 | "NVME Target Enabled State %s\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 175 | statep); |
| 176 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 177 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 178 | "NVME Target: lpfc", |
| 179 | phba->brd_no, |
| 180 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 181 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 182 | phba->targetport->port_id); |
| 183 | |
Maurizio Lombardi | ea98ab3 | 2017-04-18 11:55:51 +0200 | [diff] [blame] | 184 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 185 | "\nNVME Target: Statistics\n"); |
| 186 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
| 187 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 188 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 189 | atomic_read(&tgtp->rcv_ls_req_in), |
| 190 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 191 | atomic_read(&tgtp->xmt_ls_abort)); |
| 192 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 193 | atomic_read(&tgtp->rcv_ls_req_out)) { |
| 194 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 195 | "Rcv LS: in %08x != out %08x\n", |
| 196 | atomic_read(&tgtp->rcv_ls_req_in), |
| 197 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 198 | } |
| 199 | |
| 200 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 201 | "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n", |
| 202 | atomic_read(&tgtp->xmt_ls_rsp), |
| 203 | atomic_read(&tgtp->xmt_ls_drop), |
| 204 | atomic_read(&tgtp->xmt_ls_rsp_cmpl), |
| 205 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 206 | |
| 207 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 5073842 | 2017-08-01 15:12:40 -0700 | [diff] [blame] | 208 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 209 | "Drop %08x\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 210 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
James Smart | 5073842 | 2017-08-01 15:12:40 -0700 | [diff] [blame] | 211 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 212 | atomic_read(&tgtp->xmt_fcp_release), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 213 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 214 | |
| 215 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 216 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
| 217 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 218 | "Rcv FCP: in %08x != out %08x\n", |
| 219 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 220 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 221 | } |
| 222 | |
| 223 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 224 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " |
| 225 | "drop %08x\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 226 | atomic_read(&tgtp->xmt_fcp_read), |
| 227 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 228 | atomic_read(&tgtp->xmt_fcp_write), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 229 | atomic_read(&tgtp->xmt_fcp_rsp), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 230 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 231 | |
| 232 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 233 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 234 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 235 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 236 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 237 | |
| 238 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 239 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 240 | atomic_read(&tgtp->xmt_fcp_abort), |
| 241 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 242 | |
| 243 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 244 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x", |
| 245 | atomic_read(&tgtp->xmt_abort_sol), |
| 246 | atomic_read(&tgtp->xmt_abort_unsol), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 247 | atomic_read(&tgtp->xmt_abort_rsp), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 248 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 249 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 250 | /* Calculate outstanding IOs */ |
| 251 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 252 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 253 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 254 | |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 255 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 256 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 257 | "CTX Outstanding %08llx\n", |
James Smart | 966bb5b | 2017-06-15 22:56:45 -0700 | [diff] [blame] | 258 | phba->sli4_hba.nvmet_xri_cnt, |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 259 | phba->sli4_hba.nvmet_io_wait_cnt, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 260 | phba->sli4_hba.nvmet_io_wait_total, |
| 261 | tot); |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 262 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 263 | len += snprintf(buf+len, PAGE_SIZE-len, "\n"); |
| 264 | return len; |
| 265 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 266 | |
| 267 | localport = vport->localport; |
| 268 | if (!localport) { |
| 269 | len = snprintf(buf, PAGE_SIZE, |
| 270 | "NVME Initiator x%llx is not allocated\n", |
| 271 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 272 | return len; |
| 273 | } |
| 274 | len = snprintf(buf, PAGE_SIZE, "NVME Initiator Enabled\n"); |
| 275 | |
| 276 | spin_lock_irq(shost->host_lock); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 277 | |
| 278 | /* Port state is only one of two values for now. */ |
| 279 | if (localport->port_id) |
| 280 | statep = "ONLINE"; |
| 281 | else |
| 282 | statep = "UNKNOWN "; |
| 283 | |
| 284 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 285 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 286 | "NVME LPORT lpfc", |
| 287 | phba->brd_no, |
| 288 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 289 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 290 | localport->port_id, statep); |
| 291 | |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 292 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 293 | if (!ndlp->nrport) |
| 294 | continue; |
| 295 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 296 | /* local short-hand pointer. */ |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 297 | nrport = ndlp->nrport->remoteport; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 298 | |
| 299 | /* Port state is only one of two values for now. */ |
| 300 | switch (nrport->port_state) { |
| 301 | case FC_OBJSTATE_ONLINE: |
| 302 | statep = "ONLINE"; |
| 303 | break; |
| 304 | case FC_OBJSTATE_UNKNOWN: |
| 305 | statep = "UNKNOWN "; |
| 306 | break; |
| 307 | default: |
| 308 | statep = "UNSUPPORTED"; |
| 309 | break; |
| 310 | } |
| 311 | |
| 312 | /* Tab in to show lport ownership. */ |
| 313 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 314 | "NVME RPORT "); |
| 315 | if (phba->brd_no >= 10) |
| 316 | len += snprintf(buf + len, PAGE_SIZE - len, " "); |
| 317 | |
| 318 | len += snprintf(buf + len, PAGE_SIZE - len, "WWPN x%llx ", |
| 319 | nrport->port_name); |
| 320 | len += snprintf(buf + len, PAGE_SIZE - len, "WWNN x%llx ", |
| 321 | nrport->node_name); |
| 322 | len += snprintf(buf + len, PAGE_SIZE - len, "DID x%06x ", |
| 323 | nrport->port_id); |
| 324 | |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 325 | /* An NVME rport can have multiple roles. */ |
| 326 | if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 327 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 328 | "INITIATOR "); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 329 | if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 330 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 331 | "TARGET "); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 332 | if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 333 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 334 | "DISCSRVC "); |
| 335 | if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | |
| 336 | FC_PORT_ROLE_NVME_TARGET | |
| 337 | FC_PORT_ROLE_NVME_DISCOVERY)) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 338 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 339 | "UNKNOWN ROLE x%x", |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 340 | nrport->port_role); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 341 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 342 | len += snprintf(buf + len, PAGE_SIZE - len, "%s ", statep); |
| 343 | /* Terminate the string. */ |
| 344 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
| 345 | } |
| 346 | spin_unlock_irq(shost->host_lock); |
| 347 | |
Maurizio Lombardi | ea98ab3 | 2017-04-18 11:55:51 +0200 | [diff] [blame] | 348 | len += snprintf(buf + len, PAGE_SIZE - len, "\nNVME Statistics\n"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 349 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 350 | "LS: Xmt %016x Cmpl %016x\n", |
| 351 | atomic_read(&phba->fc4NvmeLsRequests), |
| 352 | atomic_read(&phba->fc4NvmeLsCmpls)); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 353 | |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 354 | tot = atomic_read(&phba->fc4NvmeIoCmpls); |
| 355 | data1 = atomic_read(&phba->fc4NvmeInputRequests); |
| 356 | data2 = atomic_read(&phba->fc4NvmeOutputRequests); |
| 357 | data3 = atomic_read(&phba->fc4NvmeControlRequests); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 358 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 359 | "FCP: Rd %016llx Wr %016llx IO %016llx\n", |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 360 | data1, data2, data3); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 361 | |
| 362 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 363 | " Cmpl %016llx Outstanding %016llx\n", |
| 364 | tot, (data1 + data2 + data3) - tot); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 365 | return len; |
| 366 | } |
| 367 | |
| 368 | static ssize_t |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 369 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 370 | char *buf) |
| 371 | { |
| 372 | struct Scsi_Host *shost = class_to_shost(dev); |
| 373 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 374 | struct lpfc_hba *phba = vport->phba; |
| 375 | |
| 376 | if (phba->cfg_enable_bg) |
| 377 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 378 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 379 | else |
| 380 | return snprintf(buf, PAGE_SIZE, |
| 381 | "BlockGuard Not Supported\n"); |
| 382 | else |
| 383 | return snprintf(buf, PAGE_SIZE, |
| 384 | "BlockGuard Disabled\n"); |
| 385 | } |
| 386 | |
| 387 | static ssize_t |
| 388 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 389 | char *buf) |
| 390 | { |
| 391 | struct Scsi_Host *shost = class_to_shost(dev); |
| 392 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 393 | struct lpfc_hba *phba = vport->phba; |
| 394 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 395 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 396 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | static ssize_t |
| 400 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 401 | char *buf) |
| 402 | { |
| 403 | struct Scsi_Host *shost = class_to_shost(dev); |
| 404 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 405 | struct lpfc_hba *phba = vport->phba; |
| 406 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 407 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 408 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | static ssize_t |
| 412 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 413 | char *buf) |
| 414 | { |
| 415 | struct Scsi_Host *shost = class_to_shost(dev); |
| 416 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 417 | struct lpfc_hba *phba = vport->phba; |
| 418 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 419 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 420 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 421 | } |
| 422 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 423 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 424 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 425 | * @dev: class converted to a Scsi_host structure. |
| 426 | * @attr: device attribute, not used. |
| 427 | * @buf: on return contains the formatted text from lpfc_info(). |
| 428 | * |
| 429 | * Returns: size of formatted string. |
| 430 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 431 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 432 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 433 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 434 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 435 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 436 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 437 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 438 | } |
| 439 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 440 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 441 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 442 | * @dev: class converted to a Scsi_host structure. |
| 443 | * @attr: device attribute, not used. |
| 444 | * @buf: on return contains the formatted text serial number. |
| 445 | * |
| 446 | * Returns: size of formatted string. |
| 447 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 448 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 449 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 450 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 451 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 452 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 453 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 454 | struct lpfc_hba *phba = vport->phba; |
| 455 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 456 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 457 | } |
| 458 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 459 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 460 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 461 | * @dev: class converted to a Scsi_host structure. |
| 462 | * @attr: device attribute, not used. |
| 463 | * @buf: on return contains the formatted support level. |
| 464 | * |
| 465 | * Description: |
| 466 | * Returns a number indicating the temperature sensor level currently |
| 467 | * supported, zero or one in ascii. |
| 468 | * |
| 469 | * Returns: size of formatted string. |
| 470 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 471 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 472 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 473 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 474 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 475 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 476 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 477 | struct lpfc_hba *phba = vport->phba; |
| 478 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 479 | } |
| 480 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 481 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 482 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 483 | * @dev: class converted to a Scsi_host structure. |
| 484 | * @attr: device attribute, not used. |
| 485 | * @buf: on return contains the scsi vpd model description. |
| 486 | * |
| 487 | * Returns: size of formatted string. |
| 488 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 489 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 490 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 491 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 492 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 493 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 494 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 495 | struct lpfc_hba *phba = vport->phba; |
| 496 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 497 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 498 | } |
| 499 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 500 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 501 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 502 | * @dev: class converted to a Scsi_host structure. |
| 503 | * @attr: device attribute, not used. |
| 504 | * @buf: on return contains the scsi vpd model name. |
| 505 | * |
| 506 | * Returns: size of formatted string. |
| 507 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 508 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 509 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 510 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 511 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 512 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 513 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 514 | struct lpfc_hba *phba = vport->phba; |
| 515 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 516 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 517 | } |
| 518 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 519 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 520 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 521 | * @dev: class converted to a Scsi_host structure. |
| 522 | * @attr: device attribute, not used. |
| 523 | * @buf: on return contains the scsi vpd program type. |
| 524 | * |
| 525 | * Returns: size of formatted string. |
| 526 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 527 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 528 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 529 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 530 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 531 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 532 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 533 | struct lpfc_hba *phba = vport->phba; |
| 534 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 535 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 536 | } |
| 537 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 538 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 539 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 540 | * @dev: class converted to a Scsi_host structure. |
| 541 | * @attr: device attribute, not used. |
| 542 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 543 | * |
| 544 | * Returns: size of formatted string. |
| 545 | **/ |
| 546 | static ssize_t |
| 547 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 548 | { |
| 549 | struct Scsi_Host *shost = class_to_shost(dev); |
| 550 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 551 | struct lpfc_hba *phba = vport->phba; |
| 552 | |
| 553 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 554 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 555 | } |
| 556 | |
| 557 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 558 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 559 | * @dev: class converted to a Scsi_host structure. |
| 560 | * @attr: device attribute, not used. |
| 561 | * @buf: on return contains scsi vpd program type. |
| 562 | * |
| 563 | * Returns: size of formatted string. |
| 564 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 565 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 566 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 567 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 568 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 569 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 570 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 571 | struct lpfc_hba *phba = vport->phba; |
| 572 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 573 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 574 | } |
| 575 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 576 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 577 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 578 | * @dev: class converted to a Scsi_host structure. |
| 579 | * @attr: device attribute, not used. |
| 580 | * @buf: on return contains the scsi vpd program type. |
| 581 | * |
| 582 | * Returns: size of formatted string. |
| 583 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 584 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 585 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 586 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 587 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 588 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 589 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 590 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 591 | uint32_t if_type; |
| 592 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 593 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 594 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 595 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 596 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 597 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 598 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 599 | |
| 600 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 601 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 602 | fwrev, phba->sli_rev); |
| 603 | else |
| 604 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 605 | fwrev, phba->sli_rev, if_type, sli_family); |
| 606 | |
| 607 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 608 | } |
| 609 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 610 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 611 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 612 | * @dev: class converted to a Scsi_host structure. |
| 613 | * @attr: device attribute, not used. |
| 614 | * @buf: on return contains the scsi vpd program type. |
| 615 | * |
| 616 | * Returns: size of formatted string. |
| 617 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 618 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 619 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 620 | { |
| 621 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 622 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 623 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 624 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 625 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 626 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 627 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 628 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 629 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 630 | |
| 631 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 632 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 633 | * @dev: class converted to a Scsi_host structure. |
| 634 | * @attr: device attribute, not used. |
| 635 | * @buf: on return contains the ROM and FCode ascii strings. |
| 636 | * |
| 637 | * Returns: size of formatted string. |
| 638 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 639 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 640 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 641 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 642 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 643 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 644 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 645 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 646 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 647 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 648 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 649 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 650 | |
| 651 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
| 652 | return snprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 653 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 654 | |
| 655 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 656 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 657 | * @dev: class converted to a Scsi_host structure. |
| 658 | * @attr: device attribute, not used. |
| 659 | * @buf: on return contains text describing the state of the link. |
| 660 | * |
| 661 | * Notes: |
| 662 | * The switch statement has no default so zero will be returned. |
| 663 | * |
| 664 | * Returns: size of formatted string. |
| 665 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 666 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 667 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 668 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 669 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 670 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 671 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 672 | struct lpfc_hba *phba = vport->phba; |
| 673 | int len = 0; |
| 674 | |
| 675 | switch (phba->link_state) { |
| 676 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 677 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 678 | case LPFC_INIT_START: |
| 679 | case LPFC_INIT_MBX_CMDS: |
| 680 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 681 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 682 | if (phba->hba_flag & LINK_DISABLED) |
| 683 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 684 | "Link Down - User disabled\n"); |
| 685 | else |
| 686 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 687 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 688 | break; |
| 689 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 690 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 691 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 692 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 693 | |
| 694 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 695 | case LPFC_LOCAL_CFG_LINK: |
| 696 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 697 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 698 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 699 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 700 | case LPFC_FLOGI: |
| 701 | case LPFC_FABRIC_CFG_LINK: |
| 702 | case LPFC_NS_REG: |
| 703 | case LPFC_NS_QRY: |
| 704 | case LPFC_BUILD_DISC_LIST: |
| 705 | case LPFC_DISC_AUTH: |
| 706 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 707 | "Discovery\n"); |
| 708 | break; |
| 709 | case LPFC_VPORT_READY: |
| 710 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 711 | break; |
| 712 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 713 | case LPFC_VPORT_FAILED: |
| 714 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 715 | break; |
| 716 | |
| 717 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 718 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 719 | "Unknown\n"); |
| 720 | break; |
| 721 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 722 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 723 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 724 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 725 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 726 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 727 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 728 | " Public Loop\n"); |
| 729 | else |
| 730 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 731 | " Private Loop\n"); |
| 732 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 733 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 734 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 735 | " Fabric\n"); |
| 736 | else |
| 737 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 738 | " Point-2-Point\n"); |
| 739 | } |
| 740 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 741 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 742 | return len; |
| 743 | } |
| 744 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 745 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 746 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 747 | * @dev: class unused variable. |
| 748 | * @attr: device attribute, not used. |
| 749 | * @buf: on return contains the module description text. |
| 750 | * |
| 751 | * Returns: size of formatted string. |
| 752 | **/ |
| 753 | static ssize_t |
| 754 | lpfc_sli4_protocol_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 | |
| 761 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 762 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 763 | |
| 764 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 765 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 766 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 767 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 768 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 769 | } |
| 770 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 771 | } |
| 772 | |
| 773 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 774 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 775 | * (OAS) is supported. |
| 776 | * @dev: class unused variable. |
| 777 | * @attr: device attribute, not used. |
| 778 | * @buf: on return contains the module description text. |
| 779 | * |
| 780 | * Returns: size of formatted string. |
| 781 | **/ |
| 782 | static ssize_t |
| 783 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 784 | char *buf) |
| 785 | { |
| 786 | struct Scsi_Host *shost = class_to_shost(dev); |
| 787 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 788 | struct lpfc_hba *phba = vport->phba; |
| 789 | |
| 790 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 791 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 792 | } |
| 793 | |
| 794 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 795 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 796 | * @dev: class device that is converted into a Scsi_host. |
| 797 | * @attr: device attribute, not used. |
| 798 | * @buf: one or more lpfc_polling_flags values. |
| 799 | * @count: not used. |
| 800 | * |
| 801 | * Returns: |
| 802 | * -EINVAL if the buffer is not "up" or "down" |
| 803 | * return from link state change function if non-zero |
| 804 | * length of the buf on success |
| 805 | **/ |
| 806 | static ssize_t |
| 807 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 808 | const char *buf, size_t count) |
| 809 | { |
| 810 | struct Scsi_Host *shost = class_to_shost(dev); |
| 811 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 812 | struct lpfc_hba *phba = vport->phba; |
| 813 | |
| 814 | int status = -EINVAL; |
| 815 | |
| 816 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 817 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 818 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 819 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 820 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 821 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 822 | |
| 823 | if (status == 0) |
| 824 | return strlen(buf); |
| 825 | else |
| 826 | return status; |
| 827 | } |
| 828 | |
| 829 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 830 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 831 | * @dev: class device that is converted into a Scsi_host. |
| 832 | * @attr: device attribute, not used. |
| 833 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 834 | * |
| 835 | * Description: |
| 836 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 837 | * vport counts. |
| 838 | * |
| 839 | * Returns: size of formatted string. |
| 840 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 841 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 842 | lpfc_num_discovered_ports_show(struct device *dev, |
| 843 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 844 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 845 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 846 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 847 | |
| 848 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 849 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 850 | } |
| 851 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 852 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 853 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 854 | * @shost: Scsi_Host pointer. |
| 855 | * |
| 856 | * Description: |
| 857 | * Bring the link down gracefully then re-init the link. The firmware will |
| 858 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 859 | * |
| 860 | * Returns: |
| 861 | * -EPERM port offline or management commands are being blocked |
| 862 | * -ENOMEM cannot allocate memory for the mailbox command |
| 863 | * -EIO error sending the mailbox command |
| 864 | * zero for success |
| 865 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 866 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 867 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 868 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 869 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 870 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 871 | LPFC_MBOXQ_t *pmboxq; |
| 872 | int mbxstatus = MBXERR_ERROR; |
| 873 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 874 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 875 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 876 | return -EPERM; |
| 877 | |
| 878 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 879 | |
| 880 | if (!pmboxq) |
| 881 | return -ENOMEM; |
| 882 | |
| 883 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 884 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 885 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 886 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 887 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 888 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 889 | if ((mbxstatus == MBX_SUCCESS) && |
| 890 | (pmboxq->u.mb.mbxStatus == 0 || |
| 891 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 892 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 893 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 894 | phba->cfg_link_speed); |
| 895 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 896 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 897 | if ((mbxstatus == MBX_SUCCESS) && |
| 898 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 899 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 900 | "2859 SLI authentication is required " |
| 901 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 902 | } |
| 903 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 904 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 905 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 906 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 907 | |
| 908 | if (mbxstatus == MBXERR_ERROR) |
| 909 | return -EIO; |
| 910 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 911 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 912 | } |
| 913 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 914 | int |
| 915 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 916 | { |
| 917 | int cnt = 0; |
| 918 | |
| 919 | spin_lock_irq(lock); |
| 920 | while (!list_empty(q)) { |
| 921 | spin_unlock_irq(lock); |
| 922 | msleep(20); |
| 923 | if (cnt++ > 250) { /* 5 secs */ |
| 924 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 925 | "0466 %s %s\n", |
| 926 | "Outstanding IO when ", |
| 927 | "bringing Adapter offline\n"); |
| 928 | return 0; |
| 929 | } |
| 930 | spin_lock_irq(lock); |
| 931 | } |
| 932 | spin_unlock_irq(lock); |
| 933 | return 1; |
| 934 | } |
| 935 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 936 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 937 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 938 | * @phba: lpfc_hba pointer. |
| 939 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 940 | * |
| 941 | * Notes: |
| 942 | * Assumes any error from lpfc_do_offline() will be negative. |
| 943 | * Can wait up to 5 seconds for the port ring buffers count |
| 944 | * 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] | 945 | * 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] | 946 | * |
| 947 | * Returns: |
| 948 | * -EIO error posting the event |
| 949 | * zero for success |
| 950 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 951 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 952 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 953 | { |
| 954 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 955 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 956 | struct lpfc_sli_ring *pring; |
| 957 | struct lpfc_sli *psli; |
| 958 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 959 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 960 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 961 | |
| 962 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 963 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 964 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 965 | if (rc == 0) |
| 966 | return -ENOMEM; |
| 967 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 968 | wait_for_completion(&online_compl); |
| 969 | |
| 970 | if (status != 0) |
| 971 | return -EIO; |
| 972 | |
| 973 | psli = &phba->sli; |
| 974 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 975 | /* Wait a little for things to settle down, but not |
| 976 | * long enough for dev loss timeout to expire. |
| 977 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 978 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 979 | for (i = 0; i < psli->num_rings; i++) { |
| 980 | pring = &psli->sli3_ring[i]; |
| 981 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 982 | &phba->hbalock)) |
| 983 | goto out; |
| 984 | } |
| 985 | } else { |
| 986 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 987 | pring = qp->pring; |
| 988 | if (!pring) |
| 989 | continue; |
| 990 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 991 | &pring->ring_lock)) |
| 992 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 993 | } |
| 994 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 995 | out: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 996 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 997 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 998 | if (rc == 0) |
| 999 | return -ENOMEM; |
| 1000 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1001 | wait_for_completion(&online_compl); |
| 1002 | |
| 1003 | if (status != 0) |
| 1004 | return -EIO; |
| 1005 | |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1009 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1010 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1011 | * @phba: lpfc_hba pointer. |
| 1012 | * |
| 1013 | * Description: |
| 1014 | * If the port is configured to allow a reset then the hba is brought |
| 1015 | * offline then online. |
| 1016 | * |
| 1017 | * Notes: |
| 1018 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1019 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1020 | * |
| 1021 | * Returns: |
| 1022 | * lpfc_do_offline() return code if not zero |
| 1023 | * -EIO reset not configured or error posting the event |
| 1024 | * zero for success |
| 1025 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1026 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1027 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1028 | { |
| 1029 | struct completion online_compl; |
| 1030 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1031 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1032 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1033 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1034 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1035 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1036 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1037 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1038 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1039 | if (status != 0) |
| 1040 | return status; |
| 1041 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1042 | |
| 1043 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1044 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1045 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1046 | if (rc == 0) |
| 1047 | return -ENOMEM; |
| 1048 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1049 | wait_for_completion(&online_compl); |
| 1050 | |
| 1051 | if (status != 0) |
| 1052 | return -EIO; |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1057 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1058 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1059 | * @dev: class device that is converted into a Scsi_host. |
| 1060 | * @attr: device attribute, not used. |
| 1061 | * @buf: containing the string "selective". |
| 1062 | * @count: unused variable. |
| 1063 | * |
| 1064 | * Description: |
| 1065 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1066 | * is called to perform the reset. |
| 1067 | * |
| 1068 | * Notes: |
| 1069 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1070 | * 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] | 1071 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1072 | * |
| 1073 | * Returns: |
| 1074 | * -EINVAL if the buffer does not contain the string "selective" |
| 1075 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1076 | * return value of lpfc_selective_reset() if the call fails |
| 1077 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1078 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1079 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1080 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1081 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1082 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1083 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1084 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1085 | int status = -EINVAL; |
| 1086 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1087 | if (!phba->cfg_enable_hba_reset) |
| 1088 | return -EACCES; |
| 1089 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1090 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1091 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1092 | |
| 1093 | if (status == 0) |
| 1094 | return strlen(buf); |
| 1095 | else |
| 1096 | return status; |
| 1097 | } |
| 1098 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1099 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1100 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1101 | * @phba: lpfc_hba pointer. |
| 1102 | * |
| 1103 | * Description: |
| 1104 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1105 | * the readyness after performing a firmware reset. |
| 1106 | * |
| 1107 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1108 | * 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] | 1109 | * reset, -EIO when port timeout from recovering from the reset. |
| 1110 | * |
| 1111 | * Note: |
| 1112 | * As the caller will interpret the return code by value, be careful in making |
| 1113 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1114 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1115 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1116 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1117 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1118 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1119 | int i; |
| 1120 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1121 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1122 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1123 | &portstat_reg.word0); |
| 1124 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1125 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1126 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1127 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1128 | return -EPERM; |
| 1129 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1130 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1131 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1132 | msleep(10); |
| 1133 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1134 | &portstat_reg.word0); |
| 1135 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1136 | continue; |
| 1137 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1138 | continue; |
| 1139 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1140 | continue; |
| 1141 | break; |
| 1142 | } |
| 1143 | |
| 1144 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1145 | return 0; |
| 1146 | else |
| 1147 | return -EIO; |
| 1148 | } |
| 1149 | |
| 1150 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1151 | * 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] | 1152 | * @phba: lpfc_hba pointer. |
| 1153 | * |
| 1154 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1155 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1156 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1157 | * |
| 1158 | * Returns: |
| 1159 | * zero for success |
| 1160 | **/ |
| 1161 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1162 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1163 | { |
| 1164 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1165 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1166 | uint32_t before_fc_flag; |
| 1167 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1168 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1169 | int status = 0, rc = 0; |
| 1170 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1171 | |
| 1172 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1173 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1174 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1175 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 1176 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 1177 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1178 | return -EPERM; |
| 1179 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1180 | /* Keep state if we need to restore back */ |
| 1181 | before_fc_flag = phba->pport->fc_flag; |
| 1182 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1183 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1184 | /* Disable SR-IOV virtual functions if enabled */ |
| 1185 | if (phba->cfg_sriov_nr_virtfn) { |
| 1186 | pci_disable_sriov(pdev); |
| 1187 | phba->cfg_sriov_nr_virtfn = 0; |
| 1188 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1189 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1190 | if (opcode == LPFC_FW_DUMP) |
| 1191 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1192 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1193 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1194 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1195 | if (status != 0) { |
| 1196 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1197 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1198 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1199 | |
| 1200 | /* wait for the device to be quiesced before firmware reset */ |
| 1201 | msleep(100); |
| 1202 | |
| 1203 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1204 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1205 | |
| 1206 | if (opcode == LPFC_FW_DUMP) |
| 1207 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1208 | else if (opcode == LPFC_FW_RESET) |
| 1209 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1210 | else if (opcode == LPFC_DV_RESET) |
| 1211 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1212 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1213 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1214 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1215 | /* flush */ |
| 1216 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1217 | |
| 1218 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1219 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1220 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1221 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1222 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1223 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1224 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1225 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1226 | } else if (rc == -EIO) { |
| 1227 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1228 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1229 | "3153 Fail to perform the requested " |
| 1230 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1231 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /* keep the original port state */ |
| 1235 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1236 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1237 | |
| 1238 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1239 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1240 | LPFC_EVT_ONLINE); |
| 1241 | if (!job_posted) |
| 1242 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1243 | |
| 1244 | wait_for_completion(&online_compl); |
| 1245 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1246 | out: |
| 1247 | /* in any case, restore the virtual functions enabled as before */ |
| 1248 | if (sriov_nr_virtfn) { |
| 1249 | sriov_err = |
| 1250 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1251 | if (!sriov_err) |
| 1252 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1253 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1254 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1255 | /* return proper error code */ |
| 1256 | if (!rc) { |
| 1257 | if (!job_posted) |
| 1258 | rc = -ENOMEM; |
| 1259 | else if (status) |
| 1260 | rc = -EIO; |
| 1261 | } |
| 1262 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1266 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1267 | * @dev: class device that is converted into a Scsi_host. |
| 1268 | * @attr: device attribute, not used. |
| 1269 | * @buf: on return contains the ascii number of nport events. |
| 1270 | * |
| 1271 | * Returns: size of formatted string. |
| 1272 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1273 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1274 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1275 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1276 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1277 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1278 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1279 | struct lpfc_hba *phba = vport->phba; |
| 1280 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1281 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1282 | } |
| 1283 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1284 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1285 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1286 | * @dev: class device that is converted into a Scsi_host. |
| 1287 | * @attr: device attribute, not used. |
| 1288 | * @buf: on return contains the state of the adapter. |
| 1289 | * |
| 1290 | * Returns: size of formatted string. |
| 1291 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1292 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1293 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1294 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1295 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1296 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1297 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1298 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1299 | char * state; |
| 1300 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1301 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1302 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1303 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1304 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1305 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1306 | state = "offline"; |
| 1307 | else |
| 1308 | state = "online"; |
| 1309 | |
| 1310 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1311 | } |
| 1312 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1313 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1314 | * 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] | 1315 | * @dev: class device that is converted into a Scsi_host. |
| 1316 | * @attr: device attribute, not used. |
| 1317 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1318 | * @count: unused variable. |
| 1319 | * |
| 1320 | * Returns: |
| 1321 | * -EACCES if enable hba reset not enabled |
| 1322 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1323 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1324 | * buf length greater than zero indicates success |
| 1325 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1326 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1327 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1328 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1329 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1330 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1331 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1332 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1333 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1334 | char *board_mode_str = NULL; |
| 1335 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1336 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1337 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1338 | if (!phba->cfg_enable_hba_reset) { |
| 1339 | status = -EACCES; |
| 1340 | goto board_mode_out; |
| 1341 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1342 | |
| 1343 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1344 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1345 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1346 | init_completion(&online_compl); |
| 1347 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1348 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1349 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1350 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1351 | if (rc == 0) { |
| 1352 | status = -ENOMEM; |
| 1353 | goto board_mode_out; |
| 1354 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1355 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1356 | if (status) |
| 1357 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1358 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1359 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1360 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1361 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1362 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1363 | else |
| 1364 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1365 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1366 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1367 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1368 | else |
| 1369 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1370 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1371 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1372 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1373 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1374 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1375 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1376 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1377 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1378 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1379 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1380 | if (!status) |
| 1381 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1382 | else { |
| 1383 | board_mode_str = strchr(buf, '\n'); |
| 1384 | if (board_mode_str) |
| 1385 | *board_mode_str = '\0'; |
| 1386 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1387 | "3097 Failed \"%s\", status(%d), " |
| 1388 | "fc_flag(x%x)\n", |
| 1389 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1390 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1391 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1392 | } |
| 1393 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1394 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1395 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1396 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1397 | * @mxri: max xri count. |
| 1398 | * @axri: available xri count. |
| 1399 | * @mrpi: max rpi count. |
| 1400 | * @arpi: available rpi count. |
| 1401 | * @mvpi: max vpi count. |
| 1402 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1403 | * |
| 1404 | * Description: |
| 1405 | * If an integer pointer for an count is not null then the value for the |
| 1406 | * count is returned. |
| 1407 | * |
| 1408 | * Returns: |
| 1409 | * zero on error |
| 1410 | * one for success |
| 1411 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1412 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1413 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1414 | uint32_t *mxri, uint32_t *axri, |
| 1415 | uint32_t *mrpi, uint32_t *arpi, |
| 1416 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1417 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1418 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1419 | LPFC_MBOXQ_t *pmboxq; |
| 1420 | MAILBOX_t *pmb; |
| 1421 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1422 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1423 | |
| 1424 | /* |
| 1425 | * prevent udev from issuing mailbox commands until the port is |
| 1426 | * configured. |
| 1427 | */ |
| 1428 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1429 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1430 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1431 | return 0; |
| 1432 | |
| 1433 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1434 | return 0; |
| 1435 | |
| 1436 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1437 | if (!pmboxq) |
| 1438 | return 0; |
| 1439 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1440 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1441 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1442 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1443 | pmb->mbxOwner = OWN_HOST; |
| 1444 | pmboxq->context1 = NULL; |
| 1445 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1446 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1447 | rc = MBX_NOT_FINISHED; |
| 1448 | else |
| 1449 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1450 | |
| 1451 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1452 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1453 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1454 | return 0; |
| 1455 | } |
| 1456 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1457 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1458 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1459 | if (mrpi) |
| 1460 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1461 | if (arpi) |
| 1462 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1463 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1464 | if (mxri) |
| 1465 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1466 | if (axri) |
| 1467 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1468 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1469 | |
| 1470 | /* Account for differences with SLI-3. Get vpi count from |
| 1471 | * mailbox data and subtract one for max vpi value. |
| 1472 | */ |
| 1473 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1474 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1475 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1476 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1477 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1478 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1479 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1480 | } else { |
| 1481 | if (mrpi) |
| 1482 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1483 | if (arpi) |
| 1484 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1485 | if (mxri) |
| 1486 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1487 | if (axri) |
| 1488 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1489 | if (mvpi) |
| 1490 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1491 | if (avpi) |
| 1492 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1493 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1494 | |
| 1495 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1496 | return 1; |
| 1497 | } |
| 1498 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1499 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1500 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1501 | * @dev: class device that is converted into a Scsi_host. |
| 1502 | * @attr: device attribute, not used. |
| 1503 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1504 | * |
| 1505 | * Description: |
| 1506 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1507 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1508 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1509 | * must check for "Unknown" in the buffer to detect a failure. |
| 1510 | * |
| 1511 | * Returns: size of formatted string. |
| 1512 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1513 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1514 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1515 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1516 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1517 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1518 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1519 | struct lpfc_hba *phba = vport->phba; |
| 1520 | uint32_t cnt; |
| 1521 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1522 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1523 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1524 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1525 | } |
| 1526 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1527 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1528 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1529 | * @dev: class device that is converted into a Scsi_host. |
| 1530 | * @attr: device attribute, not used. |
| 1531 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1532 | * |
| 1533 | * Description: |
| 1534 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1535 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1536 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1537 | * must check for "Unknown" in the buffer to detect a failure. |
| 1538 | * |
| 1539 | * Returns: size of formatted string. |
| 1540 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1541 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1542 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1543 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1544 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1545 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1546 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1547 | struct lpfc_hba *phba = vport->phba; |
| 1548 | uint32_t cnt, acnt; |
| 1549 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1550 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1551 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1552 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1553 | } |
| 1554 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1555 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1556 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1557 | * @dev: class device that is converted into a Scsi_host. |
| 1558 | * @attr: device attribute, not used. |
| 1559 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1560 | * |
| 1561 | * Description: |
| 1562 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1563 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1564 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1565 | * must check for "Unknown" in the buffer to detect a failure. |
| 1566 | * |
| 1567 | * Returns: size of formatted string. |
| 1568 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1569 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1570 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1571 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1572 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1573 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1574 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1575 | struct lpfc_hba *phba = vport->phba; |
| 1576 | uint32_t cnt; |
| 1577 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1578 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1579 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1580 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1581 | } |
| 1582 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1583 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1584 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1585 | * @dev: class device that is converted into a Scsi_host. |
| 1586 | * @attr: device attribute, not used. |
| 1587 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1588 | * |
| 1589 | * Description: |
| 1590 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1591 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1592 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1593 | * must check for "Unknown" in the buffer to detect a failure. |
| 1594 | * |
| 1595 | * Returns: size of formatted string. |
| 1596 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1597 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1598 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1599 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1600 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1601 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1602 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1603 | struct lpfc_hba *phba = vport->phba; |
| 1604 | uint32_t cnt, acnt; |
| 1605 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1606 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1607 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1608 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1609 | } |
| 1610 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1611 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1612 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1613 | * @dev: class device that is converted into a Scsi_host. |
| 1614 | * @attr: device attribute, not used. |
| 1615 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1616 | * |
| 1617 | * Description: |
| 1618 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1619 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1620 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1621 | * must check for "Unknown" in the buffer to detect a failure. |
| 1622 | * |
| 1623 | * Returns: size of formatted string. |
| 1624 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1625 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1626 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1627 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1628 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1629 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1630 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1631 | struct lpfc_hba *phba = vport->phba; |
| 1632 | uint32_t cnt; |
| 1633 | |
| 1634 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1635 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1636 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1637 | } |
| 1638 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1639 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1640 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1641 | * @dev: class device that is converted into a Scsi_host. |
| 1642 | * @attr: device attribute, not used. |
| 1643 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1644 | * |
| 1645 | * Description: |
| 1646 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1647 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1648 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1649 | * must check for "Unknown" in the buffer to detect a failure. |
| 1650 | * |
| 1651 | * Returns: size of formatted string. |
| 1652 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1653 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1654 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1655 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1656 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1657 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1658 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1659 | struct lpfc_hba *phba = vport->phba; |
| 1660 | uint32_t cnt, acnt; |
| 1661 | |
| 1662 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1663 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1664 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1665 | } |
| 1666 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1667 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1668 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1669 | * @dev: class device that is converted into a Scsi_host. |
| 1670 | * @attr: device attribute, not used. |
| 1671 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1672 | * |
| 1673 | * Description: |
| 1674 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1675 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1676 | * the id of the vport. |
| 1677 | * |
| 1678 | * Returns: size of formatted string. |
| 1679 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1680 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1681 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1682 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1683 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1684 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1685 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1686 | struct lpfc_hba *phba = vport->phba; |
| 1687 | |
| 1688 | if (!(phba->max_vpi)) |
| 1689 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1690 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1691 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1692 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1693 | } |
| 1694 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1695 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1696 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1697 | * @dev: class device that is converted into a Scsi_host. |
| 1698 | * @attr: device attribute, not used. |
| 1699 | * @buf: on return contains the cfg_poll in hex. |
| 1700 | * |
| 1701 | * Notes: |
| 1702 | * cfg_poll should be a lpfc_polling_flags type. |
| 1703 | * |
| 1704 | * Returns: size of formatted string. |
| 1705 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1706 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1707 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1708 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1709 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1710 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1711 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1712 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1713 | |
| 1714 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1715 | } |
| 1716 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1717 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1718 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1719 | * @dev: class device that is converted into a Scsi_host. |
| 1720 | * @attr: device attribute, not used. |
| 1721 | * @buf: one or more lpfc_polling_flags values. |
| 1722 | * @count: not used. |
| 1723 | * |
| 1724 | * Notes: |
| 1725 | * buf contents converted to integer and checked for a valid value. |
| 1726 | * |
| 1727 | * Returns: |
| 1728 | * -EINVAL if the buffer connot be converted or is out of range |
| 1729 | * length of the buf on success |
| 1730 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1731 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1732 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1733 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1734 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1735 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1736 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1737 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1738 | uint32_t creg_val; |
| 1739 | uint32_t old_val; |
| 1740 | int val=0; |
| 1741 | |
| 1742 | if (!isdigit(buf[0])) |
| 1743 | return -EINVAL; |
| 1744 | |
| 1745 | if (sscanf(buf, "%i", &val) != 1) |
| 1746 | return -EINVAL; |
| 1747 | |
| 1748 | if ((val & 0x3) != val) |
| 1749 | return -EINVAL; |
| 1750 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1751 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1752 | val = 0; |
| 1753 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1754 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1755 | "3051 lpfc_poll changed from %d to %d\n", |
| 1756 | phba->cfg_poll, val); |
| 1757 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1758 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1759 | |
| 1760 | old_val = phba->cfg_poll; |
| 1761 | |
| 1762 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1763 | if ((val & DISABLE_FCP_RING_INT) && |
| 1764 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1765 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1766 | spin_unlock_irq(&phba->hbalock); |
| 1767 | return -EINVAL; |
| 1768 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1769 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1770 | writel(creg_val, phba->HCregaddr); |
| 1771 | readl(phba->HCregaddr); /* flush */ |
| 1772 | |
| 1773 | lpfc_poll_start_timer(phba); |
| 1774 | } |
| 1775 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1776 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1777 | return -EINVAL; |
| 1778 | } |
| 1779 | |
| 1780 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1781 | (old_val & DISABLE_FCP_RING_INT)) |
| 1782 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1783 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1784 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1785 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1786 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1787 | spin_unlock_irq(&phba->hbalock); |
| 1788 | return -EINVAL; |
| 1789 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1790 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1791 | writel(creg_val, phba->HCregaddr); |
| 1792 | readl(phba->HCregaddr); /* flush */ |
| 1793 | } |
| 1794 | |
| 1795 | phba->cfg_poll = val; |
| 1796 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1797 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1798 | |
| 1799 | return strlen(buf); |
| 1800 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1801 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1802 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1803 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1804 | * @dev: class unused variable. |
| 1805 | * @attr: device attribute, not used. |
| 1806 | * @buf: on return contains the module description text. |
| 1807 | * |
| 1808 | * Returns: size of formatted string. |
| 1809 | **/ |
| 1810 | static ssize_t |
| 1811 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1812 | char *buf) |
| 1813 | { |
| 1814 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1815 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1816 | struct lpfc_hba *phba = vport->phba; |
| 1817 | |
| 1818 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1819 | } |
| 1820 | |
| 1821 | /** |
| 1822 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1823 | * @dev: class unused variable. |
| 1824 | * @attr: device attribute, not used. |
| 1825 | * @buf: on return contains the module description text. |
| 1826 | * |
| 1827 | * Returns: size of formatted string. |
| 1828 | **/ |
| 1829 | static ssize_t |
| 1830 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1831 | char *buf) |
| 1832 | { |
| 1833 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1834 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1835 | struct lpfc_hba *phba = vport->phba; |
| 1836 | |
| 1837 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1838 | } |
| 1839 | |
| 1840 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1841 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1842 | * @dev: class converted to a Scsi_host structure. |
| 1843 | * @attr: device attribute, not used. |
| 1844 | * @buf: on return contains the formatted text. |
| 1845 | * |
| 1846 | * Returns: size of formatted string. |
| 1847 | **/ |
| 1848 | static ssize_t |
| 1849 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1850 | char *buf) |
| 1851 | { |
| 1852 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1853 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1854 | struct lpfc_hba *phba = vport->phba; |
| 1855 | |
| 1856 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1857 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1858 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1859 | "" : "Not "); |
| 1860 | } |
| 1861 | |
| 1862 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1863 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1864 | * @dev: class converted to a Scsi_host structure. |
| 1865 | * @attr: device attribute, not used. |
| 1866 | * @buf: on return contains the formatted support level. |
| 1867 | * |
| 1868 | * Description: |
| 1869 | * Returns the maximum number of virtual functions a physical function can |
| 1870 | * support, 0 will be returned if called on virtual function. |
| 1871 | * |
| 1872 | * Returns: size of formatted string. |
| 1873 | **/ |
| 1874 | static ssize_t |
| 1875 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1876 | struct device_attribute *attr, |
| 1877 | char *buf) |
| 1878 | { |
| 1879 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1880 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1881 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1882 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1883 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1884 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1885 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1886 | } |
| 1887 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1888 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 1889 | { |
| 1890 | return val >= min && val <= max; |
| 1891 | } |
| 1892 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1893 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 1894 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 1895 | * @phba: pointer the the adapter structure. |
| 1896 | * @val: integer attribute value. |
| 1897 | * |
| 1898 | * Description: |
| 1899 | * Validates the min and max values then sets the |
| 1900 | * adapter config field if in the valid range. prints error message |
| 1901 | * and does not set the parameter if invalid. |
| 1902 | * |
| 1903 | * Returns: |
| 1904 | * zero on success |
| 1905 | * -EINVAL if val is invalid |
| 1906 | */ |
| 1907 | static ssize_t |
| 1908 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 1909 | { |
| 1910 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 1911 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1912 | "3068 %s_enable_bbcr changed from %d to %d\n", |
| 1913 | LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val); |
| 1914 | phba->cfg_enable_bbcr = val; |
| 1915 | return 0; |
| 1916 | } |
| 1917 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1918 | "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n", |
| 1919 | LPFC_DRIVER_NAME, val); |
| 1920 | return -EINVAL; |
| 1921 | } |
| 1922 | |
| 1923 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1924 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1925 | * |
| 1926 | * Description: |
| 1927 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1928 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1929 | * |
| 1930 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1931 | * @dev: class device that is converted into a Scsi_host. |
| 1932 | * @attr: device attribute, not used. |
| 1933 | * @buf: on return contains the attribute value in decimal. |
| 1934 | * |
| 1935 | * Returns: size of formatted string. |
| 1936 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1937 | #define lpfc_param_show(attr) \ |
| 1938 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1939 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1940 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1941 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1942 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1943 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1944 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1945 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1946 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1947 | } |
| 1948 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1949 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1950 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1951 | * |
| 1952 | * Description: |
| 1953 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1954 | * into a function with the name lpfc_hba_queue_depth_show |
| 1955 | * |
| 1956 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1957 | * @dev: class device that is converted into a Scsi_host. |
| 1958 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1959 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1960 | * |
| 1961 | * Returns: size of formatted string. |
| 1962 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1963 | #define lpfc_param_hex_show(attr) \ |
| 1964 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1965 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1966 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1967 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1968 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1969 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1970 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1971 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1972 | val = phba->cfg_##attr;\ |
| 1973 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1974 | phba->cfg_##attr);\ |
| 1975 | } |
| 1976 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1977 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1978 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1979 | * |
| 1980 | * Description: |
| 1981 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1982 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1983 | * takes a default argument, a minimum and maximum argument. |
| 1984 | * |
| 1985 | * lpfc_##attr##_init: Initializes an attribute. |
| 1986 | * @phba: pointer the the adapter structure. |
| 1987 | * @val: integer attribute value. |
| 1988 | * |
| 1989 | * Validates the min and max values then sets the adapter config field |
| 1990 | * accordingly, or uses the default if out of range and prints an error message. |
| 1991 | * |
| 1992 | * Returns: |
| 1993 | * zero on success |
| 1994 | * -EINVAL if default used |
| 1995 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1996 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1997 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1998 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1999 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2000 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2001 | phba->cfg_##attr = val;\ |
| 2002 | return 0;\ |
| 2003 | }\ |
| 2004 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2005 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2006 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2007 | phba->cfg_##attr = default;\ |
| 2008 | return -EINVAL;\ |
| 2009 | } |
| 2010 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2011 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2012 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2013 | * |
| 2014 | * Description: |
| 2015 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2016 | * into a function with the name lpfc_hba_queue_depth_set |
| 2017 | * |
| 2018 | * lpfc_##attr##_set: Sets an attribute value. |
| 2019 | * @phba: pointer the the adapter structure. |
| 2020 | * @val: integer attribute value. |
| 2021 | * |
| 2022 | * Description: |
| 2023 | * Validates the min and max values then sets the |
| 2024 | * adapter config field if in the valid range. prints error message |
| 2025 | * and does not set the parameter if invalid. |
| 2026 | * |
| 2027 | * Returns: |
| 2028 | * zero on success |
| 2029 | * -EINVAL if val is invalid |
| 2030 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2031 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2032 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2033 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2034 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2035 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2036 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2037 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2038 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2039 | phba->cfg_##attr = val;\ |
| 2040 | return 0;\ |
| 2041 | }\ |
| 2042 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2043 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2044 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2045 | return -EINVAL;\ |
| 2046 | } |
| 2047 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2048 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2049 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2050 | * |
| 2051 | * Description: |
| 2052 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2053 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2054 | * |
| 2055 | * lpfc_##attr##_store: Set an sttribute value. |
| 2056 | * @dev: class device that is converted into a Scsi_host. |
| 2057 | * @attr: device attribute, not used. |
| 2058 | * @buf: contains the attribute value in ascii. |
| 2059 | * @count: not used. |
| 2060 | * |
| 2061 | * Description: |
| 2062 | * Convert the ascii text number to an integer, then |
| 2063 | * use the lpfc_##attr##_set function to set the value. |
| 2064 | * |
| 2065 | * Returns: |
| 2066 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2067 | * length of buffer upon success. |
| 2068 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2069 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2070 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2071 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2072 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2073 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2074 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2075 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2076 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2077 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2078 | if (!isdigit(buf[0]))\ |
| 2079 | return -EINVAL;\ |
| 2080 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2081 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2082 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2083 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2084 | else \ |
| 2085 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | } |
| 2087 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2088 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2089 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2090 | * |
| 2091 | * Description: |
| 2092 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2093 | * into a function with the name lpfc_hba_queue_depth_show |
| 2094 | * |
| 2095 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2096 | * @dev: class device that is converted into a Scsi_host. |
| 2097 | * @attr: device attribute, not used. |
| 2098 | * @buf: on return contains the attribute value in decimal. |
| 2099 | * |
| 2100 | * Returns: length of formatted string. |
| 2101 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2102 | #define lpfc_vport_param_show(attr) \ |
| 2103 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2104 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2105 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2106 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2107 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2108 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2109 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 2110 | } |
| 2111 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2112 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2113 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2114 | * |
| 2115 | * Description: |
| 2116 | * Macro that given an attr e.g. |
| 2117 | * hba_queue_depth expands into a function with the name |
| 2118 | * lpfc_hba_queue_depth_show |
| 2119 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2120 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
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. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2123 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2124 | * |
| 2125 | * Returns: length of formatted string. |
| 2126 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2127 | #define lpfc_vport_param_hex_show(attr) \ |
| 2128 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2129 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2130 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2131 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2132 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2133 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2134 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 2135 | } |
| 2136 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2137 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2138 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2139 | * |
| 2140 | * Description: |
| 2141 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2142 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2143 | * takes a default argument, a minimum and maximum argument. |
| 2144 | * |
| 2145 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2146 | * adapter config field accordingly, or uses the default if out of range |
| 2147 | * and prints an error message. |
| 2148 | * @phba: pointer the the adapter structure. |
| 2149 | * @val: integer attribute value. |
| 2150 | * |
| 2151 | * Returns: |
| 2152 | * zero on success |
| 2153 | * -EINVAL if default used |
| 2154 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2155 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2156 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2157 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2158 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2159 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2160 | vport->cfg_##attr = val;\ |
| 2161 | return 0;\ |
| 2162 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2163 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2164 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2165 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2166 | vport->cfg_##attr = default;\ |
| 2167 | return -EINVAL;\ |
| 2168 | } |
| 2169 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2170 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2171 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2172 | * |
| 2173 | * Description: |
| 2174 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2175 | * into a function with the name lpfc_hba_queue_depth_set |
| 2176 | * |
| 2177 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2178 | * adapter config field if in the valid range. prints error message |
| 2179 | * and does not set the parameter if invalid. |
| 2180 | * @phba: pointer the the adapter structure. |
| 2181 | * @val: integer attribute value. |
| 2182 | * |
| 2183 | * Returns: |
| 2184 | * zero on success |
| 2185 | * -EINVAL if val is invalid |
| 2186 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2187 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2188 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2189 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2190 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2191 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2192 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2193 | "3053 lpfc_" #attr \ |
| 2194 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2195 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2196 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2197 | vport->cfg_##attr = val;\ |
| 2198 | return 0;\ |
| 2199 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2200 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2201 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2202 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2203 | return -EINVAL;\ |
| 2204 | } |
| 2205 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2206 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2207 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2208 | * |
| 2209 | * Description: |
| 2210 | * Macro that given an attr e.g. hba_queue_depth |
| 2211 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2212 | * |
| 2213 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2214 | * use the lpfc_##attr##_set function to set the value. |
| 2215 | * @cdev: class device that is converted into a Scsi_host. |
| 2216 | * @buf: contains the attribute value in decimal. |
| 2217 | * @count: not used. |
| 2218 | * |
| 2219 | * Returns: |
| 2220 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2221 | * length of buffer upon success. |
| 2222 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2223 | #define lpfc_vport_param_store(attr) \ |
| 2224 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2225 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2226 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2227 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2228 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2229 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2230 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2231 | if (!isdigit(buf[0]))\ |
| 2232 | return -EINVAL;\ |
| 2233 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2234 | return -EINVAL;\ |
| 2235 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2236 | return strlen(buf);\ |
| 2237 | else \ |
| 2238 | return -EINVAL;\ |
| 2239 | } |
| 2240 | |
| 2241 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2242 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2243 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2244 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2245 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2246 | 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] | 2247 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2248 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2249 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2250 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2251 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2252 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2253 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2254 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2255 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2256 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2257 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2258 | lpfc_option_rom_version_show, NULL); |
| 2259 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2260 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2261 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2262 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 2263 | static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 2264 | static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2265 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2266 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2267 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2268 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2269 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2270 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2271 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2272 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2273 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2274 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 2275 | static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2276 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 2277 | static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2278 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2279 | static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, |
| 2280 | lpfc_sriov_hw_max_virtfn_show, NULL); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2281 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2282 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2283 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2284 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2285 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2286 | #define WWN_SZ 8 |
| 2287 | /** |
| 2288 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2289 | * @buf: WWN string. |
| 2290 | * @cnt: Length of string. |
| 2291 | * @wwn: Array to receive converted wwn value. |
| 2292 | * |
| 2293 | * Returns: |
| 2294 | * -EINVAL if the buffer does not contain a valid wwn |
| 2295 | * 0 success |
| 2296 | **/ |
| 2297 | static size_t |
| 2298 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2299 | { |
| 2300 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2301 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2302 | /* Count may include a LF at end of string */ |
| 2303 | if (buf[cnt-1] == '\n') |
| 2304 | cnt--; |
| 2305 | |
| 2306 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2307 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2308 | return -EINVAL; |
| 2309 | |
| 2310 | memset(wwn, 0, WWN_SZ); |
| 2311 | |
| 2312 | /* Validate and store the new name */ |
| 2313 | for (i = 0, j = 0; i < 16; i++) { |
| 2314 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2315 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2316 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2317 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2318 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2319 | j = ((j << 4) | (*buf++ - '0')); |
| 2320 | else |
| 2321 | return -EINVAL; |
| 2322 | if (i % 2) { |
| 2323 | wwn[i/2] = j & 0xff; |
| 2324 | j = 0; |
| 2325 | } |
| 2326 | } |
| 2327 | return 0; |
| 2328 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2329 | /** |
| 2330 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2331 | * @dev: class device that is converted into a Scsi_host. |
| 2332 | * @attr: device attribute, not used. |
| 2333 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2334 | * @count: must be size of lpfc_soft_wwn_key. |
| 2335 | * |
| 2336 | * Returns: |
| 2337 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2338 | * length of buf indicates success |
| 2339 | **/ |
| 2340 | static ssize_t |
| 2341 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2342 | const char *buf, size_t count) |
| 2343 | { |
| 2344 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2345 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2346 | struct lpfc_hba *phba = vport->phba; |
| 2347 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2348 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2349 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2350 | |
| 2351 | /* |
| 2352 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2353 | * We require that the user write a specific key to enable |
| 2354 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2355 | * is written, the enable key resets. If further updates are |
| 2356 | * desired, the key must be written again to re-enable the |
| 2357 | * attribute. |
| 2358 | * |
| 2359 | * The "key" is not secret - it is a hardcoded string shown |
| 2360 | * here. The intent is to protect against the random user or |
| 2361 | * application that is just writing attributes. |
| 2362 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2363 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2364 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2365 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2366 | " be enabled: fawwpn is enabled\n"); |
| 2367 | return -EINVAL; |
| 2368 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2369 | |
| 2370 | /* count may include a LF at end of string */ |
| 2371 | if (buf[cnt-1] == '\n') |
| 2372 | cnt--; |
| 2373 | |
| 2374 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2375 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2376 | return -EINVAL; |
| 2377 | |
| 2378 | phba->soft_wwn_enable = 1; |
| 2379 | |
| 2380 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2381 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2382 | phba->brd_no); |
| 2383 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2384 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2385 | |
| 2386 | return count; |
| 2387 | } |
| 2388 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 2389 | lpfc_soft_wwn_enable_store); |
| 2390 | |
| 2391 | /** |
| 2392 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2393 | * @dev: class device that is converted into a Scsi_host. |
| 2394 | * @attr: device attribute, not used. |
| 2395 | * @buf: on return contains the wwpn in hexadecimal. |
| 2396 | * |
| 2397 | * Returns: size of formatted string. |
| 2398 | **/ |
| 2399 | static ssize_t |
| 2400 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2401 | char *buf) |
| 2402 | { |
| 2403 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2404 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2405 | struct lpfc_hba *phba = vport->phba; |
| 2406 | |
| 2407 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2408 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2409 | } |
| 2410 | |
| 2411 | /** |
| 2412 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2413 | * @dev class device that is converted into a Scsi_host. |
| 2414 | * @attr: device attribute, not used. |
| 2415 | * @buf: contains the wwpn in hexadecimal. |
| 2416 | * @count: number of wwpn bytes in buf |
| 2417 | * |
| 2418 | * Returns: |
| 2419 | * -EACCES hba reset not enabled, adapter over temp |
| 2420 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2421 | * -EIO error taking adapter offline or online |
| 2422 | * value of count on success |
| 2423 | **/ |
| 2424 | static ssize_t |
| 2425 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2426 | const char *buf, size_t count) |
| 2427 | { |
| 2428 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2429 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2430 | struct lpfc_hba *phba = vport->phba; |
| 2431 | struct completion online_compl; |
| 2432 | int stat1 = 0, stat2 = 0; |
| 2433 | unsigned int cnt = count; |
| 2434 | u8 wwpn[WWN_SZ]; |
| 2435 | int rc; |
| 2436 | |
| 2437 | if (!phba->cfg_enable_hba_reset) |
| 2438 | return -EACCES; |
| 2439 | spin_lock_irq(&phba->hbalock); |
| 2440 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2441 | spin_unlock_irq(&phba->hbalock); |
| 2442 | return -EACCES; |
| 2443 | } |
| 2444 | spin_unlock_irq(&phba->hbalock); |
| 2445 | /* count may include a LF at end of string */ |
| 2446 | if (buf[cnt-1] == '\n') |
| 2447 | cnt--; |
| 2448 | |
| 2449 | if (!phba->soft_wwn_enable) |
| 2450 | return -EINVAL; |
| 2451 | |
| 2452 | /* lock setting wwpn, wwnn down */ |
| 2453 | phba->soft_wwn_enable = 0; |
| 2454 | |
| 2455 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2456 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2457 | /* not able to set wwpn, unlock it */ |
| 2458 | phba->soft_wwn_enable = 1; |
| 2459 | return rc; |
| 2460 | } |
| 2461 | |
| 2462 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2463 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2464 | if (phba->cfg_soft_wwnn) |
| 2465 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2466 | |
| 2467 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2468 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2469 | |
| 2470 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2471 | if (stat1) |
| 2472 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2473 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2474 | "reinit adapter - %d\n", stat1); |
| 2475 | init_completion(&online_compl); |
| 2476 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2477 | LPFC_EVT_ONLINE); |
| 2478 | if (rc == 0) |
| 2479 | return -ENOMEM; |
| 2480 | |
| 2481 | wait_for_completion(&online_compl); |
| 2482 | if (stat2) |
| 2483 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2484 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2485 | "reinit adapter - %d\n", stat2); |
| 2486 | return (stat1 || stat2) ? -EIO : count; |
| 2487 | } |
| 2488 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, |
| 2489 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
| 2490 | |
| 2491 | /** |
| 2492 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2493 | * @dev: class device that is converted into a Scsi_host. |
| 2494 | * @attr: device attribute, not used. |
| 2495 | * @buf: on return contains the wwnn in hexadecimal. |
| 2496 | * |
| 2497 | * Returns: size of formatted string. |
| 2498 | **/ |
| 2499 | static ssize_t |
| 2500 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2501 | char *buf) |
| 2502 | { |
| 2503 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2504 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2505 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2506 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2507 | } |
| 2508 | |
| 2509 | /** |
| 2510 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2511 | * @cdev: class device that is converted into a Scsi_host. |
| 2512 | * @buf: contains the ww node name in hexadecimal. |
| 2513 | * @count: number of wwnn bytes in buf. |
| 2514 | * |
| 2515 | * Returns: |
| 2516 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2517 | * value of count on success |
| 2518 | **/ |
| 2519 | static ssize_t |
| 2520 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2521 | const char *buf, size_t count) |
| 2522 | { |
| 2523 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2524 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2525 | unsigned int cnt = count; |
| 2526 | u8 wwnn[WWN_SZ]; |
| 2527 | int rc; |
| 2528 | |
| 2529 | /* count may include a LF at end of string */ |
| 2530 | if (buf[cnt-1] == '\n') |
| 2531 | cnt--; |
| 2532 | |
| 2533 | if (!phba->soft_wwn_enable) |
| 2534 | return -EINVAL; |
| 2535 | |
| 2536 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2537 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2538 | /* Allow wwnn to be set many times, as long as the enable |
| 2539 | * is set. However, once the wwpn is set, everything locks. |
| 2540 | */ |
| 2541 | return rc; |
| 2542 | } |
| 2543 | |
| 2544 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2545 | |
| 2546 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2547 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2548 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2549 | |
| 2550 | return count; |
| 2551 | } |
| 2552 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, |
| 2553 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2554 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2555 | /** |
| 2556 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2557 | * Optimized Access Storage (OAS) operations. |
| 2558 | * @dev: class device that is converted into a Scsi_host. |
| 2559 | * @attr: device attribute, not used. |
| 2560 | * @buf: buffer for passing information. |
| 2561 | * |
| 2562 | * Returns: |
| 2563 | * value of count |
| 2564 | **/ |
| 2565 | static ssize_t |
| 2566 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2567 | char *buf) |
| 2568 | { |
| 2569 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2570 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2571 | |
| 2572 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2573 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2574 | } |
| 2575 | |
| 2576 | /** |
| 2577 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2578 | * Optimized Access Storage (OAS) operations. |
| 2579 | * @dev: class device that is converted into a Scsi_host. |
| 2580 | * @attr: device attribute, not used. |
| 2581 | * @buf: buffer for passing information. |
| 2582 | * @count: Size of the data buffer. |
| 2583 | * |
| 2584 | * Returns: |
| 2585 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2586 | * -EPERM oas is not supported by hba |
| 2587 | * value of count on success |
| 2588 | **/ |
| 2589 | static ssize_t |
| 2590 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2591 | const char *buf, size_t count) |
| 2592 | { |
| 2593 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2594 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2595 | unsigned int cnt = count; |
| 2596 | uint8_t wwpn[WWN_SZ]; |
| 2597 | int rc; |
| 2598 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2599 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2600 | return -EPERM; |
| 2601 | |
| 2602 | /* count may include a LF at end of string */ |
| 2603 | if (buf[cnt-1] == '\n') |
| 2604 | cnt--; |
| 2605 | |
| 2606 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2607 | if (rc) |
| 2608 | return rc; |
| 2609 | |
| 2610 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2611 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2612 | if (wwn_to_u64(wwpn) == 0) |
| 2613 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2614 | else |
| 2615 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2616 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2617 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2618 | return count; |
| 2619 | } |
| 2620 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2621 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2622 | |
| 2623 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2624 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2625 | * Optimized Access Storage (OAS) operations. |
| 2626 | * @dev: class device that is converted into a Scsi_host. |
| 2627 | * @attr: device attribute, not used. |
| 2628 | * @buf: buffer for passing information. |
| 2629 | * |
| 2630 | * Returns: |
| 2631 | * value of count |
| 2632 | **/ |
| 2633 | static ssize_t |
| 2634 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2635 | char *buf) |
| 2636 | { |
| 2637 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2638 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2639 | |
| 2640 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2641 | } |
| 2642 | |
| 2643 | /** |
| 2644 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2645 | * Optimized Access Storage (OAS) operations. |
| 2646 | * @dev: class device that is converted into a Scsi_host. |
| 2647 | * @attr: device attribute, not used. |
| 2648 | * @buf: buffer for passing information. |
| 2649 | * @count: Size of the data buffer. |
| 2650 | * |
| 2651 | * Returns: |
| 2652 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2653 | * -EPERM oas is not supported by hba |
| 2654 | * value of count on success |
| 2655 | **/ |
| 2656 | static ssize_t |
| 2657 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2658 | const char *buf, size_t count) |
| 2659 | { |
| 2660 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2661 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2662 | unsigned int cnt = count; |
| 2663 | unsigned long val; |
| 2664 | int ret; |
| 2665 | |
| 2666 | if (!phba->cfg_fof) |
| 2667 | return -EPERM; |
| 2668 | |
| 2669 | /* count may include a LF at end of string */ |
| 2670 | if (buf[cnt-1] == '\n') |
| 2671 | cnt--; |
| 2672 | |
| 2673 | ret = kstrtoul(buf, 0, &val); |
| 2674 | if (ret || (val > 0x7f)) |
| 2675 | return -EINVAL; |
| 2676 | |
| 2677 | if (val) |
| 2678 | phba->cfg_oas_priority = (uint8_t)val; |
| 2679 | else |
| 2680 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2681 | return count; |
| 2682 | } |
| 2683 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2684 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2685 | |
| 2686 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2687 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2688 | * for Optimized Access Storage (OAS) operations. |
| 2689 | * @dev: class device that is converted into a Scsi_host. |
| 2690 | * @attr: device attribute, not used. |
| 2691 | * @buf: buffer for passing information. |
| 2692 | * |
| 2693 | * Returns: |
| 2694 | * value of count on success |
| 2695 | **/ |
| 2696 | static ssize_t |
| 2697 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2698 | char *buf) |
| 2699 | { |
| 2700 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2701 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2702 | |
| 2703 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2704 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2705 | } |
| 2706 | |
| 2707 | /** |
| 2708 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2709 | * for Optimized Access Storage (OAS) operations. |
| 2710 | * @dev: class device that is converted into a Scsi_host. |
| 2711 | * @attr: device attribute, not used. |
| 2712 | * @buf: buffer for passing information. |
| 2713 | * @count: Size of the data buffer. |
| 2714 | * |
| 2715 | * Returns: |
| 2716 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2717 | * -EPERM oas is not supported by hba |
| 2718 | * value of count on success |
| 2719 | **/ |
| 2720 | static ssize_t |
| 2721 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2722 | const char *buf, size_t count) |
| 2723 | { |
| 2724 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2725 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2726 | unsigned int cnt = count; |
| 2727 | uint8_t wwpn[WWN_SZ]; |
| 2728 | int rc; |
| 2729 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2730 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2731 | return -EPERM; |
| 2732 | |
| 2733 | /* count may include a LF at end of string */ |
| 2734 | if (buf[cnt-1] == '\n') |
| 2735 | cnt--; |
| 2736 | |
| 2737 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2738 | if (rc) |
| 2739 | return rc; |
| 2740 | |
| 2741 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2742 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2743 | if (wwn_to_u64(wwpn) == 0) |
| 2744 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2745 | else |
| 2746 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2747 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2748 | if (phba->cfg_oas_priority == 0) |
| 2749 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2750 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2751 | return count; |
| 2752 | } |
| 2753 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2754 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2755 | |
| 2756 | /** |
| 2757 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2758 | * of whether luns will be enabled or disabled |
| 2759 | * for Optimized Access Storage (OAS) operations. |
| 2760 | * @dev: class device that is converted into a Scsi_host. |
| 2761 | * @attr: device attribute, not used. |
| 2762 | * @buf: buffer for passing information. |
| 2763 | * |
| 2764 | * Returns: |
| 2765 | * size of formatted string. |
| 2766 | **/ |
| 2767 | static ssize_t |
| 2768 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2769 | char *buf) |
| 2770 | { |
| 2771 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2772 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2773 | |
| 2774 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2775 | } |
| 2776 | |
| 2777 | /** |
| 2778 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2779 | * of whether luns will be enabled or disabled |
| 2780 | * for Optimized Access Storage (OAS) operations. |
| 2781 | * @dev: class device that is converted into a Scsi_host. |
| 2782 | * @attr: device attribute, not used. |
| 2783 | * @buf: buffer for passing information. |
| 2784 | * @count: Size of the data buffer. |
| 2785 | * |
| 2786 | * Returns: |
| 2787 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2788 | * -EPERM oas is not supported by hba |
| 2789 | * value of count on success |
| 2790 | **/ |
| 2791 | static ssize_t |
| 2792 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2793 | const char *buf, size_t count) |
| 2794 | { |
| 2795 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2796 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2797 | int val = 0; |
| 2798 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2799 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2800 | return -EPERM; |
| 2801 | |
| 2802 | if (!isdigit(buf[0])) |
| 2803 | return -EINVAL; |
| 2804 | |
| 2805 | if (sscanf(buf, "%i", &val) != 1) |
| 2806 | return -EINVAL; |
| 2807 | |
| 2808 | if ((val != 0) && (val != 1)) |
| 2809 | return -EINVAL; |
| 2810 | |
| 2811 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2812 | return strlen(buf); |
| 2813 | } |
| 2814 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2815 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2816 | |
| 2817 | /** |
| 2818 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2819 | * Storage (OAS) lun returned by the |
| 2820 | * lpfc_oas_lun_show function. |
| 2821 | * @dev: class device that is converted into a Scsi_host. |
| 2822 | * @attr: device attribute, not used. |
| 2823 | * @buf: buffer for passing information. |
| 2824 | * |
| 2825 | * Returns: |
| 2826 | * size of formatted string. |
| 2827 | **/ |
| 2828 | static ssize_t |
| 2829 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2830 | char *buf) |
| 2831 | { |
| 2832 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2833 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2834 | |
| 2835 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2836 | return -EFAULT; |
| 2837 | |
| 2838 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2839 | } |
| 2840 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2841 | lpfc_oas_lun_status_show, NULL); |
| 2842 | |
| 2843 | |
| 2844 | /** |
| 2845 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2846 | * (OAS) operations. |
| 2847 | * @phba: lpfc_hba pointer. |
| 2848 | * @ndlp: pointer to fcp target node. |
| 2849 | * @lun: the fc lun for setting oas state. |
| 2850 | * @oas_state: the oas state to be set to the lun. |
| 2851 | * |
| 2852 | * Returns: |
| 2853 | * SUCCESS : 0 |
| 2854 | * -EPERM OAS is not enabled or not supported by this port. |
| 2855 | * |
| 2856 | */ |
| 2857 | static size_t |
| 2858 | 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] | 2859 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2860 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2861 | { |
| 2862 | |
| 2863 | int rc = 0; |
| 2864 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2865 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2866 | return -EPERM; |
| 2867 | |
| 2868 | if (oas_state) { |
| 2869 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2870 | (struct lpfc_name *)tgt_wwpn, |
| 2871 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2872 | rc = -ENOMEM; |
| 2873 | } else { |
| 2874 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2875 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2876 | } |
| 2877 | return rc; |
| 2878 | |
| 2879 | } |
| 2880 | |
| 2881 | /** |
| 2882 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2883 | * Access Storage (OAS) operations. |
| 2884 | * @phba: lpfc_hba pointer. |
| 2885 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2886 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2887 | * @lun_status: status of the lun returned lun |
| 2888 | * |
| 2889 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2890 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2891 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2892 | * |
| 2893 | * Return: |
| 2894 | * lun that is OAS enabled for the vport/target |
| 2895 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2896 | */ |
| 2897 | static uint64_t |
| 2898 | 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] | 2899 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 2900 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2901 | { |
| 2902 | uint64_t found_lun; |
| 2903 | |
| 2904 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2905 | return NOT_OAS_ENABLED_LUN; |
| 2906 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2907 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2908 | (struct lpfc_name *) |
| 2909 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2910 | &phba->sli4_hba.oas_next_lun, |
| 2911 | (struct lpfc_name *)vpt_wwpn, |
| 2912 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2913 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2914 | return found_lun; |
| 2915 | else |
| 2916 | return NOT_OAS_ENABLED_LUN; |
| 2917 | } |
| 2918 | |
| 2919 | /** |
| 2920 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2921 | * @phba: lpfc_hba pointer. |
| 2922 | * @vpt_wwpn: vport wwpn by reference. |
| 2923 | * @tgt_wwpn: target wwpn by reference. |
| 2924 | * @lun: the fc lun for setting oas state. |
| 2925 | * @oas_state: the oas state to be set to the oas_lun. |
| 2926 | * |
| 2927 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2928 | * a lun for OAS operations. |
| 2929 | * |
| 2930 | * Return: |
| 2931 | * SUCCESS: 0 |
| 2932 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2933 | * -EPERM: OAS is not enabled |
| 2934 | */ |
| 2935 | static ssize_t |
| 2936 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2937 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2938 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2939 | { |
| 2940 | |
| 2941 | int rc; |
| 2942 | |
| 2943 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2944 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2945 | return rc; |
| 2946 | } |
| 2947 | |
| 2948 | /** |
| 2949 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2950 | * @dev: class device that is converted into a Scsi_host. |
| 2951 | * @attr: device attribute, not used. |
| 2952 | * @buf: buffer for passing information. |
| 2953 | * |
| 2954 | * This routine returns a lun enabled for OAS each time the function |
| 2955 | * is called. |
| 2956 | * |
| 2957 | * Returns: |
| 2958 | * SUCCESS: size of formatted string. |
| 2959 | * -EFAULT: target or vport wwpn was not set properly. |
| 2960 | * -EPERM: oas is not enabled. |
| 2961 | **/ |
| 2962 | static ssize_t |
| 2963 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 2964 | char *buf) |
| 2965 | { |
| 2966 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2967 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2968 | |
| 2969 | uint64_t oas_lun; |
| 2970 | int len = 0; |
| 2971 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2972 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2973 | return -EPERM; |
| 2974 | |
| 2975 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2976 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 2977 | return -EFAULT; |
| 2978 | |
| 2979 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2980 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 2981 | return -EFAULT; |
| 2982 | |
| 2983 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 2984 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2985 | &phba->cfg_oas_lun_status, |
| 2986 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2987 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 2988 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 2989 | |
| 2990 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 2991 | |
| 2992 | return len; |
| 2993 | } |
| 2994 | |
| 2995 | /** |
| 2996 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 2997 | * @dev: class device that is converted into a Scsi_host. |
| 2998 | * @attr: device attribute, not used. |
| 2999 | * @buf: buffer for passing information. |
| 3000 | * |
| 3001 | * This function sets the OAS state for lun. Before this function is called, |
| 3002 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3003 | * |
| 3004 | * Returns: |
| 3005 | * SUCCESS: size of formatted string. |
| 3006 | * -EFAULT: target or vport wwpn was not set properly. |
| 3007 | * -EPERM: oas is not enabled. |
| 3008 | * size of formatted string. |
| 3009 | **/ |
| 3010 | static ssize_t |
| 3011 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3012 | const char *buf, size_t count) |
| 3013 | { |
| 3014 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3015 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3016 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3017 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3018 | ssize_t rc; |
| 3019 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3020 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3021 | return -EPERM; |
| 3022 | |
| 3023 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3024 | return -EFAULT; |
| 3025 | |
| 3026 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3027 | return -EFAULT; |
| 3028 | |
| 3029 | if (!isdigit(buf[0])) |
| 3030 | return -EINVAL; |
| 3031 | |
| 3032 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3033 | return -EINVAL; |
| 3034 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3035 | pri = phba->cfg_oas_priority; |
| 3036 | if (pri == 0) |
| 3037 | pri = phba->cfg_XLanePriority; |
| 3038 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3039 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3040 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3041 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3042 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3043 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3044 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3045 | |
| 3046 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3047 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3048 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3049 | if (rc) |
| 3050 | return rc; |
| 3051 | |
| 3052 | return count; |
| 3053 | } |
| 3054 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3055 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3056 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3057 | int lpfc_enable_nvmet_cnt; |
| 3058 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3059 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3060 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3061 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3062 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3063 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3064 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3065 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3066 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3067 | " 0 - none," |
| 3068 | " 1 - poll with interrupts enabled" |
| 3069 | " 3 - poll and disable FCP ring interrupts"); |
| 3070 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3071 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 3072 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3073 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3074 | int lpfc_no_hba_reset_cnt; |
| 3075 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3076 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3077 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3078 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3079 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3080 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3081 | "SLI mode selector:" |
| 3082 | " 0 - auto (SLI-3 if supported)," |
| 3083 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3084 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3085 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3086 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3087 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3088 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3089 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3090 | "FCF Fast failover=1 Priority failover=2"); |
| 3091 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3092 | /* |
| 3093 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3094 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3095 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3096 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3097 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3098 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3099 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3100 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3101 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3102 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3103 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3104 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3105 | # 0x2 = never bring up link |
| 3106 | # Default value is 0. |
| 3107 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3108 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3109 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3110 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3111 | /* |
| 3112 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3113 | # 1 - (1024) |
| 3114 | # 2 - (2048) |
| 3115 | # 3 - (3072) |
| 3116 | # 4 - (4096) |
| 3117 | # 5 - (5120) |
| 3118 | */ |
| 3119 | static ssize_t |
| 3120 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3121 | { |
| 3122 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3123 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3124 | |
| 3125 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 3126 | } |
| 3127 | |
| 3128 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3129 | lpfc_iocb_hw_show, NULL); |
| 3130 | static ssize_t |
| 3131 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3132 | { |
| 3133 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3134 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3135 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3136 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3137 | return snprintf(buf, PAGE_SIZE, "%d\n", pring->txq_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3138 | } |
| 3139 | |
| 3140 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3141 | lpfc_txq_hw_show, NULL); |
| 3142 | static ssize_t |
| 3143 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3144 | char *buf) |
| 3145 | { |
| 3146 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3147 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3148 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3149 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3150 | return snprintf(buf, PAGE_SIZE, "%d\n", pring->txcmplq_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3151 | } |
| 3152 | |
| 3153 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3154 | lpfc_txcmplq_hw_show, NULL); |
| 3155 | |
James Smart | 0d8c8ba | 2016-10-13 15:06:07 -0700 | [diff] [blame] | 3156 | LPFC_ATTR_R(iocb_cnt, 2, 1, 5, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3157 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3158 | |
| 3159 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3160 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3161 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3162 | */ |
| 3163 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3164 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3165 | module_param(lpfc_nodev_tmo, int, 0); |
| 3166 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3167 | "Seconds driver will hold I/O waiting " |
| 3168 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3169 | |
| 3170 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3171 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3172 | * @dev: class converted to a Scsi_host structure. |
| 3173 | * @attr: device attribute, not used. |
| 3174 | * @buf: on return contains the dev loss timeout in decimal. |
| 3175 | * |
| 3176 | * Returns: size of formatted string. |
| 3177 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3178 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3179 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3180 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3181 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3182 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3183 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3184 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3185 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3186 | } |
| 3187 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3188 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3189 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3190 | * @vport: lpfc vport structure pointer. |
| 3191 | * @val: contains the nodev timeout value. |
| 3192 | * |
| 3193 | * Description: |
| 3194 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3195 | * a kernel error message is printed and zero is returned. |
| 3196 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3197 | * Otherwise nodev tmo is set to the default value. |
| 3198 | * |
| 3199 | * Returns: |
| 3200 | * zero if already set or if val is in range |
| 3201 | * -EINVAL val out of range |
| 3202 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3203 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3204 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3205 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3206 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3207 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3208 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3209 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3210 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3211 | "parameter because lpfc_devloss_tmo " |
| 3212 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3213 | return 0; |
| 3214 | } |
| 3215 | |
| 3216 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3217 | vport->cfg_nodev_tmo = val; |
| 3218 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3219 | return 0; |
| 3220 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3221 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3222 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3223 | " %d, allowed range is [%d, %d]\n", |
| 3224 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3225 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3226 | return -EINVAL; |
| 3227 | } |
| 3228 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3229 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3230 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3231 | * @vport: lpfc vport structure pointer. |
| 3232 | * |
| 3233 | * Description: |
| 3234 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3235 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3236 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3237 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3238 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3239 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3240 | struct lpfc_nodelist *ndlp; |
| 3241 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3242 | shost = lpfc_shost_from_vport(vport); |
| 3243 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3244 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3245 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3246 | continue; |
| 3247 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3248 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame^] | 3249 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3250 | if (ndlp->nrport) |
| 3251 | nvme_fc_set_remoteport_devloss(ndlp->nrport->remoteport, |
| 3252 | vport->cfg_devloss_tmo); |
| 3253 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3254 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3255 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3256 | } |
| 3257 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3258 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3259 | * 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] | 3260 | * @vport: lpfc vport structure pointer. |
| 3261 | * @val: contains the tmo value. |
| 3262 | * |
| 3263 | * Description: |
| 3264 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3265 | * then a kernel error message is printed and zero is returned. |
| 3266 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3267 | * Otherwise nodev tmo is set to the default value. |
| 3268 | * |
| 3269 | * Returns: |
| 3270 | * zero if already set or if val is in range |
| 3271 | * -EINVAL val out of range |
| 3272 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3273 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3274 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3275 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3276 | if (vport->dev_loss_tmo_changed || |
| 3277 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3278 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3279 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3280 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3281 | return 0; |
| 3282 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3283 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3284 | vport->cfg_nodev_tmo = val; |
| 3285 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3286 | /* |
| 3287 | * For compat: set the fc_host dev loss so new rports |
| 3288 | * will get the value. |
| 3289 | */ |
| 3290 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3291 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3292 | return 0; |
| 3293 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3294 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3295 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3296 | "%d, allowed range is [%d, %d]\n", |
| 3297 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3298 | return -EINVAL; |
| 3299 | } |
| 3300 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3301 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3302 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3303 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 3304 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3305 | |
| 3306 | /* |
| 3307 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3308 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3309 | # value is 30. |
| 3310 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3311 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3312 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3313 | "Seconds driver will hold I/O waiting " |
| 3314 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3315 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3316 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3317 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3318 | |
| 3319 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3320 | * 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] | 3321 | * @vport: lpfc vport structure pointer. |
| 3322 | * @val: contains the tmo value. |
| 3323 | * |
| 3324 | * Description: |
| 3325 | * If val is in a valid range then set the vport nodev tmo, |
| 3326 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3327 | * Else a kernel error message is printed. |
| 3328 | * |
| 3329 | * Returns: |
| 3330 | * zero if val is in range |
| 3331 | * -EINVAL val out of range |
| 3332 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3333 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3334 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3335 | { |
| 3336 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3337 | vport->cfg_nodev_tmo = val; |
| 3338 | vport->cfg_devloss_tmo = val; |
| 3339 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3340 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3341 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3342 | return 0; |
| 3343 | } |
| 3344 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3345 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3346 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3347 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3348 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3349 | return -EINVAL; |
| 3350 | } |
| 3351 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3352 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3353 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 3354 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3355 | |
| 3356 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3357 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3358 | * lpfc_suppress_rsp = 0 Disable |
| 3359 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3360 | * |
| 3361 | */ |
| 3362 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3363 | "Enable suppress rsp feature is firmware supports it"); |
| 3364 | |
| 3365 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3366 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
| 3367 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3368 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3369 | * |
| 3370 | */ |
| 3371 | LPFC_ATTR_R(nvmet_mrq, |
| 3372 | 1, 1, 16, |
| 3373 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3374 | |
| 3375 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3376 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3377 | * Supported Values: 1 - register just FCP |
| 3378 | * 3 - register both FCP and NVME |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3379 | * Supported values are [1,3]. Default value is 1 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3380 | */ |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3381 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3382 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
| 3383 | "Define fc4 type to register with fabric."); |
| 3384 | |
| 3385 | /* |
| 3386 | * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME |
| 3387 | * This parameter is only used if: |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3388 | * lpfc_enable_fc4_type is 3 - register both FCP and NVME and |
| 3389 | * port is not configured for NVMET. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3390 | * |
| 3391 | * ELS/CT always get 10% of XRIs, up to a maximum of 250 |
| 3392 | * The remaining XRIs get split up based on lpfc_xri_split per port: |
| 3393 | * |
| 3394 | * Supported Values are in percentages |
| 3395 | * the xri_split value is the percentage the SCSI port will get. The remaining |
| 3396 | * percentage will go to NVME. |
| 3397 | */ |
| 3398 | LPFC_ATTR_R(xri_split, 50, 10, 90, |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 3399 | "Division of XRI resources between SCSI and NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3400 | |
| 3401 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3402 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3403 | # deluged with LOTS of information. |
| 3404 | # 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] | 3405 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3406 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3407 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3408 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3409 | |
| 3410 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3411 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3412 | # objects that have been registered with the nameserver after login. |
| 3413 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3414 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3415 | "Deregister nameserver objects before LOGO"); |
| 3416 | |
| 3417 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3418 | # lun_queue_depth: This parameter is used to limit the number of outstanding |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3419 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3420 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3421 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3422 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3423 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3424 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3425 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3426 | |
| 3427 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3428 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3429 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3430 | */ |
| 3431 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3432 | "Max number of FCP commands we can queue to a specific target port"); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3433 | |
| 3434 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3435 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3436 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3437 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3438 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3439 | # the hba_queue_depth. |
| 3440 | */ |
| 3441 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3442 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3443 | |
| 3444 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3445 | # peer_port_login: This parameter allows/prevents logins |
| 3446 | # between peer ports hosted on the same physical port. |
| 3447 | # When this parameter is set 0 peer ports of same physical port |
| 3448 | # are not allowed to login to each other. |
| 3449 | # When this parameter is set 1 peer ports of same physical port |
| 3450 | # are allowed to login to each other. |
| 3451 | # Default value of this parameter is 0. |
| 3452 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3453 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3454 | "Allow peer ports on the same physical port to login to each " |
| 3455 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3456 | |
| 3457 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3458 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3459 | # between Virtual Ports and remote initiators. |
| 3460 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3461 | # other initiators and will attempt to PLOGI all remote ports. |
| 3462 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3463 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3464 | # This parameter does not restrict to the physical port. |
| 3465 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3466 | # Default value of this parameter is 1. |
| 3467 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3468 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3469 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3470 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3471 | "Restrict virtual ports login to remote initiators."); |
| 3472 | lpfc_vport_param_show(restrict_login); |
| 3473 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3474 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3475 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3476 | * @vport: lpfc vport structure pointer. |
| 3477 | * @val: contains the restrict login value. |
| 3478 | * |
| 3479 | * Description: |
| 3480 | * If val is not in a valid range then log a kernel error message and set |
| 3481 | * the vport restrict login to one. |
| 3482 | * If the port type is physical clear the restrict login flag and return. |
| 3483 | * Else set the restrict login flag to val. |
| 3484 | * |
| 3485 | * Returns: |
| 3486 | * zero if val is in range |
| 3487 | * -EINVAL val out of range |
| 3488 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3489 | static int |
| 3490 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3491 | { |
| 3492 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3493 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3494 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3495 | "be set to %d, allowed range is [0, 1]\n", |
| 3496 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3497 | vport->cfg_restrict_login = 1; |
| 3498 | return -EINVAL; |
| 3499 | } |
| 3500 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3501 | vport->cfg_restrict_login = 0; |
| 3502 | return 0; |
| 3503 | } |
| 3504 | vport->cfg_restrict_login = val; |
| 3505 | return 0; |
| 3506 | } |
| 3507 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3508 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3509 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3510 | * @vport: lpfc vport structure pointer. |
| 3511 | * @val: contains the restrict login value. |
| 3512 | * |
| 3513 | * Description: |
| 3514 | * If val is not in a valid range then log a kernel error message and set |
| 3515 | * the vport restrict login to one. |
| 3516 | * If the port type is physical and the val is not zero log a kernel |
| 3517 | * error message, clear the restrict login flag and return zero. |
| 3518 | * Else set the restrict login flag to val. |
| 3519 | * |
| 3520 | * Returns: |
| 3521 | * zero if val is in range |
| 3522 | * -EINVAL val out of range |
| 3523 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3524 | static int |
| 3525 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3526 | { |
| 3527 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3528 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3529 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3530 | "be set to %d, allowed range is [0, 1]\n", |
| 3531 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3532 | vport->cfg_restrict_login = 1; |
| 3533 | return -EINVAL; |
| 3534 | } |
| 3535 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3536 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3537 | "0468 lpfc_restrict_login must be 0 for " |
| 3538 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3539 | vport->cfg_restrict_login = 0; |
| 3540 | return 0; |
| 3541 | } |
| 3542 | vport->cfg_restrict_login = val; |
| 3543 | return 0; |
| 3544 | } |
| 3545 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3546 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 3547 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3548 | |
| 3549 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3550 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3551 | # From a protocol standpoint "select ID" usually means select the |
| 3552 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3553 | # annex" which contains a table that maps a "select ID" (a number |
| 3554 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3555 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3556 | # ALPA. |
| 3557 | # |
| 3558 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3559 | # cause the lpfc driver to use an inverted table, effectively |
| 3560 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3561 | # |
| 3562 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3563 | # and will not work across a fabric. Also this parameter will take |
| 3564 | # effect only in the case when ALPA map is not available.) |
| 3565 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3566 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3567 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3568 | |
| 3569 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3570 | # lpfc_topology: link topology for init link |
| 3571 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3572 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3573 | # 0x02 = attempt point-to-point mode only |
| 3574 | # 0x04 = attempt loop mode only |
| 3575 | # 0x06 = attempt point-to-point mode then loop |
| 3576 | # Set point-to-point mode if you want to run as an N_Port. |
| 3577 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3578 | # Default value is 0. |
| 3579 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3580 | LPFC_ATTR(topology, 0, 0, 6, |
| 3581 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3582 | |
| 3583 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3584 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3585 | * @phba: lpfc_hba pointer. |
| 3586 | * @val: topology value. |
| 3587 | * |
| 3588 | * Description: |
| 3589 | * If val is in a valid range then set the adapter's topology field and |
| 3590 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3591 | * |
| 3592 | * If the value is not in range log a kernel error message and return an error. |
| 3593 | * |
| 3594 | * Returns: |
| 3595 | * zero if val is in range and lip okay |
| 3596 | * non-zero return value from lpfc_issue_lip() |
| 3597 | * -EINVAL val out of range |
| 3598 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3599 | static ssize_t |
| 3600 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3601 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3602 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3603 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3604 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3605 | struct lpfc_hba *phba = vport->phba; |
| 3606 | int val = 0; |
| 3607 | int nolip = 0; |
| 3608 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3609 | int err; |
| 3610 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3611 | |
| 3612 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3613 | nolip = 1; |
| 3614 | val_buf = &buf[strlen("nolip ")]; |
| 3615 | } |
| 3616 | |
| 3617 | if (!isdigit(val_buf[0])) |
| 3618 | return -EINVAL; |
| 3619 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3620 | return -EINVAL; |
| 3621 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3622 | if (val >= 0 && val <= 6) { |
| 3623 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3624 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3625 | val == 4) { |
| 3626 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3627 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3628 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3629 | return -EINVAL; |
| 3630 | } |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3631 | if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && |
| 3632 | val == 4) { |
| 3633 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3634 | "3114 Loop mode not supported\n"); |
| 3635 | return -EINVAL; |
| 3636 | } |
| 3637 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3638 | if (nolip) |
| 3639 | return strlen(buf); |
| 3640 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3641 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3642 | "3054 lpfc_topology changed from %d to %d\n", |
| 3643 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3644 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3645 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3646 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3647 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3648 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3649 | return -EINVAL; |
| 3650 | } else |
| 3651 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3652 | } |
| 3653 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3654 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3655 | "allowed range is [0, 6]\n", |
| 3656 | phba->brd_no, val); |
| 3657 | return -EINVAL; |
| 3658 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3659 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3660 | lpfc_param_show(topology) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3661 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3662 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3663 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3664 | /** |
| 3665 | * lpfc_static_vport_show: Read callback function for |
| 3666 | * lpfc_static_vport sysfs file. |
| 3667 | * @dev: Pointer to class device object. |
| 3668 | * @attr: device attribute structure. |
| 3669 | * @buf: Data buffer. |
| 3670 | * |
| 3671 | * This function is the read call back function for |
| 3672 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3673 | * sysfs file report the mageability of the vport. |
| 3674 | **/ |
| 3675 | static ssize_t |
| 3676 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3677 | char *buf) |
| 3678 | { |
| 3679 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3680 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3681 | if (vport->vport_flag & STATIC_VPORT) |
| 3682 | sprintf(buf, "1\n"); |
| 3683 | else |
| 3684 | sprintf(buf, "0\n"); |
| 3685 | |
| 3686 | return strlen(buf); |
| 3687 | } |
| 3688 | |
| 3689 | /* |
| 3690 | * Sysfs attribute to control the statistical data collection. |
| 3691 | */ |
| 3692 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 3693 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3694 | |
| 3695 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3696 | * 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] | 3697 | * @dev: Pointer to class device. |
| 3698 | * @buf: Data buffer. |
| 3699 | * @count: Size of the data buffer. |
| 3700 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 3701 | * 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] | 3702 | * sysfs file. This function parse the command written to the sysfs file |
| 3703 | * and take appropriate action. These commands are used for controlling |
| 3704 | * driver statistical data collection. |
| 3705 | * Following are the command this function handles. |
| 3706 | * |
| 3707 | * setbucket <bucket_type> <base> <step> |
| 3708 | * = Set the latency buckets. |
| 3709 | * destroybucket = destroy all the buckets. |
| 3710 | * start = start data collection |
| 3711 | * stop = stop data collection |
| 3712 | * reset = reset the collected data |
| 3713 | **/ |
| 3714 | static ssize_t |
| 3715 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3716 | const char *buf, size_t count) |
| 3717 | { |
| 3718 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3719 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3720 | struct lpfc_hba *phba = vport->phba; |
| 3721 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3722 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3723 | unsigned long i; |
| 3724 | char *str_ptr, *token; |
| 3725 | struct lpfc_vport **vports; |
| 3726 | struct Scsi_Host *v_shost; |
| 3727 | char *bucket_type_str, *base_str, *step_str; |
| 3728 | unsigned long base, step, bucket_type; |
| 3729 | |
| 3730 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3731 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3732 | return -EINVAL; |
| 3733 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 3734 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3735 | str_ptr = &bucket_data[0]; |
| 3736 | /* Ignore this token - this is command token */ |
| 3737 | token = strsep(&str_ptr, "\t "); |
| 3738 | if (!token) |
| 3739 | return -EINVAL; |
| 3740 | |
| 3741 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3742 | if (!bucket_type_str) |
| 3743 | return -EINVAL; |
| 3744 | |
| 3745 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3746 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3747 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3748 | bucket_type = LPFC_POWER2_BUCKET; |
| 3749 | else |
| 3750 | return -EINVAL; |
| 3751 | |
| 3752 | base_str = strsep(&str_ptr, "\t "); |
| 3753 | if (!base_str) |
| 3754 | return -EINVAL; |
| 3755 | base = simple_strtoul(base_str, NULL, 0); |
| 3756 | |
| 3757 | step_str = strsep(&str_ptr, "\t "); |
| 3758 | if (!step_str) |
| 3759 | return -EINVAL; |
| 3760 | step = simple_strtoul(step_str, NULL, 0); |
| 3761 | if (!step) |
| 3762 | return -EINVAL; |
| 3763 | |
| 3764 | /* Block the data collection for every vport */ |
| 3765 | vports = lpfc_create_vport_work_array(phba); |
| 3766 | if (vports == NULL) |
| 3767 | return -ENOMEM; |
| 3768 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3769 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3770 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3771 | spin_lock_irq(v_shost->host_lock); |
| 3772 | /* Block and reset data collection */ |
| 3773 | vports[i]->stat_data_blocked = 1; |
| 3774 | if (vports[i]->stat_data_enabled) |
| 3775 | lpfc_vport_reset_stat_data(vports[i]); |
| 3776 | spin_unlock_irq(v_shost->host_lock); |
| 3777 | } |
| 3778 | |
| 3779 | /* Set the bucket attributes */ |
| 3780 | phba->bucket_type = bucket_type; |
| 3781 | phba->bucket_base = base; |
| 3782 | phba->bucket_step = step; |
| 3783 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3784 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3785 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3786 | |
| 3787 | /* Unblock data collection */ |
| 3788 | spin_lock_irq(v_shost->host_lock); |
| 3789 | vports[i]->stat_data_blocked = 0; |
| 3790 | spin_unlock_irq(v_shost->host_lock); |
| 3791 | } |
| 3792 | lpfc_destroy_vport_work_array(phba, vports); |
| 3793 | return strlen(buf); |
| 3794 | } |
| 3795 | |
| 3796 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3797 | vports = lpfc_create_vport_work_array(phba); |
| 3798 | if (vports == NULL) |
| 3799 | return -ENOMEM; |
| 3800 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3801 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3802 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3803 | spin_lock_irq(shost->host_lock); |
| 3804 | vports[i]->stat_data_blocked = 1; |
| 3805 | lpfc_free_bucket(vport); |
| 3806 | vport->stat_data_enabled = 0; |
| 3807 | vports[i]->stat_data_blocked = 0; |
| 3808 | spin_unlock_irq(shost->host_lock); |
| 3809 | } |
| 3810 | lpfc_destroy_vport_work_array(phba, vports); |
| 3811 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3812 | phba->bucket_base = 0; |
| 3813 | phba->bucket_step = 0; |
| 3814 | return strlen(buf); |
| 3815 | } |
| 3816 | |
| 3817 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3818 | /* If no buckets configured return error */ |
| 3819 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3820 | return -EINVAL; |
| 3821 | spin_lock_irq(shost->host_lock); |
| 3822 | if (vport->stat_data_enabled) { |
| 3823 | spin_unlock_irq(shost->host_lock); |
| 3824 | return strlen(buf); |
| 3825 | } |
| 3826 | lpfc_alloc_bucket(vport); |
| 3827 | vport->stat_data_enabled = 1; |
| 3828 | spin_unlock_irq(shost->host_lock); |
| 3829 | return strlen(buf); |
| 3830 | } |
| 3831 | |
| 3832 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3833 | spin_lock_irq(shost->host_lock); |
| 3834 | if (vport->stat_data_enabled == 0) { |
| 3835 | spin_unlock_irq(shost->host_lock); |
| 3836 | return strlen(buf); |
| 3837 | } |
| 3838 | lpfc_free_bucket(vport); |
| 3839 | vport->stat_data_enabled = 0; |
| 3840 | spin_unlock_irq(shost->host_lock); |
| 3841 | return strlen(buf); |
| 3842 | } |
| 3843 | |
| 3844 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3845 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3846 | || !vport->stat_data_enabled) |
| 3847 | return strlen(buf); |
| 3848 | spin_lock_irq(shost->host_lock); |
| 3849 | vport->stat_data_blocked = 1; |
| 3850 | lpfc_vport_reset_stat_data(vport); |
| 3851 | vport->stat_data_blocked = 0; |
| 3852 | spin_unlock_irq(shost->host_lock); |
| 3853 | return strlen(buf); |
| 3854 | } |
| 3855 | return -EINVAL; |
| 3856 | } |
| 3857 | |
| 3858 | |
| 3859 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3860 | * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3861 | * @dev: Pointer to class device object. |
| 3862 | * @buf: Data buffer. |
| 3863 | * |
| 3864 | * This function is the read call back function for |
| 3865 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3866 | * current statistical data collection state. |
| 3867 | **/ |
| 3868 | static ssize_t |
| 3869 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3870 | char *buf) |
| 3871 | { |
| 3872 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3873 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3874 | struct lpfc_hba *phba = vport->phba; |
| 3875 | int index = 0; |
| 3876 | int i; |
| 3877 | char *bucket_type; |
| 3878 | unsigned long bucket_value; |
| 3879 | |
| 3880 | switch (phba->bucket_type) { |
| 3881 | case LPFC_LINEAR_BUCKET: |
| 3882 | bucket_type = "linear"; |
| 3883 | break; |
| 3884 | case LPFC_POWER2_BUCKET: |
| 3885 | bucket_type = "power2"; |
| 3886 | break; |
| 3887 | default: |
| 3888 | bucket_type = "No Bucket"; |
| 3889 | break; |
| 3890 | } |
| 3891 | |
| 3892 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3893 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3894 | " Bucket step :%d\nLatency Ranges :", |
| 3895 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3896 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3897 | index = strlen(buf); |
| 3898 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3899 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3900 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3901 | bucket_value = phba->bucket_base + |
| 3902 | phba->bucket_step * i; |
| 3903 | else |
| 3904 | bucket_value = phba->bucket_base + |
| 3905 | (1 << i) * phba->bucket_step; |
| 3906 | |
| 3907 | if (index + 10 > PAGE_SIZE) |
| 3908 | break; |
| 3909 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3910 | index = strlen(buf); |
| 3911 | } |
| 3912 | } |
| 3913 | sprintf(&buf[index], "\n"); |
| 3914 | return strlen(buf); |
| 3915 | } |
| 3916 | |
| 3917 | /* |
| 3918 | * Sysfs attribute to control the statistical data collection. |
| 3919 | */ |
| 3920 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 3921 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 3922 | |
| 3923 | /* |
| 3924 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3925 | */ |
| 3926 | |
| 3927 | /* |
| 3928 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3929 | * for each target. |
| 3930 | */ |
| 3931 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3932 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3933 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3934 | |
| 3935 | |
| 3936 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3937 | * 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] | 3938 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3939 | * @kobj: Pointer to the kernel object |
| 3940 | * @bin_attr: Attribute object |
| 3941 | * @buff: Buffer pointer |
| 3942 | * @off: File offset |
| 3943 | * @count: Buffer size |
| 3944 | * |
| 3945 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3946 | * sysfs file. This function export the statistical data to user |
| 3947 | * applications. |
| 3948 | **/ |
| 3949 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3950 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3951 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3952 | char *buf, loff_t off, size_t count) |
| 3953 | { |
| 3954 | struct device *dev = container_of(kobj, struct device, |
| 3955 | kobj); |
| 3956 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3957 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3958 | struct lpfc_hba *phba = vport->phba; |
| 3959 | int i = 0, index = 0; |
| 3960 | unsigned long nport_index; |
| 3961 | struct lpfc_nodelist *ndlp = NULL; |
| 3962 | nport_index = (unsigned long)off / |
| 3963 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3964 | |
| 3965 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3966 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3967 | return 0; |
| 3968 | |
| 3969 | spin_lock_irq(shost->host_lock); |
| 3970 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3971 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 3972 | continue; |
| 3973 | |
| 3974 | if (nport_index > 0) { |
| 3975 | nport_index--; |
| 3976 | continue; |
| 3977 | } |
| 3978 | |
| 3979 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 3980 | > count) |
| 3981 | break; |
| 3982 | |
| 3983 | if (!ndlp->lat_data) |
| 3984 | continue; |
| 3985 | |
| 3986 | /* Print the WWN */ |
| 3987 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 3988 | ndlp->nlp_portname.u.wwn[0], |
| 3989 | ndlp->nlp_portname.u.wwn[1], |
| 3990 | ndlp->nlp_portname.u.wwn[2], |
| 3991 | ndlp->nlp_portname.u.wwn[3], |
| 3992 | ndlp->nlp_portname.u.wwn[4], |
| 3993 | ndlp->nlp_portname.u.wwn[5], |
| 3994 | ndlp->nlp_portname.u.wwn[6], |
| 3995 | ndlp->nlp_portname.u.wwn[7]); |
| 3996 | |
| 3997 | index = strlen(buf); |
| 3998 | |
| 3999 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4000 | sprintf(&buf[index], "%010u,", |
| 4001 | ndlp->lat_data[i].cmd_count); |
| 4002 | index = strlen(buf); |
| 4003 | } |
| 4004 | sprintf(&buf[index], "\n"); |
| 4005 | index = strlen(buf); |
| 4006 | } |
| 4007 | spin_unlock_irq(shost->host_lock); |
| 4008 | return index; |
| 4009 | } |
| 4010 | |
| 4011 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4012 | .attr = { |
| 4013 | .name = "lpfc_drvr_stat_data", |
| 4014 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4015 | }, |
| 4016 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4017 | .read = sysfs_drvr_stat_data_read, |
| 4018 | .write = NULL, |
| 4019 | }; |
| 4020 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4021 | /* |
| 4022 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4023 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4024 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4025 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4026 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4027 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4028 | * @phba: lpfc_hba pointer. |
| 4029 | * @val: link speed value. |
| 4030 | * |
| 4031 | * Description: |
| 4032 | * If val is in a valid range then set the adapter's link speed field and |
| 4033 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4034 | * |
| 4035 | * Notes: |
| 4036 | * If the value is not in range log a kernel error message and return an error. |
| 4037 | * |
| 4038 | * Returns: |
| 4039 | * zero if val is in range and lip okay. |
| 4040 | * non-zero return value from lpfc_issue_lip() |
| 4041 | * -EINVAL val out of range |
| 4042 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4043 | static ssize_t |
| 4044 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4045 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4046 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4047 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4048 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4049 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4050 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4051 | int nolip = 0; |
| 4052 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4053 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4054 | uint32_t prev_val, if_type; |
| 4055 | |
| 4056 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 4057 | if (if_type == LPFC_SLI_INTF_IF_TYPE_2 && |
| 4058 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4059 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4060 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4061 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4062 | nolip = 1; |
| 4063 | val_buf = &buf[strlen("nolip ")]; |
| 4064 | } |
| 4065 | |
| 4066 | if (!isdigit(val_buf[0])) |
| 4067 | return -EINVAL; |
| 4068 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4069 | return -EINVAL; |
| 4070 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4071 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4072 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4073 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4074 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4075 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4076 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4077 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4078 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4079 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4080 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
| 4081 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4082 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4083 | "2879 lpfc_link_speed attribute cannot be set " |
| 4084 | "to %d. Speed is not supported by this port.\n", |
| 4085 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4086 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4087 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4088 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 4089 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 4090 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4091 | "3112 lpfc_link_speed attribute cannot be set " |
| 4092 | "to %d. Speed is not supported in loop mode.\n", |
| 4093 | val); |
| 4094 | return -EINVAL; |
| 4095 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4096 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 4097 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4098 | prev_val = phba->cfg_link_speed; |
| 4099 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4100 | if (nolip) |
| 4101 | return strlen(buf); |
| 4102 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4103 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4104 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4105 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4106 | return -EINVAL; |
| 4107 | } else |
| 4108 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4109 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4110 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4111 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4112 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4113 | return -EINVAL; |
| 4114 | } |
| 4115 | |
| 4116 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4117 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4118 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4119 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4120 | |
| 4121 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4122 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4123 | * @phba: lpfc_hba pointer. |
| 4124 | * @val: link speed value. |
| 4125 | * |
| 4126 | * Description: |
| 4127 | * If val is in a valid range then set the adapter's link speed field. |
| 4128 | * |
| 4129 | * Notes: |
| 4130 | * If the value is not in range log a kernel error message, clear the link |
| 4131 | * speed and return an error. |
| 4132 | * |
| 4133 | * Returns: |
| 4134 | * zero if val saved. |
| 4135 | * -EINVAL val out of range |
| 4136 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4137 | static int |
| 4138 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4139 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4140 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 4141 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4142 | "3111 lpfc_link_speed of %d cannot " |
| 4143 | "support loop mode, setting topology to default.\n", |
| 4144 | val); |
| 4145 | phba->cfg_topology = 0; |
| 4146 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4147 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 4148 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4149 | phba->cfg_link_speed = val; |
| 4150 | return 0; |
| 4151 | } |
| 4152 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4153 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4154 | "be set to %d, allowed values are " |
| 4155 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4156 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4157 | return -EINVAL; |
| 4158 | } |
| 4159 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4160 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4161 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4162 | |
| 4163 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4164 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4165 | # 0 = aer disabled or not supported |
| 4166 | # 1 = aer supported and enabled (default) |
| 4167 | # Value range is [0,1]. Default value is 1. |
| 4168 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4169 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4170 | "Enable PCIe device AER support"); |
| 4171 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4172 | |
| 4173 | /** |
| 4174 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4175 | * |
| 4176 | * @dev: class device that is converted into a Scsi_host. |
| 4177 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4178 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4179 | * @count: unused variable. |
| 4180 | * |
| 4181 | * Description: |
| 4182 | * If the val is 1 and currently the device's AER capability was not |
| 4183 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4184 | * enable the device's AER capability. If the helper routine enabling |
| 4185 | * AER returns success, update the device's cfg_aer_support flag to |
| 4186 | * indicate AER is supported by the device; otherwise, if the device |
| 4187 | * AER capability is already enabled to support AER, then do nothing. |
| 4188 | * |
| 4189 | * If the val is 0 and currently the device's AER support was enabled, |
| 4190 | * invoke the kernel's disable AER helper routine. After that, update |
| 4191 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4192 | * by the device; otherwise, if the device AER capability is already |
| 4193 | * disabled from supporting AER, then do nothing. |
| 4194 | * |
| 4195 | * Returns: |
| 4196 | * length of the buf on success if val is in range the intended mode |
| 4197 | * is supported. |
| 4198 | * -EINVAL if val out of range or intended mode is not supported. |
| 4199 | **/ |
| 4200 | static ssize_t |
| 4201 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4202 | const char *buf, size_t count) |
| 4203 | { |
| 4204 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4205 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4206 | struct lpfc_hba *phba = vport->phba; |
| 4207 | int val = 0, rc = -EINVAL; |
| 4208 | |
| 4209 | if (!isdigit(buf[0])) |
| 4210 | return -EINVAL; |
| 4211 | if (sscanf(buf, "%i", &val) != 1) |
| 4212 | return -EINVAL; |
| 4213 | |
| 4214 | switch (val) { |
| 4215 | case 0: |
| 4216 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4217 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4218 | if (!rc) { |
| 4219 | spin_lock_irq(&phba->hbalock); |
| 4220 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4221 | spin_unlock_irq(&phba->hbalock); |
| 4222 | phba->cfg_aer_support = 0; |
| 4223 | rc = strlen(buf); |
| 4224 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4225 | rc = -EPERM; |
| 4226 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4227 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4228 | rc = strlen(buf); |
| 4229 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4230 | break; |
| 4231 | case 1: |
| 4232 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4233 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4234 | if (!rc) { |
| 4235 | spin_lock_irq(&phba->hbalock); |
| 4236 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4237 | spin_unlock_irq(&phba->hbalock); |
| 4238 | phba->cfg_aer_support = 1; |
| 4239 | rc = strlen(buf); |
| 4240 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4241 | rc = -EPERM; |
| 4242 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4243 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4244 | rc = strlen(buf); |
| 4245 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4246 | break; |
| 4247 | default: |
| 4248 | rc = -EINVAL; |
| 4249 | break; |
| 4250 | } |
| 4251 | return rc; |
| 4252 | } |
| 4253 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4254 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 4255 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 4256 | |
| 4257 | /** |
| 4258 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4259 | * @dev: class device that is converted into a Scsi_host. |
| 4260 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4261 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4262 | * @count: unused variable. |
| 4263 | * |
| 4264 | * Description: |
| 4265 | * If the @buf contains 1 and the device currently has the AER support |
| 4266 | * enabled, then invokes the kernel AER helper routine |
| 4267 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4268 | * error status register. |
| 4269 | * |
| 4270 | * Notes: |
| 4271 | * |
| 4272 | * Returns: |
| 4273 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4274 | * enabled with the AER support. |
| 4275 | **/ |
| 4276 | static ssize_t |
| 4277 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4278 | const char *buf, size_t count) |
| 4279 | { |
| 4280 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4281 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4282 | struct lpfc_hba *phba = vport->phba; |
| 4283 | int val, rc = -1; |
| 4284 | |
| 4285 | if (!isdigit(buf[0])) |
| 4286 | return -EINVAL; |
| 4287 | if (sscanf(buf, "%i", &val) != 1) |
| 4288 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4289 | if (val != 1) |
| 4290 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4291 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4292 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4293 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4294 | |
| 4295 | if (rc == 0) |
| 4296 | return strlen(buf); |
| 4297 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4298 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4299 | } |
| 4300 | |
| 4301 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4302 | lpfc_aer_cleanup_state); |
| 4303 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4304 | /** |
| 4305 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4306 | * |
| 4307 | * @dev: class device that is converted into a Scsi_host. |
| 4308 | * @attr: device attribute, not used. |
| 4309 | * @buf: containing the string the number of vfs to be enabled. |
| 4310 | * @count: unused variable. |
| 4311 | * |
| 4312 | * Description: |
| 4313 | * When this api is called either through user sysfs, the driver shall |
| 4314 | * try to enable or disable SR-IOV virtual functions according to the |
| 4315 | * following: |
| 4316 | * |
| 4317 | * If zero virtual function has been enabled to the physical function, |
| 4318 | * the driver shall invoke the pci enable virtual function api trying |
| 4319 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4320 | * than the maximum supported, the maximum virtual function number will |
| 4321 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4322 | * be used for invoking the api. If the api call returned success, the |
| 4323 | * actual number of virtual functions enabled will be set to the driver |
| 4324 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4325 | * cfg_sriov_nr_virtfn remains zero. |
| 4326 | * |
| 4327 | * If none-zero virtual functions have already been enabled to the |
| 4328 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4329 | * -EINVAL will be returned and the driver does nothing; |
| 4330 | * |
| 4331 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4332 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4333 | * disabling virtual function api shall be invoded to disable all the |
| 4334 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4335 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4336 | * nothing. |
| 4337 | * |
| 4338 | * Returns: |
| 4339 | * length of the buf on success if val is in range the intended mode |
| 4340 | * is supported. |
| 4341 | * -EINVAL if val out of range or intended mode is not supported. |
| 4342 | **/ |
| 4343 | static ssize_t |
| 4344 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4345 | const char *buf, size_t count) |
| 4346 | { |
| 4347 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4348 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4349 | struct lpfc_hba *phba = vport->phba; |
| 4350 | struct pci_dev *pdev = phba->pcidev; |
| 4351 | int val = 0, rc = -EINVAL; |
| 4352 | |
| 4353 | /* Sanity check on user data */ |
| 4354 | if (!isdigit(buf[0])) |
| 4355 | return -EINVAL; |
| 4356 | if (sscanf(buf, "%i", &val) != 1) |
| 4357 | return -EINVAL; |
| 4358 | if (val < 0) |
| 4359 | return -EINVAL; |
| 4360 | |
| 4361 | /* Request disabling virtual functions */ |
| 4362 | if (val == 0) { |
| 4363 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4364 | pci_disable_sriov(pdev); |
| 4365 | phba->cfg_sriov_nr_virtfn = 0; |
| 4366 | } |
| 4367 | return strlen(buf); |
| 4368 | } |
| 4369 | |
| 4370 | /* Request enabling virtual functions */ |
| 4371 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4372 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4373 | "3018 There are %d virtual functions " |
| 4374 | "enabled on physical function.\n", |
| 4375 | phba->cfg_sriov_nr_virtfn); |
| 4376 | return -EEXIST; |
| 4377 | } |
| 4378 | |
| 4379 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4380 | phba->cfg_sriov_nr_virtfn = val; |
| 4381 | else { |
| 4382 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4383 | "3019 Enabling %d virtual functions is not " |
| 4384 | "allowed.\n", val); |
| 4385 | return -EINVAL; |
| 4386 | } |
| 4387 | |
| 4388 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4389 | if (rc) { |
| 4390 | phba->cfg_sriov_nr_virtfn = 0; |
| 4391 | rc = -EPERM; |
| 4392 | } else |
| 4393 | rc = strlen(buf); |
| 4394 | |
| 4395 | return rc; |
| 4396 | } |
| 4397 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4398 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4399 | "Enable PCIe device SR-IOV virtual fn"); |
| 4400 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4401 | lpfc_param_show(sriov_nr_virtfn) |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4402 | static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, |
| 4403 | lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); |
| 4404 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4405 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4406 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4407 | * |
| 4408 | * @dev: class device that is converted into a Scsi_host. |
| 4409 | * @attr: device attribute, not used. |
| 4410 | * @buf: containing the string the number of vfs to be enabled. |
| 4411 | * @count: unused variable. |
| 4412 | * |
| 4413 | * Description: |
| 4414 | * |
| 4415 | * Returns: |
| 4416 | * length of the buf on success if val is in range the intended mode |
| 4417 | * is supported. |
| 4418 | * -EINVAL if val out of range or intended mode is not supported. |
| 4419 | **/ |
| 4420 | static ssize_t |
| 4421 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4422 | struct device_attribute *attr, |
| 4423 | const char *buf, size_t count) |
| 4424 | { |
| 4425 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4426 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4427 | struct lpfc_hba *phba = vport->phba; |
| 4428 | int val = 0, rc = -EINVAL; |
| 4429 | |
| 4430 | /* Sanity check on user data */ |
| 4431 | if (!isdigit(buf[0])) |
| 4432 | return -EINVAL; |
| 4433 | if (sscanf(buf, "%i", &val) != 1) |
| 4434 | return -EINVAL; |
| 4435 | if (val != 1) |
| 4436 | return -EINVAL; |
| 4437 | |
| 4438 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4439 | if (rc) |
| 4440 | rc = -EPERM; |
| 4441 | else |
| 4442 | rc = strlen(buf); |
| 4443 | return rc; |
| 4444 | } |
| 4445 | |
| 4446 | static int lpfc_req_fw_upgrade; |
| 4447 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4448 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4449 | lpfc_param_show(request_firmware_upgrade) |
| 4450 | |
| 4451 | /** |
| 4452 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4453 | * @phba: lpfc_hba pointer. |
| 4454 | * @val: 0 or 1. |
| 4455 | * |
| 4456 | * Description: |
| 4457 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4458 | * |
| 4459 | * Returns: |
| 4460 | * zero if val saved. |
| 4461 | * -EINVAL val out of range |
| 4462 | **/ |
| 4463 | static int |
| 4464 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4465 | { |
| 4466 | if (val >= 0 && val <= 1) { |
| 4467 | phba->cfg_request_firmware_upgrade = val; |
| 4468 | return 0; |
| 4469 | } |
| 4470 | return -EINVAL; |
| 4471 | } |
| 4472 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4473 | lpfc_request_firmware_upgrade_show, |
| 4474 | lpfc_request_firmware_upgrade_store); |
| 4475 | |
| 4476 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4477 | * lpfc_fcp_imax_store |
| 4478 | * |
| 4479 | * @dev: class device that is converted into a Scsi_host. |
| 4480 | * @attr: device attribute, not used. |
| 4481 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4482 | * @count: unused variable. |
| 4483 | * |
| 4484 | * Description: |
| 4485 | * If val is in a valid range [636,651042], then set the adapter's |
| 4486 | * maximum number of fast-path FCP interrupts per second. |
| 4487 | * |
| 4488 | * Returns: |
| 4489 | * length of the buf on success if val is in range the intended mode |
| 4490 | * is supported. |
| 4491 | * -EINVAL if val out of range or intended mode is not supported. |
| 4492 | **/ |
| 4493 | static ssize_t |
| 4494 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4495 | const char *buf, size_t count) |
| 4496 | { |
| 4497 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4498 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4499 | struct lpfc_hba *phba = vport->phba; |
| 4500 | int val = 0, i; |
| 4501 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4502 | /* fcp_imax is only valid for SLI4 */ |
| 4503 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4504 | return -EINVAL; |
| 4505 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4506 | /* Sanity check on user data */ |
| 4507 | if (!isdigit(buf[0])) |
| 4508 | return -EINVAL; |
| 4509 | if (sscanf(buf, "%i", &val) != 1) |
| 4510 | return -EINVAL; |
| 4511 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4512 | /* |
| 4513 | * Value range for the HBA is [5000,5000000] |
| 4514 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4515 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4516 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4517 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4518 | return -EINVAL; |
| 4519 | |
| 4520 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4521 | phba->initial_imax = phba->cfg_fcp_imax; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 4522 | |
| 4523 | for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT) |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4524 | lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT, |
| 4525 | val); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4526 | |
| 4527 | return strlen(buf); |
| 4528 | } |
| 4529 | |
| 4530 | /* |
| 4531 | # 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] | 4532 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4533 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4534 | # 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] | 4535 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4536 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4537 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4538 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4539 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4540 | lpfc_param_show(fcp_imax) |
| 4541 | |
| 4542 | /** |
| 4543 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4544 | * @phba: lpfc_hba pointer. |
| 4545 | * @val: link speed value. |
| 4546 | * |
| 4547 | * Description: |
| 4548 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4549 | * maximum number of fast-path FCP interrupts per second. |
| 4550 | * |
| 4551 | * Returns: |
| 4552 | * zero if val saved. |
| 4553 | * -EINVAL val out of range |
| 4554 | **/ |
| 4555 | static int |
| 4556 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4557 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4558 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4559 | phba->cfg_fcp_imax = 0; |
| 4560 | return 0; |
| 4561 | } |
| 4562 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4563 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 4564 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4565 | phba->cfg_fcp_imax = val; |
| 4566 | return 0; |
| 4567 | } |
| 4568 | |
| 4569 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4570 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 4571 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4572 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4573 | |
| 4574 | return 0; |
| 4575 | } |
| 4576 | |
| 4577 | static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, |
| 4578 | lpfc_fcp_imax_show, lpfc_fcp_imax_store); |
| 4579 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4580 | /* |
| 4581 | * lpfc_auto_imax: Controls Auto-interrupt coalescing values support. |
| 4582 | * 0 No auto_imax support |
| 4583 | * 1 auto imax on |
| 4584 | * Auto imax will change the value of fcp_imax on a per EQ basis, using |
| 4585 | * the EQ Delay Multiplier, depending on the activity for that EQ. |
| 4586 | * Value range [0,1]. Default value is 1. |
| 4587 | */ |
| 4588 | LPFC_ATTR_RW(auto_imax, 1, 0, 1, "Enable Auto imax"); |
| 4589 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4590 | /** |
| 4591 | * lpfc_state_show - Display current driver CPU affinity |
| 4592 | * @dev: class converted to a Scsi_host structure. |
| 4593 | * @attr: device attribute, not used. |
| 4594 | * @buf: on return contains text describing the state of the link. |
| 4595 | * |
| 4596 | * Returns: size of formatted string. |
| 4597 | **/ |
| 4598 | static ssize_t |
| 4599 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4600 | char *buf) |
| 4601 | { |
| 4602 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4603 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4604 | struct lpfc_hba *phba = vport->phba; |
| 4605 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4606 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4607 | |
| 4608 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4609 | (phba->intr_type != MSIX)) |
| 4610 | return len; |
| 4611 | |
| 4612 | switch (phba->cfg_fcp_cpu_map) { |
| 4613 | case 0: |
| 4614 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4615 | "fcp_cpu_map: No mapping (%d)\n", |
| 4616 | phba->cfg_fcp_cpu_map); |
| 4617 | return len; |
| 4618 | case 1: |
| 4619 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4620 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4621 | "%d online CPUs\n", |
| 4622 | phba->cfg_fcp_cpu_map, |
| 4623 | phba->sli4_hba.num_online_cpu); |
| 4624 | break; |
| 4625 | case 2: |
| 4626 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4627 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4628 | "%d online CPUs\n", |
| 4629 | phba->cfg_fcp_cpu_map, |
| 4630 | phba->sli4_hba.num_online_cpu); |
| 4631 | break; |
| 4632 | } |
| 4633 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4634 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4635 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4636 | |
| 4637 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4638 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4639 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4640 | "CPU %02d io_chan %02d " |
| 4641 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4642 | phba->sli4_hba.curr_disp_cpu, |
| 4643 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4644 | cpup->core_id); |
| 4645 | else |
| 4646 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4647 | "CPU %02d io_chan %02d " |
| 4648 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4649 | phba->sli4_hba.curr_disp_cpu, |
| 4650 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4651 | cpup->core_id, cpup->irq); |
| 4652 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4653 | phba->sli4_hba.curr_disp_cpu++; |
| 4654 | |
| 4655 | /* display max number of CPUs keeping some margin */ |
| 4656 | if (phba->sli4_hba.curr_disp_cpu < |
| 4657 | phba->sli4_hba.num_present_cpu && |
| 4658 | (len >= (PAGE_SIZE - 64))) { |
| 4659 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4660 | break; |
| 4661 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4662 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4663 | |
| 4664 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4665 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4666 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4667 | return len; |
| 4668 | } |
| 4669 | |
| 4670 | /** |
| 4671 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4672 | * @dev: class device that is converted into a Scsi_host. |
| 4673 | * @attr: device attribute, not used. |
| 4674 | * @buf: one or more lpfc_polling_flags values. |
| 4675 | * @count: not used. |
| 4676 | * |
| 4677 | * Returns: |
| 4678 | * -EINVAL - Not implemented yet. |
| 4679 | **/ |
| 4680 | static ssize_t |
| 4681 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4682 | const char *buf, size_t count) |
| 4683 | { |
| 4684 | int status = -EINVAL; |
| 4685 | return status; |
| 4686 | } |
| 4687 | |
| 4688 | /* |
| 4689 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4690 | # for the HBA. |
| 4691 | # |
| 4692 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4693 | # 0 - Do not affinitze IRQ vectors |
| 4694 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4695 | # (start with CPU0 for each HBA) |
| 4696 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4697 | # (round robin thru all CPUs across all HBAs) |
| 4698 | */ |
| 4699 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4700 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4701 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4702 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4703 | |
| 4704 | /** |
| 4705 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4706 | * @phba: lpfc_hba pointer. |
| 4707 | * @val: link speed value. |
| 4708 | * |
| 4709 | * Description: |
| 4710 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4711 | * MSIX vectors. |
| 4712 | * |
| 4713 | * Returns: |
| 4714 | * zero if val saved. |
| 4715 | * -EINVAL val out of range |
| 4716 | **/ |
| 4717 | static int |
| 4718 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4719 | { |
| 4720 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4721 | phba->cfg_fcp_cpu_map = 0; |
| 4722 | return 0; |
| 4723 | } |
| 4724 | |
| 4725 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4726 | phba->cfg_fcp_cpu_map = val; |
| 4727 | return 0; |
| 4728 | } |
| 4729 | |
| 4730 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4731 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 4732 | "default\n", val); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4733 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4734 | |
| 4735 | return 0; |
| 4736 | } |
| 4737 | |
| 4738 | static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, |
| 4739 | lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store); |
| 4740 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4741 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4742 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4743 | # Value range is [2,3]. Default value is 3. |
| 4744 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4745 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4746 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4747 | |
| 4748 | /* |
| 4749 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4750 | # is [0,1]. Default value is 0. |
| 4751 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4752 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4753 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4754 | |
| 4755 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4756 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4757 | # that support first burst. |
| 4758 | # Value range is [0,65536]. Default value is 0. |
| 4759 | */ |
| 4760 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4761 | "First burst size for Targets that support first burst"); |
| 4762 | |
| 4763 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4764 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 4765 | * When the driver is configured as an NVME target, this value is |
| 4766 | * communicated to the NVME initiator in the PRLI response. It is |
| 4767 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 4768 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4769 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4770 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4771 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4772 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 4773 | "NVME Target mode first burst size in 512B increments."); |
| 4774 | |
| 4775 | /* |
| 4776 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 4777 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 4778 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
| 4779 | * processed by the initiator for subsequent NVME FCP IO. For the target |
| 4780 | * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size |
| 4781 | * driver parameter as the target function's first burst size returned to the |
| 4782 | * initiator in the target's NVME PRLI response. Parameter supported on physical |
| 4783 | * port only - no NPIV support. |
| 4784 | * Value range is [0,1]. Default value is 0 (disabled). |
| 4785 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4786 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
| 4787 | "Enable First Burst feature on I and T functions."); |
| 4788 | |
| 4789 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4790 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4791 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4792 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4793 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4794 | # to limit the I/O completion time to the parameter value. |
| 4795 | # The value is set in milliseconds. |
| 4796 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 4797 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4798 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 4799 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4800 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4801 | static int |
| 4802 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4803 | { |
| 4804 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4805 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4806 | |
| 4807 | if (val == vport->cfg_max_scsicmpl_time) |
| 4808 | return 0; |
| 4809 | if ((val < 0) || (val > 60000)) |
| 4810 | return -EINVAL; |
| 4811 | vport->cfg_max_scsicmpl_time = val; |
| 4812 | |
| 4813 | spin_lock_irq(shost->host_lock); |
| 4814 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4815 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4816 | continue; |
| 4817 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4818 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4819 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4820 | } |
| 4821 | spin_unlock_irq(shost->host_lock); |
| 4822 | return 0; |
| 4823 | } |
| 4824 | lpfc_vport_param_store(max_scsicmpl_time); |
| 4825 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 4826 | lpfc_max_scsicmpl_time_show, |
| 4827 | lpfc_max_scsicmpl_time_store); |
| 4828 | |
| 4829 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4830 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4831 | # range is [0,1]. Default value is 0. |
| 4832 | */ |
| 4833 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4834 | |
| 4835 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4836 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4837 | * range is [0,1]. Default value is 0. |
| 4838 | * For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4839 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 4840 | * current CPU. |
| 4841 | * |
| 4842 | * LPFC_FCP_SCHED_ROUND_ROBIN == 0 |
| 4843 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 4844 | * |
| 4845 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 4846 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 4847 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 4848 | * through WQs will be used. |
| 4849 | */ |
| 4850 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN, |
| 4851 | LPFC_FCP_SCHED_ROUND_ROBIN, |
| 4852 | LPFC_FCP_SCHED_BY_CPU, |
| 4853 | "Determine scheduling algorithm for " |
| 4854 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4855 | |
| 4856 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4857 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4858 | # range is [0,1]. Default value is 0. |
| 4859 | # For [0], bus reset issues target reset to ALL devices |
| 4860 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4861 | */ |
| 4862 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4863 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4864 | |
| 4865 | |
| 4866 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4867 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4868 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4869 | # 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] | 4870 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4871 | # cr_delay is set to 0. |
| 4872 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4873 | 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] | 4874 | "interrupt response is generated"); |
| 4875 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4876 | 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] | 4877 | "interrupt response is generated"); |
| 4878 | |
| 4879 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4880 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4881 | # cmd/rsp IOCB entries across. |
| 4882 | # Value range is [1,2]. Default value is 1. |
| 4883 | */ |
| 4884 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4885 | "SLI rings to spread IOCB entries across"); |
| 4886 | |
| 4887 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4888 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4889 | # identifies what rctl value to configure the additional ring for. |
| 4890 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4891 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4892 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4893 | 255, "Identifies RCTL for additional ring configuration"); |
| 4894 | |
| 4895 | /* |
| 4896 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4897 | # identifies what type value to configure the additional ring for. |
| 4898 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4899 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4900 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4901 | 255, "Identifies TYPE for additional ring configuration"); |
| 4902 | |
| 4903 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4904 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 4905 | # 0 = SmartSAN functionality disabled (default) |
| 4906 | # 1 = SmartSAN functionality enabled |
| 4907 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 4908 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4909 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4910 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 4911 | |
| 4912 | /* |
| 4913 | # lpfc_fdmi_on: Controls FDMI support. |
| 4914 | # 0 No FDMI support (default) |
| 4915 | # 1 Traditional FDMI support |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4916 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 4917 | # however, if that fails, it will fallback to FDMI-1. |
| 4918 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 4919 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 4920 | # lpfc_fdmi_on. |
| 4921 | # Value range [0,1]. Default value is 0. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4922 | */ |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4923 | LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4924 | |
| 4925 | /* |
| 4926 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4927 | # discovery). Value range is [1,64]. Default value = 32. |
| 4928 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4929 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4930 | "during discovery"); |
| 4931 | |
| 4932 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4933 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4934 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4935 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4936 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4937 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4938 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4939 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4940 | # on a target can take minutes of wall clock time. Additionally, |
| 4941 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4942 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4943 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4944 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4945 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4946 | # devices present, when in fact, there is only 1. |
| 4947 | # A customer that is aware of their target behaviors, and the results as |
| 4948 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4949 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4950 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4951 | # Value range is [0,65535]. Default value is 255. |
| 4952 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4953 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 4954 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4955 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4956 | /* |
| 4957 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4958 | # Value range is [1,255], default value is 10. |
| 4959 | */ |
| 4960 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4961 | "Milliseconds driver will wait between polling FCP ring"); |
| 4962 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4963 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4964 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4965 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4966 | */ |
| 4967 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4968 | "Maximum time to wait for task management commands to complete"); |
| 4969 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4970 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4971 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4972 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4973 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4974 | # 2 = MSI-X enabled (default) |
| 4975 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4976 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4977 | 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] | 4978 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4979 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4980 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 4981 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4982 | * |
| 4983 | * 0 = NVME OAS disabled |
| 4984 | * 1 = NVME OAS enabled |
| 4985 | * |
| 4986 | * Value range is [0,1]. Default value is 0. |
| 4987 | */ |
| 4988 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 4989 | "Use OAS bit on NVME IOs"); |
| 4990 | |
| 4991 | /* |
| 4992 | * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver |
| 4993 | * will advertise it supports to the SCSI layer. This also will map to |
| 4994 | * the number of WQs the driver will create. |
| 4995 | * |
| 4996 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 4997 | * 1,32 = Manually specify how many io channels to use. |
| 4998 | * |
| 4999 | * Value range is [0,32]. Default value is 4. |
| 5000 | */ |
| 5001 | LPFC_ATTR_R(fcp_io_channel, |
| 5002 | LPFC_FCP_IO_CHAN_DEF, |
| 5003 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5004 | "Set the number of FCP I/O channels"); |
| 5005 | |
| 5006 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5007 | * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver |
| 5008 | * will advertise it supports to the NVME layer. This also will map to |
| 5009 | * the number of WQs the driver will create. |
| 5010 | * |
| 5011 | * This module parameter is valid when lpfc_enable_fc4_type is set |
| 5012 | * to support NVME. |
| 5013 | * |
| 5014 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5015 | * hardware queue. The administrative queue will always map to WQ 0 |
| 5016 | * A hardware IO queue maps (qidx) to a specific driver WQ. |
| 5017 | * |
| 5018 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5019 | * 1,32 = Manually specify how many io channels to use. |
| 5020 | * |
| 5021 | * Value range is [0,32]. Default value is 0. |
| 5022 | */ |
| 5023 | LPFC_ATTR_R(nvme_io_channel, |
| 5024 | LPFC_NVME_IO_CHAN_DEF, |
| 5025 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
| 5026 | "Set the number of NVME I/O channels"); |
| 5027 | |
| 5028 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5029 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 5030 | # 0 = HBA resets disabled |
| 5031 | # 1 = HBA resets enabled (default) |
| 5032 | # Value range is [0,1]. Default value is 1. |
| 5033 | */ |
| 5034 | LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver."); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5035 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5036 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5037 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5038 | # 0 = HBA Heartbeat disabled |
| 5039 | # 1 = HBA Heartbeat enabled (default) |
| 5040 | # Value range is [0,1]. Default value is 1. |
| 5041 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5042 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5043 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5044 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5045 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 5046 | # 0x0 Express Lane Feature disabled |
| 5047 | # 0x1 Express Lane Feature enabled |
| 5048 | # Value range is [0,1]. Default value is 0. |
| 5049 | */ |
| 5050 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 5051 | |
| 5052 | /* |
| 5053 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 5054 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 5055 | # Value range is [0x0,0x7f]. Default value is 0 |
| 5056 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 5057 | 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] | 5058 | |
| 5059 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5060 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 5061 | # 0 = BlockGuard disabled (default) |
| 5062 | # 1 = BlockGuard enabled |
| 5063 | # Value range is [0,1]. Default value is 0. |
| 5064 | */ |
| 5065 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5066 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5067 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5068 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 5069 | # 0 = disabled (default) |
| 5070 | # 1 = enabled |
| 5071 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 5072 | # |
| 5073 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5074 | */ |
| 5075 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 5076 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5077 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5078 | # lpfc_prot_mask: i |
| 5079 | # - Bit mask of host protection capabilities used to register with the |
| 5080 | # SCSI mid-layer |
| 5081 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5082 | # - Allows you to ultimately specify which profiles to use |
| 5083 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5084 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5085 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5086 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5087 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5088 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5089 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5090 | # |
| 5091 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5092 | LPFC_ATTR(prot_mask, |
| 5093 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5094 | SHOST_DIX_TYPE0_PROTECTION | |
| 5095 | SHOST_DIX_TYPE1_PROTECTION), |
| 5096 | 0, |
| 5097 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5098 | SHOST_DIX_TYPE0_PROTECTION | |
| 5099 | SHOST_DIX_TYPE1_PROTECTION), |
| 5100 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5101 | |
| 5102 | /* |
| 5103 | # lpfc_prot_guard: i |
| 5104 | # - 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] | 5105 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5106 | # - Allows you to ultimately specify which profiles to use |
| 5107 | # - Default will result in registering capabilities for all guard types |
| 5108 | # |
| 5109 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5110 | LPFC_ATTR(prot_guard, |
| 5111 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5112 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5113 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5114 | /* |
| 5115 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5116 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5117 | * This parameter can have value 0 or 1. |
| 5118 | * When this parameter is set to 0, no delay is added to the initial |
| 5119 | * discovery. |
| 5120 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5121 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5122 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5123 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5124 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5125 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5126 | * Default value is 0. |
| 5127 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5128 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5129 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5130 | |
| 5131 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5132 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5133 | * This value can be set to values between 64 and 4096. The default value is |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5134 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 5135 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5136 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5137 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5138 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5139 | */ |
| 5140 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 5141 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 5142 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5143 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5144 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 5145 | * 0 = MDS Diagnostics disabled (default) |
| 5146 | * 1 = MDS Diagnostics enabled |
| 5147 | * Value range is [0,1]. Default value is 0. |
| 5148 | */ |
| 5149 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 5150 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5151 | /* |
| 5152 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 5153 | * 0 = BB Credit Recovery disabled |
| 5154 | * 1 = BB Credit Recovery enabled (default) |
| 5155 | * Value range is [0,1]. Default value is 1. |
| 5156 | */ |
| 5157 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 5158 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5159 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5160 | &dev_attr_nvme_info, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5161 | &dev_attr_bg_info, |
| 5162 | &dev_attr_bg_guard_err, |
| 5163 | &dev_attr_bg_apptag_err, |
| 5164 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5165 | &dev_attr_info, |
| 5166 | &dev_attr_serialnum, |
| 5167 | &dev_attr_modeldesc, |
| 5168 | &dev_attr_modelname, |
| 5169 | &dev_attr_programtype, |
| 5170 | &dev_attr_portnum, |
| 5171 | &dev_attr_fwrev, |
| 5172 | &dev_attr_hdw, |
| 5173 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5174 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5175 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 5176 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5177 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5178 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5179 | &dev_attr_lpfc_temp_sensor, |
| 5180 | &dev_attr_lpfc_log_verbose, |
| 5181 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5182 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5183 | &dev_attr_lpfc_hba_queue_depth, |
| 5184 | &dev_attr_lpfc_peer_port_login, |
| 5185 | &dev_attr_lpfc_nodev_tmo, |
| 5186 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5187 | &dev_attr_lpfc_enable_fc4_type, |
| 5188 | &dev_attr_lpfc_xri_split, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5189 | &dev_attr_lpfc_fcp_class, |
| 5190 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5191 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5192 | &dev_attr_lpfc_ack0, |
| 5193 | &dev_attr_lpfc_topology, |
| 5194 | &dev_attr_lpfc_scan_down, |
| 5195 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5196 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5197 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5198 | &dev_attr_lpfc_cr_delay, |
| 5199 | &dev_attr_lpfc_cr_count, |
| 5200 | &dev_attr_lpfc_multi_ring_support, |
| 5201 | &dev_attr_lpfc_multi_ring_rctl, |
| 5202 | &dev_attr_lpfc_multi_ring_type, |
| 5203 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5204 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5205 | &dev_attr_lpfc_max_luns, |
| 5206 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5207 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5208 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5209 | &dev_attr_nport_evt_cnt, |
| 5210 | &dev_attr_board_mode, |
| 5211 | &dev_attr_max_vpi, |
| 5212 | &dev_attr_used_vpi, |
| 5213 | &dev_attr_max_rpi, |
| 5214 | &dev_attr_used_rpi, |
| 5215 | &dev_attr_max_xri, |
| 5216 | &dev_attr_used_xri, |
| 5217 | &dev_attr_npiv_info, |
| 5218 | &dev_attr_issue_reset, |
| 5219 | &dev_attr_lpfc_poll, |
| 5220 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5221 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5222 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5223 | &dev_attr_lpfc_nvme_oas, |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5224 | &dev_attr_lpfc_auto_imax, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5225 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5226 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5227 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5228 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5229 | &dev_attr_lpfc_nvme_io_channel, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5230 | &dev_attr_lpfc_nvmet_mrq, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5231 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5232 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5233 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 5234 | &dev_attr_lpfc_soft_wwnn, |
| 5235 | &dev_attr_lpfc_soft_wwpn, |
| 5236 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5237 | &dev_attr_lpfc_enable_hba_reset, |
| 5238 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5239 | &dev_attr_lpfc_EnableXLane, |
| 5240 | &dev_attr_lpfc_XLanePriority, |
| 5241 | &dev_attr_lpfc_xlane_lun, |
| 5242 | &dev_attr_lpfc_xlane_tgt, |
| 5243 | &dev_attr_lpfc_xlane_vpt, |
| 5244 | &dev_attr_lpfc_xlane_lun_state, |
| 5245 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5246 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5247 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5248 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5249 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5250 | &dev_attr_lpfc_aer_support, |
| 5251 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5252 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5253 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5254 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5255 | &dev_attr_lpfc_iocb_cnt, |
| 5256 | &dev_attr_iocb_hw, |
| 5257 | &dev_attr_txq_hw, |
| 5258 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5259 | &dev_attr_lpfc_fips_level, |
| 5260 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5261 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5262 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5263 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5264 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5265 | &dev_attr_lpfc_enable_mds_diags, |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5266 | &dev_attr_lpfc_enable_bbcr, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5267 | NULL, |
| 5268 | }; |
| 5269 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5270 | struct device_attribute *lpfc_vport_attrs[] = { |
| 5271 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5272 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5273 | &dev_attr_num_discovered_ports, |
| 5274 | &dev_attr_lpfc_drvr_version, |
| 5275 | &dev_attr_lpfc_log_verbose, |
| 5276 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5277 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5278 | &dev_attr_lpfc_nodev_tmo, |
| 5279 | &dev_attr_lpfc_devloss_tmo, |
| 5280 | &dev_attr_lpfc_hba_queue_depth, |
| 5281 | &dev_attr_lpfc_peer_port_login, |
| 5282 | &dev_attr_lpfc_restrict_login, |
| 5283 | &dev_attr_lpfc_fcp_class, |
| 5284 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5285 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5286 | &dev_attr_lpfc_max_luns, |
| 5287 | &dev_attr_nport_evt_cnt, |
| 5288 | &dev_attr_npiv_info, |
| 5289 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5290 | &dev_attr_lpfc_max_scsicmpl_time, |
| 5291 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 5292 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5293 | &dev_attr_lpfc_fips_level, |
| 5294 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5295 | NULL, |
| 5296 | }; |
| 5297 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5298 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5299 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5300 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5301 | * @kobj: kernel kobject that contains the kernel class device. |
| 5302 | * @bin_attr: kernel attributes passed to us. |
| 5303 | * @buf: contains the data to be written to the adapter IOREG space. |
| 5304 | * @off: offset into buffer to beginning of data. |
| 5305 | * @count: bytes to transfer. |
| 5306 | * |
| 5307 | * Description: |
| 5308 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5309 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 5310 | * |
| 5311 | * Returns: |
| 5312 | * -ERANGE off and count combo out of range |
| 5313 | * -EINVAL off, count or buff address invalid |
| 5314 | * -EPERM adapter is offline |
| 5315 | * value of count, buf contents written |
| 5316 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5317 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5318 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 5319 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5320 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5321 | { |
| 5322 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5323 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5324 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5325 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5326 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5327 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5328 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5329 | return -EPERM; |
| 5330 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5331 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5332 | return -ERANGE; |
| 5333 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5334 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 5335 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5336 | |
| 5337 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5338 | return -EINVAL; |
| 5339 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5340 | /* This is to protect HBA registers from accidental writes. */ |
| 5341 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 5342 | return -EINVAL; |
| 5343 | |
| 5344 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5345 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5346 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5347 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5348 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 5349 | buf_off += sizeof(uint32_t)) |
| 5350 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5351 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 5352 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5353 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5354 | |
| 5355 | return count; |
| 5356 | } |
| 5357 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5358 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5359 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5360 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5361 | * @kobj: kernel kobject that contains the kernel class device. |
| 5362 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5363 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5364 | * @off: offset into buffer to beginning of data. |
| 5365 | * @count: bytes to transfer. |
| 5366 | * |
| 5367 | * Description: |
| 5368 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5369 | * Uses the adapter io control registers to read data into buf. |
| 5370 | * |
| 5371 | * Returns: |
| 5372 | * -ERANGE off and count combo out of range |
| 5373 | * -EINVAL off, count or buff address invalid |
| 5374 | * value of count, buf contents read |
| 5375 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5376 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5377 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 5378 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5379 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5380 | { |
| 5381 | size_t buf_off; |
| 5382 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5383 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5384 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5385 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5386 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5387 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5388 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5389 | return -EPERM; |
| 5390 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5391 | if (off > FF_REG_AREA_SIZE) |
| 5392 | return -ERANGE; |
| 5393 | |
| 5394 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5395 | count = FF_REG_AREA_SIZE - off; |
| 5396 | |
| 5397 | if (count == 0) return 0; |
| 5398 | |
| 5399 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5400 | return -EINVAL; |
| 5401 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5402 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5403 | |
| 5404 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 5405 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5406 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5407 | } |
| 5408 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5409 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5410 | |
| 5411 | return count; |
| 5412 | } |
| 5413 | |
| 5414 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5415 | .attr = { |
| 5416 | .name = "ctlreg", |
| 5417 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5418 | }, |
| 5419 | .size = 256, |
| 5420 | .read = sysfs_ctlreg_read, |
| 5421 | .write = sysfs_ctlreg_write, |
| 5422 | }; |
| 5423 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5424 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5425 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5426 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5427 | * @kobj: kernel kobject that contains the kernel class device. |
| 5428 | * @bin_attr: kernel attributes passed to us. |
| 5429 | * @buf: contains the data to be written to sysfs mbox. |
| 5430 | * @off: offset into buffer to beginning of data. |
| 5431 | * @count: bytes to transfer. |
| 5432 | * |
| 5433 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5434 | * Deprecated function. All mailbox access from user space is performed via the |
| 5435 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5436 | * |
| 5437 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5438 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5439 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5440 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5441 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5442 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5443 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5444 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5445 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5446 | } |
| 5447 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5448 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5449 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5450 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5451 | * @kobj: kernel kobject that contains the kernel class device. |
| 5452 | * @bin_attr: kernel attributes passed to us. |
| 5453 | * @buf: contains the data to be read from sysfs mbox. |
| 5454 | * @off: offset into buffer to beginning of data. |
| 5455 | * @count: bytes to transfer. |
| 5456 | * |
| 5457 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5458 | * Deprecated function. All mailbox access from user space is performed via the |
| 5459 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5460 | * |
| 5461 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5462 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5463 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5464 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5465 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5466 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5467 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5468 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5469 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5470 | } |
| 5471 | |
| 5472 | static struct bin_attribute sysfs_mbox_attr = { |
| 5473 | .attr = { |
| 5474 | .name = "mbox", |
| 5475 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5476 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5477 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5478 | .read = sysfs_mbox_read, |
| 5479 | .write = sysfs_mbox_write, |
| 5480 | }; |
| 5481 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5482 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5483 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5484 | * @vport: address of lpfc vport structure. |
| 5485 | * |
| 5486 | * Return codes: |
| 5487 | * zero on success |
| 5488 | * error return code from sysfs_create_bin_file() |
| 5489 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5490 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5491 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5492 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5493 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5494 | int error; |
| 5495 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5496 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5497 | &sysfs_drvr_stat_data_attr); |
| 5498 | |
| 5499 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5500 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5501 | goto out; |
| 5502 | |
| 5503 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5504 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5505 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5506 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5507 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5508 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5509 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5510 | if (error) |
| 5511 | goto out_remove_ctlreg_attr; |
| 5512 | |
| 5513 | return 0; |
| 5514 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5515 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5516 | out_remove_stat_attr: |
| 5517 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5518 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5519 | out: |
| 5520 | return error; |
| 5521 | } |
| 5522 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5523 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5524 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5525 | * @vport: address of lpfc vport structure. |
| 5526 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5527 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5528 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5529 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5530 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5531 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5532 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5533 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5534 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5535 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5536 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5537 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5538 | } |
| 5539 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5540 | /* |
| 5541 | * Dynamic FC Host Attributes Support |
| 5542 | */ |
| 5543 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5544 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5545 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 5546 | * @shost: kernel scsi host pointer. |
| 5547 | **/ |
| 5548 | static void |
| 5549 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 5550 | { |
| 5551 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5552 | |
| 5553 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 5554 | sizeof fc_host_symbolic_name(shost)); |
| 5555 | } |
| 5556 | |
| 5557 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5558 | * 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] | 5559 | * @shost: kernel scsi host pointer. |
| 5560 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5561 | static void |
| 5562 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5563 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5564 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5565 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5566 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5567 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5568 | } |
| 5569 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5570 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5571 | * 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] | 5572 | * @shost: kernel scsi host pointer. |
| 5573 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5574 | static void |
| 5575 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5576 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5577 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5578 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5579 | |
| 5580 | spin_lock_irq(shost->host_lock); |
| 5581 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5582 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5583 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5584 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5585 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5586 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5587 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5588 | else |
| 5589 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5590 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5591 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5592 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5593 | else |
| 5594 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5595 | } |
| 5596 | } else |
| 5597 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5598 | |
| 5599 | spin_unlock_irq(shost->host_lock); |
| 5600 | } |
| 5601 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5602 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5603 | * 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] | 5604 | * @shost: kernel scsi host pointer. |
| 5605 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5606 | static void |
| 5607 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5608 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5609 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5610 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5611 | |
| 5612 | spin_lock_irq(shost->host_lock); |
| 5613 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5614 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5615 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5616 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5617 | switch (phba->link_state) { |
| 5618 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5619 | case LPFC_LINK_DOWN: |
| 5620 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5621 | break; |
| 5622 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5623 | case LPFC_CLEAR_LA: |
| 5624 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5625 | /* Links up, reports port state accordingly */ |
| 5626 | if (vport->port_state < LPFC_VPORT_READY) |
| 5627 | fc_host_port_state(shost) = |
| 5628 | FC_PORTSTATE_BYPASSED; |
| 5629 | else |
| 5630 | fc_host_port_state(shost) = |
| 5631 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5632 | break; |
| 5633 | case LPFC_HBA_ERROR: |
| 5634 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5635 | break; |
| 5636 | default: |
| 5637 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5638 | break; |
| 5639 | } |
| 5640 | } |
| 5641 | |
| 5642 | spin_unlock_irq(shost->host_lock); |
| 5643 | } |
| 5644 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5645 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5646 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5647 | * @shost: kernel scsi host pointer. |
| 5648 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5649 | static void |
| 5650 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5651 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5652 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5653 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5654 | |
| 5655 | spin_lock_irq(shost->host_lock); |
| 5656 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 5657 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5658 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5659 | case LPFC_LINK_SPEED_1GHZ: |
| 5660 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5661 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5662 | case LPFC_LINK_SPEED_2GHZ: |
| 5663 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5664 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5665 | case LPFC_LINK_SPEED_4GHZ: |
| 5666 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5667 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5668 | case LPFC_LINK_SPEED_8GHZ: |
| 5669 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5670 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5671 | case LPFC_LINK_SPEED_10GHZ: |
| 5672 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5673 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5674 | case LPFC_LINK_SPEED_16GHZ: |
| 5675 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5676 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 5677 | case LPFC_LINK_SPEED_32GHZ: |
| 5678 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 5679 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5680 | default: |
| 5681 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5682 | break; |
| 5683 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5684 | } else |
| 5685 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5686 | |
| 5687 | spin_unlock_irq(shost->host_lock); |
| 5688 | } |
| 5689 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5690 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5691 | * 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] | 5692 | * @shost: kernel scsi host pointer. |
| 5693 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5694 | static void |
| 5695 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5696 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5697 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5698 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5699 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5700 | |
| 5701 | spin_lock_irq(shost->host_lock); |
| 5702 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5703 | if ((vport->port_state > LPFC_FLOGI) && |
| 5704 | ((vport->fc_flag & FC_FABRIC) || |
| 5705 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5706 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5707 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5708 | else |
| 5709 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5710 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5711 | |
| 5712 | spin_unlock_irq(shost->host_lock); |
| 5713 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5714 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5715 | } |
| 5716 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5717 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5718 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5719 | * @shost: kernel scsi host pointer. |
| 5720 | * |
| 5721 | * Notes: |
| 5722 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5723 | * management not allowed, memory allocation error, or mbox error. |
| 5724 | * |
| 5725 | * Returns: |
| 5726 | * NULL for error |
| 5727 | * address of the adapter host statistics |
| 5728 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5729 | static struct fc_host_statistics * |
| 5730 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5731 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5732 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5733 | struct lpfc_hba *phba = vport->phba; |
| 5734 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5735 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5736 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5737 | LPFC_MBOXQ_t *pmboxq; |
| 5738 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5739 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5740 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5741 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5742 | /* |
| 5743 | * prevent udev from issuing mailbox commands until the port is |
| 5744 | * configured. |
| 5745 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5746 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5747 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5748 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5749 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5750 | |
| 5751 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5752 | return NULL; |
| 5753 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5754 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5755 | if (!pmboxq) |
| 5756 | return NULL; |
| 5757 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5758 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5759 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5760 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5761 | pmb->mbxOwner = OWN_HOST; |
| 5762 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5763 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5764 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5765 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5766 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5767 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5768 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5769 | |
| 5770 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5771 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5772 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5773 | return NULL; |
| 5774 | } |
| 5775 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5776 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5777 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5778 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5779 | /* |
| 5780 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5781 | * converted to words |
| 5782 | */ |
| 5783 | hs->tx_words = (uint64_t) |
| 5784 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5785 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5786 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5787 | hs->rx_words = (uint64_t) |
| 5788 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5789 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5790 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5791 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5792 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5793 | pmb->mbxOwner = OWN_HOST; |
| 5794 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5795 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5796 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5797 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5798 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5799 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5800 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5801 | |
| 5802 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5803 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5804 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5805 | return NULL; |
| 5806 | } |
| 5807 | |
| 5808 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5809 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5810 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5811 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5812 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5813 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5814 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5815 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5816 | hs->link_failure_count -= lso->link_failure_count; |
| 5817 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5818 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5819 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5820 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5821 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5822 | hs->error_frames -= lso->error_frames; |
| 5823 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5824 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5825 | hs->lip_count = -1; |
| 5826 | hs->nos_count = (phba->link_events >> 1); |
| 5827 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5828 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5829 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5830 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5831 | hs->nos_count = -1; |
| 5832 | } else { |
| 5833 | hs->lip_count = -1; |
| 5834 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5835 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5836 | } |
| 5837 | |
| 5838 | hs->dumped_frames = -1; |
| 5839 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5840 | seconds = get_seconds(); |
| 5841 | if (seconds < psli->stats_start) |
| 5842 | hs->seconds_since_last_reset = seconds + |
| 5843 | ((unsigned long)-1 - psli->stats_start); |
| 5844 | else |
| 5845 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5846 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5847 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5848 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5849 | return hs; |
| 5850 | } |
| 5851 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5852 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5853 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5854 | * @shost: kernel scsi host pointer. |
| 5855 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5856 | static void |
| 5857 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5858 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5859 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5860 | struct lpfc_hba *phba = vport->phba; |
| 5861 | struct lpfc_sli *psli = &phba->sli; |
| 5862 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5863 | LPFC_MBOXQ_t *pmboxq; |
| 5864 | MAILBOX_t *pmb; |
| 5865 | int rc = 0; |
| 5866 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5867 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5868 | return; |
| 5869 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5870 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5871 | if (!pmboxq) |
| 5872 | return; |
| 5873 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5874 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5875 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5876 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5877 | pmb->mbxOwner = OWN_HOST; |
| 5878 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5879 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5880 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5881 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5882 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5883 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5884 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5885 | else |
| 5886 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5887 | |
| 5888 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5889 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5890 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5891 | return; |
| 5892 | } |
| 5893 | |
| 5894 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5895 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5896 | pmb->mbxOwner = OWN_HOST; |
| 5897 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5898 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5899 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5900 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5901 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5902 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5903 | else |
| 5904 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5905 | |
| 5906 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5907 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5908 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5909 | return; |
| 5910 | } |
| 5911 | |
| 5912 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5913 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5914 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5915 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5916 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5917 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5918 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5919 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5920 | lso->link_events = (phba->link_events >> 1); |
| 5921 | else |
| 5922 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5923 | |
| 5924 | psli->stats_start = get_seconds(); |
| 5925 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5926 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5927 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5928 | return; |
| 5929 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5930 | |
| 5931 | /* |
| 5932 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5933 | * are no sysfs handlers for link_down_tmo. |
| 5934 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5935 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5936 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5937 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5938 | * @starget: kernel scsi target pointer. |
| 5939 | * |
| 5940 | * Returns: |
| 5941 | * address of the node list if found |
| 5942 | * NULL target not found |
| 5943 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5944 | static struct lpfc_nodelist * |
| 5945 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5946 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5947 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5948 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5949 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5950 | |
| 5951 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5952 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5953 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5954 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5955 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5956 | starget->id == ndlp->nlp_sid) { |
| 5957 | spin_unlock_irq(shost->host_lock); |
| 5958 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5959 | } |
| 5960 | } |
| 5961 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5962 | return NULL; |
| 5963 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5964 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5965 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5966 | * 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] | 5967 | * @starget: kernel scsi target pointer. |
| 5968 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5969 | static void |
| 5970 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5971 | { |
| 5972 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5973 | |
| 5974 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5975 | } |
| 5976 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5977 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5978 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5979 | * @starget: kernel scsi target pointer. |
| 5980 | * |
| 5981 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 5982 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5983 | static void |
| 5984 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 5985 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5986 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5987 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5988 | fc_starget_node_name(starget) = |
| 5989 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5990 | } |
| 5991 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5992 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5993 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5994 | * @starget: kernel scsi target pointer. |
| 5995 | * |
| 5996 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 5997 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5998 | static void |
| 5999 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 6000 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6001 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6002 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6003 | fc_starget_port_name(starget) = |
| 6004 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6005 | } |
| 6006 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6007 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6008 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6009 | * @rport: fc rport address. |
| 6010 | * @timeout: new value for dev loss tmo. |
| 6011 | * |
| 6012 | * Description: |
| 6013 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 6014 | * dev_loss_tmo to one. |
| 6015 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6016 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6017 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 6018 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6019 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6020 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6021 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6022 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6023 | } |
| 6024 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6025 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6026 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6027 | * |
| 6028 | * Description: |
| 6029 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 6030 | * |
| 6031 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 6032 | * @cdev: class converted to an fc_rport. |
| 6033 | * @buf: on return contains the target_field or zero. |
| 6034 | * |
| 6035 | * Returns: size of formatted string. |
| 6036 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6037 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 6038 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6039 | lpfc_show_rport_##field (struct device *dev, \ |
| 6040 | struct device_attribute *attr, \ |
| 6041 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6042 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6043 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6044 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 6045 | return snprintf(buf, sz, format_string, \ |
| 6046 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 6047 | } |
| 6048 | |
| 6049 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 6050 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 6051 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 6052 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6053 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6054 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6055 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 6056 | * |
| 6057 | * Description: |
| 6058 | * This function is called by the transport after the @fc_vport's symbolic name |
| 6059 | * 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] | 6060 | * 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] | 6061 | **/ |
| 6062 | static void |
| 6063 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 6064 | { |
| 6065 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 6066 | |
| 6067 | if (vport->port_state == LPFC_VPORT_READY) |
| 6068 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 6069 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6070 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6071 | /** |
| 6072 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 6073 | * @phba: Pointer to lpfc_hba struct. |
| 6074 | * |
| 6075 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 6076 | * 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] | 6077 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6078 | * before hba port or vport created. |
| 6079 | **/ |
| 6080 | static void |
| 6081 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 6082 | { |
| 6083 | phba->cfg_log_verbose = verbose; |
| 6084 | } |
| 6085 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6086 | struct fc_function_template lpfc_transport_functions = { |
| 6087 | /* fixed attributes the driver supports */ |
| 6088 | .show_host_node_name = 1, |
| 6089 | .show_host_port_name = 1, |
| 6090 | .show_host_supported_classes = 1, |
| 6091 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6092 | .show_host_supported_speeds = 1, |
| 6093 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6094 | |
| 6095 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6096 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6097 | |
| 6098 | /* dynamic attributes the driver supports */ |
| 6099 | .get_host_port_id = lpfc_get_host_port_id, |
| 6100 | .show_host_port_id = 1, |
| 6101 | |
| 6102 | .get_host_port_type = lpfc_get_host_port_type, |
| 6103 | .show_host_port_type = 1, |
| 6104 | |
| 6105 | .get_host_port_state = lpfc_get_host_port_state, |
| 6106 | .show_host_port_state = 1, |
| 6107 | |
| 6108 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6109 | .show_host_active_fc4s = 1, |
| 6110 | |
| 6111 | .get_host_speed = lpfc_get_host_speed, |
| 6112 | .show_host_speed = 1, |
| 6113 | |
| 6114 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6115 | .show_host_fabric_name = 1, |
| 6116 | |
| 6117 | /* |
| 6118 | * The LPFC driver treats linkdown handling as target loss events |
| 6119 | * so there are no sysfs handlers for link_down_tmo. |
| 6120 | */ |
| 6121 | |
| 6122 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6123 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6124 | |
| 6125 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6126 | .show_rport_maxframe_size = 1, |
| 6127 | .show_rport_supported_classes = 1, |
| 6128 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6129 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6130 | .show_rport_dev_loss_tmo = 1, |
| 6131 | |
| 6132 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6133 | .show_starget_port_id = 1, |
| 6134 | |
| 6135 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6136 | .show_starget_node_name = 1, |
| 6137 | |
| 6138 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6139 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 6140 | |
| 6141 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6142 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6143 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6144 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6145 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6146 | |
| 6147 | .vport_disable = lpfc_vport_disable, |
| 6148 | |
| 6149 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 6150 | |
| 6151 | .bsg_request = lpfc_bsg_request, |
| 6152 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6153 | }; |
| 6154 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6155 | struct fc_function_template lpfc_vport_transport_functions = { |
| 6156 | /* fixed attributes the driver supports */ |
| 6157 | .show_host_node_name = 1, |
| 6158 | .show_host_port_name = 1, |
| 6159 | .show_host_supported_classes = 1, |
| 6160 | .show_host_supported_fc4s = 1, |
| 6161 | .show_host_supported_speeds = 1, |
| 6162 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6163 | |
| 6164 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6165 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6166 | |
| 6167 | /* dynamic attributes the driver supports */ |
| 6168 | .get_host_port_id = lpfc_get_host_port_id, |
| 6169 | .show_host_port_id = 1, |
| 6170 | |
| 6171 | .get_host_port_type = lpfc_get_host_port_type, |
| 6172 | .show_host_port_type = 1, |
| 6173 | |
| 6174 | .get_host_port_state = lpfc_get_host_port_state, |
| 6175 | .show_host_port_state = 1, |
| 6176 | |
| 6177 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6178 | .show_host_active_fc4s = 1, |
| 6179 | |
| 6180 | .get_host_speed = lpfc_get_host_speed, |
| 6181 | .show_host_speed = 1, |
| 6182 | |
| 6183 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6184 | .show_host_fabric_name = 1, |
| 6185 | |
| 6186 | /* |
| 6187 | * The LPFC driver treats linkdown handling as target loss events |
| 6188 | * so there are no sysfs handlers for link_down_tmo. |
| 6189 | */ |
| 6190 | |
| 6191 | .get_fc_host_stats = lpfc_get_stats, |
| 6192 | .reset_fc_host_stats = lpfc_reset_stats, |
| 6193 | |
| 6194 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6195 | .show_rport_maxframe_size = 1, |
| 6196 | .show_rport_supported_classes = 1, |
| 6197 | |
| 6198 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6199 | .show_rport_dev_loss_tmo = 1, |
| 6200 | |
| 6201 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6202 | .show_starget_port_id = 1, |
| 6203 | |
| 6204 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6205 | .show_starget_node_name = 1, |
| 6206 | |
| 6207 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6208 | .show_starget_port_name = 1, |
| 6209 | |
| 6210 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6211 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 6212 | |
| 6213 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6214 | |
| 6215 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6216 | }; |
| 6217 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6218 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6219 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6220 | * @phba: lpfc_hba pointer. |
| 6221 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6222 | void |
| 6223 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 6224 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6225 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6226 | 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] | 6227 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 6228 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 6229 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 6230 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 6231 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6232 | lpfc_ack0_init(phba, lpfc_ack0); |
| 6233 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6234 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 6235 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6236 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 6237 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6238 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6239 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6240 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 6241 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 6242 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6243 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6244 | lpfc_auto_imax_init(phba, lpfc_auto_imax); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6245 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6246 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6247 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 6248 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6249 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6250 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 6251 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 6252 | phba->cfg_EnableXLane = 0; |
| 6253 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6254 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6255 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6256 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6257 | phba->cfg_oas_lun_state = 0; |
| 6258 | phba->cfg_oas_lun_status = 0; |
| 6259 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6260 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6261 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6262 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 6263 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 6264 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6265 | phba->cfg_poll = 0; |
| 6266 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6267 | phba->cfg_poll = lpfc_poll; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6268 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6269 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6270 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6271 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6272 | |
| 6273 | /* Initialize first burst. Target vs Initiator are different. */ |
| 6274 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6275 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6276 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
| 6277 | lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6278 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6279 | |
| 6280 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 6281 | /* NVME only supported on SLI4 */ |
| 6282 | phba->nvmet_support = 0; |
| 6283 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6284 | phba->cfg_enable_bbcr = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6285 | } else { |
| 6286 | /* We MUST have FCP support */ |
| 6287 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 6288 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 6289 | } |
| 6290 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6291 | if (phba->cfg_auto_imax && !phba->cfg_fcp_imax) |
| 6292 | phba->cfg_auto_imax = 0; |
| 6293 | phba->initial_imax = phba->cfg_fcp_imax; |
| 6294 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6295 | /* A value of 0 means use the number of CPUs found in the system */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6296 | if (phba->cfg_fcp_io_channel == 0) |
| 6297 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6298 | if (phba->cfg_nvme_io_channel == 0) |
| 6299 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6300 | |
| 6301 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME) |
| 6302 | phba->cfg_fcp_io_channel = 0; |
| 6303 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6304 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) |
| 6305 | phba->cfg_nvme_io_channel = 0; |
| 6306 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6307 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6308 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6309 | else |
| 6310 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6311 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6312 | phba->cfg_soft_wwnn = 0L; |
| 6313 | phba->cfg_soft_wwpn = 0L; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6314 | lpfc_xri_split_init(phba, lpfc_xri_split); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6315 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 6316 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6317 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6318 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6319 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6320 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6321 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6322 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 6323 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 6324 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6325 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6326 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6327 | return; |
| 6328 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 6329 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6330 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6331 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 6332 | * dependencies between protocols and roles. |
| 6333 | * @phba: lpfc_hba pointer. |
| 6334 | **/ |
| 6335 | void |
| 6336 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 6337 | { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6338 | if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu) |
| 6339 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6340 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6341 | if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu) |
| 6342 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
| 6343 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6344 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 6345 | phba->nvmet_support) { |
| 6346 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
| 6347 | phba->cfg_fcp_io_channel = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6348 | |
| 6349 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 6350 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 6351 | "NVME Target PRLI ACC enable_fb ", |
| 6352 | phba->cfg_nvme_enable_fb, |
| 6353 | phba->cfg_nvmet_fb_size, |
| 6354 | LPFC_NVMET_FB_SZ_MAX); |
| 6355 | |
| 6356 | if (phba->cfg_nvme_enable_fb == 0) |
| 6357 | phba->cfg_nvmet_fb_size = 0; |
| 6358 | else { |
| 6359 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 6360 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 6361 | } |
| 6362 | |
| 6363 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
| 6364 | if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) { |
| 6365 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6366 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 6367 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 6368 | phba->cfg_nvmet_mrq); |
| 6369 | } |
| 6370 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6371 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 6372 | phba->nvmet_support = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6373 | phba->cfg_nvmet_mrq = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6374 | phba->cfg_nvmet_fb_size = 0; |
| 6375 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6376 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6377 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6378 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6379 | else |
| 6380 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
| 6381 | } |
| 6382 | |
| 6383 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6384 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6385 | * @vport: lpfc_vport pointer. |
| 6386 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6387 | void |
| 6388 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 6389 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6390 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6391 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6392 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6393 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 6394 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 6395 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 6396 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 6397 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 6398 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6399 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6400 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6401 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 6402 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 6403 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 6404 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6405 | return; |
| 6406 | } |