| 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 | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 151 | struct lpfc_nvme_lport *lport; |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 152 | struct lpfc_nodelist *ndlp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 153 | struct nvme_fc_remote_port *nrport; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 154 | uint64_t data1, data2, data3, tot; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 155 | char *statep; |
| 156 | int len = 0; |
| 157 | |
| 158 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
| 159 | len += snprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
| 160 | return len; |
| 161 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 162 | if (phba->nvmet_support) { |
| 163 | if (!phba->targetport) { |
| 164 | len = snprintf(buf, PAGE_SIZE, |
| 165 | "NVME Target: x%llx is not allocated\n", |
| 166 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 167 | return len; |
| 168 | } |
| 169 | /* Port state is only one of two values for now. */ |
| 170 | if (phba->targetport->port_id) |
| 171 | statep = "REGISTERED"; |
| 172 | else |
| 173 | statep = "INIT"; |
| 174 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | b4fd681 | 2017-06-15 22:56:42 -0700 | [diff] [blame] | 175 | "NVME Target Enabled State %s\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 176 | statep); |
| 177 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 178 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 179 | "NVME Target: lpfc", |
| 180 | phba->brd_no, |
| 181 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 182 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 183 | phba->targetport->port_id); |
| 184 | |
Maurizio Lombardi | ea98ab3 | 2017-04-18 11:55:51 +0200 | [diff] [blame] | 185 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 186 | "\nNVME Target: Statistics\n"); |
| 187 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
| 188 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 189 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 190 | atomic_read(&tgtp->rcv_ls_req_in), |
| 191 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 192 | atomic_read(&tgtp->xmt_ls_abort)); |
| 193 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 194 | atomic_read(&tgtp->rcv_ls_req_out)) { |
| 195 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 196 | "Rcv LS: in %08x != out %08x\n", |
| 197 | atomic_read(&tgtp->rcv_ls_req_in), |
| 198 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 199 | } |
| 200 | |
| 201 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 202 | "LS: Xmt %08x Drop %08x Cmpl %08x\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 203 | atomic_read(&tgtp->xmt_ls_rsp), |
| 204 | atomic_read(&tgtp->xmt_ls_drop), |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 205 | atomic_read(&tgtp->xmt_ls_rsp_cmpl)); |
| 206 | |
| 207 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 208 | "LS: RSP Abort %08x xb %08x Err %08x\n", |
| 209 | atomic_read(&tgtp->xmt_ls_rsp_aborted), |
| 210 | atomic_read(&tgtp->xmt_ls_rsp_xb_set), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 211 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 212 | |
| 213 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 5073842 | 2017-08-01 15:12:40 -0700 | [diff] [blame] | 214 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 215 | "Drop %08x\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 216 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
James Smart | 5073842 | 2017-08-01 15:12:40 -0700 | [diff] [blame] | 217 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 218 | atomic_read(&tgtp->xmt_fcp_release), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 219 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 220 | |
| 221 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 222 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
| 223 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 224 | "Rcv FCP: in %08x != out %08x\n", |
| 225 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 226 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 227 | } |
| 228 | |
| 229 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 230 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " |
| 231 | "drop %08x\n", |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 232 | atomic_read(&tgtp->xmt_fcp_read), |
| 233 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 234 | atomic_read(&tgtp->xmt_fcp_write), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 235 | atomic_read(&tgtp->xmt_fcp_rsp), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 236 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 237 | |
| 238 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 239 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 240 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 241 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 242 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 243 | |
| 244 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 245 | "FCP Rsp Abort: %08x xb %08x xricqe %08x\n", |
| 246 | atomic_read(&tgtp->xmt_fcp_rsp_aborted), |
| 247 | atomic_read(&tgtp->xmt_fcp_rsp_xb_set), |
| 248 | atomic_read(&tgtp->xmt_fcp_xri_abort_cqe)); |
| 249 | |
| 250 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 251 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 252 | atomic_read(&tgtp->xmt_fcp_abort), |
| 253 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 254 | |
| 255 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 256 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x", |
| 257 | atomic_read(&tgtp->xmt_abort_sol), |
| 258 | atomic_read(&tgtp->xmt_abort_unsol), |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 259 | atomic_read(&tgtp->xmt_abort_rsp), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 260 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 261 | |
James Smart | 411de51 | 2018-01-30 15:58:52 -0800 | [diff] [blame^] | 262 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 263 | "DELAY: ctx %08x fod %08x wqfull %08x\n", |
| 264 | atomic_read(&tgtp->defer_ctx), |
| 265 | atomic_read(&tgtp->defer_fod), |
| 266 | atomic_read(&tgtp->defer_wqfull)); |
| 267 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 268 | /* Calculate outstanding IOs */ |
| 269 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 270 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 271 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 272 | |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 273 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 274 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 275 | "CTX Outstanding %08llx\n", |
James Smart | 966bb5b | 2017-06-15 22:56:45 -0700 | [diff] [blame] | 276 | phba->sli4_hba.nvmet_xri_cnt, |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 277 | phba->sli4_hba.nvmet_io_wait_cnt, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 278 | phba->sli4_hba.nvmet_io_wait_total, |
| 279 | tot); |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 280 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 281 | len += snprintf(buf+len, PAGE_SIZE-len, "\n"); |
| 282 | return len; |
| 283 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 284 | |
| 285 | localport = vport->localport; |
| 286 | if (!localport) { |
| 287 | len = snprintf(buf, PAGE_SIZE, |
| 288 | "NVME Initiator x%llx is not allocated\n", |
| 289 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 290 | return len; |
| 291 | } |
Colin Ian King | 5c665ae | 2017-12-22 00:28:52 +0000 | [diff] [blame] | 292 | lport = (struct lpfc_nvme_lport *)localport->private; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 293 | len = snprintf(buf, PAGE_SIZE, "NVME Initiator Enabled\n"); |
| 294 | |
| 295 | spin_lock_irq(shost->host_lock); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 296 | |
| 297 | /* Port state is only one of two values for now. */ |
| 298 | if (localport->port_id) |
| 299 | statep = "ONLINE"; |
| 300 | else |
| 301 | statep = "UNKNOWN "; |
| 302 | |
| 303 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 304 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 305 | "NVME LPORT lpfc", |
| 306 | phba->brd_no, |
| 307 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 308 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 309 | localport->port_id, statep); |
| 310 | |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 311 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 312 | if (!ndlp->nrport) |
| 313 | continue; |
| 314 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 315 | /* local short-hand pointer. */ |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 316 | nrport = ndlp->nrport->remoteport; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 317 | |
| 318 | /* Port state is only one of two values for now. */ |
| 319 | switch (nrport->port_state) { |
| 320 | case FC_OBJSTATE_ONLINE: |
| 321 | statep = "ONLINE"; |
| 322 | break; |
| 323 | case FC_OBJSTATE_UNKNOWN: |
| 324 | statep = "UNKNOWN "; |
| 325 | break; |
| 326 | default: |
| 327 | statep = "UNSUPPORTED"; |
| 328 | break; |
| 329 | } |
| 330 | |
| 331 | /* Tab in to show lport ownership. */ |
| 332 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 333 | "NVME RPORT "); |
| 334 | if (phba->brd_no >= 10) |
| 335 | len += snprintf(buf + len, PAGE_SIZE - len, " "); |
| 336 | |
| 337 | len += snprintf(buf + len, PAGE_SIZE - len, "WWPN x%llx ", |
| 338 | nrport->port_name); |
| 339 | len += snprintf(buf + len, PAGE_SIZE - len, "WWNN x%llx ", |
| 340 | nrport->node_name); |
| 341 | len += snprintf(buf + len, PAGE_SIZE - len, "DID x%06x ", |
| 342 | nrport->port_id); |
| 343 | |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 344 | /* An NVME rport can have multiple roles. */ |
| 345 | if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 346 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 347 | "INITIATOR "); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 348 | if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 349 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 350 | "TARGET "); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 351 | if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 352 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 353 | "DISCSRVC "); |
| 354 | if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | |
| 355 | FC_PORT_ROLE_NVME_TARGET | |
| 356 | FC_PORT_ROLE_NVME_DISCOVERY)) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 357 | len += snprintf(buf + len, PAGE_SIZE - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 358 | "UNKNOWN ROLE x%x", |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 359 | nrport->port_role); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 360 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 361 | len += snprintf(buf + len, PAGE_SIZE - len, "%s ", statep); |
| 362 | /* Terminate the string. */ |
| 363 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
| 364 | } |
| 365 | spin_unlock_irq(shost->host_lock); |
| 366 | |
Maurizio Lombardi | ea98ab3 | 2017-04-18 11:55:51 +0200 | [diff] [blame] | 367 | len += snprintf(buf + len, PAGE_SIZE - len, "\nNVME Statistics\n"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 368 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 369 | "LS: Xmt %010x Cmpl %010x Abort %08x\n", |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 370 | atomic_read(&phba->fc4NvmeLsRequests), |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 371 | atomic_read(&phba->fc4NvmeLsCmpls), |
| 372 | atomic_read(&lport->xmt_ls_abort)); |
| 373 | |
| 374 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 375 | "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n", |
| 376 | atomic_read(&lport->xmt_ls_err), |
| 377 | atomic_read(&lport->cmpl_ls_xb), |
| 378 | atomic_read(&lport->cmpl_ls_err)); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 379 | |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 380 | tot = atomic_read(&phba->fc4NvmeIoCmpls); |
| 381 | data1 = atomic_read(&phba->fc4NvmeInputRequests); |
| 382 | data2 = atomic_read(&phba->fc4NvmeOutputRequests); |
| 383 | data3 = atomic_read(&phba->fc4NvmeControlRequests); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 384 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 385 | "FCP: Rd %016llx Wr %016llx IO %016llx\n", |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 386 | data1, data2, data3); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 387 | |
| 388 | len += snprintf(buf+len, PAGE_SIZE-len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 389 | " noxri %08x nondlp %08x qdepth %08x " |
| 390 | "wqerr %08x\n", |
| 391 | atomic_read(&lport->xmt_fcp_noxri), |
| 392 | atomic_read(&lport->xmt_fcp_bad_ndlp), |
| 393 | atomic_read(&lport->xmt_fcp_qdepth), |
| 394 | atomic_read(&lport->xmt_fcp_wqerr)); |
| 395 | |
| 396 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 397 | " Cmpl %016llx Outstanding %016llx Abort %08x\n", |
| 398 | tot, ((data1 + data2 + data3) - tot), |
| 399 | atomic_read(&lport->xmt_fcp_abort)); |
| 400 | |
| 401 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 402 | "FCP CMPL: xb %08x Err %08x\n", |
| 403 | atomic_read(&lport->cmpl_fcp_xb), |
| 404 | atomic_read(&lport->cmpl_fcp_err)); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 405 | return len; |
| 406 | } |
| 407 | |
| 408 | static ssize_t |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 409 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 410 | char *buf) |
| 411 | { |
| 412 | struct Scsi_Host *shost = class_to_shost(dev); |
| 413 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 414 | struct lpfc_hba *phba = vport->phba; |
| 415 | |
| 416 | if (phba->cfg_enable_bg) |
| 417 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 418 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 419 | else |
| 420 | return snprintf(buf, PAGE_SIZE, |
| 421 | "BlockGuard Not Supported\n"); |
| 422 | else |
| 423 | return snprintf(buf, PAGE_SIZE, |
| 424 | "BlockGuard Disabled\n"); |
| 425 | } |
| 426 | |
| 427 | static ssize_t |
| 428 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 429 | char *buf) |
| 430 | { |
| 431 | struct Scsi_Host *shost = class_to_shost(dev); |
| 432 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 433 | struct lpfc_hba *phba = vport->phba; |
| 434 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 435 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 436 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | static ssize_t |
| 440 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 441 | char *buf) |
| 442 | { |
| 443 | struct Scsi_Host *shost = class_to_shost(dev); |
| 444 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 445 | struct lpfc_hba *phba = vport->phba; |
| 446 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 447 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 448 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | static ssize_t |
| 452 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 453 | char *buf) |
| 454 | { |
| 455 | struct Scsi_Host *shost = class_to_shost(dev); |
| 456 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 457 | struct lpfc_hba *phba = vport->phba; |
| 458 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 459 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 460 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 461 | } |
| 462 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 463 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 464 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 465 | * @dev: class converted to a Scsi_host structure. |
| 466 | * @attr: device attribute, not used. |
| 467 | * @buf: on return contains the formatted text from lpfc_info(). |
| 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_info_show(struct device *dev, struct device_attribute *attr, |
| 473 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 474 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 475 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 476 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 477 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 478 | } |
| 479 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 480 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 481 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 482 | * @dev: class converted to a Scsi_host structure. |
| 483 | * @attr: device attribute, not used. |
| 484 | * @buf: on return contains the formatted text serial number. |
| 485 | * |
| 486 | * Returns: size of formatted string. |
| 487 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 488 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 489 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 490 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 491 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 492 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 493 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 494 | struct lpfc_hba *phba = vport->phba; |
| 495 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 496 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 497 | } |
| 498 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 499 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 500 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 501 | * @dev: class converted to a Scsi_host structure. |
| 502 | * @attr: device attribute, not used. |
| 503 | * @buf: on return contains the formatted support level. |
| 504 | * |
| 505 | * Description: |
| 506 | * Returns a number indicating the temperature sensor level currently |
| 507 | * supported, zero or one in ascii. |
| 508 | * |
| 509 | * Returns: size of formatted string. |
| 510 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 511 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 512 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 513 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 514 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 515 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 516 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 517 | struct lpfc_hba *phba = vport->phba; |
| 518 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 519 | } |
| 520 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 521 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 522 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 523 | * @dev: class converted to a Scsi_host structure. |
| 524 | * @attr: device attribute, not used. |
| 525 | * @buf: on return contains the scsi vpd model description. |
| 526 | * |
| 527 | * Returns: size of formatted string. |
| 528 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 529 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 530 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 531 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 532 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 533 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 534 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 535 | struct lpfc_hba *phba = vport->phba; |
| 536 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 537 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 538 | } |
| 539 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 540 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 541 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 542 | * @dev: class converted to a Scsi_host structure. |
| 543 | * @attr: device attribute, not used. |
| 544 | * @buf: on return contains the scsi vpd model name. |
| 545 | * |
| 546 | * Returns: size of formatted string. |
| 547 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 548 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 549 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 550 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 551 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 552 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 553 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 554 | struct lpfc_hba *phba = vport->phba; |
| 555 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 556 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 557 | } |
| 558 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 559 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 560 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 561 | * @dev: class converted to a Scsi_host structure. |
| 562 | * @attr: device attribute, not used. |
| 563 | * @buf: on return contains the scsi vpd program type. |
| 564 | * |
| 565 | * Returns: size of formatted string. |
| 566 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 567 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 568 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 569 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 570 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 571 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 572 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 573 | struct lpfc_hba *phba = vport->phba; |
| 574 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 575 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 576 | } |
| 577 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 578 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 579 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 580 | * @dev: class converted to a Scsi_host structure. |
| 581 | * @attr: device attribute, not used. |
| 582 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 583 | * |
| 584 | * Returns: size of formatted string. |
| 585 | **/ |
| 586 | static ssize_t |
| 587 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 588 | { |
| 589 | struct Scsi_Host *shost = class_to_shost(dev); |
| 590 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 591 | struct lpfc_hba *phba = vport->phba; |
| 592 | |
| 593 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 594 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 595 | } |
| 596 | |
| 597 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 598 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 599 | * @dev: class converted to a Scsi_host structure. |
| 600 | * @attr: device attribute, not used. |
| 601 | * @buf: on return contains scsi vpd program type. |
| 602 | * |
| 603 | * Returns: size of formatted string. |
| 604 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 605 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 606 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 607 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 608 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 609 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 610 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 611 | struct lpfc_hba *phba = vport->phba; |
| 612 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 613 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 614 | } |
| 615 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 616 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 617 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 618 | * @dev: class converted to a Scsi_host structure. |
| 619 | * @attr: device attribute, not used. |
| 620 | * @buf: on return contains the scsi vpd program type. |
| 621 | * |
| 622 | * Returns: size of formatted string. |
| 623 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 624 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 625 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 626 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 627 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 628 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 629 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 630 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 631 | uint32_t if_type; |
| 632 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 633 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 634 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 635 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 636 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 637 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 638 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 639 | |
| 640 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 641 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 642 | fwrev, phba->sli_rev); |
| 643 | else |
| 644 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 645 | fwrev, phba->sli_rev, if_type, sli_family); |
| 646 | |
| 647 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 648 | } |
| 649 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 650 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 651 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 652 | * @dev: class converted to a Scsi_host structure. |
| 653 | * @attr: device attribute, not used. |
| 654 | * @buf: on return contains the scsi vpd program type. |
| 655 | * |
| 656 | * Returns: size of formatted string. |
| 657 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 658 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 659 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 660 | { |
| 661 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 662 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 663 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 664 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 665 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 666 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 667 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 668 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 669 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 670 | |
| 671 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 672 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 673 | * @dev: class converted to a Scsi_host structure. |
| 674 | * @attr: device attribute, not used. |
| 675 | * @buf: on return contains the ROM and FCode ascii strings. |
| 676 | * |
| 677 | * Returns: size of formatted string. |
| 678 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 679 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 680 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 681 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 682 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 683 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 684 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 685 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 686 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 687 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 688 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 689 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 690 | |
| 691 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
| 692 | return snprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 693 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 694 | |
| 695 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 696 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 697 | * @dev: class converted to a Scsi_host structure. |
| 698 | * @attr: device attribute, not used. |
| 699 | * @buf: on return contains text describing the state of the link. |
| 700 | * |
| 701 | * Notes: |
| 702 | * The switch statement has no default so zero will be returned. |
| 703 | * |
| 704 | * Returns: size of formatted string. |
| 705 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 706 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 707 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 708 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 709 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 710 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 711 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 712 | struct lpfc_hba *phba = vport->phba; |
| 713 | int len = 0; |
| 714 | |
| 715 | switch (phba->link_state) { |
| 716 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 717 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 718 | case LPFC_INIT_START: |
| 719 | case LPFC_INIT_MBX_CMDS: |
| 720 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 721 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 722 | if (phba->hba_flag & LINK_DISABLED) |
| 723 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 724 | "Link Down - User disabled\n"); |
| 725 | else |
| 726 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 727 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 728 | break; |
| 729 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 730 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 731 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 732 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 733 | |
| 734 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 735 | case LPFC_LOCAL_CFG_LINK: |
| 736 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 737 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 738 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 739 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 740 | case LPFC_FLOGI: |
| 741 | case LPFC_FABRIC_CFG_LINK: |
| 742 | case LPFC_NS_REG: |
| 743 | case LPFC_NS_QRY: |
| 744 | case LPFC_BUILD_DISC_LIST: |
| 745 | case LPFC_DISC_AUTH: |
| 746 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 747 | "Discovery\n"); |
| 748 | break; |
| 749 | case LPFC_VPORT_READY: |
| 750 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 751 | break; |
| 752 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 753 | case LPFC_VPORT_FAILED: |
| 754 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 755 | break; |
| 756 | |
| 757 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 758 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 759 | "Unknown\n"); |
| 760 | break; |
| 761 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 762 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 763 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 764 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 765 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 766 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 767 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 768 | " Public Loop\n"); |
| 769 | else |
| 770 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 771 | " Private Loop\n"); |
| 772 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 773 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 774 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 775 | " Fabric\n"); |
| 776 | else |
| 777 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 778 | " Point-2-Point\n"); |
| 779 | } |
| 780 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 781 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 782 | return len; |
| 783 | } |
| 784 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 785 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 786 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 787 | * @dev: class unused variable. |
| 788 | * @attr: device attribute, not used. |
| 789 | * @buf: on return contains the module description text. |
| 790 | * |
| 791 | * Returns: size of formatted string. |
| 792 | **/ |
| 793 | static ssize_t |
| 794 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 795 | char *buf) |
| 796 | { |
| 797 | struct Scsi_Host *shost = class_to_shost(dev); |
| 798 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 799 | struct lpfc_hba *phba = vport->phba; |
| 800 | |
| 801 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 802 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 803 | |
| 804 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 805 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 806 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 807 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 808 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 809 | } |
| 810 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 811 | } |
| 812 | |
| 813 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 814 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 815 | * (OAS) is supported. |
| 816 | * @dev: class unused variable. |
| 817 | * @attr: device attribute, not used. |
| 818 | * @buf: on return contains the module description text. |
| 819 | * |
| 820 | * Returns: size of formatted string. |
| 821 | **/ |
| 822 | static ssize_t |
| 823 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 824 | char *buf) |
| 825 | { |
| 826 | struct Scsi_Host *shost = class_to_shost(dev); |
| 827 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 828 | struct lpfc_hba *phba = vport->phba; |
| 829 | |
| 830 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 831 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 832 | } |
| 833 | |
| 834 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 835 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 836 | * @dev: class device that is converted into a Scsi_host. |
| 837 | * @attr: device attribute, not used. |
| 838 | * @buf: one or more lpfc_polling_flags values. |
| 839 | * @count: not used. |
| 840 | * |
| 841 | * Returns: |
| 842 | * -EINVAL if the buffer is not "up" or "down" |
| 843 | * return from link state change function if non-zero |
| 844 | * length of the buf on success |
| 845 | **/ |
| 846 | static ssize_t |
| 847 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 848 | const char *buf, size_t count) |
| 849 | { |
| 850 | struct Scsi_Host *shost = class_to_shost(dev); |
| 851 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 852 | struct lpfc_hba *phba = vport->phba; |
| 853 | |
| 854 | int status = -EINVAL; |
| 855 | |
| 856 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 857 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 858 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 859 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 860 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 861 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 862 | |
| 863 | if (status == 0) |
| 864 | return strlen(buf); |
| 865 | else |
| 866 | return status; |
| 867 | } |
| 868 | |
| 869 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 870 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 871 | * @dev: class device that is converted into a Scsi_host. |
| 872 | * @attr: device attribute, not used. |
| 873 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 874 | * |
| 875 | * Description: |
| 876 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 877 | * vport counts. |
| 878 | * |
| 879 | * Returns: size of formatted string. |
| 880 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 881 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 882 | lpfc_num_discovered_ports_show(struct device *dev, |
| 883 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 884 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 885 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 886 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 887 | |
| 888 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 889 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 890 | } |
| 891 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 892 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 893 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 894 | * @shost: Scsi_Host pointer. |
| 895 | * |
| 896 | * Description: |
| 897 | * Bring the link down gracefully then re-init the link. The firmware will |
| 898 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 899 | * |
| 900 | * Returns: |
| 901 | * -EPERM port offline or management commands are being blocked |
| 902 | * -ENOMEM cannot allocate memory for the mailbox command |
| 903 | * -EIO error sending the mailbox command |
| 904 | * zero for success |
| 905 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 906 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 907 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 908 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 909 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 910 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 911 | LPFC_MBOXQ_t *pmboxq; |
| 912 | int mbxstatus = MBXERR_ERROR; |
| 913 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 914 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 915 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 916 | return -EPERM; |
| 917 | |
| 918 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 919 | |
| 920 | if (!pmboxq) |
| 921 | return -ENOMEM; |
| 922 | |
| 923 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 924 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 925 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 926 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 927 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 928 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 929 | if ((mbxstatus == MBX_SUCCESS) && |
| 930 | (pmboxq->u.mb.mbxStatus == 0 || |
| 931 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 932 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 933 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 934 | phba->cfg_link_speed); |
| 935 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 936 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 937 | if ((mbxstatus == MBX_SUCCESS) && |
| 938 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 939 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 940 | "2859 SLI authentication is required " |
| 941 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 942 | } |
| 943 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 944 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 945 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 946 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 947 | |
| 948 | if (mbxstatus == MBXERR_ERROR) |
| 949 | return -EIO; |
| 950 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 951 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 952 | } |
| 953 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 954 | int |
| 955 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 956 | { |
| 957 | int cnt = 0; |
| 958 | |
| 959 | spin_lock_irq(lock); |
| 960 | while (!list_empty(q)) { |
| 961 | spin_unlock_irq(lock); |
| 962 | msleep(20); |
| 963 | if (cnt++ > 250) { /* 5 secs */ |
| 964 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 965 | "0466 %s %s\n", |
| 966 | "Outstanding IO when ", |
| 967 | "bringing Adapter offline\n"); |
| 968 | return 0; |
| 969 | } |
| 970 | spin_lock_irq(lock); |
| 971 | } |
| 972 | spin_unlock_irq(lock); |
| 973 | return 1; |
| 974 | } |
| 975 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 976 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 977 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 978 | * @phba: lpfc_hba pointer. |
| 979 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 980 | * |
| 981 | * Notes: |
| 982 | * Assumes any error from lpfc_do_offline() will be negative. |
| 983 | * Can wait up to 5 seconds for the port ring buffers count |
| 984 | * 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] | 985 | * 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] | 986 | * |
| 987 | * Returns: |
| 988 | * -EIO error posting the event |
| 989 | * zero for success |
| 990 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 991 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 992 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 993 | { |
| 994 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 995 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 996 | struct lpfc_sli_ring *pring; |
| 997 | struct lpfc_sli *psli; |
| 998 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 999 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1000 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1001 | |
| 1002 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1003 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1004 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1005 | if (rc == 0) |
| 1006 | return -ENOMEM; |
| 1007 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1008 | wait_for_completion(&online_compl); |
| 1009 | |
| 1010 | if (status != 0) |
| 1011 | return -EIO; |
| 1012 | |
| 1013 | psli = &phba->sli; |
| 1014 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1015 | /* Wait a little for things to settle down, but not |
| 1016 | * long enough for dev loss timeout to expire. |
| 1017 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1018 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 1019 | for (i = 0; i < psli->num_rings; i++) { |
| 1020 | pring = &psli->sli3_ring[i]; |
| 1021 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1022 | &phba->hbalock)) |
| 1023 | goto out; |
| 1024 | } |
| 1025 | } else { |
| 1026 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 1027 | pring = qp->pring; |
| 1028 | if (!pring) |
| 1029 | continue; |
| 1030 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1031 | &pring->ring_lock)) |
| 1032 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1033 | } |
| 1034 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1035 | out: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1036 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1037 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 1038 | if (rc == 0) |
| 1039 | return -ENOMEM; |
| 1040 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1041 | wait_for_completion(&online_compl); |
| 1042 | |
| 1043 | if (status != 0) |
| 1044 | return -EIO; |
| 1045 | |
| 1046 | return 0; |
| 1047 | } |
| 1048 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1049 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1050 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1051 | * @phba: lpfc_hba pointer. |
| 1052 | * |
| 1053 | * Description: |
| 1054 | * If the port is configured to allow a reset then the hba is brought |
| 1055 | * offline then online. |
| 1056 | * |
| 1057 | * Notes: |
| 1058 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1059 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1060 | * |
| 1061 | * Returns: |
| 1062 | * lpfc_do_offline() return code if not zero |
| 1063 | * -EIO reset not configured or error posting the event |
| 1064 | * zero for success |
| 1065 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1066 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1067 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1068 | { |
| 1069 | struct completion online_compl; |
| 1070 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1071 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1072 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1073 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1074 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1075 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1076 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1077 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1078 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1079 | if (status != 0) |
| 1080 | return status; |
| 1081 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1082 | |
| 1083 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1084 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1085 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1086 | if (rc == 0) |
| 1087 | return -ENOMEM; |
| 1088 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1089 | wait_for_completion(&online_compl); |
| 1090 | |
| 1091 | if (status != 0) |
| 1092 | return -EIO; |
| 1093 | |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1097 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1098 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1099 | * @dev: class device that is converted into a Scsi_host. |
| 1100 | * @attr: device attribute, not used. |
| 1101 | * @buf: containing the string "selective". |
| 1102 | * @count: unused variable. |
| 1103 | * |
| 1104 | * Description: |
| 1105 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1106 | * is called to perform the reset. |
| 1107 | * |
| 1108 | * Notes: |
| 1109 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1110 | * 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] | 1111 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1112 | * |
| 1113 | * Returns: |
| 1114 | * -EINVAL if the buffer does not contain the string "selective" |
| 1115 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1116 | * return value of lpfc_selective_reset() if the call fails |
| 1117 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1118 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1119 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1120 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1121 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1122 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1123 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1124 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1125 | int status = -EINVAL; |
| 1126 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1127 | if (!phba->cfg_enable_hba_reset) |
| 1128 | return -EACCES; |
| 1129 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1130 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1131 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1132 | |
| 1133 | if (status == 0) |
| 1134 | return strlen(buf); |
| 1135 | else |
| 1136 | return status; |
| 1137 | } |
| 1138 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1139 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1140 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1141 | * @phba: lpfc_hba pointer. |
| 1142 | * |
| 1143 | * Description: |
| 1144 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1145 | * the readyness after performing a firmware reset. |
| 1146 | * |
| 1147 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1148 | * 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] | 1149 | * reset, -EIO when port timeout from recovering from the reset. |
| 1150 | * |
| 1151 | * Note: |
| 1152 | * As the caller will interpret the return code by value, be careful in making |
| 1153 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1154 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1155 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1156 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1157 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1158 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1159 | int i; |
| 1160 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1161 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1162 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1163 | &portstat_reg.word0); |
| 1164 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1165 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1166 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1167 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1168 | return -EPERM; |
| 1169 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1170 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1171 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1172 | msleep(10); |
| 1173 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1174 | &portstat_reg.word0); |
| 1175 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1176 | continue; |
| 1177 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1178 | continue; |
| 1179 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1180 | continue; |
| 1181 | break; |
| 1182 | } |
| 1183 | |
| 1184 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1185 | return 0; |
| 1186 | else |
| 1187 | return -EIO; |
| 1188 | } |
| 1189 | |
| 1190 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1191 | * 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] | 1192 | * @phba: lpfc_hba pointer. |
| 1193 | * |
| 1194 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1195 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1196 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1197 | * |
| 1198 | * Returns: |
| 1199 | * zero for success |
| 1200 | **/ |
| 1201 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1202 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1203 | { |
| 1204 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1205 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1206 | uint32_t before_fc_flag; |
| 1207 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1208 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1209 | int status = 0, rc = 0; |
| 1210 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1211 | |
| 1212 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1213 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1214 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1215 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 1216 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 1217 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1218 | return -EPERM; |
| 1219 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1220 | /* Keep state if we need to restore back */ |
| 1221 | before_fc_flag = phba->pport->fc_flag; |
| 1222 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1223 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1224 | /* Disable SR-IOV virtual functions if enabled */ |
| 1225 | if (phba->cfg_sriov_nr_virtfn) { |
| 1226 | pci_disable_sriov(pdev); |
| 1227 | phba->cfg_sriov_nr_virtfn = 0; |
| 1228 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1229 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1230 | if (opcode == LPFC_FW_DUMP) |
| 1231 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1232 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1233 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1234 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1235 | if (status != 0) { |
| 1236 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1237 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1238 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1239 | |
| 1240 | /* wait for the device to be quiesced before firmware reset */ |
| 1241 | msleep(100); |
| 1242 | |
| 1243 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1244 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1245 | |
| 1246 | if (opcode == LPFC_FW_DUMP) |
| 1247 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1248 | else if (opcode == LPFC_FW_RESET) |
| 1249 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1250 | else if (opcode == LPFC_DV_RESET) |
| 1251 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1252 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1253 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1254 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1255 | /* flush */ |
| 1256 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1257 | |
| 1258 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1259 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1260 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1261 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1262 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1263 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1264 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1265 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1266 | } else if (rc == -EIO) { |
| 1267 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1268 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1269 | "3153 Fail to perform the requested " |
| 1270 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1271 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | /* keep the original port state */ |
| 1275 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1276 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1277 | |
| 1278 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1279 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1280 | LPFC_EVT_ONLINE); |
| 1281 | if (!job_posted) |
| 1282 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1283 | |
| 1284 | wait_for_completion(&online_compl); |
| 1285 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1286 | out: |
| 1287 | /* in any case, restore the virtual functions enabled as before */ |
| 1288 | if (sriov_nr_virtfn) { |
| 1289 | sriov_err = |
| 1290 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1291 | if (!sriov_err) |
| 1292 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1293 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1294 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1295 | /* return proper error code */ |
| 1296 | if (!rc) { |
| 1297 | if (!job_posted) |
| 1298 | rc = -ENOMEM; |
| 1299 | else if (status) |
| 1300 | rc = -EIO; |
| 1301 | } |
| 1302 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1306 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1307 | * @dev: class device that is converted into a Scsi_host. |
| 1308 | * @attr: device attribute, not used. |
| 1309 | * @buf: on return contains the ascii number of nport events. |
| 1310 | * |
| 1311 | * Returns: size of formatted string. |
| 1312 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1313 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1314 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1315 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1316 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1317 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1318 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1319 | struct lpfc_hba *phba = vport->phba; |
| 1320 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1321 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1322 | } |
| 1323 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1324 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1325 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1326 | * @dev: class device that is converted into a Scsi_host. |
| 1327 | * @attr: device attribute, not used. |
| 1328 | * @buf: on return contains the state of the adapter. |
| 1329 | * |
| 1330 | * Returns: size of formatted string. |
| 1331 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1332 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1333 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1334 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1335 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1336 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1337 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1338 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1339 | char * state; |
| 1340 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1341 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1342 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1343 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1344 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1345 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1346 | state = "offline"; |
| 1347 | else |
| 1348 | state = "online"; |
| 1349 | |
| 1350 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1351 | } |
| 1352 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1353 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1354 | * 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] | 1355 | * @dev: class device that is converted into a Scsi_host. |
| 1356 | * @attr: device attribute, not used. |
| 1357 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1358 | * @count: unused variable. |
| 1359 | * |
| 1360 | * Returns: |
| 1361 | * -EACCES if enable hba reset not enabled |
| 1362 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1363 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1364 | * buf length greater than zero indicates success |
| 1365 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1366 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1367 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1368 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1369 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1370 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1371 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1372 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1373 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1374 | char *board_mode_str = NULL; |
| 1375 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1376 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1377 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1378 | if (!phba->cfg_enable_hba_reset) { |
| 1379 | status = -EACCES; |
| 1380 | goto board_mode_out; |
| 1381 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1382 | |
| 1383 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1384 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1385 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1386 | init_completion(&online_compl); |
| 1387 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1388 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1389 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1390 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1391 | if (rc == 0) { |
| 1392 | status = -ENOMEM; |
| 1393 | goto board_mode_out; |
| 1394 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1395 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1396 | if (status) |
| 1397 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1398 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1399 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1400 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1401 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1402 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1403 | else |
| 1404 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1405 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1406 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1407 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1408 | else |
| 1409 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1410 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1411 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1412 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1413 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1414 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1415 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1416 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1417 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1418 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1419 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1420 | if (!status) |
| 1421 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1422 | else { |
| 1423 | board_mode_str = strchr(buf, '\n'); |
| 1424 | if (board_mode_str) |
| 1425 | *board_mode_str = '\0'; |
| 1426 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1427 | "3097 Failed \"%s\", status(%d), " |
| 1428 | "fc_flag(x%x)\n", |
| 1429 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1430 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1431 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1432 | } |
| 1433 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1434 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1435 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1436 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1437 | * @mxri: max xri count. |
| 1438 | * @axri: available xri count. |
| 1439 | * @mrpi: max rpi count. |
| 1440 | * @arpi: available rpi count. |
| 1441 | * @mvpi: max vpi count. |
| 1442 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1443 | * |
| 1444 | * Description: |
| 1445 | * If an integer pointer for an count is not null then the value for the |
| 1446 | * count is returned. |
| 1447 | * |
| 1448 | * Returns: |
| 1449 | * zero on error |
| 1450 | * one for success |
| 1451 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1452 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1453 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1454 | uint32_t *mxri, uint32_t *axri, |
| 1455 | uint32_t *mrpi, uint32_t *arpi, |
| 1456 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1457 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1458 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1459 | LPFC_MBOXQ_t *pmboxq; |
| 1460 | MAILBOX_t *pmb; |
| 1461 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1462 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1463 | |
| 1464 | /* |
| 1465 | * prevent udev from issuing mailbox commands until the port is |
| 1466 | * configured. |
| 1467 | */ |
| 1468 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1469 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1470 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1471 | return 0; |
| 1472 | |
| 1473 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1474 | return 0; |
| 1475 | |
| 1476 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1477 | if (!pmboxq) |
| 1478 | return 0; |
| 1479 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1480 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1481 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1482 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1483 | pmb->mbxOwner = OWN_HOST; |
| 1484 | pmboxq->context1 = NULL; |
| 1485 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1486 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1487 | rc = MBX_NOT_FINISHED; |
| 1488 | else |
| 1489 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1490 | |
| 1491 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1492 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1493 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1494 | return 0; |
| 1495 | } |
| 1496 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1497 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1498 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1499 | if (mrpi) |
| 1500 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1501 | if (arpi) |
| 1502 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1503 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1504 | if (mxri) |
| 1505 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1506 | if (axri) |
| 1507 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1508 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1509 | |
| 1510 | /* Account for differences with SLI-3. Get vpi count from |
| 1511 | * mailbox data and subtract one for max vpi value. |
| 1512 | */ |
| 1513 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1514 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1515 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1516 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1517 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1518 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1519 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1520 | } else { |
| 1521 | if (mrpi) |
| 1522 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1523 | if (arpi) |
| 1524 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1525 | if (mxri) |
| 1526 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1527 | if (axri) |
| 1528 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1529 | if (mvpi) |
| 1530 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1531 | if (avpi) |
| 1532 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1533 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1534 | |
| 1535 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1536 | return 1; |
| 1537 | } |
| 1538 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1539 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1540 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1541 | * @dev: class device that is converted into a Scsi_host. |
| 1542 | * @attr: device attribute, not used. |
| 1543 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1544 | * |
| 1545 | * Description: |
| 1546 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1547 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1548 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1549 | * must check for "Unknown" in the buffer to detect a failure. |
| 1550 | * |
| 1551 | * Returns: size of formatted string. |
| 1552 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1553 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1554 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1555 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1556 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1557 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1558 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1559 | struct lpfc_hba *phba = vport->phba; |
| 1560 | uint32_t cnt; |
| 1561 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1562 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1563 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1564 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1565 | } |
| 1566 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1567 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1568 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1569 | * @dev: class device that is converted into a Scsi_host. |
| 1570 | * @attr: device attribute, not used. |
| 1571 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1572 | * |
| 1573 | * Description: |
| 1574 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1575 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1576 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1577 | * must check for "Unknown" in the buffer to detect a failure. |
| 1578 | * |
| 1579 | * Returns: size of formatted string. |
| 1580 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1581 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1582 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1583 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1584 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1585 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1586 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1587 | struct lpfc_hba *phba = vport->phba; |
| 1588 | uint32_t cnt, acnt; |
| 1589 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1590 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1591 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1592 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1593 | } |
| 1594 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1595 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1596 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1597 | * @dev: class device that is converted into a Scsi_host. |
| 1598 | * @attr: device attribute, not used. |
| 1599 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1600 | * |
| 1601 | * Description: |
| 1602 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1603 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1604 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1605 | * must check for "Unknown" in the buffer to detect a failure. |
| 1606 | * |
| 1607 | * Returns: size of formatted string. |
| 1608 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1609 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1610 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1611 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1612 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1613 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1614 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1615 | struct lpfc_hba *phba = vport->phba; |
| 1616 | uint32_t cnt; |
| 1617 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1618 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1619 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1620 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1621 | } |
| 1622 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1623 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1624 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1625 | * @dev: class device that is converted into a Scsi_host. |
| 1626 | * @attr: device attribute, not used. |
| 1627 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1628 | * |
| 1629 | * Description: |
| 1630 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1631 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1632 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1633 | * must check for "Unknown" in the buffer to detect a failure. |
| 1634 | * |
| 1635 | * Returns: size of formatted string. |
| 1636 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1637 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1638 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1639 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1640 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1641 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1642 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1643 | struct lpfc_hba *phba = vport->phba; |
| 1644 | uint32_t cnt, acnt; |
| 1645 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1646 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1647 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1648 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1649 | } |
| 1650 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1651 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1652 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1653 | * @dev: class device that is converted into a Scsi_host. |
| 1654 | * @attr: device attribute, not used. |
| 1655 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1656 | * |
| 1657 | * Description: |
| 1658 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1659 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1660 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1661 | * must check for "Unknown" in the buffer to detect a failure. |
| 1662 | * |
| 1663 | * Returns: size of formatted string. |
| 1664 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1665 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1666 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1667 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1668 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1669 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1670 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1671 | struct lpfc_hba *phba = vport->phba; |
| 1672 | uint32_t cnt; |
| 1673 | |
| 1674 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1675 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1676 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1677 | } |
| 1678 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1679 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1680 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1681 | * @dev: class device that is converted into a Scsi_host. |
| 1682 | * @attr: device attribute, not used. |
| 1683 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1684 | * |
| 1685 | * Description: |
| 1686 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1687 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1688 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1689 | * must check for "Unknown" in the buffer to detect a failure. |
| 1690 | * |
| 1691 | * Returns: size of formatted string. |
| 1692 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1693 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1694 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1695 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1696 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1697 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1698 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1699 | struct lpfc_hba *phba = vport->phba; |
| 1700 | uint32_t cnt, acnt; |
| 1701 | |
| 1702 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1703 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1704 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1705 | } |
| 1706 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1707 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1708 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1709 | * @dev: class device that is converted into a Scsi_host. |
| 1710 | * @attr: device attribute, not used. |
| 1711 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1712 | * |
| 1713 | * Description: |
| 1714 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1715 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1716 | * the id of the vport. |
| 1717 | * |
| 1718 | * Returns: size of formatted string. |
| 1719 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1720 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1721 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1722 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1723 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1724 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1725 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1726 | struct lpfc_hba *phba = vport->phba; |
| 1727 | |
| 1728 | if (!(phba->max_vpi)) |
| 1729 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1730 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1731 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1732 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1733 | } |
| 1734 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1735 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1736 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1737 | * @dev: class device that is converted into a Scsi_host. |
| 1738 | * @attr: device attribute, not used. |
| 1739 | * @buf: on return contains the cfg_poll in hex. |
| 1740 | * |
| 1741 | * Notes: |
| 1742 | * cfg_poll should be a lpfc_polling_flags type. |
| 1743 | * |
| 1744 | * Returns: size of formatted string. |
| 1745 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1746 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1747 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1748 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1749 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1750 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1751 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1752 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1753 | |
| 1754 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1755 | } |
| 1756 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1757 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1758 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1759 | * @dev: class device that is converted into a Scsi_host. |
| 1760 | * @attr: device attribute, not used. |
| 1761 | * @buf: one or more lpfc_polling_flags values. |
| 1762 | * @count: not used. |
| 1763 | * |
| 1764 | * Notes: |
| 1765 | * buf contents converted to integer and checked for a valid value. |
| 1766 | * |
| 1767 | * Returns: |
| 1768 | * -EINVAL if the buffer connot be converted or is out of range |
| 1769 | * length of the buf on success |
| 1770 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1771 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1772 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1773 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1774 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1775 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1776 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1777 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1778 | uint32_t creg_val; |
| 1779 | uint32_t old_val; |
| 1780 | int val=0; |
| 1781 | |
| 1782 | if (!isdigit(buf[0])) |
| 1783 | return -EINVAL; |
| 1784 | |
| 1785 | if (sscanf(buf, "%i", &val) != 1) |
| 1786 | return -EINVAL; |
| 1787 | |
| 1788 | if ((val & 0x3) != val) |
| 1789 | return -EINVAL; |
| 1790 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1791 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1792 | val = 0; |
| 1793 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1794 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1795 | "3051 lpfc_poll changed from %d to %d\n", |
| 1796 | phba->cfg_poll, val); |
| 1797 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1798 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1799 | |
| 1800 | old_val = phba->cfg_poll; |
| 1801 | |
| 1802 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1803 | if ((val & DISABLE_FCP_RING_INT) && |
| 1804 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1805 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1806 | spin_unlock_irq(&phba->hbalock); |
| 1807 | return -EINVAL; |
| 1808 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1809 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1810 | writel(creg_val, phba->HCregaddr); |
| 1811 | readl(phba->HCregaddr); /* flush */ |
| 1812 | |
| 1813 | lpfc_poll_start_timer(phba); |
| 1814 | } |
| 1815 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1816 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1817 | return -EINVAL; |
| 1818 | } |
| 1819 | |
| 1820 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1821 | (old_val & DISABLE_FCP_RING_INT)) |
| 1822 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1823 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1824 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1825 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1826 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1827 | spin_unlock_irq(&phba->hbalock); |
| 1828 | return -EINVAL; |
| 1829 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1830 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1831 | writel(creg_val, phba->HCregaddr); |
| 1832 | readl(phba->HCregaddr); /* flush */ |
| 1833 | } |
| 1834 | |
| 1835 | phba->cfg_poll = val; |
| 1836 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1837 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1838 | |
| 1839 | return strlen(buf); |
| 1840 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1841 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1842 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1843 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1844 | * @dev: class unused variable. |
| 1845 | * @attr: device attribute, not used. |
| 1846 | * @buf: on return contains the module description text. |
| 1847 | * |
| 1848 | * Returns: size of formatted string. |
| 1849 | **/ |
| 1850 | static ssize_t |
| 1851 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1852 | char *buf) |
| 1853 | { |
| 1854 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1855 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1856 | struct lpfc_hba *phba = vport->phba; |
| 1857 | |
| 1858 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1859 | } |
| 1860 | |
| 1861 | /** |
| 1862 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1863 | * @dev: class unused variable. |
| 1864 | * @attr: device attribute, not used. |
| 1865 | * @buf: on return contains the module description text. |
| 1866 | * |
| 1867 | * Returns: size of formatted string. |
| 1868 | **/ |
| 1869 | static ssize_t |
| 1870 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1871 | char *buf) |
| 1872 | { |
| 1873 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1874 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1875 | struct lpfc_hba *phba = vport->phba; |
| 1876 | |
| 1877 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1878 | } |
| 1879 | |
| 1880 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1881 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1882 | * @dev: class converted to a Scsi_host structure. |
| 1883 | * @attr: device attribute, not used. |
| 1884 | * @buf: on return contains the formatted text. |
| 1885 | * |
| 1886 | * Returns: size of formatted string. |
| 1887 | **/ |
| 1888 | static ssize_t |
| 1889 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1890 | char *buf) |
| 1891 | { |
| 1892 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1893 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1894 | struct lpfc_hba *phba = vport->phba; |
| 1895 | |
| 1896 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1897 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1898 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1899 | "" : "Not "); |
| 1900 | } |
| 1901 | |
| 1902 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1903 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1904 | * @dev: class converted to a Scsi_host structure. |
| 1905 | * @attr: device attribute, not used. |
| 1906 | * @buf: on return contains the formatted support level. |
| 1907 | * |
| 1908 | * Description: |
| 1909 | * Returns the maximum number of virtual functions a physical function can |
| 1910 | * support, 0 will be returned if called on virtual function. |
| 1911 | * |
| 1912 | * Returns: size of formatted string. |
| 1913 | **/ |
| 1914 | static ssize_t |
| 1915 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1916 | struct device_attribute *attr, |
| 1917 | char *buf) |
| 1918 | { |
| 1919 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1920 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1921 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1922 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1923 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1924 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1925 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1926 | } |
| 1927 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1928 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 1929 | { |
| 1930 | return val >= min && val <= max; |
| 1931 | } |
| 1932 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1933 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 1934 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 1935 | * @phba: pointer the the adapter structure. |
| 1936 | * @val: integer attribute value. |
| 1937 | * |
| 1938 | * Description: |
| 1939 | * Validates the min and max values then sets the |
| 1940 | * adapter config field if in the valid range. prints error message |
| 1941 | * and does not set the parameter if invalid. |
| 1942 | * |
| 1943 | * Returns: |
| 1944 | * zero on success |
| 1945 | * -EINVAL if val is invalid |
| 1946 | */ |
| 1947 | static ssize_t |
| 1948 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 1949 | { |
| 1950 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 1951 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1952 | "3068 %s_enable_bbcr changed from %d to %d\n", |
| 1953 | LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val); |
| 1954 | phba->cfg_enable_bbcr = val; |
| 1955 | return 0; |
| 1956 | } |
| 1957 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1958 | "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n", |
| 1959 | LPFC_DRIVER_NAME, val); |
| 1960 | return -EINVAL; |
| 1961 | } |
| 1962 | |
| 1963 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1964 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1965 | * |
| 1966 | * Description: |
| 1967 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1968 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1969 | * |
| 1970 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1971 | * @dev: class device that is converted into a Scsi_host. |
| 1972 | * @attr: device attribute, not used. |
| 1973 | * @buf: on return contains the attribute value in decimal. |
| 1974 | * |
| 1975 | * Returns: size of formatted string. |
| 1976 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1977 | #define lpfc_param_show(attr) \ |
| 1978 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1979 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1980 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1981 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1982 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1983 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1984 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1985 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1986 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1987 | } |
| 1988 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1989 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1990 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1991 | * |
| 1992 | * Description: |
| 1993 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1994 | * into a function with the name lpfc_hba_queue_depth_show |
| 1995 | * |
| 1996 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1997 | * @dev: class device that is converted into a Scsi_host. |
| 1998 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1999 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2000 | * |
| 2001 | * Returns: size of formatted string. |
| 2002 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2003 | #define lpfc_param_hex_show(attr) \ |
| 2004 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2005 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2006 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2007 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2008 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2009 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2010 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2011 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2012 | val = phba->cfg_##attr;\ |
| 2013 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 2014 | phba->cfg_##attr);\ |
| 2015 | } |
| 2016 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2017 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 2018 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2019 | * |
| 2020 | * Description: |
| 2021 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2022 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2023 | * takes a default argument, a minimum and maximum argument. |
| 2024 | * |
| 2025 | * lpfc_##attr##_init: Initializes an attribute. |
| 2026 | * @phba: pointer the the adapter structure. |
| 2027 | * @val: integer attribute value. |
| 2028 | * |
| 2029 | * Validates the min and max values then sets the adapter config field |
| 2030 | * accordingly, or uses the default if out of range and prints an error message. |
| 2031 | * |
| 2032 | * Returns: |
| 2033 | * zero on success |
| 2034 | * -EINVAL if default used |
| 2035 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2036 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 2037 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2038 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2039 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2040 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2041 | phba->cfg_##attr = val;\ |
| 2042 | return 0;\ |
| 2043 | }\ |
| 2044 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2045 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2046 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2047 | phba->cfg_##attr = default;\ |
| 2048 | return -EINVAL;\ |
| 2049 | } |
| 2050 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2051 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2052 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2053 | * |
| 2054 | * Description: |
| 2055 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2056 | * into a function with the name lpfc_hba_queue_depth_set |
| 2057 | * |
| 2058 | * lpfc_##attr##_set: Sets an attribute value. |
| 2059 | * @phba: pointer the the adapter structure. |
| 2060 | * @val: integer attribute value. |
| 2061 | * |
| 2062 | * Description: |
| 2063 | * Validates the min and max values then sets the |
| 2064 | * adapter config field if in the valid range. prints error message |
| 2065 | * and does not set the parameter if invalid. |
| 2066 | * |
| 2067 | * Returns: |
| 2068 | * zero on success |
| 2069 | * -EINVAL if val is invalid |
| 2070 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2071 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2072 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2073 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2074 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2075 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2076 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2077 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2078 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2079 | phba->cfg_##attr = val;\ |
| 2080 | return 0;\ |
| 2081 | }\ |
| 2082 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2083 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2084 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2085 | return -EINVAL;\ |
| 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_param_store - Set a vport 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_store. |
| 2094 | * |
| 2095 | * lpfc_##attr##_store: Set an sttribute value. |
| 2096 | * @dev: class device that is converted into a Scsi_host. |
| 2097 | * @attr: device attribute, not used. |
| 2098 | * @buf: contains the attribute value in ascii. |
| 2099 | * @count: not used. |
| 2100 | * |
| 2101 | * Description: |
| 2102 | * Convert the ascii text number to an integer, then |
| 2103 | * use the lpfc_##attr##_set function to set the value. |
| 2104 | * |
| 2105 | * Returns: |
| 2106 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2107 | * length of buffer upon success. |
| 2108 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2109 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2110 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2111 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2112 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2113 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2114 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2115 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2116 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2117 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2118 | if (!isdigit(buf[0]))\ |
| 2119 | return -EINVAL;\ |
| 2120 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2121 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2122 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2123 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2124 | else \ |
| 2125 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2126 | } |
| 2127 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2128 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2129 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2130 | * |
| 2131 | * Description: |
| 2132 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2133 | * into a function with the name lpfc_hba_queue_depth_show |
| 2134 | * |
| 2135 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2136 | * @dev: class device that is converted into a Scsi_host. |
| 2137 | * @attr: device attribute, not used. |
| 2138 | * @buf: on return contains the attribute value in decimal. |
| 2139 | * |
| 2140 | * Returns: length of formatted string. |
| 2141 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2142 | #define lpfc_vport_param_show(attr) \ |
| 2143 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2144 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2145 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2146 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2147 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2148 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2149 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 2150 | } |
| 2151 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2152 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2153 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2154 | * |
| 2155 | * Description: |
| 2156 | * Macro that given an attr e.g. |
| 2157 | * hba_queue_depth expands into a function with the name |
| 2158 | * lpfc_hba_queue_depth_show |
| 2159 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2160 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2161 | * @dev: class device that is converted into a Scsi_host. |
| 2162 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2163 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2164 | * |
| 2165 | * Returns: length of formatted string. |
| 2166 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2167 | #define lpfc_vport_param_hex_show(attr) \ |
| 2168 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2169 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2170 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2171 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2172 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2173 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2174 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 2175 | } |
| 2176 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2177 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2178 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2179 | * |
| 2180 | * Description: |
| 2181 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2182 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2183 | * takes a default argument, a minimum and maximum argument. |
| 2184 | * |
| 2185 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2186 | * adapter config field accordingly, or uses the default if out of range |
| 2187 | * and prints an error message. |
| 2188 | * @phba: pointer the the adapter structure. |
| 2189 | * @val: integer attribute value. |
| 2190 | * |
| 2191 | * Returns: |
| 2192 | * zero on success |
| 2193 | * -EINVAL if default used |
| 2194 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2195 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2196 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2197 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2198 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2199 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2200 | vport->cfg_##attr = val;\ |
| 2201 | return 0;\ |
| 2202 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2203 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2204 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2205 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2206 | vport->cfg_##attr = default;\ |
| 2207 | return -EINVAL;\ |
| 2208 | } |
| 2209 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2210 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2211 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2212 | * |
| 2213 | * Description: |
| 2214 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2215 | * into a function with the name lpfc_hba_queue_depth_set |
| 2216 | * |
| 2217 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2218 | * adapter config field if in the valid range. prints error message |
| 2219 | * and does not set the parameter if invalid. |
| 2220 | * @phba: pointer the the adapter structure. |
| 2221 | * @val: integer attribute value. |
| 2222 | * |
| 2223 | * Returns: |
| 2224 | * zero on success |
| 2225 | * -EINVAL if val is invalid |
| 2226 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2227 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2228 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2229 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2230 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2231 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2232 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2233 | "3053 lpfc_" #attr \ |
| 2234 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2235 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2236 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2237 | vport->cfg_##attr = val;\ |
| 2238 | return 0;\ |
| 2239 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2240 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2241 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2242 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2243 | return -EINVAL;\ |
| 2244 | } |
| 2245 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2246 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2247 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2248 | * |
| 2249 | * Description: |
| 2250 | * Macro that given an attr e.g. hba_queue_depth |
| 2251 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2252 | * |
| 2253 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2254 | * use the lpfc_##attr##_set function to set the value. |
| 2255 | * @cdev: class device that is converted into a Scsi_host. |
| 2256 | * @buf: contains the attribute value in decimal. |
| 2257 | * @count: not used. |
| 2258 | * |
| 2259 | * Returns: |
| 2260 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2261 | * length of buffer upon success. |
| 2262 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2263 | #define lpfc_vport_param_store(attr) \ |
| 2264 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2265 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2266 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2267 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2268 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2269 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2270 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2271 | if (!isdigit(buf[0]))\ |
| 2272 | return -EINVAL;\ |
| 2273 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2274 | return -EINVAL;\ |
| 2275 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2276 | return strlen(buf);\ |
| 2277 | else \ |
| 2278 | return -EINVAL;\ |
| 2279 | } |
| 2280 | |
| 2281 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2282 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2283 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2284 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2285 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2286 | 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] | 2287 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2288 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2289 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2290 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2291 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2292 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2293 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2294 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2295 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2296 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2297 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2298 | lpfc_option_rom_version_show, NULL); |
| 2299 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2300 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2301 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2302 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2303 | static DEVICE_ATTR_RO(lpfc_drvr_version); |
| 2304 | static DEVICE_ATTR_RO(lpfc_enable_fip); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2305 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2306 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2307 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2308 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2309 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2310 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2311 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2312 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2313 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2314 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2315 | static DEVICE_ATTR_RO(lpfc_temp_sensor); |
| 2316 | static DEVICE_ATTR_RO(lpfc_fips_level); |
| 2317 | static DEVICE_ATTR_RO(lpfc_fips_rev); |
| 2318 | static DEVICE_ATTR_RO(lpfc_dss); |
| 2319 | static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2320 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2321 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2322 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2323 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2324 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2325 | #define WWN_SZ 8 |
| 2326 | /** |
| 2327 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2328 | * @buf: WWN string. |
| 2329 | * @cnt: Length of string. |
| 2330 | * @wwn: Array to receive converted wwn value. |
| 2331 | * |
| 2332 | * Returns: |
| 2333 | * -EINVAL if the buffer does not contain a valid wwn |
| 2334 | * 0 success |
| 2335 | **/ |
| 2336 | static size_t |
| 2337 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2338 | { |
| 2339 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2340 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2341 | /* Count may include a LF at end of string */ |
| 2342 | if (buf[cnt-1] == '\n') |
| 2343 | cnt--; |
| 2344 | |
| 2345 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2346 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2347 | return -EINVAL; |
| 2348 | |
| 2349 | memset(wwn, 0, WWN_SZ); |
| 2350 | |
| 2351 | /* Validate and store the new name */ |
| 2352 | for (i = 0, j = 0; i < 16; i++) { |
| 2353 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2354 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2355 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2356 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2357 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2358 | j = ((j << 4) | (*buf++ - '0')); |
| 2359 | else |
| 2360 | return -EINVAL; |
| 2361 | if (i % 2) { |
| 2362 | wwn[i/2] = j & 0xff; |
| 2363 | j = 0; |
| 2364 | } |
| 2365 | } |
| 2366 | return 0; |
| 2367 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2368 | /** |
| 2369 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2370 | * @dev: class device that is converted into a Scsi_host. |
| 2371 | * @attr: device attribute, not used. |
| 2372 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2373 | * @count: must be size of lpfc_soft_wwn_key. |
| 2374 | * |
| 2375 | * Returns: |
| 2376 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2377 | * length of buf indicates success |
| 2378 | **/ |
| 2379 | static ssize_t |
| 2380 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2381 | const char *buf, size_t count) |
| 2382 | { |
| 2383 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2384 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2385 | struct lpfc_hba *phba = vport->phba; |
| 2386 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2387 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2388 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2389 | |
| 2390 | /* |
| 2391 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2392 | * We require that the user write a specific key to enable |
| 2393 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2394 | * is written, the enable key resets. If further updates are |
| 2395 | * desired, the key must be written again to re-enable the |
| 2396 | * attribute. |
| 2397 | * |
| 2398 | * The "key" is not secret - it is a hardcoded string shown |
| 2399 | * here. The intent is to protect against the random user or |
| 2400 | * application that is just writing attributes. |
| 2401 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2402 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2403 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2404 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2405 | " be enabled: fawwpn is enabled\n"); |
| 2406 | return -EINVAL; |
| 2407 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2408 | |
| 2409 | /* count may include a LF at end of string */ |
| 2410 | if (buf[cnt-1] == '\n') |
| 2411 | cnt--; |
| 2412 | |
| 2413 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2414 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2415 | return -EINVAL; |
| 2416 | |
| 2417 | phba->soft_wwn_enable = 1; |
| 2418 | |
| 2419 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2420 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2421 | phba->brd_no); |
| 2422 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2423 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2424 | |
| 2425 | return count; |
| 2426 | } |
Joe Perches | 6cbaefb | 2017-12-19 10:15:09 -0800 | [diff] [blame] | 2427 | static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2428 | |
| 2429 | /** |
| 2430 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2431 | * @dev: class device that is converted into a Scsi_host. |
| 2432 | * @attr: device attribute, not used. |
| 2433 | * @buf: on return contains the wwpn in hexadecimal. |
| 2434 | * |
| 2435 | * Returns: size of formatted string. |
| 2436 | **/ |
| 2437 | static ssize_t |
| 2438 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2439 | char *buf) |
| 2440 | { |
| 2441 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2442 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2443 | struct lpfc_hba *phba = vport->phba; |
| 2444 | |
| 2445 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2446 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2447 | } |
| 2448 | |
| 2449 | /** |
| 2450 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2451 | * @dev class device that is converted into a Scsi_host. |
| 2452 | * @attr: device attribute, not used. |
| 2453 | * @buf: contains the wwpn in hexadecimal. |
| 2454 | * @count: number of wwpn bytes in buf |
| 2455 | * |
| 2456 | * Returns: |
| 2457 | * -EACCES hba reset not enabled, adapter over temp |
| 2458 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2459 | * -EIO error taking adapter offline or online |
| 2460 | * value of count on success |
| 2461 | **/ |
| 2462 | static ssize_t |
| 2463 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2464 | const char *buf, size_t count) |
| 2465 | { |
| 2466 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2467 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2468 | struct lpfc_hba *phba = vport->phba; |
| 2469 | struct completion online_compl; |
| 2470 | int stat1 = 0, stat2 = 0; |
| 2471 | unsigned int cnt = count; |
| 2472 | u8 wwpn[WWN_SZ]; |
| 2473 | int rc; |
| 2474 | |
| 2475 | if (!phba->cfg_enable_hba_reset) |
| 2476 | return -EACCES; |
| 2477 | spin_lock_irq(&phba->hbalock); |
| 2478 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2479 | spin_unlock_irq(&phba->hbalock); |
| 2480 | return -EACCES; |
| 2481 | } |
| 2482 | spin_unlock_irq(&phba->hbalock); |
| 2483 | /* count may include a LF at end of string */ |
| 2484 | if (buf[cnt-1] == '\n') |
| 2485 | cnt--; |
| 2486 | |
| 2487 | if (!phba->soft_wwn_enable) |
| 2488 | return -EINVAL; |
| 2489 | |
| 2490 | /* lock setting wwpn, wwnn down */ |
| 2491 | phba->soft_wwn_enable = 0; |
| 2492 | |
| 2493 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2494 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2495 | /* not able to set wwpn, unlock it */ |
| 2496 | phba->soft_wwn_enable = 1; |
| 2497 | return rc; |
| 2498 | } |
| 2499 | |
| 2500 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2501 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2502 | if (phba->cfg_soft_wwnn) |
| 2503 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2504 | |
| 2505 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2506 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2507 | |
| 2508 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2509 | if (stat1) |
| 2510 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2511 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2512 | "reinit adapter - %d\n", stat1); |
| 2513 | init_completion(&online_compl); |
| 2514 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2515 | LPFC_EVT_ONLINE); |
| 2516 | if (rc == 0) |
| 2517 | return -ENOMEM; |
| 2518 | |
| 2519 | wait_for_completion(&online_compl); |
| 2520 | if (stat2) |
| 2521 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2522 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2523 | "reinit adapter - %d\n", stat2); |
| 2524 | return (stat1 || stat2) ? -EIO : count; |
| 2525 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2526 | static DEVICE_ATTR_RW(lpfc_soft_wwpn); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2527 | |
| 2528 | /** |
| 2529 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2530 | * @dev: class device that is converted into a Scsi_host. |
| 2531 | * @attr: device attribute, not used. |
| 2532 | * @buf: on return contains the wwnn in hexadecimal. |
| 2533 | * |
| 2534 | * Returns: size of formatted string. |
| 2535 | **/ |
| 2536 | static ssize_t |
| 2537 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2538 | char *buf) |
| 2539 | { |
| 2540 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2541 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2542 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2543 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2544 | } |
| 2545 | |
| 2546 | /** |
| 2547 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2548 | * @cdev: class device that is converted into a Scsi_host. |
| 2549 | * @buf: contains the ww node name in hexadecimal. |
| 2550 | * @count: number of wwnn bytes in buf. |
| 2551 | * |
| 2552 | * Returns: |
| 2553 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2554 | * value of count on success |
| 2555 | **/ |
| 2556 | static ssize_t |
| 2557 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2558 | const char *buf, size_t count) |
| 2559 | { |
| 2560 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2561 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2562 | unsigned int cnt = count; |
| 2563 | u8 wwnn[WWN_SZ]; |
| 2564 | int rc; |
| 2565 | |
| 2566 | /* count may include a LF at end of string */ |
| 2567 | if (buf[cnt-1] == '\n') |
| 2568 | cnt--; |
| 2569 | |
| 2570 | if (!phba->soft_wwn_enable) |
| 2571 | return -EINVAL; |
| 2572 | |
| 2573 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2574 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2575 | /* Allow wwnn to be set many times, as long as the enable |
| 2576 | * is set. However, once the wwpn is set, everything locks. |
| 2577 | */ |
| 2578 | return rc; |
| 2579 | } |
| 2580 | |
| 2581 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2582 | |
| 2583 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2584 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2585 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2586 | |
| 2587 | return count; |
| 2588 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2589 | static DEVICE_ATTR_RW(lpfc_soft_wwnn); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2590 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2591 | /** |
| 2592 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2593 | * Optimized Access Storage (OAS) operations. |
| 2594 | * @dev: class device that is converted into a Scsi_host. |
| 2595 | * @attr: device attribute, not used. |
| 2596 | * @buf: buffer for passing information. |
| 2597 | * |
| 2598 | * Returns: |
| 2599 | * value of count |
| 2600 | **/ |
| 2601 | static ssize_t |
| 2602 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2603 | char *buf) |
| 2604 | { |
| 2605 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2606 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2607 | |
| 2608 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2609 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2610 | } |
| 2611 | |
| 2612 | /** |
| 2613 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2614 | * Optimized Access Storage (OAS) operations. |
| 2615 | * @dev: class device that is converted into a Scsi_host. |
| 2616 | * @attr: device attribute, not used. |
| 2617 | * @buf: buffer for passing information. |
| 2618 | * @count: Size of the data buffer. |
| 2619 | * |
| 2620 | * Returns: |
| 2621 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2622 | * -EPERM oas is not supported by hba |
| 2623 | * value of count on success |
| 2624 | **/ |
| 2625 | static ssize_t |
| 2626 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2627 | const char *buf, size_t count) |
| 2628 | { |
| 2629 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2630 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2631 | unsigned int cnt = count; |
| 2632 | uint8_t wwpn[WWN_SZ]; |
| 2633 | int rc; |
| 2634 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2635 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2636 | return -EPERM; |
| 2637 | |
| 2638 | /* count may include a LF at end of string */ |
| 2639 | if (buf[cnt-1] == '\n') |
| 2640 | cnt--; |
| 2641 | |
| 2642 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2643 | if (rc) |
| 2644 | return rc; |
| 2645 | |
| 2646 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2647 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2648 | if (wwn_to_u64(wwpn) == 0) |
| 2649 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2650 | else |
| 2651 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2652 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2653 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2654 | return count; |
| 2655 | } |
| 2656 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2657 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2658 | |
| 2659 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2660 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2661 | * Optimized Access Storage (OAS) operations. |
| 2662 | * @dev: class device that is converted into a Scsi_host. |
| 2663 | * @attr: device attribute, not used. |
| 2664 | * @buf: buffer for passing information. |
| 2665 | * |
| 2666 | * Returns: |
| 2667 | * value of count |
| 2668 | **/ |
| 2669 | static ssize_t |
| 2670 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2671 | char *buf) |
| 2672 | { |
| 2673 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2674 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2675 | |
| 2676 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2677 | } |
| 2678 | |
| 2679 | /** |
| 2680 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2681 | * Optimized Access Storage (OAS) operations. |
| 2682 | * @dev: class device that is converted into a Scsi_host. |
| 2683 | * @attr: device attribute, not used. |
| 2684 | * @buf: buffer for passing information. |
| 2685 | * @count: Size of the data buffer. |
| 2686 | * |
| 2687 | * Returns: |
| 2688 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2689 | * -EPERM oas is not supported by hba |
| 2690 | * value of count on success |
| 2691 | **/ |
| 2692 | static ssize_t |
| 2693 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2694 | const char *buf, size_t count) |
| 2695 | { |
| 2696 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2697 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2698 | unsigned int cnt = count; |
| 2699 | unsigned long val; |
| 2700 | int ret; |
| 2701 | |
| 2702 | if (!phba->cfg_fof) |
| 2703 | return -EPERM; |
| 2704 | |
| 2705 | /* count may include a LF at end of string */ |
| 2706 | if (buf[cnt-1] == '\n') |
| 2707 | cnt--; |
| 2708 | |
| 2709 | ret = kstrtoul(buf, 0, &val); |
| 2710 | if (ret || (val > 0x7f)) |
| 2711 | return -EINVAL; |
| 2712 | |
| 2713 | if (val) |
| 2714 | phba->cfg_oas_priority = (uint8_t)val; |
| 2715 | else |
| 2716 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2717 | return count; |
| 2718 | } |
| 2719 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2720 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2721 | |
| 2722 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2723 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2724 | * for Optimized Access Storage (OAS) operations. |
| 2725 | * @dev: class device that is converted into a Scsi_host. |
| 2726 | * @attr: device attribute, not used. |
| 2727 | * @buf: buffer for passing information. |
| 2728 | * |
| 2729 | * Returns: |
| 2730 | * value of count on success |
| 2731 | **/ |
| 2732 | static ssize_t |
| 2733 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2734 | char *buf) |
| 2735 | { |
| 2736 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2737 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2738 | |
| 2739 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2740 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2741 | } |
| 2742 | |
| 2743 | /** |
| 2744 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2745 | * for Optimized Access Storage (OAS) operations. |
| 2746 | * @dev: class device that is converted into a Scsi_host. |
| 2747 | * @attr: device attribute, not used. |
| 2748 | * @buf: buffer for passing information. |
| 2749 | * @count: Size of the data buffer. |
| 2750 | * |
| 2751 | * Returns: |
| 2752 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2753 | * -EPERM oas is not supported by hba |
| 2754 | * value of count on success |
| 2755 | **/ |
| 2756 | static ssize_t |
| 2757 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2758 | const char *buf, size_t count) |
| 2759 | { |
| 2760 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2761 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2762 | unsigned int cnt = count; |
| 2763 | uint8_t wwpn[WWN_SZ]; |
| 2764 | int rc; |
| 2765 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2766 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2767 | return -EPERM; |
| 2768 | |
| 2769 | /* count may include a LF at end of string */ |
| 2770 | if (buf[cnt-1] == '\n') |
| 2771 | cnt--; |
| 2772 | |
| 2773 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2774 | if (rc) |
| 2775 | return rc; |
| 2776 | |
| 2777 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2778 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2779 | if (wwn_to_u64(wwpn) == 0) |
| 2780 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2781 | else |
| 2782 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2783 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2784 | if (phba->cfg_oas_priority == 0) |
| 2785 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2786 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2787 | return count; |
| 2788 | } |
| 2789 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2790 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2791 | |
| 2792 | /** |
| 2793 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2794 | * of whether luns will be enabled or disabled |
| 2795 | * for Optimized Access Storage (OAS) operations. |
| 2796 | * @dev: class device that is converted into a Scsi_host. |
| 2797 | * @attr: device attribute, not used. |
| 2798 | * @buf: buffer for passing information. |
| 2799 | * |
| 2800 | * Returns: |
| 2801 | * size of formatted string. |
| 2802 | **/ |
| 2803 | static ssize_t |
| 2804 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2805 | char *buf) |
| 2806 | { |
| 2807 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2808 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2809 | |
| 2810 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2811 | } |
| 2812 | |
| 2813 | /** |
| 2814 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2815 | * of whether luns will be enabled or disabled |
| 2816 | * for Optimized Access Storage (OAS) operations. |
| 2817 | * @dev: class device that is converted into a Scsi_host. |
| 2818 | * @attr: device attribute, not used. |
| 2819 | * @buf: buffer for passing information. |
| 2820 | * @count: Size of the data buffer. |
| 2821 | * |
| 2822 | * Returns: |
| 2823 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2824 | * -EPERM oas is not supported by hba |
| 2825 | * value of count on success |
| 2826 | **/ |
| 2827 | static ssize_t |
| 2828 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2829 | const char *buf, size_t count) |
| 2830 | { |
| 2831 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2832 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2833 | int val = 0; |
| 2834 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2835 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2836 | return -EPERM; |
| 2837 | |
| 2838 | if (!isdigit(buf[0])) |
| 2839 | return -EINVAL; |
| 2840 | |
| 2841 | if (sscanf(buf, "%i", &val) != 1) |
| 2842 | return -EINVAL; |
| 2843 | |
| 2844 | if ((val != 0) && (val != 1)) |
| 2845 | return -EINVAL; |
| 2846 | |
| 2847 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2848 | return strlen(buf); |
| 2849 | } |
| 2850 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2851 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2852 | |
| 2853 | /** |
| 2854 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2855 | * Storage (OAS) lun returned by the |
| 2856 | * lpfc_oas_lun_show function. |
| 2857 | * @dev: class device that is converted into a Scsi_host. |
| 2858 | * @attr: device attribute, not used. |
| 2859 | * @buf: buffer for passing information. |
| 2860 | * |
| 2861 | * Returns: |
| 2862 | * size of formatted string. |
| 2863 | **/ |
| 2864 | static ssize_t |
| 2865 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2866 | char *buf) |
| 2867 | { |
| 2868 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2869 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2870 | |
| 2871 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2872 | return -EFAULT; |
| 2873 | |
| 2874 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2875 | } |
| 2876 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2877 | lpfc_oas_lun_status_show, NULL); |
| 2878 | |
| 2879 | |
| 2880 | /** |
| 2881 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2882 | * (OAS) operations. |
| 2883 | * @phba: lpfc_hba pointer. |
| 2884 | * @ndlp: pointer to fcp target node. |
| 2885 | * @lun: the fc lun for setting oas state. |
| 2886 | * @oas_state: the oas state to be set to the lun. |
| 2887 | * |
| 2888 | * Returns: |
| 2889 | * SUCCESS : 0 |
| 2890 | * -EPERM OAS is not enabled or not supported by this port. |
| 2891 | * |
| 2892 | */ |
| 2893 | static size_t |
| 2894 | 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] | 2895 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2896 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2897 | { |
| 2898 | |
| 2899 | int rc = 0; |
| 2900 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2901 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2902 | return -EPERM; |
| 2903 | |
| 2904 | if (oas_state) { |
| 2905 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2906 | (struct lpfc_name *)tgt_wwpn, |
| 2907 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2908 | rc = -ENOMEM; |
| 2909 | } else { |
| 2910 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2911 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2912 | } |
| 2913 | return rc; |
| 2914 | |
| 2915 | } |
| 2916 | |
| 2917 | /** |
| 2918 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2919 | * Access Storage (OAS) operations. |
| 2920 | * @phba: lpfc_hba pointer. |
| 2921 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2922 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2923 | * @lun_status: status of the lun returned lun |
| 2924 | * |
| 2925 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2926 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2927 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2928 | * |
| 2929 | * Return: |
| 2930 | * lun that is OAS enabled for the vport/target |
| 2931 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2932 | */ |
| 2933 | static uint64_t |
| 2934 | 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] | 2935 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 2936 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2937 | { |
| 2938 | uint64_t found_lun; |
| 2939 | |
| 2940 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2941 | return NOT_OAS_ENABLED_LUN; |
| 2942 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2943 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2944 | (struct lpfc_name *) |
| 2945 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2946 | &phba->sli4_hba.oas_next_lun, |
| 2947 | (struct lpfc_name *)vpt_wwpn, |
| 2948 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2949 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2950 | return found_lun; |
| 2951 | else |
| 2952 | return NOT_OAS_ENABLED_LUN; |
| 2953 | } |
| 2954 | |
| 2955 | /** |
| 2956 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2957 | * @phba: lpfc_hba pointer. |
| 2958 | * @vpt_wwpn: vport wwpn by reference. |
| 2959 | * @tgt_wwpn: target wwpn by reference. |
| 2960 | * @lun: the fc lun for setting oas state. |
| 2961 | * @oas_state: the oas state to be set to the oas_lun. |
| 2962 | * |
| 2963 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2964 | * a lun for OAS operations. |
| 2965 | * |
| 2966 | * Return: |
| 2967 | * SUCCESS: 0 |
| 2968 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2969 | * -EPERM: OAS is not enabled |
| 2970 | */ |
| 2971 | static ssize_t |
| 2972 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2973 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2974 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2975 | { |
| 2976 | |
| 2977 | int rc; |
| 2978 | |
| 2979 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2980 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2981 | return rc; |
| 2982 | } |
| 2983 | |
| 2984 | /** |
| 2985 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2986 | * @dev: class device that is converted into a Scsi_host. |
| 2987 | * @attr: device attribute, not used. |
| 2988 | * @buf: buffer for passing information. |
| 2989 | * |
| 2990 | * This routine returns a lun enabled for OAS each time the function |
| 2991 | * is called. |
| 2992 | * |
| 2993 | * Returns: |
| 2994 | * SUCCESS: size of formatted string. |
| 2995 | * -EFAULT: target or vport wwpn was not set properly. |
| 2996 | * -EPERM: oas is not enabled. |
| 2997 | **/ |
| 2998 | static ssize_t |
| 2999 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 3000 | char *buf) |
| 3001 | { |
| 3002 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3003 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3004 | |
| 3005 | uint64_t oas_lun; |
| 3006 | int len = 0; |
| 3007 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3008 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3009 | return -EPERM; |
| 3010 | |
| 3011 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3012 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 3013 | return -EFAULT; |
| 3014 | |
| 3015 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3016 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 3017 | return -EFAULT; |
| 3018 | |
| 3019 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 3020 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3021 | &phba->cfg_oas_lun_status, |
| 3022 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3023 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 3024 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 3025 | |
| 3026 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 3027 | |
| 3028 | return len; |
| 3029 | } |
| 3030 | |
| 3031 | /** |
| 3032 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 3033 | * @dev: class device that is converted into a Scsi_host. |
| 3034 | * @attr: device attribute, not used. |
| 3035 | * @buf: buffer for passing information. |
| 3036 | * |
| 3037 | * This function sets the OAS state for lun. Before this function is called, |
| 3038 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3039 | * |
| 3040 | * Returns: |
| 3041 | * SUCCESS: size of formatted string. |
| 3042 | * -EFAULT: target or vport wwpn was not set properly. |
| 3043 | * -EPERM: oas is not enabled. |
| 3044 | * size of formatted string. |
| 3045 | **/ |
| 3046 | static ssize_t |
| 3047 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3048 | const char *buf, size_t count) |
| 3049 | { |
| 3050 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3051 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3052 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3053 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3054 | ssize_t rc; |
| 3055 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3056 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3057 | return -EPERM; |
| 3058 | |
| 3059 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3060 | return -EFAULT; |
| 3061 | |
| 3062 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3063 | return -EFAULT; |
| 3064 | |
| 3065 | if (!isdigit(buf[0])) |
| 3066 | return -EINVAL; |
| 3067 | |
| 3068 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3069 | return -EINVAL; |
| 3070 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3071 | pri = phba->cfg_oas_priority; |
| 3072 | if (pri == 0) |
| 3073 | pri = phba->cfg_XLanePriority; |
| 3074 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3075 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3076 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3077 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3078 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3079 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3080 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3081 | |
| 3082 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3083 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3084 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3085 | if (rc) |
| 3086 | return rc; |
| 3087 | |
| 3088 | return count; |
| 3089 | } |
| 3090 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3091 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3092 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3093 | int lpfc_enable_nvmet_cnt; |
| 3094 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3095 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3096 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3097 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3098 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3099 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3100 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3101 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3102 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3103 | " 0 - none," |
| 3104 | " 1 - poll with interrupts enabled" |
| 3105 | " 3 - poll and disable FCP ring interrupts"); |
| 3106 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3107 | static DEVICE_ATTR_RW(lpfc_poll); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3108 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3109 | int lpfc_no_hba_reset_cnt; |
| 3110 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3111 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3112 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3113 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3114 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3115 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3116 | "SLI mode selector:" |
| 3117 | " 0 - auto (SLI-3 if supported)," |
| 3118 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3119 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3120 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3121 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3122 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3123 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3124 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3125 | "FCF Fast failover=1 Priority failover=2"); |
| 3126 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3127 | /* |
| 3128 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3129 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3130 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3131 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3132 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3133 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3134 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3135 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3136 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3137 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3138 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3139 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3140 | # 0x2 = never bring up link |
| 3141 | # Default value is 0. |
| 3142 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3143 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3144 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3145 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3146 | /* |
| 3147 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3148 | # 1 - (1024) |
| 3149 | # 2 - (2048) |
| 3150 | # 3 - (3072) |
| 3151 | # 4 - (4096) |
| 3152 | # 5 - (5120) |
| 3153 | */ |
| 3154 | static ssize_t |
| 3155 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3156 | { |
| 3157 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3158 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3159 | |
| 3160 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 3161 | } |
| 3162 | |
| 3163 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3164 | lpfc_iocb_hw_show, NULL); |
| 3165 | static ssize_t |
| 3166 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3167 | { |
| 3168 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3169 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3170 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3171 | |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3172 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 3173 | pring ? pring->txq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3174 | } |
| 3175 | |
| 3176 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3177 | lpfc_txq_hw_show, NULL); |
| 3178 | static ssize_t |
| 3179 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3180 | char *buf) |
| 3181 | { |
| 3182 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3183 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3184 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3185 | |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3186 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 3187 | pring ? pring->txcmplq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3188 | } |
| 3189 | |
| 3190 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3191 | lpfc_txcmplq_hw_show, NULL); |
| 3192 | |
James Smart | 0d8c8ba | 2016-10-13 15:06:07 -0700 | [diff] [blame] | 3193 | LPFC_ATTR_R(iocb_cnt, 2, 1, 5, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3194 | "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] | 3195 | |
| 3196 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3197 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3198 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3199 | */ |
| 3200 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3201 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3202 | module_param(lpfc_nodev_tmo, int, 0); |
| 3203 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3204 | "Seconds driver will hold I/O waiting " |
| 3205 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3206 | |
| 3207 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3208 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3209 | * @dev: class converted to a Scsi_host structure. |
| 3210 | * @attr: device attribute, not used. |
| 3211 | * @buf: on return contains the dev loss timeout in decimal. |
| 3212 | * |
| 3213 | * Returns: size of formatted string. |
| 3214 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3215 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3216 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3217 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3218 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3219 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3220 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3221 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3222 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3223 | } |
| 3224 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3225 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3226 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3227 | * @vport: lpfc vport structure pointer. |
| 3228 | * @val: contains the nodev timeout value. |
| 3229 | * |
| 3230 | * Description: |
| 3231 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3232 | * a kernel error message is printed and zero is returned. |
| 3233 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3234 | * Otherwise nodev tmo is set to the default value. |
| 3235 | * |
| 3236 | * Returns: |
| 3237 | * zero if already set or if val is in range |
| 3238 | * -EINVAL val out of range |
| 3239 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3240 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3241 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3242 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3243 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3244 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3245 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3246 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3247 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3248 | "parameter because lpfc_devloss_tmo " |
| 3249 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3250 | return 0; |
| 3251 | } |
| 3252 | |
| 3253 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3254 | vport->cfg_nodev_tmo = val; |
| 3255 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3256 | return 0; |
| 3257 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3258 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3259 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3260 | " %d, allowed range is [%d, %d]\n", |
| 3261 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3262 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3263 | return -EINVAL; |
| 3264 | } |
| 3265 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3266 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3267 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3268 | * @vport: lpfc vport structure pointer. |
| 3269 | * |
| 3270 | * Description: |
| 3271 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3272 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3273 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3274 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3275 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3276 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3277 | struct lpfc_nodelist *ndlp; |
| 3278 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3279 | shost = lpfc_shost_from_vport(vport); |
| 3280 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3281 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3282 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3283 | continue; |
| 3284 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3285 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3286 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3287 | if (ndlp->nrport) |
| 3288 | nvme_fc_set_remoteport_devloss(ndlp->nrport->remoteport, |
| 3289 | vport->cfg_devloss_tmo); |
| 3290 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3291 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3292 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3293 | } |
| 3294 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3295 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3296 | * 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] | 3297 | * @vport: lpfc vport structure pointer. |
| 3298 | * @val: contains the tmo value. |
| 3299 | * |
| 3300 | * Description: |
| 3301 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3302 | * then a kernel error message is printed and zero is returned. |
| 3303 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3304 | * Otherwise nodev tmo is set to the default value. |
| 3305 | * |
| 3306 | * Returns: |
| 3307 | * zero if already set or if val is in range |
| 3308 | * -EINVAL val out of range |
| 3309 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3310 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3311 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3312 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3313 | if (vport->dev_loss_tmo_changed || |
| 3314 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3315 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3316 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3317 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3318 | return 0; |
| 3319 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3320 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3321 | vport->cfg_nodev_tmo = val; |
| 3322 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3323 | /* |
| 3324 | * For compat: set the fc_host dev loss so new rports |
| 3325 | * will get the value. |
| 3326 | */ |
| 3327 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3328 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3329 | return 0; |
| 3330 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3331 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3332 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3333 | "%d, allowed range is [%d, %d]\n", |
| 3334 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3335 | return -EINVAL; |
| 3336 | } |
| 3337 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3338 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3339 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3340 | static DEVICE_ATTR_RW(lpfc_nodev_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3341 | |
| 3342 | /* |
| 3343 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3344 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3345 | # value is 30. |
| 3346 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3347 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3348 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3349 | "Seconds driver will hold I/O waiting " |
| 3350 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3351 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3352 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3353 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3354 | |
| 3355 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3356 | * 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] | 3357 | * @vport: lpfc vport structure pointer. |
| 3358 | * @val: contains the tmo value. |
| 3359 | * |
| 3360 | * Description: |
| 3361 | * If val is in a valid range then set the vport nodev tmo, |
| 3362 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3363 | * Else a kernel error message is printed. |
| 3364 | * |
| 3365 | * Returns: |
| 3366 | * zero if val is in range |
| 3367 | * -EINVAL val out of range |
| 3368 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3369 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3370 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3371 | { |
| 3372 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3373 | vport->cfg_nodev_tmo = val; |
| 3374 | vport->cfg_devloss_tmo = val; |
| 3375 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3376 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3377 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3378 | return 0; |
| 3379 | } |
| 3380 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3381 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3382 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3383 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3384 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3385 | return -EINVAL; |
| 3386 | } |
| 3387 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3388 | lpfc_vport_param_store(devloss_tmo) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3389 | static DEVICE_ATTR_RW(lpfc_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3390 | |
| 3391 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3392 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3393 | * lpfc_suppress_rsp = 0 Disable |
| 3394 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3395 | * |
| 3396 | */ |
| 3397 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3398 | "Enable suppress rsp feature is firmware supports it"); |
| 3399 | |
| 3400 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3401 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3402 | * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3403 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3404 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3405 | * |
| 3406 | */ |
| 3407 | LPFC_ATTR_R(nvmet_mrq, |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3408 | LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3409 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3410 | |
| 3411 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3412 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3413 | * Supported Values: 1 - register just FCP |
| 3414 | * 3 - register both FCP and NVME |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3415 | * Supported values are [1,3]. Default value is 1 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3416 | */ |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3417 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3418 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3419 | "Enable FC4 Protocol support - FCP / NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3420 | |
| 3421 | /* |
| 3422 | * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME |
| 3423 | * This parameter is only used if: |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3424 | * lpfc_enable_fc4_type is 3 - register both FCP and NVME and |
| 3425 | * port is not configured for NVMET. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3426 | * |
| 3427 | * ELS/CT always get 10% of XRIs, up to a maximum of 250 |
| 3428 | * The remaining XRIs get split up based on lpfc_xri_split per port: |
| 3429 | * |
| 3430 | * Supported Values are in percentages |
| 3431 | * the xri_split value is the percentage the SCSI port will get. The remaining |
| 3432 | * percentage will go to NVME. |
| 3433 | */ |
| 3434 | LPFC_ATTR_R(xri_split, 50, 10, 90, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3435 | "Percentage of FCP XRI resources versus NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3436 | |
| 3437 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3438 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3439 | # deluged with LOTS of information. |
| 3440 | # 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] | 3441 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3442 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3443 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3444 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3445 | |
| 3446 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3447 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3448 | # objects that have been registered with the nameserver after login. |
| 3449 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3450 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3451 | "Deregister nameserver objects before LOGO"); |
| 3452 | |
| 3453 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3454 | # 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] | 3455 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3456 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3457 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3458 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3459 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3460 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3461 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3462 | |
| 3463 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3464 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3465 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3466 | */ |
| 3467 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3468 | "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] | 3469 | |
| 3470 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3471 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3472 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3473 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3474 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3475 | # the hba_queue_depth. |
| 3476 | */ |
| 3477 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3478 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3479 | |
| 3480 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3481 | # peer_port_login: This parameter allows/prevents logins |
| 3482 | # between peer ports hosted on the same physical port. |
| 3483 | # When this parameter is set 0 peer ports of same physical port |
| 3484 | # are not allowed to login to each other. |
| 3485 | # When this parameter is set 1 peer ports of same physical port |
| 3486 | # are allowed to login to each other. |
| 3487 | # Default value of this parameter is 0. |
| 3488 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3489 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3490 | "Allow peer ports on the same physical port to login to each " |
| 3491 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3492 | |
| 3493 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3494 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3495 | # between Virtual Ports and remote initiators. |
| 3496 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3497 | # other initiators and will attempt to PLOGI all remote ports. |
| 3498 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3499 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3500 | # This parameter does not restrict to the physical port. |
| 3501 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3502 | # Default value of this parameter is 1. |
| 3503 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3504 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3505 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3506 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3507 | "Restrict virtual ports login to remote initiators."); |
| 3508 | lpfc_vport_param_show(restrict_login); |
| 3509 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3510 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3511 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3512 | * @vport: lpfc vport structure pointer. |
| 3513 | * @val: contains the restrict login value. |
| 3514 | * |
| 3515 | * Description: |
| 3516 | * If val is not in a valid range then log a kernel error message and set |
| 3517 | * the vport restrict login to one. |
| 3518 | * If the port type is physical clear the restrict login flag and return. |
| 3519 | * Else set the restrict login flag to val. |
| 3520 | * |
| 3521 | * Returns: |
| 3522 | * zero if val is in range |
| 3523 | * -EINVAL val out of range |
| 3524 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3525 | static int |
| 3526 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3527 | { |
| 3528 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3529 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3530 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3531 | "be set to %d, allowed range is [0, 1]\n", |
| 3532 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3533 | vport->cfg_restrict_login = 1; |
| 3534 | return -EINVAL; |
| 3535 | } |
| 3536 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3537 | vport->cfg_restrict_login = 0; |
| 3538 | return 0; |
| 3539 | } |
| 3540 | vport->cfg_restrict_login = val; |
| 3541 | return 0; |
| 3542 | } |
| 3543 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3544 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3545 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3546 | * @vport: lpfc vport structure pointer. |
| 3547 | * @val: contains the restrict login value. |
| 3548 | * |
| 3549 | * Description: |
| 3550 | * If val is not in a valid range then log a kernel error message and set |
| 3551 | * the vport restrict login to one. |
| 3552 | * If the port type is physical and the val is not zero log a kernel |
| 3553 | * error message, clear the restrict login flag and return zero. |
| 3554 | * Else set the restrict login flag to val. |
| 3555 | * |
| 3556 | * Returns: |
| 3557 | * zero if val is in range |
| 3558 | * -EINVAL val out of range |
| 3559 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3560 | static int |
| 3561 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3562 | { |
| 3563 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3564 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3565 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3566 | "be set to %d, allowed range is [0, 1]\n", |
| 3567 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3568 | vport->cfg_restrict_login = 1; |
| 3569 | return -EINVAL; |
| 3570 | } |
| 3571 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3572 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3573 | "0468 lpfc_restrict_login must be 0 for " |
| 3574 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3575 | vport->cfg_restrict_login = 0; |
| 3576 | return 0; |
| 3577 | } |
| 3578 | vport->cfg_restrict_login = val; |
| 3579 | return 0; |
| 3580 | } |
| 3581 | lpfc_vport_param_store(restrict_login); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3582 | static DEVICE_ATTR_RW(lpfc_restrict_login); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3583 | |
| 3584 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3585 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3586 | # From a protocol standpoint "select ID" usually means select the |
| 3587 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3588 | # annex" which contains a table that maps a "select ID" (a number |
| 3589 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3590 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3591 | # ALPA. |
| 3592 | # |
| 3593 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3594 | # cause the lpfc driver to use an inverted table, effectively |
| 3595 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3596 | # |
| 3597 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3598 | # and will not work across a fabric. Also this parameter will take |
| 3599 | # effect only in the case when ALPA map is not available.) |
| 3600 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3601 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3602 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3603 | |
| 3604 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3605 | # lpfc_topology: link topology for init link |
| 3606 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3607 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3608 | # 0x02 = attempt point-to-point mode only |
| 3609 | # 0x04 = attempt loop mode only |
| 3610 | # 0x06 = attempt point-to-point mode then loop |
| 3611 | # Set point-to-point mode if you want to run as an N_Port. |
| 3612 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3613 | # Default value is 0. |
| 3614 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3615 | LPFC_ATTR(topology, 0, 0, 6, |
| 3616 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3617 | |
| 3618 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3619 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3620 | * @phba: lpfc_hba pointer. |
| 3621 | * @val: topology value. |
| 3622 | * |
| 3623 | * Description: |
| 3624 | * If val is in a valid range then set the adapter's topology field and |
| 3625 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3626 | * |
| 3627 | * If the value is not in range log a kernel error message and return an error. |
| 3628 | * |
| 3629 | * Returns: |
| 3630 | * zero if val is in range and lip okay |
| 3631 | * non-zero return value from lpfc_issue_lip() |
| 3632 | * -EINVAL val out of range |
| 3633 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3634 | static ssize_t |
| 3635 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3636 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3637 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3638 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3639 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3640 | struct lpfc_hba *phba = vport->phba; |
| 3641 | int val = 0; |
| 3642 | int nolip = 0; |
| 3643 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3644 | int err; |
| 3645 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3646 | |
| 3647 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3648 | nolip = 1; |
| 3649 | val_buf = &buf[strlen("nolip ")]; |
| 3650 | } |
| 3651 | |
| 3652 | if (!isdigit(val_buf[0])) |
| 3653 | return -EINVAL; |
| 3654 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3655 | return -EINVAL; |
| 3656 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3657 | if (val >= 0 && val <= 6) { |
| 3658 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3659 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3660 | val == 4) { |
| 3661 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3662 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3663 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3664 | return -EINVAL; |
| 3665 | } |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3666 | if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && |
| 3667 | val == 4) { |
| 3668 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3669 | "3114 Loop mode not supported\n"); |
| 3670 | return -EINVAL; |
| 3671 | } |
| 3672 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3673 | if (nolip) |
| 3674 | return strlen(buf); |
| 3675 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3676 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3677 | "3054 lpfc_topology changed from %d to %d\n", |
| 3678 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3679 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3680 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3681 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3682 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3683 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3684 | return -EINVAL; |
| 3685 | } else |
| 3686 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3687 | } |
| 3688 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3689 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3690 | "allowed range is [0, 6]\n", |
| 3691 | phba->brd_no, val); |
| 3692 | return -EINVAL; |
| 3693 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3694 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3695 | lpfc_param_show(topology) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3696 | static DEVICE_ATTR_RW(lpfc_topology); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3697 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3698 | /** |
| 3699 | * lpfc_static_vport_show: Read callback function for |
| 3700 | * lpfc_static_vport sysfs file. |
| 3701 | * @dev: Pointer to class device object. |
| 3702 | * @attr: device attribute structure. |
| 3703 | * @buf: Data buffer. |
| 3704 | * |
| 3705 | * This function is the read call back function for |
| 3706 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3707 | * sysfs file report the mageability of the vport. |
| 3708 | **/ |
| 3709 | static ssize_t |
| 3710 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3711 | char *buf) |
| 3712 | { |
| 3713 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3714 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3715 | if (vport->vport_flag & STATIC_VPORT) |
| 3716 | sprintf(buf, "1\n"); |
| 3717 | else |
| 3718 | sprintf(buf, "0\n"); |
| 3719 | |
| 3720 | return strlen(buf); |
| 3721 | } |
| 3722 | |
| 3723 | /* |
| 3724 | * Sysfs attribute to control the statistical data collection. |
| 3725 | */ |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 3726 | static DEVICE_ATTR_RO(lpfc_static_vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3727 | |
| 3728 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3729 | * 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] | 3730 | * @dev: Pointer to class device. |
| 3731 | * @buf: Data buffer. |
| 3732 | * @count: Size of the data buffer. |
| 3733 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 3734 | * 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] | 3735 | * sysfs file. This function parse the command written to the sysfs file |
| 3736 | * and take appropriate action. These commands are used for controlling |
| 3737 | * driver statistical data collection. |
| 3738 | * Following are the command this function handles. |
| 3739 | * |
| 3740 | * setbucket <bucket_type> <base> <step> |
| 3741 | * = Set the latency buckets. |
| 3742 | * destroybucket = destroy all the buckets. |
| 3743 | * start = start data collection |
| 3744 | * stop = stop data collection |
| 3745 | * reset = reset the collected data |
| 3746 | **/ |
| 3747 | static ssize_t |
| 3748 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3749 | const char *buf, size_t count) |
| 3750 | { |
| 3751 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3752 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3753 | struct lpfc_hba *phba = vport->phba; |
| 3754 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3755 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3756 | unsigned long i; |
| 3757 | char *str_ptr, *token; |
| 3758 | struct lpfc_vport **vports; |
| 3759 | struct Scsi_Host *v_shost; |
| 3760 | char *bucket_type_str, *base_str, *step_str; |
| 3761 | unsigned long base, step, bucket_type; |
| 3762 | |
| 3763 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3764 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3765 | return -EINVAL; |
| 3766 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 3767 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3768 | str_ptr = &bucket_data[0]; |
| 3769 | /* Ignore this token - this is command token */ |
| 3770 | token = strsep(&str_ptr, "\t "); |
| 3771 | if (!token) |
| 3772 | return -EINVAL; |
| 3773 | |
| 3774 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3775 | if (!bucket_type_str) |
| 3776 | return -EINVAL; |
| 3777 | |
| 3778 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3779 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3780 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3781 | bucket_type = LPFC_POWER2_BUCKET; |
| 3782 | else |
| 3783 | return -EINVAL; |
| 3784 | |
| 3785 | base_str = strsep(&str_ptr, "\t "); |
| 3786 | if (!base_str) |
| 3787 | return -EINVAL; |
| 3788 | base = simple_strtoul(base_str, NULL, 0); |
| 3789 | |
| 3790 | step_str = strsep(&str_ptr, "\t "); |
| 3791 | if (!step_str) |
| 3792 | return -EINVAL; |
| 3793 | step = simple_strtoul(step_str, NULL, 0); |
| 3794 | if (!step) |
| 3795 | return -EINVAL; |
| 3796 | |
| 3797 | /* Block the data collection for every vport */ |
| 3798 | vports = lpfc_create_vport_work_array(phba); |
| 3799 | if (vports == NULL) |
| 3800 | return -ENOMEM; |
| 3801 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3802 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3803 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3804 | spin_lock_irq(v_shost->host_lock); |
| 3805 | /* Block and reset data collection */ |
| 3806 | vports[i]->stat_data_blocked = 1; |
| 3807 | if (vports[i]->stat_data_enabled) |
| 3808 | lpfc_vport_reset_stat_data(vports[i]); |
| 3809 | spin_unlock_irq(v_shost->host_lock); |
| 3810 | } |
| 3811 | |
| 3812 | /* Set the bucket attributes */ |
| 3813 | phba->bucket_type = bucket_type; |
| 3814 | phba->bucket_base = base; |
| 3815 | phba->bucket_step = step; |
| 3816 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3817 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3818 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3819 | |
| 3820 | /* Unblock data collection */ |
| 3821 | spin_lock_irq(v_shost->host_lock); |
| 3822 | vports[i]->stat_data_blocked = 0; |
| 3823 | spin_unlock_irq(v_shost->host_lock); |
| 3824 | } |
| 3825 | lpfc_destroy_vport_work_array(phba, vports); |
| 3826 | return strlen(buf); |
| 3827 | } |
| 3828 | |
| 3829 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3830 | vports = lpfc_create_vport_work_array(phba); |
| 3831 | if (vports == NULL) |
| 3832 | return -ENOMEM; |
| 3833 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3834 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3835 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3836 | spin_lock_irq(shost->host_lock); |
| 3837 | vports[i]->stat_data_blocked = 1; |
| 3838 | lpfc_free_bucket(vport); |
| 3839 | vport->stat_data_enabled = 0; |
| 3840 | vports[i]->stat_data_blocked = 0; |
| 3841 | spin_unlock_irq(shost->host_lock); |
| 3842 | } |
| 3843 | lpfc_destroy_vport_work_array(phba, vports); |
| 3844 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3845 | phba->bucket_base = 0; |
| 3846 | phba->bucket_step = 0; |
| 3847 | return strlen(buf); |
| 3848 | } |
| 3849 | |
| 3850 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3851 | /* If no buckets configured return error */ |
| 3852 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3853 | return -EINVAL; |
| 3854 | spin_lock_irq(shost->host_lock); |
| 3855 | if (vport->stat_data_enabled) { |
| 3856 | spin_unlock_irq(shost->host_lock); |
| 3857 | return strlen(buf); |
| 3858 | } |
| 3859 | lpfc_alloc_bucket(vport); |
| 3860 | vport->stat_data_enabled = 1; |
| 3861 | spin_unlock_irq(shost->host_lock); |
| 3862 | return strlen(buf); |
| 3863 | } |
| 3864 | |
| 3865 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3866 | spin_lock_irq(shost->host_lock); |
| 3867 | if (vport->stat_data_enabled == 0) { |
| 3868 | spin_unlock_irq(shost->host_lock); |
| 3869 | return strlen(buf); |
| 3870 | } |
| 3871 | lpfc_free_bucket(vport); |
| 3872 | vport->stat_data_enabled = 0; |
| 3873 | spin_unlock_irq(shost->host_lock); |
| 3874 | return strlen(buf); |
| 3875 | } |
| 3876 | |
| 3877 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3878 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3879 | || !vport->stat_data_enabled) |
| 3880 | return strlen(buf); |
| 3881 | spin_lock_irq(shost->host_lock); |
| 3882 | vport->stat_data_blocked = 1; |
| 3883 | lpfc_vport_reset_stat_data(vport); |
| 3884 | vport->stat_data_blocked = 0; |
| 3885 | spin_unlock_irq(shost->host_lock); |
| 3886 | return strlen(buf); |
| 3887 | } |
| 3888 | return -EINVAL; |
| 3889 | } |
| 3890 | |
| 3891 | |
| 3892 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3893 | * 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] | 3894 | * @dev: Pointer to class device object. |
| 3895 | * @buf: Data buffer. |
| 3896 | * |
| 3897 | * This function is the read call back function for |
| 3898 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3899 | * current statistical data collection state. |
| 3900 | **/ |
| 3901 | static ssize_t |
| 3902 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3903 | char *buf) |
| 3904 | { |
| 3905 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3906 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3907 | struct lpfc_hba *phba = vport->phba; |
| 3908 | int index = 0; |
| 3909 | int i; |
| 3910 | char *bucket_type; |
| 3911 | unsigned long bucket_value; |
| 3912 | |
| 3913 | switch (phba->bucket_type) { |
| 3914 | case LPFC_LINEAR_BUCKET: |
| 3915 | bucket_type = "linear"; |
| 3916 | break; |
| 3917 | case LPFC_POWER2_BUCKET: |
| 3918 | bucket_type = "power2"; |
| 3919 | break; |
| 3920 | default: |
| 3921 | bucket_type = "No Bucket"; |
| 3922 | break; |
| 3923 | } |
| 3924 | |
| 3925 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3926 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3927 | " Bucket step :%d\nLatency Ranges :", |
| 3928 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3929 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3930 | index = strlen(buf); |
| 3931 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3932 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3933 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3934 | bucket_value = phba->bucket_base + |
| 3935 | phba->bucket_step * i; |
| 3936 | else |
| 3937 | bucket_value = phba->bucket_base + |
| 3938 | (1 << i) * phba->bucket_step; |
| 3939 | |
| 3940 | if (index + 10 > PAGE_SIZE) |
| 3941 | break; |
| 3942 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3943 | index = strlen(buf); |
| 3944 | } |
| 3945 | } |
| 3946 | sprintf(&buf[index], "\n"); |
| 3947 | return strlen(buf); |
| 3948 | } |
| 3949 | |
| 3950 | /* |
| 3951 | * Sysfs attribute to control the statistical data collection. |
| 3952 | */ |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3953 | static DEVICE_ATTR_RW(lpfc_stat_data_ctrl); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3954 | |
| 3955 | /* |
| 3956 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3957 | */ |
| 3958 | |
| 3959 | /* |
| 3960 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3961 | * for each target. |
| 3962 | */ |
| 3963 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3964 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3965 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3966 | |
| 3967 | |
| 3968 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3969 | * 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] | 3970 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3971 | * @kobj: Pointer to the kernel object |
| 3972 | * @bin_attr: Attribute object |
| 3973 | * @buff: Buffer pointer |
| 3974 | * @off: File offset |
| 3975 | * @count: Buffer size |
| 3976 | * |
| 3977 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3978 | * sysfs file. This function export the statistical data to user |
| 3979 | * applications. |
| 3980 | **/ |
| 3981 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3982 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3983 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3984 | char *buf, loff_t off, size_t count) |
| 3985 | { |
| 3986 | struct device *dev = container_of(kobj, struct device, |
| 3987 | kobj); |
| 3988 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3989 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3990 | struct lpfc_hba *phba = vport->phba; |
| 3991 | int i = 0, index = 0; |
| 3992 | unsigned long nport_index; |
| 3993 | struct lpfc_nodelist *ndlp = NULL; |
| 3994 | nport_index = (unsigned long)off / |
| 3995 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3996 | |
| 3997 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3998 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3999 | return 0; |
| 4000 | |
| 4001 | spin_lock_irq(shost->host_lock); |
| 4002 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 4003 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 4004 | continue; |
| 4005 | |
| 4006 | if (nport_index > 0) { |
| 4007 | nport_index--; |
| 4008 | continue; |
| 4009 | } |
| 4010 | |
| 4011 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 4012 | > count) |
| 4013 | break; |
| 4014 | |
| 4015 | if (!ndlp->lat_data) |
| 4016 | continue; |
| 4017 | |
| 4018 | /* Print the WWN */ |
| 4019 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 4020 | ndlp->nlp_portname.u.wwn[0], |
| 4021 | ndlp->nlp_portname.u.wwn[1], |
| 4022 | ndlp->nlp_portname.u.wwn[2], |
| 4023 | ndlp->nlp_portname.u.wwn[3], |
| 4024 | ndlp->nlp_portname.u.wwn[4], |
| 4025 | ndlp->nlp_portname.u.wwn[5], |
| 4026 | ndlp->nlp_portname.u.wwn[6], |
| 4027 | ndlp->nlp_portname.u.wwn[7]); |
| 4028 | |
| 4029 | index = strlen(buf); |
| 4030 | |
| 4031 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4032 | sprintf(&buf[index], "%010u,", |
| 4033 | ndlp->lat_data[i].cmd_count); |
| 4034 | index = strlen(buf); |
| 4035 | } |
| 4036 | sprintf(&buf[index], "\n"); |
| 4037 | index = strlen(buf); |
| 4038 | } |
| 4039 | spin_unlock_irq(shost->host_lock); |
| 4040 | return index; |
| 4041 | } |
| 4042 | |
| 4043 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4044 | .attr = { |
| 4045 | .name = "lpfc_drvr_stat_data", |
| 4046 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4047 | }, |
| 4048 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4049 | .read = sysfs_drvr_stat_data_read, |
| 4050 | .write = NULL, |
| 4051 | }; |
| 4052 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4053 | /* |
| 4054 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4055 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4056 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4057 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4058 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4059 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4060 | * @phba: lpfc_hba pointer. |
| 4061 | * @val: link speed value. |
| 4062 | * |
| 4063 | * Description: |
| 4064 | * If val is in a valid range then set the adapter's link speed field and |
| 4065 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4066 | * |
| 4067 | * Notes: |
| 4068 | * If the value is not in range log a kernel error message and return an error. |
| 4069 | * |
| 4070 | * Returns: |
| 4071 | * zero if val is in range and lip okay. |
| 4072 | * non-zero return value from lpfc_issue_lip() |
| 4073 | * -EINVAL val out of range |
| 4074 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4075 | static ssize_t |
| 4076 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4077 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4078 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4079 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4080 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4081 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4082 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4083 | int nolip = 0; |
| 4084 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4085 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4086 | uint32_t prev_val, if_type; |
| 4087 | |
| 4088 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 4089 | if (if_type == LPFC_SLI_INTF_IF_TYPE_2 && |
| 4090 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4091 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4092 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4093 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4094 | nolip = 1; |
| 4095 | val_buf = &buf[strlen("nolip ")]; |
| 4096 | } |
| 4097 | |
| 4098 | if (!isdigit(val_buf[0])) |
| 4099 | return -EINVAL; |
| 4100 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4101 | return -EINVAL; |
| 4102 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4103 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4104 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4105 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4106 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4107 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4108 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4109 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4110 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4111 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4112 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
| 4113 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4114 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4115 | "2879 lpfc_link_speed attribute cannot be set " |
| 4116 | "to %d. Speed is not supported by this port.\n", |
| 4117 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4118 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4119 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4120 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 4121 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 4122 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4123 | "3112 lpfc_link_speed attribute cannot be set " |
| 4124 | "to %d. Speed is not supported in loop mode.\n", |
| 4125 | val); |
| 4126 | return -EINVAL; |
| 4127 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4128 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 4129 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4130 | prev_val = phba->cfg_link_speed; |
| 4131 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4132 | if (nolip) |
| 4133 | return strlen(buf); |
| 4134 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4135 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4136 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4137 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4138 | return -EINVAL; |
| 4139 | } else |
| 4140 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4141 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4142 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4143 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4144 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4145 | return -EINVAL; |
| 4146 | } |
| 4147 | |
| 4148 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4149 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4150 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4151 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4152 | |
| 4153 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4154 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4155 | * @phba: lpfc_hba pointer. |
| 4156 | * @val: link speed value. |
| 4157 | * |
| 4158 | * Description: |
| 4159 | * If val is in a valid range then set the adapter's link speed field. |
| 4160 | * |
| 4161 | * Notes: |
| 4162 | * If the value is not in range log a kernel error message, clear the link |
| 4163 | * speed and return an error. |
| 4164 | * |
| 4165 | * Returns: |
| 4166 | * zero if val saved. |
| 4167 | * -EINVAL val out of range |
| 4168 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4169 | static int |
| 4170 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4171 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4172 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 4173 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4174 | "3111 lpfc_link_speed of %d cannot " |
| 4175 | "support loop mode, setting topology to default.\n", |
| 4176 | val); |
| 4177 | phba->cfg_topology = 0; |
| 4178 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4179 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 4180 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4181 | phba->cfg_link_speed = val; |
| 4182 | return 0; |
| 4183 | } |
| 4184 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4185 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4186 | "be set to %d, allowed values are " |
| 4187 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4188 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4189 | return -EINVAL; |
| 4190 | } |
| 4191 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4192 | static DEVICE_ATTR_RW(lpfc_link_speed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4193 | |
| 4194 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4195 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4196 | # 0 = aer disabled or not supported |
| 4197 | # 1 = aer supported and enabled (default) |
| 4198 | # Value range is [0,1]. Default value is 1. |
| 4199 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4200 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4201 | "Enable PCIe device AER support"); |
| 4202 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4203 | |
| 4204 | /** |
| 4205 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4206 | * |
| 4207 | * @dev: class device that is converted into a Scsi_host. |
| 4208 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4209 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4210 | * @count: unused variable. |
| 4211 | * |
| 4212 | * Description: |
| 4213 | * If the val is 1 and currently the device's AER capability was not |
| 4214 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4215 | * enable the device's AER capability. If the helper routine enabling |
| 4216 | * AER returns success, update the device's cfg_aer_support flag to |
| 4217 | * indicate AER is supported by the device; otherwise, if the device |
| 4218 | * AER capability is already enabled to support AER, then do nothing. |
| 4219 | * |
| 4220 | * If the val is 0 and currently the device's AER support was enabled, |
| 4221 | * invoke the kernel's disable AER helper routine. After that, update |
| 4222 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4223 | * by the device; otherwise, if the device AER capability is already |
| 4224 | * disabled from supporting AER, then do nothing. |
| 4225 | * |
| 4226 | * Returns: |
| 4227 | * length of the buf on success if val is in range the intended mode |
| 4228 | * is supported. |
| 4229 | * -EINVAL if val out of range or intended mode is not supported. |
| 4230 | **/ |
| 4231 | static ssize_t |
| 4232 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4233 | const char *buf, size_t count) |
| 4234 | { |
| 4235 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4236 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4237 | struct lpfc_hba *phba = vport->phba; |
| 4238 | int val = 0, rc = -EINVAL; |
| 4239 | |
| 4240 | if (!isdigit(buf[0])) |
| 4241 | return -EINVAL; |
| 4242 | if (sscanf(buf, "%i", &val) != 1) |
| 4243 | return -EINVAL; |
| 4244 | |
| 4245 | switch (val) { |
| 4246 | case 0: |
| 4247 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4248 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4249 | if (!rc) { |
| 4250 | spin_lock_irq(&phba->hbalock); |
| 4251 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4252 | spin_unlock_irq(&phba->hbalock); |
| 4253 | phba->cfg_aer_support = 0; |
| 4254 | rc = strlen(buf); |
| 4255 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4256 | rc = -EPERM; |
| 4257 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4258 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4259 | rc = strlen(buf); |
| 4260 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4261 | break; |
| 4262 | case 1: |
| 4263 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4264 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4265 | if (!rc) { |
| 4266 | spin_lock_irq(&phba->hbalock); |
| 4267 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4268 | spin_unlock_irq(&phba->hbalock); |
| 4269 | phba->cfg_aer_support = 1; |
| 4270 | rc = strlen(buf); |
| 4271 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4272 | rc = -EPERM; |
| 4273 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4274 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4275 | rc = strlen(buf); |
| 4276 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4277 | break; |
| 4278 | default: |
| 4279 | rc = -EINVAL; |
| 4280 | break; |
| 4281 | } |
| 4282 | return rc; |
| 4283 | } |
| 4284 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4285 | static DEVICE_ATTR_RW(lpfc_aer_support); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4286 | |
| 4287 | /** |
| 4288 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4289 | * @dev: class device that is converted into a Scsi_host. |
| 4290 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4291 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4292 | * @count: unused variable. |
| 4293 | * |
| 4294 | * Description: |
| 4295 | * If the @buf contains 1 and the device currently has the AER support |
| 4296 | * enabled, then invokes the kernel AER helper routine |
| 4297 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4298 | * error status register. |
| 4299 | * |
| 4300 | * Notes: |
| 4301 | * |
| 4302 | * Returns: |
| 4303 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4304 | * enabled with the AER support. |
| 4305 | **/ |
| 4306 | static ssize_t |
| 4307 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4308 | const char *buf, size_t count) |
| 4309 | { |
| 4310 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4311 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4312 | struct lpfc_hba *phba = vport->phba; |
| 4313 | int val, rc = -1; |
| 4314 | |
| 4315 | if (!isdigit(buf[0])) |
| 4316 | return -EINVAL; |
| 4317 | if (sscanf(buf, "%i", &val) != 1) |
| 4318 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4319 | if (val != 1) |
| 4320 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4321 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4322 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4323 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4324 | |
| 4325 | if (rc == 0) |
| 4326 | return strlen(buf); |
| 4327 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4328 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4329 | } |
| 4330 | |
| 4331 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4332 | lpfc_aer_cleanup_state); |
| 4333 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4334 | /** |
| 4335 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4336 | * |
| 4337 | * @dev: class device that is converted into a Scsi_host. |
| 4338 | * @attr: device attribute, not used. |
| 4339 | * @buf: containing the string the number of vfs to be enabled. |
| 4340 | * @count: unused variable. |
| 4341 | * |
| 4342 | * Description: |
| 4343 | * When this api is called either through user sysfs, the driver shall |
| 4344 | * try to enable or disable SR-IOV virtual functions according to the |
| 4345 | * following: |
| 4346 | * |
| 4347 | * If zero virtual function has been enabled to the physical function, |
| 4348 | * the driver shall invoke the pci enable virtual function api trying |
| 4349 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4350 | * than the maximum supported, the maximum virtual function number will |
| 4351 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4352 | * be used for invoking the api. If the api call returned success, the |
| 4353 | * actual number of virtual functions enabled will be set to the driver |
| 4354 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4355 | * cfg_sriov_nr_virtfn remains zero. |
| 4356 | * |
| 4357 | * If none-zero virtual functions have already been enabled to the |
| 4358 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4359 | * -EINVAL will be returned and the driver does nothing; |
| 4360 | * |
| 4361 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4362 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4363 | * disabling virtual function api shall be invoded to disable all the |
| 4364 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4365 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4366 | * nothing. |
| 4367 | * |
| 4368 | * Returns: |
| 4369 | * length of the buf on success if val is in range the intended mode |
| 4370 | * is supported. |
| 4371 | * -EINVAL if val out of range or intended mode is not supported. |
| 4372 | **/ |
| 4373 | static ssize_t |
| 4374 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4375 | const char *buf, size_t count) |
| 4376 | { |
| 4377 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4378 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4379 | struct lpfc_hba *phba = vport->phba; |
| 4380 | struct pci_dev *pdev = phba->pcidev; |
| 4381 | int val = 0, rc = -EINVAL; |
| 4382 | |
| 4383 | /* Sanity check on user data */ |
| 4384 | if (!isdigit(buf[0])) |
| 4385 | return -EINVAL; |
| 4386 | if (sscanf(buf, "%i", &val) != 1) |
| 4387 | return -EINVAL; |
| 4388 | if (val < 0) |
| 4389 | return -EINVAL; |
| 4390 | |
| 4391 | /* Request disabling virtual functions */ |
| 4392 | if (val == 0) { |
| 4393 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4394 | pci_disable_sriov(pdev); |
| 4395 | phba->cfg_sriov_nr_virtfn = 0; |
| 4396 | } |
| 4397 | return strlen(buf); |
| 4398 | } |
| 4399 | |
| 4400 | /* Request enabling virtual functions */ |
| 4401 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4402 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4403 | "3018 There are %d virtual functions " |
| 4404 | "enabled on physical function.\n", |
| 4405 | phba->cfg_sriov_nr_virtfn); |
| 4406 | return -EEXIST; |
| 4407 | } |
| 4408 | |
| 4409 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4410 | phba->cfg_sriov_nr_virtfn = val; |
| 4411 | else { |
| 4412 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4413 | "3019 Enabling %d virtual functions is not " |
| 4414 | "allowed.\n", val); |
| 4415 | return -EINVAL; |
| 4416 | } |
| 4417 | |
| 4418 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4419 | if (rc) { |
| 4420 | phba->cfg_sriov_nr_virtfn = 0; |
| 4421 | rc = -EPERM; |
| 4422 | } else |
| 4423 | rc = strlen(buf); |
| 4424 | |
| 4425 | return rc; |
| 4426 | } |
| 4427 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4428 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4429 | "Enable PCIe device SR-IOV virtual fn"); |
| 4430 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4431 | lpfc_param_show(sriov_nr_virtfn) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4432 | static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4433 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4434 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4435 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4436 | * |
| 4437 | * @dev: class device that is converted into a Scsi_host. |
| 4438 | * @attr: device attribute, not used. |
| 4439 | * @buf: containing the string the number of vfs to be enabled. |
| 4440 | * @count: unused variable. |
| 4441 | * |
| 4442 | * Description: |
| 4443 | * |
| 4444 | * Returns: |
| 4445 | * length of the buf on success if val is in range the intended mode |
| 4446 | * is supported. |
| 4447 | * -EINVAL if val out of range or intended mode is not supported. |
| 4448 | **/ |
| 4449 | static ssize_t |
| 4450 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4451 | struct device_attribute *attr, |
| 4452 | const char *buf, size_t count) |
| 4453 | { |
| 4454 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4455 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4456 | struct lpfc_hba *phba = vport->phba; |
| 4457 | int val = 0, rc = -EINVAL; |
| 4458 | |
| 4459 | /* Sanity check on user data */ |
| 4460 | if (!isdigit(buf[0])) |
| 4461 | return -EINVAL; |
| 4462 | if (sscanf(buf, "%i", &val) != 1) |
| 4463 | return -EINVAL; |
| 4464 | if (val != 1) |
| 4465 | return -EINVAL; |
| 4466 | |
| 4467 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4468 | if (rc) |
| 4469 | rc = -EPERM; |
| 4470 | else |
| 4471 | rc = strlen(buf); |
| 4472 | return rc; |
| 4473 | } |
| 4474 | |
| 4475 | static int lpfc_req_fw_upgrade; |
| 4476 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4477 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4478 | lpfc_param_show(request_firmware_upgrade) |
| 4479 | |
| 4480 | /** |
| 4481 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4482 | * @phba: lpfc_hba pointer. |
| 4483 | * @val: 0 or 1. |
| 4484 | * |
| 4485 | * Description: |
| 4486 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4487 | * |
| 4488 | * Returns: |
| 4489 | * zero if val saved. |
| 4490 | * -EINVAL val out of range |
| 4491 | **/ |
| 4492 | static int |
| 4493 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4494 | { |
| 4495 | if (val >= 0 && val <= 1) { |
| 4496 | phba->cfg_request_firmware_upgrade = val; |
| 4497 | return 0; |
| 4498 | } |
| 4499 | return -EINVAL; |
| 4500 | } |
| 4501 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4502 | lpfc_request_firmware_upgrade_show, |
| 4503 | lpfc_request_firmware_upgrade_store); |
| 4504 | |
| 4505 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4506 | * lpfc_fcp_imax_store |
| 4507 | * |
| 4508 | * @dev: class device that is converted into a Scsi_host. |
| 4509 | * @attr: device attribute, not used. |
| 4510 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4511 | * @count: unused variable. |
| 4512 | * |
| 4513 | * Description: |
| 4514 | * If val is in a valid range [636,651042], then set the adapter's |
| 4515 | * maximum number of fast-path FCP interrupts per second. |
| 4516 | * |
| 4517 | * Returns: |
| 4518 | * length of the buf on success if val is in range the intended mode |
| 4519 | * is supported. |
| 4520 | * -EINVAL if val out of range or intended mode is not supported. |
| 4521 | **/ |
| 4522 | static ssize_t |
| 4523 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4524 | const char *buf, size_t count) |
| 4525 | { |
| 4526 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4527 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4528 | struct lpfc_hba *phba = vport->phba; |
| 4529 | int val = 0, i; |
| 4530 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4531 | /* fcp_imax is only valid for SLI4 */ |
| 4532 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4533 | return -EINVAL; |
| 4534 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4535 | /* Sanity check on user data */ |
| 4536 | if (!isdigit(buf[0])) |
| 4537 | return -EINVAL; |
| 4538 | if (sscanf(buf, "%i", &val) != 1) |
| 4539 | return -EINVAL; |
| 4540 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4541 | /* |
| 4542 | * Value range for the HBA is [5000,5000000] |
| 4543 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4544 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4545 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4546 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4547 | return -EINVAL; |
| 4548 | |
| 4549 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4550 | phba->initial_imax = phba->cfg_fcp_imax; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 4551 | |
| 4552 | 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] | 4553 | lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT, |
| 4554 | val); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4555 | |
| 4556 | return strlen(buf); |
| 4557 | } |
| 4558 | |
| 4559 | /* |
| 4560 | # 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] | 4561 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4562 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4563 | # 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] | 4564 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4565 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4566 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4567 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4568 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4569 | lpfc_param_show(fcp_imax) |
| 4570 | |
| 4571 | /** |
| 4572 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4573 | * @phba: lpfc_hba pointer. |
| 4574 | * @val: link speed value. |
| 4575 | * |
| 4576 | * Description: |
| 4577 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4578 | * maximum number of fast-path FCP interrupts per second. |
| 4579 | * |
| 4580 | * Returns: |
| 4581 | * zero if val saved. |
| 4582 | * -EINVAL val out of range |
| 4583 | **/ |
| 4584 | static int |
| 4585 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4586 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4587 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4588 | phba->cfg_fcp_imax = 0; |
| 4589 | return 0; |
| 4590 | } |
| 4591 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4592 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 4593 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4594 | phba->cfg_fcp_imax = val; |
| 4595 | return 0; |
| 4596 | } |
| 4597 | |
| 4598 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4599 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 4600 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4601 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4602 | |
| 4603 | return 0; |
| 4604 | } |
| 4605 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4606 | static DEVICE_ATTR_RW(lpfc_fcp_imax); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4607 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4608 | /* |
| 4609 | * lpfc_auto_imax: Controls Auto-interrupt coalescing values support. |
| 4610 | * 0 No auto_imax support |
| 4611 | * 1 auto imax on |
| 4612 | * Auto imax will change the value of fcp_imax on a per EQ basis, using |
| 4613 | * the EQ Delay Multiplier, depending on the activity for that EQ. |
| 4614 | * Value range [0,1]. Default value is 1. |
| 4615 | */ |
| 4616 | LPFC_ATTR_RW(auto_imax, 1, 0, 1, "Enable Auto imax"); |
| 4617 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4618 | /** |
| 4619 | * lpfc_state_show - Display current driver CPU affinity |
| 4620 | * @dev: class converted to a Scsi_host structure. |
| 4621 | * @attr: device attribute, not used. |
| 4622 | * @buf: on return contains text describing the state of the link. |
| 4623 | * |
| 4624 | * Returns: size of formatted string. |
| 4625 | **/ |
| 4626 | static ssize_t |
| 4627 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4628 | char *buf) |
| 4629 | { |
| 4630 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4631 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4632 | struct lpfc_hba *phba = vport->phba; |
| 4633 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4634 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4635 | |
| 4636 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4637 | (phba->intr_type != MSIX)) |
| 4638 | return len; |
| 4639 | |
| 4640 | switch (phba->cfg_fcp_cpu_map) { |
| 4641 | case 0: |
| 4642 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4643 | "fcp_cpu_map: No mapping (%d)\n", |
| 4644 | phba->cfg_fcp_cpu_map); |
| 4645 | return len; |
| 4646 | case 1: |
| 4647 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4648 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4649 | "%d online CPUs\n", |
| 4650 | phba->cfg_fcp_cpu_map, |
| 4651 | phba->sli4_hba.num_online_cpu); |
| 4652 | break; |
| 4653 | case 2: |
| 4654 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4655 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4656 | "%d online CPUs\n", |
| 4657 | phba->cfg_fcp_cpu_map, |
| 4658 | phba->sli4_hba.num_online_cpu); |
| 4659 | break; |
| 4660 | } |
| 4661 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4662 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4663 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4664 | |
| 4665 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4666 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4667 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4668 | "CPU %02d io_chan %02d " |
| 4669 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4670 | phba->sli4_hba.curr_disp_cpu, |
| 4671 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4672 | cpup->core_id); |
| 4673 | else |
| 4674 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4675 | "CPU %02d io_chan %02d " |
| 4676 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4677 | phba->sli4_hba.curr_disp_cpu, |
| 4678 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4679 | cpup->core_id, cpup->irq); |
| 4680 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4681 | phba->sli4_hba.curr_disp_cpu++; |
| 4682 | |
| 4683 | /* display max number of CPUs keeping some margin */ |
| 4684 | if (phba->sli4_hba.curr_disp_cpu < |
| 4685 | phba->sli4_hba.num_present_cpu && |
| 4686 | (len >= (PAGE_SIZE - 64))) { |
| 4687 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4688 | break; |
| 4689 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4690 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4691 | |
| 4692 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4693 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4694 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4695 | return len; |
| 4696 | } |
| 4697 | |
| 4698 | /** |
| 4699 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4700 | * @dev: class device that is converted into a Scsi_host. |
| 4701 | * @attr: device attribute, not used. |
| 4702 | * @buf: one or more lpfc_polling_flags values. |
| 4703 | * @count: not used. |
| 4704 | * |
| 4705 | * Returns: |
| 4706 | * -EINVAL - Not implemented yet. |
| 4707 | **/ |
| 4708 | static ssize_t |
| 4709 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4710 | const char *buf, size_t count) |
| 4711 | { |
| 4712 | int status = -EINVAL; |
| 4713 | return status; |
| 4714 | } |
| 4715 | |
| 4716 | /* |
| 4717 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4718 | # for the HBA. |
| 4719 | # |
| 4720 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4721 | # 0 - Do not affinitze IRQ vectors |
| 4722 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4723 | # (start with CPU0 for each HBA) |
| 4724 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4725 | # (round robin thru all CPUs across all HBAs) |
| 4726 | */ |
| 4727 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4728 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4729 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4730 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4731 | |
| 4732 | /** |
| 4733 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4734 | * @phba: lpfc_hba pointer. |
| 4735 | * @val: link speed value. |
| 4736 | * |
| 4737 | * Description: |
| 4738 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4739 | * MSIX vectors. |
| 4740 | * |
| 4741 | * Returns: |
| 4742 | * zero if val saved. |
| 4743 | * -EINVAL val out of range |
| 4744 | **/ |
| 4745 | static int |
| 4746 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4747 | { |
| 4748 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4749 | phba->cfg_fcp_cpu_map = 0; |
| 4750 | return 0; |
| 4751 | } |
| 4752 | |
| 4753 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4754 | phba->cfg_fcp_cpu_map = val; |
| 4755 | return 0; |
| 4756 | } |
| 4757 | |
| 4758 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4759 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 4760 | "default\n", val); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4761 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4762 | |
| 4763 | return 0; |
| 4764 | } |
| 4765 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4766 | static DEVICE_ATTR_RW(lpfc_fcp_cpu_map); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4767 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4768 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4769 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4770 | # Value range is [2,3]. Default value is 3. |
| 4771 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4772 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4773 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4774 | |
| 4775 | /* |
| 4776 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4777 | # is [0,1]. Default value is 0. |
| 4778 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4779 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4780 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4781 | |
| 4782 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4783 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4784 | # that support first burst. |
| 4785 | # Value range is [0,65536]. Default value is 0. |
| 4786 | */ |
| 4787 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4788 | "First burst size for Targets that support first burst"); |
| 4789 | |
| 4790 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4791 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 4792 | * When the driver is configured as an NVME target, this value is |
| 4793 | * communicated to the NVME initiator in the PRLI response. It is |
| 4794 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 4795 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4796 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4797 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4798 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4799 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 4800 | "NVME Target mode first burst size in 512B increments."); |
| 4801 | |
| 4802 | /* |
| 4803 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 4804 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 4805 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
| 4806 | * processed by the initiator for subsequent NVME FCP IO. For the target |
| 4807 | * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size |
| 4808 | * driver parameter as the target function's first burst size returned to the |
| 4809 | * initiator in the target's NVME PRLI response. Parameter supported on physical |
| 4810 | * port only - no NPIV support. |
| 4811 | * Value range is [0,1]. Default value is 0 (disabled). |
| 4812 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4813 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
| 4814 | "Enable First Burst feature on I and T functions."); |
| 4815 | |
| 4816 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4817 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4818 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4819 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4820 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4821 | # to limit the I/O completion time to the parameter value. |
| 4822 | # The value is set in milliseconds. |
| 4823 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 4824 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4825 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 4826 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4827 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4828 | static int |
| 4829 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4830 | { |
| 4831 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4832 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4833 | |
| 4834 | if (val == vport->cfg_max_scsicmpl_time) |
| 4835 | return 0; |
| 4836 | if ((val < 0) || (val > 60000)) |
| 4837 | return -EINVAL; |
| 4838 | vport->cfg_max_scsicmpl_time = val; |
| 4839 | |
| 4840 | spin_lock_irq(shost->host_lock); |
| 4841 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4842 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4843 | continue; |
| 4844 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4845 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4846 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4847 | } |
| 4848 | spin_unlock_irq(shost->host_lock); |
| 4849 | return 0; |
| 4850 | } |
| 4851 | lpfc_vport_param_store(max_scsicmpl_time); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4852 | static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4853 | |
| 4854 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4855 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4856 | # range is [0,1]. Default value is 0. |
| 4857 | */ |
| 4858 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4859 | |
| 4860 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4861 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4862 | * range is [0,1]. Default value is 0. |
| 4863 | * For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4864 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 4865 | * current CPU. |
| 4866 | * |
| 4867 | * LPFC_FCP_SCHED_ROUND_ROBIN == 0 |
| 4868 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 4869 | * |
| 4870 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 4871 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 4872 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 4873 | * through WQs will be used. |
| 4874 | */ |
| 4875 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN, |
| 4876 | LPFC_FCP_SCHED_ROUND_ROBIN, |
| 4877 | LPFC_FCP_SCHED_BY_CPU, |
| 4878 | "Determine scheduling algorithm for " |
| 4879 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4880 | |
| 4881 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4882 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4883 | # range is [0,1]. Default value is 0. |
| 4884 | # For [0], bus reset issues target reset to ALL devices |
| 4885 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4886 | */ |
| 4887 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4888 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4889 | |
| 4890 | |
| 4891 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4892 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4893 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4894 | # 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] | 4895 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4896 | # cr_delay is set to 0. |
| 4897 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4898 | 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] | 4899 | "interrupt response is generated"); |
| 4900 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4901 | 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] | 4902 | "interrupt response is generated"); |
| 4903 | |
| 4904 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4905 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4906 | # cmd/rsp IOCB entries across. |
| 4907 | # Value range is [1,2]. Default value is 1. |
| 4908 | */ |
| 4909 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4910 | "SLI rings to spread IOCB entries across"); |
| 4911 | |
| 4912 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4913 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4914 | # identifies what rctl value to configure the additional ring for. |
| 4915 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4916 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4917 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4918 | 255, "Identifies RCTL for additional ring configuration"); |
| 4919 | |
| 4920 | /* |
| 4921 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4922 | # identifies what type value to configure the additional ring for. |
| 4923 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4924 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4925 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4926 | 255, "Identifies TYPE for additional ring configuration"); |
| 4927 | |
| 4928 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4929 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 4930 | # 0 = SmartSAN functionality disabled (default) |
| 4931 | # 1 = SmartSAN functionality enabled |
| 4932 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 4933 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4934 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4935 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 4936 | |
| 4937 | /* |
| 4938 | # lpfc_fdmi_on: Controls FDMI support. |
| 4939 | # 0 No FDMI support (default) |
| 4940 | # 1 Traditional FDMI support |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4941 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 4942 | # however, if that fails, it will fallback to FDMI-1. |
| 4943 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 4944 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 4945 | # lpfc_fdmi_on. |
| 4946 | # Value range [0,1]. Default value is 0. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4947 | */ |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4948 | LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4949 | |
| 4950 | /* |
| 4951 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4952 | # discovery). Value range is [1,64]. Default value = 32. |
| 4953 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4954 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4955 | "during discovery"); |
| 4956 | |
| 4957 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4958 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4959 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4960 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4961 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4962 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4963 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4964 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4965 | # on a target can take minutes of wall clock time. Additionally, |
| 4966 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4967 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4968 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4969 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4970 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4971 | # devices present, when in fact, there is only 1. |
| 4972 | # A customer that is aware of their target behaviors, and the results as |
| 4973 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4974 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4975 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4976 | # Value range is [0,65535]. Default value is 255. |
| 4977 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4978 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 4979 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4980 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4981 | /* |
| 4982 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4983 | # Value range is [1,255], default value is 10. |
| 4984 | */ |
| 4985 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4986 | "Milliseconds driver will wait between polling FCP ring"); |
| 4987 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4988 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4989 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4990 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4991 | */ |
| 4992 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4993 | "Maximum time to wait for task management commands to complete"); |
| 4994 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4995 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4996 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4997 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4998 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4999 | # 2 = MSI-X enabled (default) |
| 5000 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5001 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5002 | 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] | 5003 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5004 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5005 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5006 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5007 | * |
| 5008 | * 0 = NVME OAS disabled |
| 5009 | * 1 = NVME OAS enabled |
| 5010 | * |
| 5011 | * Value range is [0,1]. Default value is 0. |
| 5012 | */ |
| 5013 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 5014 | "Use OAS bit on NVME IOs"); |
| 5015 | |
| 5016 | /* |
| 5017 | * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver |
| 5018 | * will advertise it supports to the SCSI layer. This also will map to |
| 5019 | * the number of WQs the driver will create. |
| 5020 | * |
| 5021 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5022 | * 1,32 = Manually specify how many io channels to use. |
| 5023 | * |
| 5024 | * Value range is [0,32]. Default value is 4. |
| 5025 | */ |
| 5026 | LPFC_ATTR_R(fcp_io_channel, |
| 5027 | LPFC_FCP_IO_CHAN_DEF, |
| 5028 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5029 | "Set the number of FCP I/O channels"); |
| 5030 | |
| 5031 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5032 | * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver |
| 5033 | * will advertise it supports to the NVME layer. This also will map to |
| 5034 | * the number of WQs the driver will create. |
| 5035 | * |
| 5036 | * This module parameter is valid when lpfc_enable_fc4_type is set |
| 5037 | * to support NVME. |
| 5038 | * |
| 5039 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5040 | * hardware queue. The administrative queue will always map to WQ 0 |
| 5041 | * A hardware IO queue maps (qidx) to a specific driver WQ. |
| 5042 | * |
| 5043 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5044 | * 1,32 = Manually specify how many io channels to use. |
| 5045 | * |
| 5046 | * Value range is [0,32]. Default value is 0. |
| 5047 | */ |
| 5048 | LPFC_ATTR_R(nvme_io_channel, |
| 5049 | LPFC_NVME_IO_CHAN_DEF, |
| 5050 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
| 5051 | "Set the number of NVME I/O channels"); |
| 5052 | |
| 5053 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5054 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 5055 | # 0 = HBA resets disabled |
| 5056 | # 1 = HBA resets enabled (default) |
| 5057 | # Value range is [0,1]. Default value is 1. |
| 5058 | */ |
| 5059 | 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] | 5060 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5061 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5062 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5063 | # 0 = HBA Heartbeat disabled |
| 5064 | # 1 = HBA Heartbeat enabled (default) |
| 5065 | # Value range is [0,1]. Default value is 1. |
| 5066 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5067 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5068 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5069 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5070 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 5071 | # 0x0 Express Lane Feature disabled |
| 5072 | # 0x1 Express Lane Feature enabled |
| 5073 | # Value range is [0,1]. Default value is 0. |
| 5074 | */ |
| 5075 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 5076 | |
| 5077 | /* |
| 5078 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 5079 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 5080 | # Value range is [0x0,0x7f]. Default value is 0 |
| 5081 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 5082 | 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] | 5083 | |
| 5084 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5085 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 5086 | # 0 = BlockGuard disabled (default) |
| 5087 | # 1 = BlockGuard enabled |
| 5088 | # Value range is [0,1]. Default value is 0. |
| 5089 | */ |
| 5090 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5091 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5092 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5093 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 5094 | # 0 = disabled (default) |
| 5095 | # 1 = enabled |
| 5096 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 5097 | # |
| 5098 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5099 | */ |
| 5100 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 5101 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5102 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5103 | # lpfc_prot_mask: i |
| 5104 | # - Bit mask of host protection capabilities used to register with the |
| 5105 | # SCSI mid-layer |
| 5106 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5107 | # - Allows you to ultimately specify which profiles to use |
| 5108 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5109 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5110 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5111 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5112 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5113 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5114 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5115 | # |
| 5116 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5117 | LPFC_ATTR(prot_mask, |
| 5118 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5119 | SHOST_DIX_TYPE0_PROTECTION | |
| 5120 | SHOST_DIX_TYPE1_PROTECTION), |
| 5121 | 0, |
| 5122 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5123 | SHOST_DIX_TYPE0_PROTECTION | |
| 5124 | SHOST_DIX_TYPE1_PROTECTION), |
| 5125 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5126 | |
| 5127 | /* |
| 5128 | # lpfc_prot_guard: i |
| 5129 | # - 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] | 5130 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5131 | # - Allows you to ultimately specify which profiles to use |
| 5132 | # - Default will result in registering capabilities for all guard types |
| 5133 | # |
| 5134 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5135 | LPFC_ATTR(prot_guard, |
| 5136 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5137 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5138 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5139 | /* |
| 5140 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5141 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5142 | * This parameter can have value 0 or 1. |
| 5143 | * When this parameter is set to 0, no delay is added to the initial |
| 5144 | * discovery. |
| 5145 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5146 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5147 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5148 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5149 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5150 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5151 | * Default value is 0. |
| 5152 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5153 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5154 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5155 | |
| 5156 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5157 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5158 | * 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] | 5159 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 5160 | * 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] | 5161 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5162 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5163 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5164 | */ |
James Smart | b996ce3 | 2017-12-19 10:57:50 -0800 | [diff] [blame] | 5165 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_MIN_SG_SEG_CNT, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5166 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 5167 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5168 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5169 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 5170 | * 0 = MDS Diagnostics disabled (default) |
| 5171 | * 1 = MDS Diagnostics enabled |
| 5172 | * Value range is [0,1]. Default value is 0. |
| 5173 | */ |
| 5174 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 5175 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5176 | /* |
| 5177 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 5178 | * 0 = BB Credit Recovery disabled |
| 5179 | * 1 = BB Credit Recovery enabled (default) |
| 5180 | * Value range is [0,1]. Default value is 1. |
| 5181 | */ |
| 5182 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 5183 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5184 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5185 | &dev_attr_nvme_info, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5186 | &dev_attr_bg_info, |
| 5187 | &dev_attr_bg_guard_err, |
| 5188 | &dev_attr_bg_apptag_err, |
| 5189 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5190 | &dev_attr_info, |
| 5191 | &dev_attr_serialnum, |
| 5192 | &dev_attr_modeldesc, |
| 5193 | &dev_attr_modelname, |
| 5194 | &dev_attr_programtype, |
| 5195 | &dev_attr_portnum, |
| 5196 | &dev_attr_fwrev, |
| 5197 | &dev_attr_hdw, |
| 5198 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5199 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5200 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 5201 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5202 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5203 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5204 | &dev_attr_lpfc_temp_sensor, |
| 5205 | &dev_attr_lpfc_log_verbose, |
| 5206 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5207 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5208 | &dev_attr_lpfc_hba_queue_depth, |
| 5209 | &dev_attr_lpfc_peer_port_login, |
| 5210 | &dev_attr_lpfc_nodev_tmo, |
| 5211 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5212 | &dev_attr_lpfc_enable_fc4_type, |
| 5213 | &dev_attr_lpfc_xri_split, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5214 | &dev_attr_lpfc_fcp_class, |
| 5215 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5216 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5217 | &dev_attr_lpfc_ack0, |
| 5218 | &dev_attr_lpfc_topology, |
| 5219 | &dev_attr_lpfc_scan_down, |
| 5220 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5221 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5222 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5223 | &dev_attr_lpfc_cr_delay, |
| 5224 | &dev_attr_lpfc_cr_count, |
| 5225 | &dev_attr_lpfc_multi_ring_support, |
| 5226 | &dev_attr_lpfc_multi_ring_rctl, |
| 5227 | &dev_attr_lpfc_multi_ring_type, |
| 5228 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5229 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5230 | &dev_attr_lpfc_max_luns, |
| 5231 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5232 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5233 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5234 | &dev_attr_nport_evt_cnt, |
| 5235 | &dev_attr_board_mode, |
| 5236 | &dev_attr_max_vpi, |
| 5237 | &dev_attr_used_vpi, |
| 5238 | &dev_attr_max_rpi, |
| 5239 | &dev_attr_used_rpi, |
| 5240 | &dev_attr_max_xri, |
| 5241 | &dev_attr_used_xri, |
| 5242 | &dev_attr_npiv_info, |
| 5243 | &dev_attr_issue_reset, |
| 5244 | &dev_attr_lpfc_poll, |
| 5245 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5246 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5247 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5248 | &dev_attr_lpfc_nvme_oas, |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5249 | &dev_attr_lpfc_auto_imax, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5250 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5251 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5252 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5253 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5254 | &dev_attr_lpfc_nvme_io_channel, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5255 | &dev_attr_lpfc_nvmet_mrq, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5256 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5257 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5258 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 5259 | &dev_attr_lpfc_soft_wwnn, |
| 5260 | &dev_attr_lpfc_soft_wwpn, |
| 5261 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5262 | &dev_attr_lpfc_enable_hba_reset, |
| 5263 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5264 | &dev_attr_lpfc_EnableXLane, |
| 5265 | &dev_attr_lpfc_XLanePriority, |
| 5266 | &dev_attr_lpfc_xlane_lun, |
| 5267 | &dev_attr_lpfc_xlane_tgt, |
| 5268 | &dev_attr_lpfc_xlane_vpt, |
| 5269 | &dev_attr_lpfc_xlane_lun_state, |
| 5270 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5271 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5272 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5273 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5274 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5275 | &dev_attr_lpfc_aer_support, |
| 5276 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5277 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5278 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5279 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5280 | &dev_attr_lpfc_iocb_cnt, |
| 5281 | &dev_attr_iocb_hw, |
| 5282 | &dev_attr_txq_hw, |
| 5283 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5284 | &dev_attr_lpfc_fips_level, |
| 5285 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5286 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5287 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5288 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5289 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5290 | &dev_attr_lpfc_enable_mds_diags, |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5291 | &dev_attr_lpfc_enable_bbcr, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5292 | NULL, |
| 5293 | }; |
| 5294 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5295 | struct device_attribute *lpfc_vport_attrs[] = { |
| 5296 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5297 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5298 | &dev_attr_num_discovered_ports, |
| 5299 | &dev_attr_lpfc_drvr_version, |
| 5300 | &dev_attr_lpfc_log_verbose, |
| 5301 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5302 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5303 | &dev_attr_lpfc_nodev_tmo, |
| 5304 | &dev_attr_lpfc_devloss_tmo, |
| 5305 | &dev_attr_lpfc_hba_queue_depth, |
| 5306 | &dev_attr_lpfc_peer_port_login, |
| 5307 | &dev_attr_lpfc_restrict_login, |
| 5308 | &dev_attr_lpfc_fcp_class, |
| 5309 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5310 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5311 | &dev_attr_lpfc_max_luns, |
| 5312 | &dev_attr_nport_evt_cnt, |
| 5313 | &dev_attr_npiv_info, |
| 5314 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5315 | &dev_attr_lpfc_max_scsicmpl_time, |
| 5316 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 5317 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5318 | &dev_attr_lpfc_fips_level, |
| 5319 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5320 | NULL, |
| 5321 | }; |
| 5322 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5323 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5324 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5325 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5326 | * @kobj: kernel kobject that contains the kernel class device. |
| 5327 | * @bin_attr: kernel attributes passed to us. |
| 5328 | * @buf: contains the data to be written to the adapter IOREG space. |
| 5329 | * @off: offset into buffer to beginning of data. |
| 5330 | * @count: bytes to transfer. |
| 5331 | * |
| 5332 | * Description: |
| 5333 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5334 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 5335 | * |
| 5336 | * Returns: |
| 5337 | * -ERANGE off and count combo out of range |
| 5338 | * -EINVAL off, count or buff address invalid |
| 5339 | * -EPERM adapter is offline |
| 5340 | * value of count, buf contents written |
| 5341 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5342 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5343 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 5344 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5345 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5346 | { |
| 5347 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5348 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5349 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5350 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5351 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5352 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5353 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5354 | return -EPERM; |
| 5355 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5356 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5357 | return -ERANGE; |
| 5358 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5359 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 5360 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5361 | |
| 5362 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5363 | return -EINVAL; |
| 5364 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5365 | /* This is to protect HBA registers from accidental writes. */ |
| 5366 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 5367 | return -EINVAL; |
| 5368 | |
| 5369 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5370 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5371 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5372 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5373 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 5374 | buf_off += sizeof(uint32_t)) |
| 5375 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5376 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 5377 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5378 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5379 | |
| 5380 | return count; |
| 5381 | } |
| 5382 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5383 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5384 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5385 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5386 | * @kobj: kernel kobject that contains the kernel class device. |
| 5387 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5388 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5389 | * @off: offset into buffer to beginning of data. |
| 5390 | * @count: bytes to transfer. |
| 5391 | * |
| 5392 | * Description: |
| 5393 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5394 | * Uses the adapter io control registers to read data into buf. |
| 5395 | * |
| 5396 | * Returns: |
| 5397 | * -ERANGE off and count combo out of range |
| 5398 | * -EINVAL off, count or buff address invalid |
| 5399 | * value of count, buf contents read |
| 5400 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5401 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5402 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 5403 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5404 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5405 | { |
| 5406 | size_t buf_off; |
| 5407 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5408 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5409 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5410 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5411 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5412 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5413 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5414 | return -EPERM; |
| 5415 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5416 | if (off > FF_REG_AREA_SIZE) |
| 5417 | return -ERANGE; |
| 5418 | |
| 5419 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5420 | count = FF_REG_AREA_SIZE - off; |
| 5421 | |
| 5422 | if (count == 0) return 0; |
| 5423 | |
| 5424 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5425 | return -EINVAL; |
| 5426 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5427 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5428 | |
| 5429 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 5430 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5431 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5432 | } |
| 5433 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5434 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5435 | |
| 5436 | return count; |
| 5437 | } |
| 5438 | |
| 5439 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5440 | .attr = { |
| 5441 | .name = "ctlreg", |
| 5442 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5443 | }, |
| 5444 | .size = 256, |
| 5445 | .read = sysfs_ctlreg_read, |
| 5446 | .write = sysfs_ctlreg_write, |
| 5447 | }; |
| 5448 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5449 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5450 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5451 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5452 | * @kobj: kernel kobject that contains the kernel class device. |
| 5453 | * @bin_attr: kernel attributes passed to us. |
| 5454 | * @buf: contains the data to be written to sysfs mbox. |
| 5455 | * @off: offset into buffer to beginning of data. |
| 5456 | * @count: bytes to transfer. |
| 5457 | * |
| 5458 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5459 | * Deprecated function. All mailbox access from user space is performed via the |
| 5460 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5461 | * |
| 5462 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5463 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5464 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5465 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5466 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5467 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5468 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5469 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5470 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5471 | } |
| 5472 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5473 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5474 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5475 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5476 | * @kobj: kernel kobject that contains the kernel class device. |
| 5477 | * @bin_attr: kernel attributes passed to us. |
| 5478 | * @buf: contains the data to be read from sysfs mbox. |
| 5479 | * @off: offset into buffer to beginning of data. |
| 5480 | * @count: bytes to transfer. |
| 5481 | * |
| 5482 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5483 | * Deprecated function. All mailbox access from user space is performed via the |
| 5484 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5485 | * |
| 5486 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5487 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5488 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5489 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5490 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5491 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5492 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5493 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5494 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5495 | } |
| 5496 | |
| 5497 | static struct bin_attribute sysfs_mbox_attr = { |
| 5498 | .attr = { |
| 5499 | .name = "mbox", |
| 5500 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5501 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5502 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5503 | .read = sysfs_mbox_read, |
| 5504 | .write = sysfs_mbox_write, |
| 5505 | }; |
| 5506 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5507 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5508 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5509 | * @vport: address of lpfc vport structure. |
| 5510 | * |
| 5511 | * Return codes: |
| 5512 | * zero on success |
| 5513 | * error return code from sysfs_create_bin_file() |
| 5514 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5515 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5516 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5517 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5518 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5519 | int error; |
| 5520 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5521 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5522 | &sysfs_drvr_stat_data_attr); |
| 5523 | |
| 5524 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5525 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5526 | goto out; |
| 5527 | |
| 5528 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5529 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5530 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5531 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5532 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5533 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5534 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5535 | if (error) |
| 5536 | goto out_remove_ctlreg_attr; |
| 5537 | |
| 5538 | return 0; |
| 5539 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5540 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5541 | out_remove_stat_attr: |
| 5542 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5543 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5544 | out: |
| 5545 | return error; |
| 5546 | } |
| 5547 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5548 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5549 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5550 | * @vport: address of lpfc vport structure. |
| 5551 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5552 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5553 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5554 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5555 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5556 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5557 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5558 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5559 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5560 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5561 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5562 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5563 | } |
| 5564 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5565 | /* |
| 5566 | * Dynamic FC Host Attributes Support |
| 5567 | */ |
| 5568 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5569 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5570 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 5571 | * @shost: kernel scsi host pointer. |
| 5572 | **/ |
| 5573 | static void |
| 5574 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 5575 | { |
| 5576 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5577 | |
| 5578 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 5579 | sizeof fc_host_symbolic_name(shost)); |
| 5580 | } |
| 5581 | |
| 5582 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5583 | * 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] | 5584 | * @shost: kernel scsi host pointer. |
| 5585 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5586 | static void |
| 5587 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5588 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5589 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5590 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5591 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5592 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5593 | } |
| 5594 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5595 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5596 | * 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] | 5597 | * @shost: kernel scsi host pointer. |
| 5598 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5599 | static void |
| 5600 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5601 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5602 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5603 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5604 | |
| 5605 | spin_lock_irq(shost->host_lock); |
| 5606 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5607 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5608 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5609 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5610 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5611 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5612 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5613 | else |
| 5614 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5615 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5616 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5617 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5618 | else |
| 5619 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5620 | } |
| 5621 | } else |
| 5622 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5623 | |
| 5624 | spin_unlock_irq(shost->host_lock); |
| 5625 | } |
| 5626 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5627 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5628 | * 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] | 5629 | * @shost: kernel scsi host pointer. |
| 5630 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5631 | static void |
| 5632 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5633 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5634 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5635 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5636 | |
| 5637 | spin_lock_irq(shost->host_lock); |
| 5638 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5639 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5640 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5641 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5642 | switch (phba->link_state) { |
| 5643 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5644 | case LPFC_LINK_DOWN: |
| 5645 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5646 | break; |
| 5647 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5648 | case LPFC_CLEAR_LA: |
| 5649 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5650 | /* Links up, reports port state accordingly */ |
| 5651 | if (vport->port_state < LPFC_VPORT_READY) |
| 5652 | fc_host_port_state(shost) = |
| 5653 | FC_PORTSTATE_BYPASSED; |
| 5654 | else |
| 5655 | fc_host_port_state(shost) = |
| 5656 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5657 | break; |
| 5658 | case LPFC_HBA_ERROR: |
| 5659 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5660 | break; |
| 5661 | default: |
| 5662 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5663 | break; |
| 5664 | } |
| 5665 | } |
| 5666 | |
| 5667 | spin_unlock_irq(shost->host_lock); |
| 5668 | } |
| 5669 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5670 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5671 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5672 | * @shost: kernel scsi host pointer. |
| 5673 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5674 | static void |
| 5675 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5676 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5677 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5678 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5679 | |
| 5680 | spin_lock_irq(shost->host_lock); |
| 5681 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 5682 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5683 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5684 | case LPFC_LINK_SPEED_1GHZ: |
| 5685 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5686 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5687 | case LPFC_LINK_SPEED_2GHZ: |
| 5688 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5689 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5690 | case LPFC_LINK_SPEED_4GHZ: |
| 5691 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5692 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5693 | case LPFC_LINK_SPEED_8GHZ: |
| 5694 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5695 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5696 | case LPFC_LINK_SPEED_10GHZ: |
| 5697 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5698 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5699 | case LPFC_LINK_SPEED_16GHZ: |
| 5700 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5701 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 5702 | case LPFC_LINK_SPEED_32GHZ: |
| 5703 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 5704 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5705 | default: |
| 5706 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5707 | break; |
| 5708 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5709 | } else |
| 5710 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5711 | |
| 5712 | spin_unlock_irq(shost->host_lock); |
| 5713 | } |
| 5714 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5715 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5716 | * 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] | 5717 | * @shost: kernel scsi host pointer. |
| 5718 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5719 | static void |
| 5720 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5721 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5722 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5723 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5724 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5725 | |
| 5726 | spin_lock_irq(shost->host_lock); |
| 5727 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5728 | if ((vport->port_state > LPFC_FLOGI) && |
| 5729 | ((vport->fc_flag & FC_FABRIC) || |
| 5730 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5731 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5732 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5733 | else |
| 5734 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5735 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5736 | |
| 5737 | spin_unlock_irq(shost->host_lock); |
| 5738 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5739 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5740 | } |
| 5741 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5742 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5743 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5744 | * @shost: kernel scsi host pointer. |
| 5745 | * |
| 5746 | * Notes: |
| 5747 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5748 | * management not allowed, memory allocation error, or mbox error. |
| 5749 | * |
| 5750 | * Returns: |
| 5751 | * NULL for error |
| 5752 | * address of the adapter host statistics |
| 5753 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5754 | static struct fc_host_statistics * |
| 5755 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5756 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5757 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5758 | struct lpfc_hba *phba = vport->phba; |
| 5759 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5760 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5761 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5762 | LPFC_MBOXQ_t *pmboxq; |
| 5763 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5764 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5765 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5766 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5767 | /* |
| 5768 | * prevent udev from issuing mailbox commands until the port is |
| 5769 | * configured. |
| 5770 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5771 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5772 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5773 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5774 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5775 | |
| 5776 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5777 | return NULL; |
| 5778 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5779 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5780 | if (!pmboxq) |
| 5781 | return NULL; |
| 5782 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5783 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5784 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5785 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5786 | pmb->mbxOwner = OWN_HOST; |
| 5787 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5788 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5789 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5790 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5791 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5792 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5793 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5794 | |
| 5795 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5796 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5797 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5798 | return NULL; |
| 5799 | } |
| 5800 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5801 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5802 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5803 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5804 | /* |
| 5805 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5806 | * converted to words |
| 5807 | */ |
| 5808 | hs->tx_words = (uint64_t) |
| 5809 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5810 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5811 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5812 | hs->rx_words = (uint64_t) |
| 5813 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5814 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5815 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5816 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5817 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5818 | pmb->mbxOwner = OWN_HOST; |
| 5819 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5820 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5821 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5822 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5823 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5824 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5825 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5826 | |
| 5827 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5828 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5829 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5830 | return NULL; |
| 5831 | } |
| 5832 | |
| 5833 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5834 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5835 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5836 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5837 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5838 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5839 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5840 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5841 | hs->link_failure_count -= lso->link_failure_count; |
| 5842 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5843 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5844 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5845 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5846 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5847 | hs->error_frames -= lso->error_frames; |
| 5848 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5849 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5850 | hs->lip_count = -1; |
| 5851 | hs->nos_count = (phba->link_events >> 1); |
| 5852 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5853 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5854 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5855 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5856 | hs->nos_count = -1; |
| 5857 | } else { |
| 5858 | hs->lip_count = -1; |
| 5859 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5860 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5861 | } |
| 5862 | |
| 5863 | hs->dumped_frames = -1; |
| 5864 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5865 | seconds = get_seconds(); |
| 5866 | if (seconds < psli->stats_start) |
| 5867 | hs->seconds_since_last_reset = seconds + |
| 5868 | ((unsigned long)-1 - psli->stats_start); |
| 5869 | else |
| 5870 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5871 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5872 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5873 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5874 | return hs; |
| 5875 | } |
| 5876 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5877 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5878 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5879 | * @shost: kernel scsi host pointer. |
| 5880 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5881 | static void |
| 5882 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5883 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5884 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5885 | struct lpfc_hba *phba = vport->phba; |
| 5886 | struct lpfc_sli *psli = &phba->sli; |
| 5887 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5888 | LPFC_MBOXQ_t *pmboxq; |
| 5889 | MAILBOX_t *pmb; |
| 5890 | int rc = 0; |
| 5891 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5892 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5893 | return; |
| 5894 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5895 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5896 | if (!pmboxq) |
| 5897 | return; |
| 5898 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5899 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5900 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5901 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5902 | pmb->mbxOwner = OWN_HOST; |
| 5903 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5904 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5905 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5906 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5907 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5908 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5909 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5910 | else |
| 5911 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5912 | |
| 5913 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5914 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5915 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5916 | return; |
| 5917 | } |
| 5918 | |
| 5919 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5920 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5921 | pmb->mbxOwner = OWN_HOST; |
| 5922 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5923 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5924 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5925 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5926 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5927 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5928 | else |
| 5929 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5930 | |
| 5931 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5932 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5933 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5934 | return; |
| 5935 | } |
| 5936 | |
| 5937 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5938 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5939 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5940 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5941 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5942 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5943 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5944 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5945 | lso->link_events = (phba->link_events >> 1); |
| 5946 | else |
| 5947 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5948 | |
| 5949 | psli->stats_start = get_seconds(); |
| 5950 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5951 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5952 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5953 | return; |
| 5954 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5955 | |
| 5956 | /* |
| 5957 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5958 | * are no sysfs handlers for link_down_tmo. |
| 5959 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5960 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5961 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5962 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5963 | * @starget: kernel scsi target pointer. |
| 5964 | * |
| 5965 | * Returns: |
| 5966 | * address of the node list if found |
| 5967 | * NULL target not found |
| 5968 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5969 | static struct lpfc_nodelist * |
| 5970 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5971 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5972 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5973 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5974 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5975 | |
| 5976 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5977 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5978 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5979 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5980 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5981 | starget->id == ndlp->nlp_sid) { |
| 5982 | spin_unlock_irq(shost->host_lock); |
| 5983 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5984 | } |
| 5985 | } |
| 5986 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5987 | return NULL; |
| 5988 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5989 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5990 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5991 | * 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] | 5992 | * @starget: kernel scsi target pointer. |
| 5993 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5994 | static void |
| 5995 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5996 | { |
| 5997 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5998 | |
| 5999 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6000 | } |
| 6001 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6002 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6003 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6004 | * @starget: kernel scsi target pointer. |
| 6005 | * |
| 6006 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 6007 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6008 | static void |
| 6009 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 6010 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6011 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6012 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6013 | fc_starget_node_name(starget) = |
| 6014 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6015 | } |
| 6016 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6017 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6018 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6019 | * @starget: kernel scsi target pointer. |
| 6020 | * |
| 6021 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 6022 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6023 | static void |
| 6024 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 6025 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6026 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6027 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6028 | fc_starget_port_name(starget) = |
| 6029 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6030 | } |
| 6031 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6032 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6033 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6034 | * @rport: fc rport address. |
| 6035 | * @timeout: new value for dev loss tmo. |
| 6036 | * |
| 6037 | * Description: |
| 6038 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 6039 | * dev_loss_tmo to one. |
| 6040 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6041 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6042 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 6043 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6044 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6045 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6046 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6047 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6048 | } |
| 6049 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6050 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6051 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6052 | * |
| 6053 | * Description: |
| 6054 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 6055 | * |
| 6056 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 6057 | * @cdev: class converted to an fc_rport. |
| 6058 | * @buf: on return contains the target_field or zero. |
| 6059 | * |
| 6060 | * Returns: size of formatted string. |
| 6061 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6062 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 6063 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6064 | lpfc_show_rport_##field (struct device *dev, \ |
| 6065 | struct device_attribute *attr, \ |
| 6066 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6067 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6068 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6069 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 6070 | return snprintf(buf, sz, format_string, \ |
| 6071 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 6072 | } |
| 6073 | |
| 6074 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 6075 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 6076 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 6077 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6078 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6079 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6080 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 6081 | * |
| 6082 | * Description: |
| 6083 | * This function is called by the transport after the @fc_vport's symbolic name |
| 6084 | * 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] | 6085 | * 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] | 6086 | **/ |
| 6087 | static void |
| 6088 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 6089 | { |
| 6090 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 6091 | |
| 6092 | if (vport->port_state == LPFC_VPORT_READY) |
| 6093 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 6094 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6095 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6096 | /** |
| 6097 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 6098 | * @phba: Pointer to lpfc_hba struct. |
| 6099 | * |
| 6100 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 6101 | * 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] | 6102 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6103 | * before hba port or vport created. |
| 6104 | **/ |
| 6105 | static void |
| 6106 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 6107 | { |
| 6108 | phba->cfg_log_verbose = verbose; |
| 6109 | } |
| 6110 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6111 | struct fc_function_template lpfc_transport_functions = { |
| 6112 | /* fixed attributes the driver supports */ |
| 6113 | .show_host_node_name = 1, |
| 6114 | .show_host_port_name = 1, |
| 6115 | .show_host_supported_classes = 1, |
| 6116 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6117 | .show_host_supported_speeds = 1, |
| 6118 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6119 | |
| 6120 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6121 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6122 | |
| 6123 | /* dynamic attributes the driver supports */ |
| 6124 | .get_host_port_id = lpfc_get_host_port_id, |
| 6125 | .show_host_port_id = 1, |
| 6126 | |
| 6127 | .get_host_port_type = lpfc_get_host_port_type, |
| 6128 | .show_host_port_type = 1, |
| 6129 | |
| 6130 | .get_host_port_state = lpfc_get_host_port_state, |
| 6131 | .show_host_port_state = 1, |
| 6132 | |
| 6133 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6134 | .show_host_active_fc4s = 1, |
| 6135 | |
| 6136 | .get_host_speed = lpfc_get_host_speed, |
| 6137 | .show_host_speed = 1, |
| 6138 | |
| 6139 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6140 | .show_host_fabric_name = 1, |
| 6141 | |
| 6142 | /* |
| 6143 | * The LPFC driver treats linkdown handling as target loss events |
| 6144 | * so there are no sysfs handlers for link_down_tmo. |
| 6145 | */ |
| 6146 | |
| 6147 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6148 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6149 | |
| 6150 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6151 | .show_rport_maxframe_size = 1, |
| 6152 | .show_rport_supported_classes = 1, |
| 6153 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6154 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6155 | .show_rport_dev_loss_tmo = 1, |
| 6156 | |
| 6157 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6158 | .show_starget_port_id = 1, |
| 6159 | |
| 6160 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6161 | .show_starget_node_name = 1, |
| 6162 | |
| 6163 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6164 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 6165 | |
| 6166 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6167 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6168 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6169 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6170 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6171 | |
| 6172 | .vport_disable = lpfc_vport_disable, |
| 6173 | |
| 6174 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 6175 | |
| 6176 | .bsg_request = lpfc_bsg_request, |
| 6177 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6178 | }; |
| 6179 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6180 | struct fc_function_template lpfc_vport_transport_functions = { |
| 6181 | /* fixed attributes the driver supports */ |
| 6182 | .show_host_node_name = 1, |
| 6183 | .show_host_port_name = 1, |
| 6184 | .show_host_supported_classes = 1, |
| 6185 | .show_host_supported_fc4s = 1, |
| 6186 | .show_host_supported_speeds = 1, |
| 6187 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6188 | |
| 6189 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6190 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6191 | |
| 6192 | /* dynamic attributes the driver supports */ |
| 6193 | .get_host_port_id = lpfc_get_host_port_id, |
| 6194 | .show_host_port_id = 1, |
| 6195 | |
| 6196 | .get_host_port_type = lpfc_get_host_port_type, |
| 6197 | .show_host_port_type = 1, |
| 6198 | |
| 6199 | .get_host_port_state = lpfc_get_host_port_state, |
| 6200 | .show_host_port_state = 1, |
| 6201 | |
| 6202 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6203 | .show_host_active_fc4s = 1, |
| 6204 | |
| 6205 | .get_host_speed = lpfc_get_host_speed, |
| 6206 | .show_host_speed = 1, |
| 6207 | |
| 6208 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6209 | .show_host_fabric_name = 1, |
| 6210 | |
| 6211 | /* |
| 6212 | * The LPFC driver treats linkdown handling as target loss events |
| 6213 | * so there are no sysfs handlers for link_down_tmo. |
| 6214 | */ |
| 6215 | |
| 6216 | .get_fc_host_stats = lpfc_get_stats, |
| 6217 | .reset_fc_host_stats = lpfc_reset_stats, |
| 6218 | |
| 6219 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6220 | .show_rport_maxframe_size = 1, |
| 6221 | .show_rport_supported_classes = 1, |
| 6222 | |
| 6223 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6224 | .show_rport_dev_loss_tmo = 1, |
| 6225 | |
| 6226 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6227 | .show_starget_port_id = 1, |
| 6228 | |
| 6229 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6230 | .show_starget_node_name = 1, |
| 6231 | |
| 6232 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6233 | .show_starget_port_name = 1, |
| 6234 | |
| 6235 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6236 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 6237 | |
| 6238 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6239 | |
| 6240 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6241 | }; |
| 6242 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6243 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6244 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6245 | * @phba: lpfc_hba pointer. |
| 6246 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6247 | void |
| 6248 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 6249 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6250 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6251 | 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] | 6252 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 6253 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 6254 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 6255 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 6256 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6257 | lpfc_ack0_init(phba, lpfc_ack0); |
| 6258 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6259 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 6260 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6261 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 6262 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6263 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6264 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6265 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 6266 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 6267 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6268 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6269 | lpfc_auto_imax_init(phba, lpfc_auto_imax); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6270 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6271 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6272 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 6273 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6274 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6275 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 6276 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 6277 | phba->cfg_EnableXLane = 0; |
| 6278 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6279 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6280 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6281 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6282 | phba->cfg_oas_lun_state = 0; |
| 6283 | phba->cfg_oas_lun_status = 0; |
| 6284 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6285 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6286 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6287 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 6288 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 6289 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6290 | phba->cfg_poll = 0; |
| 6291 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6292 | phba->cfg_poll = lpfc_poll; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6293 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6294 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6295 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6296 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6297 | |
| 6298 | /* Initialize first burst. Target vs Initiator are different. */ |
| 6299 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6300 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6301 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
| 6302 | lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6303 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6304 | |
| 6305 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 6306 | /* NVME only supported on SLI4 */ |
| 6307 | phba->nvmet_support = 0; |
| 6308 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6309 | phba->cfg_enable_bbcr = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6310 | } else { |
| 6311 | /* We MUST have FCP support */ |
| 6312 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 6313 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 6314 | } |
| 6315 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6316 | if (phba->cfg_auto_imax && !phba->cfg_fcp_imax) |
| 6317 | phba->cfg_auto_imax = 0; |
| 6318 | phba->initial_imax = phba->cfg_fcp_imax; |
| 6319 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6320 | /* 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] | 6321 | if (phba->cfg_fcp_io_channel == 0) |
| 6322 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6323 | if (phba->cfg_nvme_io_channel == 0) |
| 6324 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6325 | |
| 6326 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME) |
| 6327 | phba->cfg_fcp_io_channel = 0; |
| 6328 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6329 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) |
| 6330 | phba->cfg_nvme_io_channel = 0; |
| 6331 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6332 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6333 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6334 | else |
| 6335 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6336 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6337 | phba->cfg_soft_wwnn = 0L; |
| 6338 | phba->cfg_soft_wwpn = 0L; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6339 | lpfc_xri_split_init(phba, lpfc_xri_split); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6340 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 6341 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6342 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6343 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6344 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6345 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6346 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6347 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 6348 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 6349 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6350 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6351 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6352 | return; |
| 6353 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 6354 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6355 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6356 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 6357 | * dependencies between protocols and roles. |
| 6358 | * @phba: lpfc_hba pointer. |
| 6359 | **/ |
| 6360 | void |
| 6361 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 6362 | { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6363 | if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu) |
| 6364 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6365 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6366 | if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu) |
| 6367 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
| 6368 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6369 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 6370 | phba->nvmet_support) { |
| 6371 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
| 6372 | phba->cfg_fcp_io_channel = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6373 | |
| 6374 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 6375 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 6376 | "NVME Target PRLI ACC enable_fb ", |
| 6377 | phba->cfg_nvme_enable_fb, |
| 6378 | phba->cfg_nvmet_fb_size, |
| 6379 | LPFC_NVMET_FB_SZ_MAX); |
| 6380 | |
| 6381 | if (phba->cfg_nvme_enable_fb == 0) |
| 6382 | phba->cfg_nvmet_fb_size = 0; |
| 6383 | else { |
| 6384 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 6385 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 6386 | } |
| 6387 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6388 | if (!phba->cfg_nvmet_mrq) |
| 6389 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6390 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6391 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
| 6392 | if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) { |
| 6393 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6394 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 6395 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 6396 | phba->cfg_nvmet_mrq); |
| 6397 | } |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6398 | if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) |
| 6399 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; |
| 6400 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6401 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6402 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 6403 | phba->nvmet_support = 0; |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6404 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_OFF; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6405 | phba->cfg_nvmet_fb_size = 0; |
| 6406 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6407 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6408 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6409 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6410 | else |
| 6411 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
| 6412 | } |
| 6413 | |
| 6414 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6415 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6416 | * @vport: lpfc_vport pointer. |
| 6417 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6418 | void |
| 6419 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 6420 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6421 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6422 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6423 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6424 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 6425 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 6426 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 6427 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 6428 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 6429 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6430 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6431 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6432 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 6433 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 6434 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 6435 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6436 | return; |
| 6437 | } |