| 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 | 0d04121 | 2019-01-28 11:14:41 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term * |
James Smart | 3e21d1c | 2018-05-04 20:37:59 -0700 | [diff] [blame] | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
James Smart | 5061157 | 2016-03-31 14:12:34 -0700 | [diff] [blame] | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * EMULEX and SLI are trademarks of Emulex. * |
James Smart | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 8 | * www.broadcom.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 9 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 12 | * modify it under the terms of version 2 of the GNU General * |
| 13 | * Public License as published by the Free Software Foundation. * |
| 14 | * This program is distributed in the hope that it will be useful. * |
| 15 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 16 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 18 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 19 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 20 | * more details, a copy of which can be found in the file COPYING * |
| 21 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | *******************************************************************/ |
| 23 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 24 | #include <linux/ctype.h> |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 25 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 26 | #include <linux/pci.h> |
| 27 | #include <linux/interrupt.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 28 | #include <linux/module.h> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 29 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 31 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 32 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 33 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | #include <scsi/scsi_device.h> |
| 35 | #include <scsi/scsi_host.h> |
| 36 | #include <scsi/scsi_tcq.h> |
| 37 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 38 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 39 | |
James Smart | 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 | |
Bart Van Assche | a73cb81 | 2019-03-28 11:06:19 -0700 | [diff] [blame] | 74 | const char *const trunk_errmsg[] = { /* map errcode */ |
| 75 | "", /* There is no such error code at index 0*/ |
| 76 | "link negotiated speed does not match existing" |
| 77 | " trunk - link was \"low\" speed", |
| 78 | "link negotiated speed does not match" |
| 79 | " existing trunk - link was \"middle\" speed", |
| 80 | "link negotiated speed does not match existing" |
| 81 | " trunk - link was \"high\" speed", |
| 82 | "Attached to non-trunking port - F_Port", |
| 83 | "Attached to non-trunking port - N_Port", |
| 84 | "FLOGI response timeout", |
| 85 | "non-FLOGI frame received", |
| 86 | "Invalid FLOGI response", |
| 87 | "Trunking initialization protocol", |
| 88 | "Trunk peer device mismatch", |
| 89 | }; |
| 90 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 91 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 92 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 93 | * @incr: integer to convert. |
| 94 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 95 | * |
| 96 | * Description: |
| 97 | * JEDEC Joint Electron Device Engineering Council. |
| 98 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 99 | * character string. The string is then terminated with a NULL in byte 9. |
| 100 | * Hex 0-9 becomes ascii '0' to '9'. |
| 101 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 102 | * |
| 103 | * Notes: |
| 104 | * Coded for 32 bit integers only. |
| 105 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 106 | static void |
| 107 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 108 | { |
| 109 | int i, j; |
| 110 | for (i = 0; i < 8; i++) { |
| 111 | j = (incr & 0xf); |
| 112 | if (j <= 9) |
| 113 | hdw[7 - i] = 0x30 + j; |
| 114 | else |
| 115 | hdw[7 - i] = 0x61 + j - 10; |
| 116 | incr = (incr >> 4); |
| 117 | } |
| 118 | hdw[8] = 0; |
| 119 | return; |
| 120 | } |
| 121 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 122 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 123 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 124 | * @dev: class unused variable. |
| 125 | * @attr: device attribute, not used. |
| 126 | * @buf: on return contains the module description text. |
| 127 | * |
| 128 | * Returns: size of formatted string. |
| 129 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 130 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 131 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 132 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 133 | { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 134 | return scnprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 135 | } |
| 136 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 137 | /** |
| 138 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 139 | * @dev: class unused variable. |
| 140 | * @attr: device attribute, not used. |
| 141 | * @buf: on return contains the module description text. |
| 142 | * |
| 143 | * Returns: size of formatted string. |
| 144 | **/ |
| 145 | static ssize_t |
| 146 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 147 | char *buf) |
| 148 | { |
| 149 | struct Scsi_Host *shost = class_to_shost(dev); |
| 150 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 151 | struct lpfc_hba *phba = vport->phba; |
| 152 | |
| 153 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 154 | return scnprintf(buf, PAGE_SIZE, "1\n"); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 155 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 156 | return scnprintf(buf, PAGE_SIZE, "0\n"); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 157 | } |
| 158 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 159 | static ssize_t |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 160 | lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, |
| 161 | char *buf) |
| 162 | { |
| 163 | struct Scsi_Host *shost = class_to_shost(dev); |
| 164 | struct lpfc_vport *vport = shost_priv(shost); |
| 165 | struct lpfc_hba *phba = vport->phba; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 166 | struct lpfc_nvmet_tgtport *tgtp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 167 | struct nvme_fc_local_port *localport; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 168 | struct lpfc_nvme_lport *lport; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 169 | struct lpfc_nvme_rport *rport; |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 170 | struct lpfc_nodelist *ndlp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 171 | struct nvme_fc_remote_port *nrport; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 172 | struct lpfc_fc4_ctrl_stat *cstat; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 173 | uint64_t data1, data2, data3; |
| 174 | uint64_t totin, totout, tot; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 175 | char *statep; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 176 | int i; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 177 | int len = 0; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 178 | char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0}; |
James Smart | e2a8be5 | 2019-05-06 17:26:47 -0700 | [diff] [blame] | 179 | unsigned long iflags = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 180 | |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 181 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 182 | len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 183 | return len; |
| 184 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 185 | if (phba->nvmet_support) { |
| 186 | if (!phba->targetport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 187 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 188 | "NVME Target: x%llx is not allocated\n", |
| 189 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 190 | return len; |
| 191 | } |
| 192 | /* Port state is only one of two values for now. */ |
| 193 | if (phba->targetport->port_id) |
| 194 | statep = "REGISTERED"; |
| 195 | else |
| 196 | statep = "INIT"; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 197 | scnprintf(tmp, sizeof(tmp), |
| 198 | "NVME Target Enabled State %s\n", |
| 199 | statep); |
| 200 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 201 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 202 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 203 | scnprintf(tmp, sizeof(tmp), |
| 204 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 205 | "NVME Target: lpfc", |
| 206 | phba->brd_no, |
| 207 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 208 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 209 | phba->targetport->port_id); |
| 210 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 211 | goto buffer_done; |
| 212 | |
| 213 | if (strlcat(buf, "\nNVME Target: Statistics\n", PAGE_SIZE) |
| 214 | >= PAGE_SIZE) |
| 215 | goto buffer_done; |
| 216 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 217 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 218 | scnprintf(tmp, sizeof(tmp), |
| 219 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 220 | atomic_read(&tgtp->rcv_ls_req_in), |
| 221 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 222 | atomic_read(&tgtp->xmt_ls_abort)); |
| 223 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 224 | goto buffer_done; |
| 225 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 226 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 227 | atomic_read(&tgtp->rcv_ls_req_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 228 | scnprintf(tmp, sizeof(tmp), |
| 229 | "Rcv LS: in %08x != out %08x\n", |
| 230 | atomic_read(&tgtp->rcv_ls_req_in), |
| 231 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 232 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 233 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 234 | } |
| 235 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 236 | scnprintf(tmp, sizeof(tmp), |
| 237 | "LS: Xmt %08x Drop %08x Cmpl %08x\n", |
| 238 | atomic_read(&tgtp->xmt_ls_rsp), |
| 239 | atomic_read(&tgtp->xmt_ls_drop), |
| 240 | atomic_read(&tgtp->xmt_ls_rsp_cmpl)); |
| 241 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 242 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 243 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 244 | scnprintf(tmp, sizeof(tmp), |
| 245 | "LS: RSP Abort %08x xb %08x Err %08x\n", |
| 246 | atomic_read(&tgtp->xmt_ls_rsp_aborted), |
| 247 | atomic_read(&tgtp->xmt_ls_rsp_xb_set), |
| 248 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 249 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 250 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 251 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 252 | scnprintf(tmp, sizeof(tmp), |
| 253 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 254 | "Drop %08x\n", |
| 255 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 256 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
| 257 | atomic_read(&tgtp->xmt_fcp_release), |
| 258 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 259 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 260 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 261 | |
| 262 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 263 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 264 | scnprintf(tmp, sizeof(tmp), |
| 265 | "Rcv FCP: in %08x != out %08x\n", |
| 266 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 267 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 268 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 269 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 270 | } |
| 271 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 272 | scnprintf(tmp, sizeof(tmp), |
| 273 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " |
| 274 | "drop %08x\n", |
| 275 | atomic_read(&tgtp->xmt_fcp_read), |
| 276 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 277 | atomic_read(&tgtp->xmt_fcp_write), |
| 278 | atomic_read(&tgtp->xmt_fcp_rsp), |
| 279 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 280 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 281 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 282 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 283 | scnprintf(tmp, sizeof(tmp), |
| 284 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 285 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 286 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 287 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 288 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 289 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 290 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 291 | scnprintf(tmp, sizeof(tmp), |
| 292 | "FCP Rsp Abort: %08x xb %08x xricqe %08x\n", |
| 293 | atomic_read(&tgtp->xmt_fcp_rsp_aborted), |
| 294 | atomic_read(&tgtp->xmt_fcp_rsp_xb_set), |
| 295 | atomic_read(&tgtp->xmt_fcp_xri_abort_cqe)); |
| 296 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 297 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 298 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 299 | scnprintf(tmp, sizeof(tmp), |
| 300 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 301 | atomic_read(&tgtp->xmt_fcp_abort), |
| 302 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 303 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 304 | goto buffer_done; |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 305 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 306 | scnprintf(tmp, sizeof(tmp), |
| 307 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n", |
| 308 | atomic_read(&tgtp->xmt_abort_sol), |
| 309 | atomic_read(&tgtp->xmt_abort_unsol), |
| 310 | atomic_read(&tgtp->xmt_abort_rsp), |
| 311 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
| 312 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 313 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 314 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 315 | scnprintf(tmp, sizeof(tmp), |
| 316 | "DELAY: ctx %08x fod %08x wqfull %08x\n", |
| 317 | atomic_read(&tgtp->defer_ctx), |
| 318 | atomic_read(&tgtp->defer_fod), |
| 319 | atomic_read(&tgtp->defer_wqfull)); |
| 320 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 321 | goto buffer_done; |
James Smart | 411de51 | 2018-01-30 15:58:52 -0800 | [diff] [blame] | 322 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 323 | /* Calculate outstanding IOs */ |
| 324 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 325 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 326 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 327 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 328 | scnprintf(tmp, sizeof(tmp), |
| 329 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 330 | "CTX Outstanding %08llx\n\n", |
| 331 | phba->sli4_hba.nvmet_xri_cnt, |
| 332 | phba->sli4_hba.nvmet_io_wait_cnt, |
| 333 | phba->sli4_hba.nvmet_io_wait_total, |
| 334 | tot); |
| 335 | strlcat(buf, tmp, PAGE_SIZE); |
| 336 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 337 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 338 | |
| 339 | localport = vport->localport; |
| 340 | if (!localport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 341 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 342 | "NVME Initiator x%llx is not allocated\n", |
| 343 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 344 | return len; |
| 345 | } |
Colin Ian King | 5c665ae | 2017-12-22 00:28:52 +0000 | [diff] [blame] | 346 | lport = (struct lpfc_nvme_lport *)localport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 347 | if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE) |
| 348 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 349 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 350 | rcu_read_lock(); |
| 351 | scnprintf(tmp, sizeof(tmp), |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 352 | "XRI Dist lpfc%d Total %d IO %d ELS %d\n", |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 353 | phba->brd_no, |
| 354 | phba->sli4_hba.max_cfg_param.max_xri, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 355 | phba->sli4_hba.io_xri_max, |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 356 | lpfc_sli4_get_els_iocb_cnt(phba)); |
| 357 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 358 | goto rcu_unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 359 | |
| 360 | /* Port state is only one of two values for now. */ |
| 361 | if (localport->port_id) |
| 362 | statep = "ONLINE"; |
| 363 | else |
| 364 | statep = "UNKNOWN "; |
| 365 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 366 | scnprintf(tmp, sizeof(tmp), |
| 367 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 368 | "NVME LPORT lpfc", |
| 369 | phba->brd_no, |
| 370 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 371 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 372 | localport->port_id, statep); |
| 373 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 374 | goto rcu_unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 375 | |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 376 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 377 | nrport = NULL; |
James Smart | e2a8be5 | 2019-05-06 17:26:47 -0700 | [diff] [blame] | 378 | spin_lock_irqsave(&vport->phba->hbalock, iflags); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 379 | rport = lpfc_ndlp_get_nrport(ndlp); |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 380 | if (rport) |
| 381 | nrport = rport->remoteport; |
James Smart | e2a8be5 | 2019-05-06 17:26:47 -0700 | [diff] [blame] | 382 | spin_unlock_irqrestore(&vport->phba->hbalock, iflags); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 383 | if (!nrport) |
| 384 | continue; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 385 | |
| 386 | /* Port state is only one of two values for now. */ |
| 387 | switch (nrport->port_state) { |
| 388 | case FC_OBJSTATE_ONLINE: |
| 389 | statep = "ONLINE"; |
| 390 | break; |
| 391 | case FC_OBJSTATE_UNKNOWN: |
| 392 | statep = "UNKNOWN "; |
| 393 | break; |
| 394 | default: |
| 395 | statep = "UNSUPPORTED"; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | /* Tab in to show lport ownership. */ |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 400 | if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 401 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 402 | if (phba->brd_no >= 10) { |
| 403 | if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 404 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 405 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 406 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 407 | scnprintf(tmp, sizeof(tmp), "WWPN x%llx ", |
| 408 | nrport->port_name); |
| 409 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 410 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 411 | |
| 412 | scnprintf(tmp, sizeof(tmp), "WWNN x%llx ", |
| 413 | nrport->node_name); |
| 414 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 415 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 416 | |
| 417 | scnprintf(tmp, sizeof(tmp), "DID x%06x ", |
| 418 | nrport->port_id); |
| 419 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 420 | goto rcu_unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 421 | |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 422 | /* An NVME rport can have multiple roles. */ |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 423 | if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) { |
| 424 | if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 425 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 426 | } |
| 427 | if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) { |
| 428 | if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 429 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 430 | } |
| 431 | if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) { |
| 432 | if (strlcat(buf, "DISCSRVC ", PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 433 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 434 | } |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 435 | if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | |
| 436 | FC_PORT_ROLE_NVME_TARGET | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 437 | FC_PORT_ROLE_NVME_DISCOVERY)) { |
| 438 | scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x", |
| 439 | nrport->port_role); |
| 440 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 441 | goto rcu_unlock_buf_done; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 442 | } |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 443 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 444 | scnprintf(tmp, sizeof(tmp), "%s\n", statep); |
| 445 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 446 | goto rcu_unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 447 | } |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 448 | rcu_read_unlock(); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 449 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 450 | if (!lport) |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 451 | goto buffer_done; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 452 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 453 | if (strlcat(buf, "\nNVME Statistics\n", PAGE_SIZE) >= PAGE_SIZE) |
| 454 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 455 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 456 | scnprintf(tmp, sizeof(tmp), |
| 457 | "LS: Xmt %010x Cmpl %010x Abort %08x\n", |
| 458 | atomic_read(&lport->fc4NvmeLsRequests), |
| 459 | atomic_read(&lport->fc4NvmeLsCmpls), |
| 460 | atomic_read(&lport->xmt_ls_abort)); |
| 461 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 462 | goto buffer_done; |
| 463 | |
| 464 | scnprintf(tmp, sizeof(tmp), |
| 465 | "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n", |
| 466 | atomic_read(&lport->xmt_ls_err), |
| 467 | atomic_read(&lport->cmpl_ls_xb), |
| 468 | atomic_read(&lport->cmpl_ls_err)); |
| 469 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 470 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 471 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 472 | totin = 0; |
| 473 | totout = 0; |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 474 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 475 | cstat = &phba->sli4_hba.hdwq[i].nvme_cstat; |
| 476 | tot = cstat->io_cmpls; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 477 | totin += tot; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 478 | data1 = cstat->input_requests; |
| 479 | data2 = cstat->output_requests; |
| 480 | data3 = cstat->control_requests; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 481 | totout += (data1 + data2 + data3); |
| 482 | } |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 483 | scnprintf(tmp, sizeof(tmp), |
| 484 | "Total FCP Cmpl %016llx Issue %016llx " |
| 485 | "OutIO %016llx\n", |
| 486 | totin, totout, totout - totin); |
| 487 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 488 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 489 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 490 | scnprintf(tmp, sizeof(tmp), |
| 491 | "\tabort %08x noxri %08x nondlp %08x qdepth %08x " |
| 492 | "wqerr %08x err %08x\n", |
| 493 | atomic_read(&lport->xmt_fcp_abort), |
| 494 | atomic_read(&lport->xmt_fcp_noxri), |
| 495 | atomic_read(&lport->xmt_fcp_bad_ndlp), |
| 496 | atomic_read(&lport->xmt_fcp_qdepth), |
| 497 | atomic_read(&lport->xmt_fcp_err), |
| 498 | atomic_read(&lport->xmt_fcp_wqerr)); |
| 499 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 500 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 501 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 502 | scnprintf(tmp, sizeof(tmp), |
| 503 | "FCP CMPL: xb %08x Err %08x\n", |
| 504 | atomic_read(&lport->cmpl_fcp_xb), |
| 505 | atomic_read(&lport->cmpl_fcp_err)); |
| 506 | strlcat(buf, tmp, PAGE_SIZE); |
| 507 | |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 508 | /* RCU is already unlocked. */ |
| 509 | goto buffer_done; |
| 510 | |
| 511 | rcu_unlock_buf_done: |
| 512 | rcu_read_unlock(); |
| 513 | |
| 514 | buffer_done: |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 515 | len = strnlen(buf, PAGE_SIZE); |
| 516 | |
| 517 | if (unlikely(len >= (PAGE_SIZE - 1))) { |
| 518 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME, |
| 519 | "6314 Catching potential buffer " |
| 520 | "overflow > PAGE_SIZE = %lu bytes\n", |
| 521 | PAGE_SIZE); |
| 522 | strlcpy(buf + PAGE_SIZE - 1 - |
| 523 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1), |
| 524 | LPFC_NVME_INFO_MORE_STR, |
| 525 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1) |
| 526 | + 1); |
| 527 | } |
| 528 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 529 | return len; |
| 530 | } |
| 531 | |
| 532 | static ssize_t |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 533 | lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr, |
| 534 | char *buf) |
| 535 | { |
| 536 | struct Scsi_Host *shost = class_to_shost(dev); |
| 537 | struct lpfc_vport *vport = shost_priv(shost); |
| 538 | struct lpfc_hba *phba = vport->phba; |
| 539 | int len; |
| 540 | struct lpfc_fc4_ctrl_stat *cstat; |
| 541 | u64 data1, data2, data3; |
| 542 | u64 tot, totin, totout; |
| 543 | int i; |
| 544 | char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0}; |
| 545 | |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 546 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) || |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 547 | (phba->sli_rev != LPFC_SLI_REV4)) |
| 548 | return 0; |
| 549 | |
| 550 | scnprintf(buf, PAGE_SIZE, "SCSI HDWQ Statistics\n"); |
| 551 | |
| 552 | totin = 0; |
| 553 | totout = 0; |
| 554 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
| 555 | cstat = &phba->sli4_hba.hdwq[i].scsi_cstat; |
| 556 | tot = cstat->io_cmpls; |
| 557 | totin += tot; |
| 558 | data1 = cstat->input_requests; |
| 559 | data2 = cstat->output_requests; |
| 560 | data3 = cstat->control_requests; |
| 561 | totout += (data1 + data2 + data3); |
| 562 | |
| 563 | scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx " |
| 564 | "IO %016llx ", i, data1, data2, data3); |
| 565 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 566 | goto buffer_done; |
| 567 | |
| 568 | scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n", |
| 569 | tot, ((data1 + data2 + data3) - tot)); |
| 570 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 571 | goto buffer_done; |
| 572 | } |
| 573 | scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx " |
| 574 | "OutIO %016llx\n", totin, totout, totout - totin); |
| 575 | strlcat(buf, tmp, PAGE_SIZE); |
| 576 | |
| 577 | buffer_done: |
| 578 | len = strnlen(buf, PAGE_SIZE); |
| 579 | |
| 580 | return len; |
| 581 | } |
| 582 | |
| 583 | static ssize_t |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 584 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 585 | char *buf) |
| 586 | { |
| 587 | struct Scsi_Host *shost = class_to_shost(dev); |
| 588 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 589 | struct lpfc_hba *phba = vport->phba; |
| 590 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 591 | if (phba->cfg_enable_bg) { |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 592 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 593 | return scnprintf(buf, PAGE_SIZE, |
| 594 | "BlockGuard Enabled\n"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 595 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 596 | return scnprintf(buf, PAGE_SIZE, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 597 | "BlockGuard Not Supported\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 598 | } else |
| 599 | return scnprintf(buf, PAGE_SIZE, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 600 | "BlockGuard Disabled\n"); |
| 601 | } |
| 602 | |
| 603 | static ssize_t |
| 604 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 605 | char *buf) |
| 606 | { |
| 607 | struct Scsi_Host *shost = class_to_shost(dev); |
| 608 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 609 | struct lpfc_hba *phba = vport->phba; |
| 610 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 611 | return scnprintf(buf, PAGE_SIZE, "%llu\n", |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 612 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | static ssize_t |
| 616 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 617 | char *buf) |
| 618 | { |
| 619 | struct Scsi_Host *shost = class_to_shost(dev); |
| 620 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 621 | struct lpfc_hba *phba = vport->phba; |
| 622 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 623 | return scnprintf(buf, PAGE_SIZE, "%llu\n", |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 624 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | static ssize_t |
| 628 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 629 | char *buf) |
| 630 | { |
| 631 | struct Scsi_Host *shost = class_to_shost(dev); |
| 632 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 633 | struct lpfc_hba *phba = vport->phba; |
| 634 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 635 | return scnprintf(buf, PAGE_SIZE, "%llu\n", |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 636 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 637 | } |
| 638 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 639 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 640 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 641 | * @dev: class converted to a Scsi_host structure. |
| 642 | * @attr: device attribute, not used. |
| 643 | * @buf: on return contains the formatted text from lpfc_info(). |
| 644 | * |
| 645 | * Returns: size of formatted string. |
| 646 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 647 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 648 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 649 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 650 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 651 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 652 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 653 | return scnprintf(buf, PAGE_SIZE, "%s\n", lpfc_info(host)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 654 | } |
| 655 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 656 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 657 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 658 | * @dev: class converted to a Scsi_host structure. |
| 659 | * @attr: device attribute, not used. |
| 660 | * @buf: on return contains the formatted text serial number. |
| 661 | * |
| 662 | * Returns: size of formatted string. |
| 663 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 664 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 665 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 666 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 667 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 668 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 669 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 670 | struct lpfc_hba *phba = vport->phba; |
| 671 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 672 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->SerialNumber); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 673 | } |
| 674 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 675 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 676 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 677 | * @dev: class converted to a Scsi_host structure. |
| 678 | * @attr: device attribute, not used. |
| 679 | * @buf: on return contains the formatted support level. |
| 680 | * |
| 681 | * Description: |
| 682 | * Returns a number indicating the temperature sensor level currently |
| 683 | * supported, zero or one in ascii. |
| 684 | * |
| 685 | * Returns: size of formatted string. |
| 686 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 687 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 688 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 689 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 690 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 691 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 692 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 693 | struct lpfc_hba *phba = vport->phba; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 694 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->temp_sensor_support); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 695 | } |
| 696 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 697 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 698 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 699 | * @dev: class converted to a Scsi_host structure. |
| 700 | * @attr: device attribute, not used. |
| 701 | * @buf: on return contains the scsi vpd model description. |
| 702 | * |
| 703 | * Returns: size of formatted string. |
| 704 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 705 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 706 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 707 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 708 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 709 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 710 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 711 | struct lpfc_hba *phba = vport->phba; |
| 712 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 713 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelDesc); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 714 | } |
| 715 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 716 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 717 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 718 | * @dev: class converted to a Scsi_host structure. |
| 719 | * @attr: device attribute, not used. |
| 720 | * @buf: on return contains the scsi vpd model name. |
| 721 | * |
| 722 | * Returns: size of formatted string. |
| 723 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 724 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 725 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 726 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 727 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 728 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 729 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 730 | struct lpfc_hba *phba = vport->phba; |
| 731 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 732 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ModelName); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 733 | } |
| 734 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 735 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 736 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 737 | * @dev: class converted to a Scsi_host structure. |
| 738 | * @attr: device attribute, not used. |
| 739 | * @buf: on return contains the scsi vpd program type. |
| 740 | * |
| 741 | * Returns: size of formatted string. |
| 742 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 743 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 744 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 745 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 746 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 747 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 748 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 749 | struct lpfc_hba *phba = vport->phba; |
| 750 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 751 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->ProgramType); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 752 | } |
| 753 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 754 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 755 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 756 | * @dev: class converted to a Scsi_host structure. |
| 757 | * @attr: device attribute, not used. |
| 758 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 759 | * |
| 760 | * Returns: size of formatted string. |
| 761 | **/ |
| 762 | static ssize_t |
| 763 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 764 | { |
| 765 | struct Scsi_Host *shost = class_to_shost(dev); |
| 766 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 767 | struct lpfc_hba *phba = vport->phba; |
| 768 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 769 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 770 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 771 | } |
| 772 | |
| 773 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 774 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 775 | * @dev: class converted to a Scsi_host structure. |
| 776 | * @attr: device attribute, not used. |
| 777 | * @buf: on return contains scsi vpd program type. |
| 778 | * |
| 779 | * Returns: size of formatted string. |
| 780 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 781 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 782 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 783 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 784 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 785 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 786 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 787 | struct lpfc_hba *phba = vport->phba; |
| 788 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 789 | return scnprintf(buf, PAGE_SIZE, "%s\n", phba->Port); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 790 | } |
| 791 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 792 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 793 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 794 | * @dev: class converted to a Scsi_host structure. |
| 795 | * @attr: device attribute, not used. |
| 796 | * @buf: on return contains the scsi vpd program type. |
| 797 | * |
| 798 | * Returns: size of formatted string. |
| 799 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 800 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 801 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 802 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 803 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 804 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 805 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 806 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 807 | uint32_t if_type; |
| 808 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 809 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 810 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 811 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 812 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 813 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 814 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 815 | |
| 816 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 817 | len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 818 | fwrev, phba->sli_rev); |
| 819 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 820 | len = scnprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 821 | fwrev, phba->sli_rev, if_type, sli_family); |
| 822 | |
| 823 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 824 | } |
| 825 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 826 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 827 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 828 | * @dev: class converted to a Scsi_host structure. |
| 829 | * @attr: device attribute, not used. |
| 830 | * @buf: on return contains the scsi vpd program type. |
| 831 | * |
| 832 | * Returns: size of formatted string. |
| 833 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 834 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 835 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 836 | { |
| 837 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 838 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 839 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 840 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 841 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 842 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 843 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 844 | return scnprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 845 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 846 | |
| 847 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 848 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 849 | * @dev: class converted to a Scsi_host structure. |
| 850 | * @attr: device attribute, not used. |
| 851 | * @buf: on return contains the ROM and FCode ascii strings. |
| 852 | * |
| 853 | * Returns: size of formatted string. |
| 854 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 855 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 856 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 857 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 858 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 859 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 860 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 861 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 862 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 863 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 864 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 865 | return scnprintf(buf, PAGE_SIZE, "%s\n", |
| 866 | phba->OptionROMVersion); |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 867 | |
| 868 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 869 | return scnprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 870 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 871 | |
| 872 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 873 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 874 | * @dev: class converted to a Scsi_host structure. |
| 875 | * @attr: device attribute, not used. |
| 876 | * @buf: on return contains text describing the state of the link. |
| 877 | * |
| 878 | * Notes: |
| 879 | * The switch statement has no default so zero will be returned. |
| 880 | * |
| 881 | * Returns: size of formatted string. |
| 882 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 883 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 884 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 885 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 886 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 887 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 888 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 889 | struct lpfc_hba *phba = vport->phba; |
| 890 | int len = 0; |
| 891 | |
| 892 | switch (phba->link_state) { |
| 893 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 894 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 895 | case LPFC_INIT_START: |
| 896 | case LPFC_INIT_MBX_CMDS: |
| 897 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 898 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 899 | if (phba->hba_flag & LINK_DISABLED) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 900 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 901 | "Link Down - User disabled\n"); |
| 902 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 903 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 904 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 905 | break; |
| 906 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 907 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 908 | case LPFC_HBA_READY: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 909 | len += scnprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 910 | |
| 911 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 912 | case LPFC_LOCAL_CFG_LINK: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 913 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 914 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 915 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 916 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 917 | case LPFC_FLOGI: |
| 918 | case LPFC_FABRIC_CFG_LINK: |
| 919 | case LPFC_NS_REG: |
| 920 | case LPFC_NS_QRY: |
| 921 | case LPFC_BUILD_DISC_LIST: |
| 922 | case LPFC_DISC_AUTH: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 923 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 924 | "Discovery\n"); |
| 925 | break; |
| 926 | case LPFC_VPORT_READY: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 927 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 928 | "Ready\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 929 | break; |
| 930 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 931 | case LPFC_VPORT_FAILED: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 932 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 933 | "Failed\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 934 | break; |
| 935 | |
| 936 | case LPFC_VPORT_UNKNOWN: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 937 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 938 | "Unknown\n"); |
| 939 | break; |
| 940 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 941 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 942 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 943 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 944 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 945 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 946 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 947 | " Public Loop\n"); |
| 948 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 949 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 950 | " Private Loop\n"); |
| 951 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 952 | if (vport->fc_flag & FC_FABRIC) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 953 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 954 | " Fabric\n"); |
| 955 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 956 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 957 | " Point-2-Point\n"); |
| 958 | } |
| 959 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 960 | |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 961 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 962 | ((bf_get(lpfc_sli_intf_if_type, |
| 963 | &phba->sli4_hba.sli_intf) == |
| 964 | LPFC_SLI_INTF_IF_TYPE_6))) { |
| 965 | struct lpfc_trunk_link link = phba->trunk_link; |
| 966 | |
| 967 | if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 968 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 969 | "Trunk port 0: Link %s %s\n", |
| 970 | (link.link0.state == LPFC_LINK_UP) ? |
| 971 | "Up" : "Down. ", |
| 972 | trunk_errmsg[link.link0.fault]); |
| 973 | |
| 974 | if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 975 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 976 | "Trunk port 1: Link %s %s\n", |
| 977 | (link.link1.state == LPFC_LINK_UP) ? |
| 978 | "Up" : "Down. ", |
| 979 | trunk_errmsg[link.link1.fault]); |
| 980 | |
| 981 | if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 982 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 983 | "Trunk port 2: Link %s %s\n", |
| 984 | (link.link2.state == LPFC_LINK_UP) ? |
| 985 | "Up" : "Down. ", |
| 986 | trunk_errmsg[link.link2.fault]); |
| 987 | |
| 988 | if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 989 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 990 | "Trunk port 3: Link %s %s\n", |
| 991 | (link.link3.state == LPFC_LINK_UP) ? |
| 992 | "Up" : "Down. ", |
| 993 | trunk_errmsg[link.link3.fault]); |
| 994 | |
| 995 | } |
| 996 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 997 | return len; |
| 998 | } |
| 999 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1000 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1001 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 1002 | * @dev: class unused variable. |
| 1003 | * @attr: device attribute, not used. |
| 1004 | * @buf: on return contains the module description text. |
| 1005 | * |
| 1006 | * Returns: size of formatted string. |
| 1007 | **/ |
| 1008 | static ssize_t |
| 1009 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 1010 | char *buf) |
| 1011 | { |
| 1012 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1013 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1014 | struct lpfc_hba *phba = vport->phba; |
| 1015 | |
| 1016 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1017 | return scnprintf(buf, PAGE_SIZE, "fc\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1018 | |
| 1019 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 1020 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1021 | return scnprintf(buf, PAGE_SIZE, "fcoe\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1022 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1023 | return scnprintf(buf, PAGE_SIZE, "fc\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1024 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1025 | return scnprintf(buf, PAGE_SIZE, "unknown\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1029 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 1030 | * (OAS) is supported. |
| 1031 | * @dev: class unused variable. |
| 1032 | * @attr: device attribute, not used. |
| 1033 | * @buf: on return contains the module description text. |
| 1034 | * |
| 1035 | * Returns: size of formatted string. |
| 1036 | **/ |
| 1037 | static ssize_t |
| 1038 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 1039 | char *buf) |
| 1040 | { |
| 1041 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1042 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 1043 | struct lpfc_hba *phba = vport->phba; |
| 1044 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1045 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1046 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 1047 | } |
| 1048 | |
| 1049 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1050 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 1051 | * @dev: class device that is converted into a Scsi_host. |
| 1052 | * @attr: device attribute, not used. |
| 1053 | * @buf: one or more lpfc_polling_flags values. |
| 1054 | * @count: not used. |
| 1055 | * |
| 1056 | * Returns: |
| 1057 | * -EINVAL if the buffer is not "up" or "down" |
| 1058 | * return from link state change function if non-zero |
| 1059 | * length of the buf on success |
| 1060 | **/ |
| 1061 | static ssize_t |
| 1062 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 1063 | const char *buf, size_t count) |
| 1064 | { |
| 1065 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1066 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1067 | struct lpfc_hba *phba = vport->phba; |
| 1068 | |
| 1069 | int status = -EINVAL; |
| 1070 | |
| 1071 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 1072 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1073 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1074 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 1075 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1076 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1077 | |
| 1078 | if (status == 0) |
| 1079 | return strlen(buf); |
| 1080 | else |
| 1081 | return status; |
| 1082 | } |
| 1083 | |
| 1084 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1085 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1086 | * @dev: class device that is converted into a Scsi_host. |
| 1087 | * @attr: device attribute, not used. |
| 1088 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 1089 | * |
| 1090 | * Description: |
| 1091 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 1092 | * vport counts. |
| 1093 | * |
| 1094 | * Returns: size of formatted string. |
| 1095 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1096 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1097 | lpfc_num_discovered_ports_show(struct device *dev, |
| 1098 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1099 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1100 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1101 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1102 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1103 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1104 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1105 | } |
| 1106 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1107 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1108 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1109 | * @shost: Scsi_Host pointer. |
| 1110 | * |
| 1111 | * Description: |
| 1112 | * Bring the link down gracefully then re-init the link. The firmware will |
| 1113 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 1114 | * |
| 1115 | * Returns: |
| 1116 | * -EPERM port offline or management commands are being blocked |
| 1117 | * -ENOMEM cannot allocate memory for the mailbox command |
| 1118 | * -EIO error sending the mailbox command |
| 1119 | * zero for success |
| 1120 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1121 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1122 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1123 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1124 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1125 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1126 | LPFC_MBOXQ_t *pmboxq; |
| 1127 | int mbxstatus = MBXERR_ERROR; |
| 1128 | |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1129 | /* |
| 1130 | * If the link is offline, disabled or BLOCK_MGMT_IO |
| 1131 | * it doesn't make any sense to allow issue_lip |
| 1132 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1133 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1134 | (phba->hba_flag & LINK_DISABLED) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 1135 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1136 | return -EPERM; |
| 1137 | |
| 1138 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 1139 | |
| 1140 | if (!pmboxq) |
| 1141 | return -ENOMEM; |
| 1142 | |
| 1143 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1144 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 1145 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1146 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 1147 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1148 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1149 | if ((mbxstatus == MBX_SUCCESS) && |
| 1150 | (pmboxq->u.mb.mbxStatus == 0 || |
| 1151 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1152 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1153 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 1154 | phba->cfg_link_speed); |
| 1155 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 1156 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 1157 | if ((mbxstatus == MBX_SUCCESS) && |
| 1158 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 1159 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 1160 | "2859 SLI authentication is required " |
| 1161 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1162 | } |
| 1163 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 1164 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1165 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1166 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1167 | |
| 1168 | if (mbxstatus == MBXERR_ERROR) |
| 1169 | return -EIO; |
| 1170 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1171 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1172 | } |
| 1173 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1174 | int |
| 1175 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 1176 | { |
| 1177 | int cnt = 0; |
| 1178 | |
| 1179 | spin_lock_irq(lock); |
| 1180 | while (!list_empty(q)) { |
| 1181 | spin_unlock_irq(lock); |
| 1182 | msleep(20); |
| 1183 | if (cnt++ > 250) { /* 5 secs */ |
| 1184 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 1185 | "0466 %s %s\n", |
| 1186 | "Outstanding IO when ", |
| 1187 | "bringing Adapter offline\n"); |
| 1188 | return 0; |
| 1189 | } |
| 1190 | spin_lock_irq(lock); |
| 1191 | } |
| 1192 | spin_unlock_irq(lock); |
| 1193 | return 1; |
| 1194 | } |
| 1195 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1196 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1197 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1198 | * @phba: lpfc_hba pointer. |
| 1199 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 1200 | * |
| 1201 | * Notes: |
| 1202 | * Assumes any error from lpfc_do_offline() will be negative. |
| 1203 | * Can wait up to 5 seconds for the port ring buffers count |
| 1204 | * 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] | 1205 | * 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] | 1206 | * |
| 1207 | * Returns: |
| 1208 | * -EIO error posting the event |
| 1209 | * zero for success |
| 1210 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1211 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1212 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 1213 | { |
| 1214 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1215 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1216 | struct lpfc_sli_ring *pring; |
| 1217 | struct lpfc_sli *psli; |
| 1218 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1219 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1220 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1221 | |
| 1222 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1223 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1224 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1225 | if (rc == 0) |
| 1226 | return -ENOMEM; |
| 1227 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1228 | wait_for_completion(&online_compl); |
| 1229 | |
| 1230 | if (status != 0) |
| 1231 | return -EIO; |
| 1232 | |
| 1233 | psli = &phba->sli; |
| 1234 | |
James Smart | 4645f7b | 2019-03-12 16:30:14 -0700 | [diff] [blame] | 1235 | /* |
| 1236 | * If freeing the queues have already started, don't access them. |
| 1237 | * Otherwise set FREE_WAIT to indicate that queues are being used |
| 1238 | * to hold the freeing process until we finish. |
| 1239 | */ |
| 1240 | spin_lock_irq(&phba->hbalock); |
| 1241 | if (!(psli->sli_flag & LPFC_QUEUE_FREE_INIT)) { |
| 1242 | psli->sli_flag |= LPFC_QUEUE_FREE_WAIT; |
| 1243 | } else { |
| 1244 | spin_unlock_irq(&phba->hbalock); |
| 1245 | goto skip_wait; |
| 1246 | } |
| 1247 | spin_unlock_irq(&phba->hbalock); |
| 1248 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1249 | /* Wait a little for things to settle down, but not |
| 1250 | * long enough for dev loss timeout to expire. |
| 1251 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1252 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 1253 | for (i = 0; i < psli->num_rings; i++) { |
| 1254 | pring = &psli->sli3_ring[i]; |
| 1255 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1256 | &phba->hbalock)) |
| 1257 | goto out; |
| 1258 | } |
| 1259 | } else { |
| 1260 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 1261 | pring = qp->pring; |
| 1262 | if (!pring) |
| 1263 | continue; |
| 1264 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1265 | &pring->ring_lock)) |
| 1266 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1267 | } |
| 1268 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1269 | out: |
James Smart | 4645f7b | 2019-03-12 16:30:14 -0700 | [diff] [blame] | 1270 | spin_lock_irq(&phba->hbalock); |
| 1271 | psli->sli_flag &= ~LPFC_QUEUE_FREE_WAIT; |
| 1272 | spin_unlock_irq(&phba->hbalock); |
| 1273 | |
| 1274 | skip_wait: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1275 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1276 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 1277 | if (rc == 0) |
| 1278 | return -ENOMEM; |
| 1279 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1280 | wait_for_completion(&online_compl); |
| 1281 | |
| 1282 | if (status != 0) |
| 1283 | return -EIO; |
| 1284 | |
| 1285 | return 0; |
| 1286 | } |
| 1287 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1288 | /** |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1289 | * lpfc_reset_pci_bus - resets PCI bridge controller's secondary bus of an HBA |
| 1290 | * @phba: lpfc_hba pointer. |
| 1291 | * |
| 1292 | * Description: |
| 1293 | * Issues a PCI secondary bus reset for the phba->pcidev. |
| 1294 | * |
| 1295 | * Notes: |
| 1296 | * First walks the bus_list to ensure only PCI devices with Emulex |
| 1297 | * vendor id, device ids that support hot reset, only one occurrence |
| 1298 | * of function 0, and all ports on the bus are in offline mode to ensure the |
| 1299 | * hot reset only affects one valid HBA. |
| 1300 | * |
| 1301 | * Returns: |
| 1302 | * -ENOTSUPP, cfg_enable_hba_reset must be of value 2 |
| 1303 | * -ENODEV, NULL ptr to pcidev |
| 1304 | * -EBADSLT, detected invalid device |
| 1305 | * -EBUSY, port is not in offline state |
| 1306 | * 0, successful |
| 1307 | */ |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 1308 | static int |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1309 | lpfc_reset_pci_bus(struct lpfc_hba *phba) |
| 1310 | { |
| 1311 | struct pci_dev *pdev = phba->pcidev; |
| 1312 | struct Scsi_Host *shost = NULL; |
| 1313 | struct lpfc_hba *phba_other = NULL; |
| 1314 | struct pci_dev *ptr = NULL; |
| 1315 | int res; |
| 1316 | |
| 1317 | if (phba->cfg_enable_hba_reset != 2) |
| 1318 | return -ENOTSUPP; |
| 1319 | |
| 1320 | if (!pdev) { |
| 1321 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "8345 pdev NULL!\n"); |
| 1322 | return -ENODEV; |
| 1323 | } |
| 1324 | |
| 1325 | res = lpfc_check_pci_resettable(phba); |
| 1326 | if (res) |
| 1327 | return res; |
| 1328 | |
| 1329 | /* Walk the list of devices on the pci_dev's bus */ |
| 1330 | list_for_each_entry(ptr, &pdev->bus->devices, bus_list) { |
| 1331 | /* Check port is offline */ |
| 1332 | shost = pci_get_drvdata(ptr); |
| 1333 | if (shost) { |
| 1334 | phba_other = |
| 1335 | ((struct lpfc_vport *)shost->hostdata)->phba; |
| 1336 | if (!(phba_other->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1337 | lpfc_printf_log(phba_other, KERN_INFO, LOG_INIT, |
| 1338 | "8349 WWPN = 0x%02x%02x%02x%02x" |
| 1339 | "%02x%02x%02x%02x is not " |
| 1340 | "offline!\n", |
| 1341 | phba_other->wwpn[0], |
| 1342 | phba_other->wwpn[1], |
| 1343 | phba_other->wwpn[2], |
| 1344 | phba_other->wwpn[3], |
| 1345 | phba_other->wwpn[4], |
| 1346 | phba_other->wwpn[5], |
| 1347 | phba_other->wwpn[6], |
| 1348 | phba_other->wwpn[7]); |
| 1349 | return -EBUSY; |
| 1350 | } |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | /* Issue PCI bus reset */ |
| 1355 | res = pci_reset_bus(pdev); |
| 1356 | if (res) { |
| 1357 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1358 | "8350 PCI reset bus failed: %d\n", res); |
| 1359 | } |
| 1360 | |
| 1361 | return res; |
| 1362 | } |
| 1363 | |
| 1364 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1365 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1366 | * @phba: lpfc_hba pointer. |
| 1367 | * |
| 1368 | * Description: |
| 1369 | * If the port is configured to allow a reset then the hba is brought |
| 1370 | * offline then online. |
| 1371 | * |
| 1372 | * Notes: |
| 1373 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1374 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1375 | * |
| 1376 | * Returns: |
| 1377 | * lpfc_do_offline() return code if not zero |
| 1378 | * -EIO reset not configured or error posting the event |
| 1379 | * zero for success |
| 1380 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1381 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1382 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1383 | { |
| 1384 | struct completion online_compl; |
| 1385 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1386 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1387 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1388 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1389 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1390 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1391 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1392 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1393 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1394 | if (status != 0) |
| 1395 | return status; |
| 1396 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1397 | |
| 1398 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1399 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1400 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1401 | if (rc == 0) |
| 1402 | return -ENOMEM; |
| 1403 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1404 | wait_for_completion(&online_compl); |
| 1405 | |
| 1406 | if (status != 0) |
| 1407 | return -EIO; |
| 1408 | |
| 1409 | return 0; |
| 1410 | } |
| 1411 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1412 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1413 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1414 | * @dev: class device that is converted into a Scsi_host. |
| 1415 | * @attr: device attribute, not used. |
| 1416 | * @buf: containing the string "selective". |
| 1417 | * @count: unused variable. |
| 1418 | * |
| 1419 | * Description: |
| 1420 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1421 | * is called to perform the reset. |
| 1422 | * |
| 1423 | * Notes: |
| 1424 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1425 | * 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] | 1426 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1427 | * |
| 1428 | * Returns: |
| 1429 | * -EINVAL if the buffer does not contain the string "selective" |
| 1430 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1431 | * return value of lpfc_selective_reset() if the call fails |
| 1432 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1433 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1434 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1435 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1436 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1437 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1438 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1439 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1440 | int status = -EINVAL; |
| 1441 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1442 | if (!phba->cfg_enable_hba_reset) |
| 1443 | return -EACCES; |
| 1444 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1445 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1446 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1447 | |
| 1448 | if (status == 0) |
| 1449 | return strlen(buf); |
| 1450 | else |
| 1451 | return status; |
| 1452 | } |
| 1453 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1454 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1455 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1456 | * @phba: lpfc_hba pointer. |
| 1457 | * |
| 1458 | * Description: |
| 1459 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1460 | * the readyness after performing a firmware reset. |
| 1461 | * |
| 1462 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1463 | * 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] | 1464 | * reset, -EIO when port timeout from recovering from the reset. |
| 1465 | * |
| 1466 | * Note: |
| 1467 | * As the caller will interpret the return code by value, be careful in making |
| 1468 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1469 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1470 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1471 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1472 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1473 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1474 | int i; |
| 1475 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1476 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1477 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1478 | &portstat_reg.word0); |
| 1479 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1480 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1481 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1482 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1483 | return -EPERM; |
| 1484 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1485 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1486 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1487 | msleep(10); |
| 1488 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1489 | &portstat_reg.word0); |
| 1490 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1491 | continue; |
| 1492 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1493 | continue; |
| 1494 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1495 | continue; |
| 1496 | break; |
| 1497 | } |
| 1498 | |
| 1499 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1500 | return 0; |
| 1501 | else |
| 1502 | return -EIO; |
| 1503 | } |
| 1504 | |
| 1505 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1506 | * 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] | 1507 | * @phba: lpfc_hba pointer. |
| 1508 | * |
| 1509 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1510 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1511 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1512 | * |
| 1513 | * Returns: |
| 1514 | * zero for success |
| 1515 | **/ |
| 1516 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1517 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1518 | { |
| 1519 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1520 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1521 | uint32_t before_fc_flag; |
| 1522 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1523 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1524 | int status = 0, rc = 0; |
| 1525 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1526 | |
| 1527 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1528 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1529 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1530 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame] | 1531 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1532 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1533 | return -EPERM; |
| 1534 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1535 | /* Keep state if we need to restore back */ |
| 1536 | before_fc_flag = phba->pport->fc_flag; |
| 1537 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1538 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1539 | /* Disable SR-IOV virtual functions if enabled */ |
| 1540 | if (phba->cfg_sriov_nr_virtfn) { |
| 1541 | pci_disable_sriov(pdev); |
| 1542 | phba->cfg_sriov_nr_virtfn = 0; |
| 1543 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1544 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1545 | if (opcode == LPFC_FW_DUMP) |
| 1546 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1547 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1548 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1549 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1550 | if (status != 0) { |
| 1551 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1552 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1553 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1554 | |
| 1555 | /* wait for the device to be quiesced before firmware reset */ |
| 1556 | msleep(100); |
| 1557 | |
| 1558 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1559 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1560 | |
| 1561 | if (opcode == LPFC_FW_DUMP) |
| 1562 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1563 | else if (opcode == LPFC_FW_RESET) |
| 1564 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1565 | else if (opcode == LPFC_DV_RESET) |
| 1566 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1567 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1568 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1569 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1570 | /* flush */ |
| 1571 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1572 | |
| 1573 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1574 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1575 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1576 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1577 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1578 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1579 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1580 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1581 | } else if (rc == -EIO) { |
| 1582 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1583 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1584 | "3153 Fail to perform the requested " |
| 1585 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1586 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | /* keep the original port state */ |
| 1590 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1591 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1592 | |
| 1593 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1594 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1595 | LPFC_EVT_ONLINE); |
| 1596 | if (!job_posted) |
| 1597 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1598 | |
| 1599 | wait_for_completion(&online_compl); |
| 1600 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1601 | out: |
| 1602 | /* in any case, restore the virtual functions enabled as before */ |
| 1603 | if (sriov_nr_virtfn) { |
| 1604 | sriov_err = |
| 1605 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1606 | if (!sriov_err) |
| 1607 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1608 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1609 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1610 | /* return proper error code */ |
| 1611 | if (!rc) { |
| 1612 | if (!job_posted) |
| 1613 | rc = -ENOMEM; |
| 1614 | else if (status) |
| 1615 | rc = -EIO; |
| 1616 | } |
| 1617 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1618 | } |
| 1619 | |
| 1620 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1621 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1622 | * @dev: class device that is converted into a Scsi_host. |
| 1623 | * @attr: device attribute, not used. |
| 1624 | * @buf: on return contains the ascii number of nport events. |
| 1625 | * |
| 1626 | * Returns: size of formatted string. |
| 1627 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1628 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1629 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1630 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1631 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1632 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1633 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1634 | struct lpfc_hba *phba = vport->phba; |
| 1635 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1636 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1637 | } |
| 1638 | |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 1639 | static int |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1640 | lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out) |
| 1641 | { |
| 1642 | LPFC_MBOXQ_t *mbox = NULL; |
| 1643 | unsigned long val = 0; |
| 1644 | char *pval = 0; |
| 1645 | int rc = 0; |
| 1646 | |
| 1647 | if (!strncmp("enable", buff_out, |
| 1648 | strlen("enable"))) { |
| 1649 | pval = buff_out + strlen("enable") + 1; |
| 1650 | rc = kstrtoul(pval, 0, &val); |
| 1651 | if (rc) |
| 1652 | return rc; /* Invalid number */ |
| 1653 | } else if (!strncmp("disable", buff_out, |
| 1654 | strlen("disable"))) { |
| 1655 | val = 0; |
| 1656 | } else { |
| 1657 | return -EINVAL; /* Invalid command */ |
| 1658 | } |
| 1659 | |
| 1660 | switch (val) { |
| 1661 | case 0: |
| 1662 | val = 0x0; /* Disable */ |
| 1663 | break; |
| 1664 | case 2: |
| 1665 | val = 0x1; /* Enable two port trunk */ |
| 1666 | break; |
| 1667 | case 4: |
| 1668 | val = 0x2; /* Enable four port trunk */ |
| 1669 | break; |
| 1670 | default: |
| 1671 | return -EINVAL; |
| 1672 | } |
| 1673 | |
| 1674 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1675 | "0070 Set trunk mode with val %ld ", val); |
| 1676 | |
| 1677 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1678 | if (!mbox) |
| 1679 | return -ENOMEM; |
| 1680 | |
| 1681 | lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE, |
| 1682 | LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE, |
| 1683 | 12, LPFC_SLI4_MBX_EMBED); |
| 1684 | |
| 1685 | bf_set(lpfc_mbx_set_trunk_mode, |
| 1686 | &mbox->u.mqe.un.set_trunk_mode, |
| 1687 | val); |
| 1688 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); |
| 1689 | if (rc) |
| 1690 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1691 | "0071 Set trunk mode failed with status: %d", |
| 1692 | rc); |
| 1693 | if (rc != MBX_TIMEOUT) |
| 1694 | mempool_free(mbox, phba->mbox_mem_pool); |
| 1695 | |
| 1696 | return 0; |
| 1697 | } |
| 1698 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1699 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1700 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1701 | * @dev: class device that is converted into a Scsi_host. |
| 1702 | * @attr: device attribute, not used. |
| 1703 | * @buf: on return contains the state of the adapter. |
| 1704 | * |
| 1705 | * Returns: size of formatted string. |
| 1706 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1707 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1708 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1709 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1710 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1711 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1712 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1713 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1714 | char * state; |
| 1715 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1716 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1717 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1718 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1719 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1720 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1721 | state = "offline"; |
| 1722 | else |
| 1723 | state = "online"; |
| 1724 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1725 | return scnprintf(buf, PAGE_SIZE, "%s\n", state); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1726 | } |
| 1727 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1728 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1729 | * 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] | 1730 | * @dev: class device that is converted into a Scsi_host. |
| 1731 | * @attr: device attribute, not used. |
| 1732 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1733 | * @count: unused variable. |
| 1734 | * |
| 1735 | * Returns: |
| 1736 | * -EACCES if enable hba reset not enabled |
| 1737 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1738 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1739 | * buf length greater than zero indicates success |
| 1740 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1741 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1742 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1743 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1744 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1745 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1746 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1747 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1748 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1749 | char *board_mode_str = NULL; |
| 1750 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1751 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1752 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1753 | if (!phba->cfg_enable_hba_reset) { |
| 1754 | status = -EACCES; |
| 1755 | goto board_mode_out; |
| 1756 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1757 | |
| 1758 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1759 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1760 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1761 | init_completion(&online_compl); |
| 1762 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1763 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1764 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1765 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1766 | if (rc == 0) { |
| 1767 | status = -ENOMEM; |
| 1768 | goto board_mode_out; |
| 1769 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1770 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1771 | if (status) |
| 1772 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1773 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1774 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1775 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1776 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1777 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1778 | else |
| 1779 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1780 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1781 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1782 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1783 | else |
| 1784 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1785 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1786 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1787 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1788 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1789 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1790 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1791 | else if (strncmp(buf, "pci_bus_reset", sizeof("pci_bus_reset") - 1) |
| 1792 | == 0) |
| 1793 | status = lpfc_reset_pci_bus(phba); |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1794 | else if (strncmp(buf, "trunk", sizeof("trunk") - 1) == 0) |
| 1795 | status = lpfc_set_trunking(phba, (char *)buf + sizeof("trunk")); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1796 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1797 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1798 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1799 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1800 | if (!status) |
| 1801 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1802 | else { |
| 1803 | board_mode_str = strchr(buf, '\n'); |
| 1804 | if (board_mode_str) |
| 1805 | *board_mode_str = '\0'; |
| 1806 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1807 | "3097 Failed \"%s\", status(%d), " |
| 1808 | "fc_flag(x%x)\n", |
| 1809 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1810 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1811 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1812 | } |
| 1813 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1814 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1815 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1816 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1817 | * @mxri: max xri count. |
| 1818 | * @axri: available xri count. |
| 1819 | * @mrpi: max rpi count. |
| 1820 | * @arpi: available rpi count. |
| 1821 | * @mvpi: max vpi count. |
| 1822 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1823 | * |
| 1824 | * Description: |
| 1825 | * If an integer pointer for an count is not null then the value for the |
| 1826 | * count is returned. |
| 1827 | * |
| 1828 | * Returns: |
| 1829 | * zero on error |
| 1830 | * one for success |
| 1831 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1832 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1833 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1834 | uint32_t *mxri, uint32_t *axri, |
| 1835 | uint32_t *mrpi, uint32_t *arpi, |
| 1836 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1837 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1838 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1839 | LPFC_MBOXQ_t *pmboxq; |
| 1840 | MAILBOX_t *pmb; |
| 1841 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1842 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1843 | |
| 1844 | /* |
| 1845 | * prevent udev from issuing mailbox commands until the port is |
| 1846 | * configured. |
| 1847 | */ |
| 1848 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1849 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1850 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1851 | return 0; |
| 1852 | |
| 1853 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1854 | return 0; |
| 1855 | |
| 1856 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1857 | if (!pmboxq) |
| 1858 | return 0; |
| 1859 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1860 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1861 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1862 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1863 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 1864 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1865 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1866 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1867 | rc = MBX_NOT_FINISHED; |
| 1868 | else |
| 1869 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1870 | |
| 1871 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1872 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1873 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1874 | return 0; |
| 1875 | } |
| 1876 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1877 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1878 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1879 | if (mrpi) |
| 1880 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1881 | if (arpi) |
| 1882 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1883 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1884 | if (mxri) |
| 1885 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1886 | if (axri) |
| 1887 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1888 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1889 | |
| 1890 | /* Account for differences with SLI-3. Get vpi count from |
| 1891 | * mailbox data and subtract one for max vpi value. |
| 1892 | */ |
| 1893 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1894 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1895 | |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 1896 | /* Limit the max we support */ |
| 1897 | if (max_vpi > LPFC_MAX_VPI) |
| 1898 | max_vpi = LPFC_MAX_VPI; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1899 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1900 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1901 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1902 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1903 | } else { |
| 1904 | if (mrpi) |
| 1905 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1906 | if (arpi) |
| 1907 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1908 | if (mxri) |
| 1909 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1910 | if (axri) |
| 1911 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1912 | if (mvpi) |
| 1913 | *mvpi = pmb->un.varRdConfig.max_vpi; |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 1914 | if (avpi) { |
| 1915 | /* avail_vpi is only valid if link is up and ready */ |
| 1916 | if (phba->link_state == LPFC_HBA_READY) |
| 1917 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1918 | else |
| 1919 | *avpi = pmb->un.varRdConfig.max_vpi; |
| 1920 | } |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1921 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1922 | |
| 1923 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1924 | return 1; |
| 1925 | } |
| 1926 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1927 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1928 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1929 | * @dev: class device that is converted into a Scsi_host. |
| 1930 | * @attr: device attribute, not used. |
| 1931 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1932 | * |
| 1933 | * Description: |
| 1934 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1935 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1936 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1937 | * must check for "Unknown" in the buffer to detect a failure. |
| 1938 | * |
| 1939 | * Returns: size of formatted string. |
| 1940 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1941 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1942 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1943 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1944 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1945 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1946 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1947 | struct lpfc_hba *phba = vport->phba; |
| 1948 | uint32_t cnt; |
| 1949 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1950 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1951 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1952 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1953 | } |
| 1954 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1955 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1956 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1957 | * @dev: class device that is converted into a Scsi_host. |
| 1958 | * @attr: device attribute, not used. |
| 1959 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1960 | * |
| 1961 | * Description: |
| 1962 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1963 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1964 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1965 | * must check for "Unknown" in the buffer to detect a failure. |
| 1966 | * |
| 1967 | * Returns: size of formatted string. |
| 1968 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1969 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1970 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1971 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1972 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1973 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1974 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1975 | struct lpfc_hba *phba = vport->phba; |
| 1976 | uint32_t cnt, acnt; |
| 1977 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1978 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1979 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1980 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1981 | } |
| 1982 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1983 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1984 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1985 | * @dev: class device that is converted into a Scsi_host. |
| 1986 | * @attr: device attribute, not used. |
| 1987 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1988 | * |
| 1989 | * Description: |
| 1990 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1991 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1992 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1993 | * must check for "Unknown" in the buffer to detect a failure. |
| 1994 | * |
| 1995 | * Returns: size of formatted string. |
| 1996 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1997 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1998 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1999 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2000 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2001 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2002 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2003 | struct lpfc_hba *phba = vport->phba; |
| 2004 | uint32_t cnt; |
| 2005 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2006 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2007 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2008 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2009 | } |
| 2010 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2011 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2012 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2013 | * @dev: class device that is converted into a Scsi_host. |
| 2014 | * @attr: device attribute, not used. |
| 2015 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 2016 | * |
| 2017 | * Description: |
| 2018 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 2019 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2020 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2021 | * must check for "Unknown" in the buffer to detect a failure. |
| 2022 | * |
| 2023 | * Returns: size of formatted string. |
| 2024 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2025 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2026 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 2027 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2028 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2029 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2030 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2031 | struct lpfc_hba *phba = vport->phba; |
| 2032 | uint32_t cnt, acnt; |
| 2033 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2034 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2035 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2036 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2037 | } |
| 2038 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2039 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2040 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2041 | * @dev: class device that is converted into a Scsi_host. |
| 2042 | * @attr: device attribute, not used. |
| 2043 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 2044 | * |
| 2045 | * Description: |
| 2046 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 2047 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2048 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2049 | * must check for "Unknown" in the buffer to detect a failure. |
| 2050 | * |
| 2051 | * Returns: size of formatted string. |
| 2052 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2053 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2054 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 2055 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2056 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2057 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2058 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2059 | struct lpfc_hba *phba = vport->phba; |
| 2060 | uint32_t cnt; |
| 2061 | |
| 2062 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2063 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2064 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2065 | } |
| 2066 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2067 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2068 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2069 | * @dev: class device that is converted into a Scsi_host. |
| 2070 | * @attr: device attribute, not used. |
| 2071 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 2072 | * |
| 2073 | * Description: |
| 2074 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 2075 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2076 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2077 | * must check for "Unknown" in the buffer to detect a failure. |
| 2078 | * |
| 2079 | * Returns: size of formatted string. |
| 2080 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2081 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2082 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 2083 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2084 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2085 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2086 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2087 | struct lpfc_hba *phba = vport->phba; |
| 2088 | uint32_t cnt, acnt; |
| 2089 | |
| 2090 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2091 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2092 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2093 | } |
| 2094 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2095 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2096 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2097 | * @dev: class device that is converted into a Scsi_host. |
| 2098 | * @attr: device attribute, not used. |
| 2099 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 2100 | * |
| 2101 | * Description: |
| 2102 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 2103 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 2104 | * the id of the vport. |
| 2105 | * |
| 2106 | * Returns: size of formatted string. |
| 2107 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2108 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2109 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 2110 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2111 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2112 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2113 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2114 | struct lpfc_hba *phba = vport->phba; |
| 2115 | |
| 2116 | if (!(phba->max_vpi)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2117 | return scnprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2118 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2119 | return scnprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 2120 | return scnprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2121 | } |
| 2122 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2123 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2124 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2125 | * @dev: class device that is converted into a Scsi_host. |
| 2126 | * @attr: device attribute, not used. |
| 2127 | * @buf: on return contains the cfg_poll in hex. |
| 2128 | * |
| 2129 | * Notes: |
| 2130 | * cfg_poll should be a lpfc_polling_flags type. |
| 2131 | * |
| 2132 | * Returns: size of formatted string. |
| 2133 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 2134 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2135 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 2136 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2137 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2138 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2139 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2140 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2141 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2142 | return scnprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2143 | } |
| 2144 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2145 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2146 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2147 | * @dev: class device that is converted into a Scsi_host. |
| 2148 | * @attr: device attribute, not used. |
| 2149 | * @buf: one or more lpfc_polling_flags values. |
| 2150 | * @count: not used. |
| 2151 | * |
| 2152 | * Notes: |
| 2153 | * buf contents converted to integer and checked for a valid value. |
| 2154 | * |
| 2155 | * Returns: |
| 2156 | * -EINVAL if the buffer connot be converted or is out of range |
| 2157 | * length of the buf on success |
| 2158 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2159 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2160 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 2161 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2162 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2163 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2164 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2165 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2166 | uint32_t creg_val; |
| 2167 | uint32_t old_val; |
| 2168 | int val=0; |
| 2169 | |
| 2170 | if (!isdigit(buf[0])) |
| 2171 | return -EINVAL; |
| 2172 | |
| 2173 | if (sscanf(buf, "%i", &val) != 1) |
| 2174 | return -EINVAL; |
| 2175 | |
| 2176 | if ((val & 0x3) != val) |
| 2177 | return -EINVAL; |
| 2178 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 2179 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 2180 | val = 0; |
| 2181 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2182 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2183 | "3051 lpfc_poll changed from %d to %d\n", |
| 2184 | phba->cfg_poll, val); |
| 2185 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2186 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2187 | |
| 2188 | old_val = phba->cfg_poll; |
| 2189 | |
| 2190 | if (val & ENABLE_FCP_RING_POLLING) { |
| 2191 | if ((val & DISABLE_FCP_RING_INT) && |
| 2192 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2193 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2194 | spin_unlock_irq(&phba->hbalock); |
| 2195 | return -EINVAL; |
| 2196 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2197 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 2198 | writel(creg_val, phba->HCregaddr); |
| 2199 | readl(phba->HCregaddr); /* flush */ |
| 2200 | |
| 2201 | lpfc_poll_start_timer(phba); |
| 2202 | } |
| 2203 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2204 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2205 | return -EINVAL; |
| 2206 | } |
| 2207 | |
| 2208 | if (!(val & DISABLE_FCP_RING_INT) && |
| 2209 | (old_val & DISABLE_FCP_RING_INT)) |
| 2210 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2211 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2212 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2213 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2214 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2215 | spin_unlock_irq(&phba->hbalock); |
| 2216 | return -EINVAL; |
| 2217 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2218 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 2219 | writel(creg_val, phba->HCregaddr); |
| 2220 | readl(phba->HCregaddr); /* flush */ |
| 2221 | } |
| 2222 | |
| 2223 | phba->cfg_poll = val; |
| 2224 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2225 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2226 | |
| 2227 | return strlen(buf); |
| 2228 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2229 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2230 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2231 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 2232 | * @dev: class unused variable. |
| 2233 | * @attr: device attribute, not used. |
| 2234 | * @buf: on return contains the module description text. |
| 2235 | * |
| 2236 | * Returns: size of formatted string. |
| 2237 | **/ |
| 2238 | static ssize_t |
| 2239 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 2240 | char *buf) |
| 2241 | { |
| 2242 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2243 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2244 | struct lpfc_hba *phba = vport->phba; |
| 2245 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2246 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | /** |
| 2250 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 2251 | * @dev: class unused variable. |
| 2252 | * @attr: device attribute, not used. |
| 2253 | * @buf: on return contains the module description text. |
| 2254 | * |
| 2255 | * Returns: size of formatted string. |
| 2256 | **/ |
| 2257 | static ssize_t |
| 2258 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 2259 | char *buf) |
| 2260 | { |
| 2261 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2262 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2263 | struct lpfc_hba *phba = vport->phba; |
| 2264 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2265 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2266 | } |
| 2267 | |
| 2268 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2269 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 2270 | * @dev: class converted to a Scsi_host structure. |
| 2271 | * @attr: device attribute, not used. |
| 2272 | * @buf: on return contains the formatted text. |
| 2273 | * |
| 2274 | * Returns: size of formatted string. |
| 2275 | **/ |
| 2276 | static ssize_t |
| 2277 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 2278 | char *buf) |
| 2279 | { |
| 2280 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2281 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2282 | struct lpfc_hba *phba = vport->phba; |
| 2283 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2284 | return scnprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2285 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 2286 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 2287 | "" : "Not "); |
| 2288 | } |
| 2289 | |
| 2290 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2291 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 2292 | * @dev: class converted to a Scsi_host structure. |
| 2293 | * @attr: device attribute, not used. |
| 2294 | * @buf: on return contains the formatted support level. |
| 2295 | * |
| 2296 | * Description: |
| 2297 | * Returns the maximum number of virtual functions a physical function can |
| 2298 | * support, 0 will be returned if called on virtual function. |
| 2299 | * |
| 2300 | * Returns: size of formatted string. |
| 2301 | **/ |
| 2302 | static ssize_t |
| 2303 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 2304 | struct device_attribute *attr, |
| 2305 | char *buf) |
| 2306 | { |
| 2307 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2308 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2309 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2310 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2311 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2312 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2313 | return scnprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2314 | } |
| 2315 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2316 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 2317 | { |
| 2318 | return val >= min && val <= max; |
| 2319 | } |
| 2320 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2321 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2322 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 2323 | * @phba: pointer the the adapter structure. |
| 2324 | * @val: integer attribute value. |
| 2325 | * |
| 2326 | * Description: |
| 2327 | * Validates the min and max values then sets the |
| 2328 | * adapter config field if in the valid range. prints error message |
| 2329 | * and does not set the parameter if invalid. |
| 2330 | * |
| 2331 | * Returns: |
| 2332 | * zero on success |
| 2333 | * -EINVAL if val is invalid |
| 2334 | */ |
| 2335 | static ssize_t |
| 2336 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 2337 | { |
| 2338 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 2339 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2340 | "3068 %s_enable_bbcr changed from %d to %d\n", |
| 2341 | LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val); |
| 2342 | phba->cfg_enable_bbcr = val; |
| 2343 | return 0; |
| 2344 | } |
| 2345 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2346 | "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n", |
| 2347 | LPFC_DRIVER_NAME, val); |
| 2348 | return -EINVAL; |
| 2349 | } |
| 2350 | |
| 2351 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2352 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2353 | * |
| 2354 | * Description: |
| 2355 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2356 | * into a function with the name lpfc_hba_queue_depth_show. |
| 2357 | * |
| 2358 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 2359 | * @dev: class device that is converted into a Scsi_host. |
| 2360 | * @attr: device attribute, not used. |
| 2361 | * @buf: on return contains the attribute value in decimal. |
| 2362 | * |
| 2363 | * Returns: size of formatted string. |
| 2364 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2365 | #define lpfc_param_show(attr) \ |
| 2366 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2367 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2368 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2369 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2370 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2371 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2372 | struct lpfc_hba *phba = vport->phba;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2373 | return scnprintf(buf, PAGE_SIZE, "%d\n",\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2374 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2375 | } |
| 2376 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2377 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2378 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2379 | * |
| 2380 | * Description: |
| 2381 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2382 | * into a function with the name lpfc_hba_queue_depth_show |
| 2383 | * |
| 2384 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 2385 | * @dev: class device that is converted into a Scsi_host. |
| 2386 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2387 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2388 | * |
| 2389 | * Returns: size of formatted string. |
| 2390 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2391 | #define lpfc_param_hex_show(attr) \ |
| 2392 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2393 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2394 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2395 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2396 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2397 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2398 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2399 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2400 | val = phba->cfg_##attr;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2401 | return scnprintf(buf, PAGE_SIZE, "%#x\n",\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2402 | phba->cfg_##attr);\ |
| 2403 | } |
| 2404 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2405 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 2406 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2407 | * |
| 2408 | * Description: |
| 2409 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2410 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2411 | * takes a default argument, a minimum and maximum argument. |
| 2412 | * |
| 2413 | * lpfc_##attr##_init: Initializes an attribute. |
| 2414 | * @phba: pointer the the adapter structure. |
| 2415 | * @val: integer attribute value. |
| 2416 | * |
| 2417 | * Validates the min and max values then sets the adapter config field |
| 2418 | * accordingly, or uses the default if out of range and prints an error message. |
| 2419 | * |
| 2420 | * Returns: |
| 2421 | * zero on success |
| 2422 | * -EINVAL if default used |
| 2423 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2424 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 2425 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2426 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2427 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2428 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2429 | phba->cfg_##attr = val;\ |
| 2430 | return 0;\ |
| 2431 | }\ |
| 2432 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2433 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2434 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2435 | phba->cfg_##attr = default;\ |
| 2436 | return -EINVAL;\ |
| 2437 | } |
| 2438 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2439 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2440 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2441 | * |
| 2442 | * Description: |
| 2443 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2444 | * into a function with the name lpfc_hba_queue_depth_set |
| 2445 | * |
| 2446 | * lpfc_##attr##_set: Sets an attribute value. |
| 2447 | * @phba: pointer the the adapter structure. |
| 2448 | * @val: integer attribute value. |
| 2449 | * |
| 2450 | * Description: |
| 2451 | * Validates the min and max values then sets the |
| 2452 | * adapter config field if in the valid range. prints error message |
| 2453 | * and does not set the parameter if invalid. |
| 2454 | * |
| 2455 | * Returns: |
| 2456 | * zero on success |
| 2457 | * -EINVAL if val is invalid |
| 2458 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2459 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2460 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2461 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2462 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2463 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2464 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2465 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2466 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2467 | phba->cfg_##attr = val;\ |
| 2468 | return 0;\ |
| 2469 | }\ |
| 2470 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2471 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2472 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2473 | return -EINVAL;\ |
| 2474 | } |
| 2475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2476 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2477 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2478 | * |
| 2479 | * Description: |
| 2480 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2481 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2482 | * |
| 2483 | * lpfc_##attr##_store: Set an sttribute value. |
| 2484 | * @dev: class device that is converted into a Scsi_host. |
| 2485 | * @attr: device attribute, not used. |
| 2486 | * @buf: contains the attribute value in ascii. |
| 2487 | * @count: not used. |
| 2488 | * |
| 2489 | * Description: |
| 2490 | * Convert the ascii text number to an integer, then |
| 2491 | * use the lpfc_##attr##_set function to set the value. |
| 2492 | * |
| 2493 | * Returns: |
| 2494 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2495 | * length of buffer upon success. |
| 2496 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2497 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2498 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2499 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2500 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2501 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2502 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2503 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2504 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2505 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2506 | if (!isdigit(buf[0]))\ |
| 2507 | return -EINVAL;\ |
| 2508 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2509 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2510 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2511 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2512 | else \ |
| 2513 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2514 | } |
| 2515 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2516 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2517 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2518 | * |
| 2519 | * Description: |
| 2520 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2521 | * into a function with the name lpfc_hba_queue_depth_show |
| 2522 | * |
| 2523 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2524 | * @dev: class device that is converted into a Scsi_host. |
| 2525 | * @attr: device attribute, not used. |
| 2526 | * @buf: on return contains the attribute value in decimal. |
| 2527 | * |
| 2528 | * Returns: length of formatted string. |
| 2529 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2530 | #define lpfc_vport_param_show(attr) \ |
| 2531 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2532 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2533 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2534 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2535 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2536 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2537 | return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2538 | } |
| 2539 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2540 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2541 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2542 | * |
| 2543 | * Description: |
| 2544 | * Macro that given an attr e.g. |
| 2545 | * hba_queue_depth expands into a function with the name |
| 2546 | * lpfc_hba_queue_depth_show |
| 2547 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2548 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2549 | * @dev: class device that is converted into a Scsi_host. |
| 2550 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2551 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2552 | * |
| 2553 | * Returns: length of formatted string. |
| 2554 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2555 | #define lpfc_vport_param_hex_show(attr) \ |
| 2556 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2557 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2558 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2559 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2560 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2561 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2562 | return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2563 | } |
| 2564 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2565 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2566 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2567 | * |
| 2568 | * Description: |
| 2569 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2570 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2571 | * takes a default argument, a minimum and maximum argument. |
| 2572 | * |
| 2573 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2574 | * adapter config field accordingly, or uses the default if out of range |
| 2575 | * and prints an error message. |
| 2576 | * @phba: pointer the the adapter structure. |
| 2577 | * @val: integer attribute value. |
| 2578 | * |
| 2579 | * Returns: |
| 2580 | * zero on success |
| 2581 | * -EINVAL if default used |
| 2582 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2583 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2584 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2585 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2586 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2587 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2588 | vport->cfg_##attr = val;\ |
| 2589 | return 0;\ |
| 2590 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2591 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2592 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2593 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2594 | vport->cfg_##attr = default;\ |
| 2595 | return -EINVAL;\ |
| 2596 | } |
| 2597 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2598 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2599 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2600 | * |
| 2601 | * Description: |
| 2602 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2603 | * into a function with the name lpfc_hba_queue_depth_set |
| 2604 | * |
| 2605 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2606 | * adapter config field if in the valid range. prints error message |
| 2607 | * and does not set the parameter if invalid. |
| 2608 | * @phba: pointer the the adapter structure. |
| 2609 | * @val: integer attribute value. |
| 2610 | * |
| 2611 | * Returns: |
| 2612 | * zero on success |
| 2613 | * -EINVAL if val is invalid |
| 2614 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2615 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2616 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2617 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2618 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2619 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2620 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2621 | "3053 lpfc_" #attr \ |
| 2622 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2623 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2624 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2625 | vport->cfg_##attr = val;\ |
| 2626 | return 0;\ |
| 2627 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2628 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2629 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2630 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2631 | return -EINVAL;\ |
| 2632 | } |
| 2633 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2634 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2635 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2636 | * |
| 2637 | * Description: |
| 2638 | * Macro that given an attr e.g. hba_queue_depth |
| 2639 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2640 | * |
| 2641 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2642 | * use the lpfc_##attr##_set function to set the value. |
| 2643 | * @cdev: class device that is converted into a Scsi_host. |
| 2644 | * @buf: contains the attribute value in decimal. |
| 2645 | * @count: not used. |
| 2646 | * |
| 2647 | * Returns: |
| 2648 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2649 | * length of buffer upon success. |
| 2650 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2651 | #define lpfc_vport_param_store(attr) \ |
| 2652 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2653 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2654 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2655 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2656 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2657 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2658 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2659 | if (!isdigit(buf[0]))\ |
| 2660 | return -EINVAL;\ |
| 2661 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2662 | return -EINVAL;\ |
| 2663 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2664 | return strlen(buf);\ |
| 2665 | else \ |
| 2666 | return -EINVAL;\ |
| 2667 | } |
| 2668 | |
| 2669 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2670 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 2671 | static DEVICE_ATTR(scsi_stat, 0444, lpfc_scsi_stat_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2672 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2673 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2674 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2675 | 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] | 2676 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2677 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2678 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2679 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2680 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2681 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2682 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2683 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2684 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2685 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2686 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2687 | lpfc_option_rom_version_show, NULL); |
| 2688 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2689 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2690 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2691 | 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] | 2692 | static DEVICE_ATTR_RO(lpfc_drvr_version); |
| 2693 | static DEVICE_ATTR_RO(lpfc_enable_fip); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2694 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2695 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2696 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2697 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2698 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2699 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2700 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2701 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2702 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2703 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2704 | static DEVICE_ATTR_RO(lpfc_temp_sensor); |
| 2705 | static DEVICE_ATTR_RO(lpfc_fips_level); |
| 2706 | static DEVICE_ATTR_RO(lpfc_fips_rev); |
| 2707 | static DEVICE_ATTR_RO(lpfc_dss); |
| 2708 | static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2709 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2710 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2711 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2712 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2713 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2714 | #define WWN_SZ 8 |
| 2715 | /** |
| 2716 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2717 | * @buf: WWN string. |
| 2718 | * @cnt: Length of string. |
| 2719 | * @wwn: Array to receive converted wwn value. |
| 2720 | * |
| 2721 | * Returns: |
| 2722 | * -EINVAL if the buffer does not contain a valid wwn |
| 2723 | * 0 success |
| 2724 | **/ |
| 2725 | static size_t |
| 2726 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2727 | { |
| 2728 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2729 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2730 | /* Count may include a LF at end of string */ |
| 2731 | if (buf[cnt-1] == '\n') |
| 2732 | cnt--; |
| 2733 | |
| 2734 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2735 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2736 | return -EINVAL; |
| 2737 | |
| 2738 | memset(wwn, 0, WWN_SZ); |
| 2739 | |
| 2740 | /* Validate and store the new name */ |
| 2741 | for (i = 0, j = 0; i < 16; i++) { |
| 2742 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2743 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2744 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2745 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2746 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2747 | j = ((j << 4) | (*buf++ - '0')); |
| 2748 | else |
| 2749 | return -EINVAL; |
| 2750 | if (i % 2) { |
| 2751 | wwn[i/2] = j & 0xff; |
| 2752 | j = 0; |
| 2753 | } |
| 2754 | } |
| 2755 | return 0; |
| 2756 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2757 | /** |
| 2758 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2759 | * @dev: class device that is converted into a Scsi_host. |
| 2760 | * @attr: device attribute, not used. |
| 2761 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2762 | * @count: must be size of lpfc_soft_wwn_key. |
| 2763 | * |
| 2764 | * Returns: |
| 2765 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2766 | * length of buf indicates success |
| 2767 | **/ |
| 2768 | static ssize_t |
| 2769 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2770 | const char *buf, size_t count) |
| 2771 | { |
| 2772 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2773 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2774 | struct lpfc_hba *phba = vport->phba; |
| 2775 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2776 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2777 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2778 | |
| 2779 | /* |
| 2780 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2781 | * We require that the user write a specific key to enable |
| 2782 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2783 | * is written, the enable key resets. If further updates are |
| 2784 | * desired, the key must be written again to re-enable the |
| 2785 | * attribute. |
| 2786 | * |
| 2787 | * The "key" is not secret - it is a hardcoded string shown |
| 2788 | * here. The intent is to protect against the random user or |
| 2789 | * application that is just writing attributes. |
| 2790 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2791 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2792 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2793 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2794 | " be enabled: fawwpn is enabled\n"); |
| 2795 | return -EINVAL; |
| 2796 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2797 | |
| 2798 | /* count may include a LF at end of string */ |
| 2799 | if (buf[cnt-1] == '\n') |
| 2800 | cnt--; |
| 2801 | |
| 2802 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2803 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2804 | return -EINVAL; |
| 2805 | |
| 2806 | phba->soft_wwn_enable = 1; |
| 2807 | |
| 2808 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2809 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2810 | phba->brd_no); |
| 2811 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2812 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2813 | |
| 2814 | return count; |
| 2815 | } |
Joe Perches | 6cbaefb | 2017-12-19 10:15:09 -0800 | [diff] [blame] | 2816 | static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2817 | |
| 2818 | /** |
| 2819 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2820 | * @dev: class device that is converted into a Scsi_host. |
| 2821 | * @attr: device attribute, not used. |
| 2822 | * @buf: on return contains the wwpn in hexadecimal. |
| 2823 | * |
| 2824 | * Returns: size of formatted string. |
| 2825 | **/ |
| 2826 | static ssize_t |
| 2827 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2828 | char *buf) |
| 2829 | { |
| 2830 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2831 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2832 | struct lpfc_hba *phba = vport->phba; |
| 2833 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2834 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2835 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2836 | } |
| 2837 | |
| 2838 | /** |
| 2839 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2840 | * @dev class device that is converted into a Scsi_host. |
| 2841 | * @attr: device attribute, not used. |
| 2842 | * @buf: contains the wwpn in hexadecimal. |
| 2843 | * @count: number of wwpn bytes in buf |
| 2844 | * |
| 2845 | * Returns: |
| 2846 | * -EACCES hba reset not enabled, adapter over temp |
| 2847 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2848 | * -EIO error taking adapter offline or online |
| 2849 | * value of count on success |
| 2850 | **/ |
| 2851 | static ssize_t |
| 2852 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2853 | const char *buf, size_t count) |
| 2854 | { |
| 2855 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2856 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2857 | struct lpfc_hba *phba = vport->phba; |
| 2858 | struct completion online_compl; |
| 2859 | int stat1 = 0, stat2 = 0; |
| 2860 | unsigned int cnt = count; |
| 2861 | u8 wwpn[WWN_SZ]; |
| 2862 | int rc; |
| 2863 | |
| 2864 | if (!phba->cfg_enable_hba_reset) |
| 2865 | return -EACCES; |
| 2866 | spin_lock_irq(&phba->hbalock); |
| 2867 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2868 | spin_unlock_irq(&phba->hbalock); |
| 2869 | return -EACCES; |
| 2870 | } |
| 2871 | spin_unlock_irq(&phba->hbalock); |
| 2872 | /* count may include a LF at end of string */ |
| 2873 | if (buf[cnt-1] == '\n') |
| 2874 | cnt--; |
| 2875 | |
| 2876 | if (!phba->soft_wwn_enable) |
| 2877 | return -EINVAL; |
| 2878 | |
| 2879 | /* lock setting wwpn, wwnn down */ |
| 2880 | phba->soft_wwn_enable = 0; |
| 2881 | |
| 2882 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2883 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2884 | /* not able to set wwpn, unlock it */ |
| 2885 | phba->soft_wwn_enable = 1; |
| 2886 | return rc; |
| 2887 | } |
| 2888 | |
| 2889 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2890 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2891 | if (phba->cfg_soft_wwnn) |
| 2892 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2893 | |
| 2894 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2895 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2896 | |
| 2897 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2898 | if (stat1) |
| 2899 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2900 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2901 | "reinit adapter - %d\n", stat1); |
| 2902 | init_completion(&online_compl); |
| 2903 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2904 | LPFC_EVT_ONLINE); |
| 2905 | if (rc == 0) |
| 2906 | return -ENOMEM; |
| 2907 | |
| 2908 | wait_for_completion(&online_compl); |
| 2909 | if (stat2) |
| 2910 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2911 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2912 | "reinit adapter - %d\n", stat2); |
| 2913 | return (stat1 || stat2) ? -EIO : count; |
| 2914 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2915 | static DEVICE_ATTR_RW(lpfc_soft_wwpn); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2916 | |
| 2917 | /** |
| 2918 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2919 | * @dev: class device that is converted into a Scsi_host. |
| 2920 | * @attr: device attribute, not used. |
| 2921 | * @buf: on return contains the wwnn in hexadecimal. |
| 2922 | * |
| 2923 | * Returns: size of formatted string. |
| 2924 | **/ |
| 2925 | static ssize_t |
| 2926 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2927 | char *buf) |
| 2928 | { |
| 2929 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2930 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2931 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2932 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2933 | } |
| 2934 | |
| 2935 | /** |
| 2936 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2937 | * @cdev: class device that is converted into a Scsi_host. |
| 2938 | * @buf: contains the ww node name in hexadecimal. |
| 2939 | * @count: number of wwnn bytes in buf. |
| 2940 | * |
| 2941 | * Returns: |
| 2942 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2943 | * value of count on success |
| 2944 | **/ |
| 2945 | static ssize_t |
| 2946 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2947 | const char *buf, size_t count) |
| 2948 | { |
| 2949 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2950 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2951 | unsigned int cnt = count; |
| 2952 | u8 wwnn[WWN_SZ]; |
| 2953 | int rc; |
| 2954 | |
| 2955 | /* count may include a LF at end of string */ |
| 2956 | if (buf[cnt-1] == '\n') |
| 2957 | cnt--; |
| 2958 | |
| 2959 | if (!phba->soft_wwn_enable) |
| 2960 | return -EINVAL; |
| 2961 | |
| 2962 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2963 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2964 | /* Allow wwnn to be set many times, as long as the enable |
| 2965 | * is set. However, once the wwpn is set, everything locks. |
| 2966 | */ |
| 2967 | return rc; |
| 2968 | } |
| 2969 | |
| 2970 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2971 | |
| 2972 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2973 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2974 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2975 | |
| 2976 | return count; |
| 2977 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2978 | static DEVICE_ATTR_RW(lpfc_soft_wwnn); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2979 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2980 | /** |
| 2981 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2982 | * Optimized Access Storage (OAS) operations. |
| 2983 | * @dev: class device that is converted into a Scsi_host. |
| 2984 | * @attr: device attribute, not used. |
| 2985 | * @buf: buffer for passing information. |
| 2986 | * |
| 2987 | * Returns: |
| 2988 | * value of count |
| 2989 | **/ |
| 2990 | static ssize_t |
| 2991 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2992 | char *buf) |
| 2993 | { |
| 2994 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2995 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2996 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2997 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2998 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2999 | } |
| 3000 | |
| 3001 | /** |
| 3002 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 3003 | * Optimized Access Storage (OAS) operations. |
| 3004 | * @dev: class device that is converted into a Scsi_host. |
| 3005 | * @attr: device attribute, not used. |
| 3006 | * @buf: buffer for passing information. |
| 3007 | * @count: Size of the data buffer. |
| 3008 | * |
| 3009 | * Returns: |
| 3010 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3011 | * -EPERM oas is not supported by hba |
| 3012 | * value of count on success |
| 3013 | **/ |
| 3014 | static ssize_t |
| 3015 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 3016 | const char *buf, size_t count) |
| 3017 | { |
| 3018 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3019 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3020 | unsigned int cnt = count; |
| 3021 | uint8_t wwpn[WWN_SZ]; |
| 3022 | int rc; |
| 3023 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3024 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3025 | return -EPERM; |
| 3026 | |
| 3027 | /* count may include a LF at end of string */ |
| 3028 | if (buf[cnt-1] == '\n') |
| 3029 | cnt--; |
| 3030 | |
| 3031 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 3032 | if (rc) |
| 3033 | return rc; |
| 3034 | |
| 3035 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3036 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3037 | if (wwn_to_u64(wwpn) == 0) |
| 3038 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 3039 | else |
| 3040 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 3041 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 3042 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3043 | return count; |
| 3044 | } |
| 3045 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 3046 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 3047 | |
| 3048 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3049 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 3050 | * Optimized Access Storage (OAS) operations. |
| 3051 | * @dev: class device that is converted into a Scsi_host. |
| 3052 | * @attr: device attribute, not used. |
| 3053 | * @buf: buffer for passing information. |
| 3054 | * |
| 3055 | * Returns: |
| 3056 | * value of count |
| 3057 | **/ |
| 3058 | static ssize_t |
| 3059 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 3060 | char *buf) |
| 3061 | { |
| 3062 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3063 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3064 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3065 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3066 | } |
| 3067 | |
| 3068 | /** |
| 3069 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 3070 | * Optimized Access Storage (OAS) operations. |
| 3071 | * @dev: class device that is converted into a Scsi_host. |
| 3072 | * @attr: device attribute, not used. |
| 3073 | * @buf: buffer for passing information. |
| 3074 | * @count: Size of the data buffer. |
| 3075 | * |
| 3076 | * Returns: |
| 3077 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3078 | * -EPERM oas is not supported by hba |
| 3079 | * value of count on success |
| 3080 | **/ |
| 3081 | static ssize_t |
| 3082 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 3083 | const char *buf, size_t count) |
| 3084 | { |
| 3085 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3086 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3087 | unsigned int cnt = count; |
| 3088 | unsigned long val; |
| 3089 | int ret; |
| 3090 | |
| 3091 | if (!phba->cfg_fof) |
| 3092 | return -EPERM; |
| 3093 | |
| 3094 | /* count may include a LF at end of string */ |
| 3095 | if (buf[cnt-1] == '\n') |
| 3096 | cnt--; |
| 3097 | |
| 3098 | ret = kstrtoul(buf, 0, &val); |
| 3099 | if (ret || (val > 0x7f)) |
| 3100 | return -EINVAL; |
| 3101 | |
| 3102 | if (val) |
| 3103 | phba->cfg_oas_priority = (uint8_t)val; |
| 3104 | else |
| 3105 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 3106 | return count; |
| 3107 | } |
| 3108 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 3109 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 3110 | |
| 3111 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3112 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 3113 | * for Optimized Access Storage (OAS) operations. |
| 3114 | * @dev: class device that is converted into a Scsi_host. |
| 3115 | * @attr: device attribute, not used. |
| 3116 | * @buf: buffer for passing information. |
| 3117 | * |
| 3118 | * Returns: |
| 3119 | * value of count on success |
| 3120 | **/ |
| 3121 | static ssize_t |
| 3122 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 3123 | char *buf) |
| 3124 | { |
| 3125 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3126 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3127 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3128 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3129 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 3130 | } |
| 3131 | |
| 3132 | /** |
| 3133 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 3134 | * for Optimized Access Storage (OAS) operations. |
| 3135 | * @dev: class device that is converted into a Scsi_host. |
| 3136 | * @attr: device attribute, not used. |
| 3137 | * @buf: buffer for passing information. |
| 3138 | * @count: Size of the data buffer. |
| 3139 | * |
| 3140 | * Returns: |
| 3141 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3142 | * -EPERM oas is not supported by hba |
| 3143 | * value of count on success |
| 3144 | **/ |
| 3145 | static ssize_t |
| 3146 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 3147 | const char *buf, size_t count) |
| 3148 | { |
| 3149 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3150 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3151 | unsigned int cnt = count; |
| 3152 | uint8_t wwpn[WWN_SZ]; |
| 3153 | int rc; |
| 3154 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3155 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3156 | return -EPERM; |
| 3157 | |
| 3158 | /* count may include a LF at end of string */ |
| 3159 | if (buf[cnt-1] == '\n') |
| 3160 | cnt--; |
| 3161 | |
| 3162 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 3163 | if (rc) |
| 3164 | return rc; |
| 3165 | |
| 3166 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3167 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3168 | if (wwn_to_u64(wwpn) == 0) |
| 3169 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 3170 | else |
| 3171 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 3172 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3173 | if (phba->cfg_oas_priority == 0) |
| 3174 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3175 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3176 | return count; |
| 3177 | } |
| 3178 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 3179 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 3180 | |
| 3181 | /** |
| 3182 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 3183 | * of whether luns will be enabled or disabled |
| 3184 | * for Optimized Access Storage (OAS) operations. |
| 3185 | * @dev: class device that is converted into a Scsi_host. |
| 3186 | * @attr: device attribute, not used. |
| 3187 | * @buf: buffer for passing information. |
| 3188 | * |
| 3189 | * Returns: |
| 3190 | * size of formatted string. |
| 3191 | **/ |
| 3192 | static ssize_t |
| 3193 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 3194 | char *buf) |
| 3195 | { |
| 3196 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3197 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3198 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3199 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | /** |
| 3203 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 3204 | * of whether luns will be enabled or disabled |
| 3205 | * for Optimized Access Storage (OAS) operations. |
| 3206 | * @dev: class device that is converted into a Scsi_host. |
| 3207 | * @attr: device attribute, not used. |
| 3208 | * @buf: buffer for passing information. |
| 3209 | * @count: Size of the data buffer. |
| 3210 | * |
| 3211 | * Returns: |
| 3212 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3213 | * -EPERM oas is not supported by hba |
| 3214 | * value of count on success |
| 3215 | **/ |
| 3216 | static ssize_t |
| 3217 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 3218 | const char *buf, size_t count) |
| 3219 | { |
| 3220 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3221 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3222 | int val = 0; |
| 3223 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3224 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3225 | return -EPERM; |
| 3226 | |
| 3227 | if (!isdigit(buf[0])) |
| 3228 | return -EINVAL; |
| 3229 | |
| 3230 | if (sscanf(buf, "%i", &val) != 1) |
| 3231 | return -EINVAL; |
| 3232 | |
| 3233 | if ((val != 0) && (val != 1)) |
| 3234 | return -EINVAL; |
| 3235 | |
| 3236 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3237 | return strlen(buf); |
| 3238 | } |
| 3239 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 3240 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 3241 | |
| 3242 | /** |
| 3243 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 3244 | * Storage (OAS) lun returned by the |
| 3245 | * lpfc_oas_lun_show function. |
| 3246 | * @dev: class device that is converted into a Scsi_host. |
| 3247 | * @attr: device attribute, not used. |
| 3248 | * @buf: buffer for passing information. |
| 3249 | * |
| 3250 | * Returns: |
| 3251 | * size of formatted string. |
| 3252 | **/ |
| 3253 | static ssize_t |
| 3254 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 3255 | char *buf) |
| 3256 | { |
| 3257 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3258 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3259 | |
| 3260 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 3261 | return -EFAULT; |
| 3262 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3263 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3264 | } |
| 3265 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 3266 | lpfc_oas_lun_status_show, NULL); |
| 3267 | |
| 3268 | |
| 3269 | /** |
| 3270 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 3271 | * (OAS) operations. |
| 3272 | * @phba: lpfc_hba pointer. |
| 3273 | * @ndlp: pointer to fcp target node. |
| 3274 | * @lun: the fc lun for setting oas state. |
| 3275 | * @oas_state: the oas state to be set to the lun. |
| 3276 | * |
| 3277 | * Returns: |
| 3278 | * SUCCESS : 0 |
| 3279 | * -EPERM OAS is not enabled or not supported by this port. |
| 3280 | * |
| 3281 | */ |
| 3282 | static size_t |
| 3283 | 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] | 3284 | uint8_t tgt_wwpn[], uint64_t lun, |
| 3285 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3286 | { |
| 3287 | |
| 3288 | int rc = 0; |
| 3289 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3290 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3291 | return -EPERM; |
| 3292 | |
| 3293 | if (oas_state) { |
| 3294 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3295 | (struct lpfc_name *)tgt_wwpn, |
| 3296 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3297 | rc = -ENOMEM; |
| 3298 | } else { |
| 3299 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3300 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3301 | } |
| 3302 | return rc; |
| 3303 | |
| 3304 | } |
| 3305 | |
| 3306 | /** |
| 3307 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 3308 | * Access Storage (OAS) operations. |
| 3309 | * @phba: lpfc_hba pointer. |
| 3310 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 3311 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 3312 | * @lun_status: status of the lun returned lun |
| 3313 | * |
| 3314 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 3315 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 3316 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 3317 | * |
| 3318 | * Return: |
| 3319 | * lun that is OAS enabled for the vport/target |
| 3320 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 3321 | */ |
| 3322 | static uint64_t |
| 3323 | 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] | 3324 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 3325 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3326 | { |
| 3327 | uint64_t found_lun; |
| 3328 | |
| 3329 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 3330 | return NOT_OAS_ENABLED_LUN; |
| 3331 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 3332 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 3333 | (struct lpfc_name *) |
| 3334 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 3335 | &phba->sli4_hba.oas_next_lun, |
| 3336 | (struct lpfc_name *)vpt_wwpn, |
| 3337 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3338 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3339 | return found_lun; |
| 3340 | else |
| 3341 | return NOT_OAS_ENABLED_LUN; |
| 3342 | } |
| 3343 | |
| 3344 | /** |
| 3345 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 3346 | * @phba: lpfc_hba pointer. |
| 3347 | * @vpt_wwpn: vport wwpn by reference. |
| 3348 | * @tgt_wwpn: target wwpn by reference. |
| 3349 | * @lun: the fc lun for setting oas state. |
| 3350 | * @oas_state: the oas state to be set to the oas_lun. |
| 3351 | * |
| 3352 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 3353 | * a lun for OAS operations. |
| 3354 | * |
| 3355 | * Return: |
| 3356 | * SUCCESS: 0 |
| 3357 | * -ENOMEM: failed to enable an lun for OAS operations |
| 3358 | * -EPERM: OAS is not enabled |
| 3359 | */ |
| 3360 | static ssize_t |
| 3361 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 3362 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3363 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3364 | { |
| 3365 | |
| 3366 | int rc; |
| 3367 | |
| 3368 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3369 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3370 | return rc; |
| 3371 | } |
| 3372 | |
| 3373 | /** |
| 3374 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 3375 | * @dev: class device that is converted into a Scsi_host. |
| 3376 | * @attr: device attribute, not used. |
| 3377 | * @buf: buffer for passing information. |
| 3378 | * |
| 3379 | * This routine returns a lun enabled for OAS each time the function |
| 3380 | * is called. |
| 3381 | * |
| 3382 | * Returns: |
| 3383 | * SUCCESS: size of formatted string. |
| 3384 | * -EFAULT: target or vport wwpn was not set properly. |
| 3385 | * -EPERM: oas is not enabled. |
| 3386 | **/ |
| 3387 | static ssize_t |
| 3388 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 3389 | char *buf) |
| 3390 | { |
| 3391 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3392 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3393 | |
| 3394 | uint64_t oas_lun; |
| 3395 | int len = 0; |
| 3396 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3397 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3398 | return -EPERM; |
| 3399 | |
| 3400 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3401 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 3402 | return -EFAULT; |
| 3403 | |
| 3404 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3405 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 3406 | return -EFAULT; |
| 3407 | |
| 3408 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 3409 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3410 | &phba->cfg_oas_lun_status, |
| 3411 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3412 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 3413 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 3414 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3415 | len += scnprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3416 | |
| 3417 | return len; |
| 3418 | } |
| 3419 | |
| 3420 | /** |
| 3421 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 3422 | * @dev: class device that is converted into a Scsi_host. |
| 3423 | * @attr: device attribute, not used. |
| 3424 | * @buf: buffer for passing information. |
| 3425 | * |
| 3426 | * This function sets the OAS state for lun. Before this function is called, |
| 3427 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3428 | * |
| 3429 | * Returns: |
| 3430 | * SUCCESS: size of formatted string. |
| 3431 | * -EFAULT: target or vport wwpn was not set properly. |
| 3432 | * -EPERM: oas is not enabled. |
| 3433 | * size of formatted string. |
| 3434 | **/ |
| 3435 | static ssize_t |
| 3436 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3437 | const char *buf, size_t count) |
| 3438 | { |
| 3439 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3440 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3441 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3442 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3443 | ssize_t rc; |
| 3444 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3445 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3446 | return -EPERM; |
| 3447 | |
| 3448 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3449 | return -EFAULT; |
| 3450 | |
| 3451 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3452 | return -EFAULT; |
| 3453 | |
| 3454 | if (!isdigit(buf[0])) |
| 3455 | return -EINVAL; |
| 3456 | |
| 3457 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3458 | return -EINVAL; |
| 3459 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3460 | pri = phba->cfg_oas_priority; |
| 3461 | if (pri == 0) |
| 3462 | pri = phba->cfg_XLanePriority; |
| 3463 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3464 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3465 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3466 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3467 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3468 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3469 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3470 | |
| 3471 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3472 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3473 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3474 | if (rc) |
| 3475 | return rc; |
| 3476 | |
| 3477 | return count; |
| 3478 | } |
| 3479 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3480 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3481 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3482 | int lpfc_enable_nvmet_cnt; |
| 3483 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3484 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3485 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3486 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3487 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3488 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3489 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3490 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3491 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3492 | " 0 - none," |
| 3493 | " 1 - poll with interrupts enabled" |
| 3494 | " 3 - poll and disable FCP ring interrupts"); |
| 3495 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3496 | static DEVICE_ATTR_RW(lpfc_poll); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3497 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3498 | int lpfc_no_hba_reset_cnt; |
| 3499 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3500 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3501 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3502 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3503 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3504 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3505 | "SLI mode selector:" |
| 3506 | " 0 - auto (SLI-3 if supported)," |
| 3507 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3508 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3509 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3510 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3511 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3512 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3513 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3514 | "FCF Fast failover=1 Priority failover=2"); |
| 3515 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3516 | /* |
| 3517 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3518 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3519 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3520 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3521 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3522 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3523 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3524 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3525 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3526 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3527 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3528 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3529 | # 0x2 = never bring up link |
| 3530 | # Default value is 0. |
| 3531 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3532 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3533 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3534 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3535 | /* |
| 3536 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3537 | # 1 - (1024) |
| 3538 | # 2 - (2048) |
| 3539 | # 3 - (3072) |
| 3540 | # 4 - (4096) |
| 3541 | # 5 - (5120) |
| 3542 | */ |
| 3543 | static ssize_t |
| 3544 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3545 | { |
| 3546 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3547 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3548 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3549 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3550 | } |
| 3551 | |
| 3552 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3553 | lpfc_iocb_hw_show, NULL); |
| 3554 | static ssize_t |
| 3555 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3556 | { |
| 3557 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3558 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3559 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3560 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3561 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3562 | pring ? pring->txq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3563 | } |
| 3564 | |
| 3565 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3566 | lpfc_txq_hw_show, NULL); |
| 3567 | static ssize_t |
| 3568 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3569 | char *buf) |
| 3570 | { |
| 3571 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3572 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3573 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3574 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3575 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3576 | pring ? pring->txcmplq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3577 | } |
| 3578 | |
| 3579 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3580 | lpfc_txcmplq_hw_show, NULL); |
| 3581 | |
James Smart | 0d8c8ba | 2016-10-13 15:06:07 -0700 | [diff] [blame] | 3582 | LPFC_ATTR_R(iocb_cnt, 2, 1, 5, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3583 | "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] | 3584 | |
| 3585 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3586 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3587 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3588 | */ |
| 3589 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3590 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3591 | module_param(lpfc_nodev_tmo, int, 0); |
| 3592 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3593 | "Seconds driver will hold I/O waiting " |
| 3594 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3595 | |
| 3596 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3597 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3598 | * @dev: class converted to a Scsi_host structure. |
| 3599 | * @attr: device attribute, not used. |
| 3600 | * @buf: on return contains the dev loss timeout in decimal. |
| 3601 | * |
| 3602 | * Returns: size of formatted string. |
| 3603 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3604 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3605 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3606 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3607 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3608 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3609 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3610 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3611 | return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3612 | } |
| 3613 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3614 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3615 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3616 | * @vport: lpfc vport structure pointer. |
| 3617 | * @val: contains the nodev timeout value. |
| 3618 | * |
| 3619 | * Description: |
| 3620 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3621 | * a kernel error message is printed and zero is returned. |
| 3622 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3623 | * Otherwise nodev tmo is set to the default value. |
| 3624 | * |
| 3625 | * Returns: |
| 3626 | * zero if already set or if val is in range |
| 3627 | * -EINVAL val out of range |
| 3628 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3629 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3630 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3631 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3632 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3633 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3634 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3635 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3636 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3637 | "parameter because lpfc_devloss_tmo " |
| 3638 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3639 | return 0; |
| 3640 | } |
| 3641 | |
| 3642 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3643 | vport->cfg_nodev_tmo = val; |
| 3644 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3645 | return 0; |
| 3646 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3647 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3648 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3649 | " %d, allowed range is [%d, %d]\n", |
| 3650 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3651 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3652 | return -EINVAL; |
| 3653 | } |
| 3654 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3655 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3656 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3657 | * @vport: lpfc vport structure pointer. |
| 3658 | * |
| 3659 | * Description: |
| 3660 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3661 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3662 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3663 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3664 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3665 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3666 | struct lpfc_nodelist *ndlp; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3667 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3668 | struct lpfc_nvme_rport *rport; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3669 | struct nvme_fc_remote_port *remoteport = NULL; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3670 | #endif |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3671 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3672 | shost = lpfc_shost_from_vport(vport); |
| 3673 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3674 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3675 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3676 | continue; |
| 3677 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3678 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3679 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3680 | spin_lock(&vport->phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3681 | rport = lpfc_ndlp_get_nrport(ndlp); |
| 3682 | if (rport) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3683 | remoteport = rport->remoteport; |
| 3684 | spin_unlock(&vport->phba->hbalock); |
| 3685 | if (remoteport) |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3686 | nvme_fc_set_remoteport_devloss(rport->remoteport, |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3687 | vport->cfg_devloss_tmo); |
| 3688 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3689 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3690 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3691 | } |
| 3692 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3693 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3694 | * 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] | 3695 | * @vport: lpfc vport structure pointer. |
| 3696 | * @val: contains the tmo value. |
| 3697 | * |
| 3698 | * Description: |
| 3699 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3700 | * then a kernel error message is printed and zero is returned. |
| 3701 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3702 | * Otherwise nodev tmo is set to the default value. |
| 3703 | * |
| 3704 | * Returns: |
| 3705 | * zero if already set or if val is in range |
| 3706 | * -EINVAL val out of range |
| 3707 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3708 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3709 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3710 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3711 | if (vport->dev_loss_tmo_changed || |
| 3712 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3713 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3714 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3715 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3716 | return 0; |
| 3717 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3718 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3719 | vport->cfg_nodev_tmo = val; |
| 3720 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3721 | /* |
| 3722 | * For compat: set the fc_host dev loss so new rports |
| 3723 | * will get the value. |
| 3724 | */ |
| 3725 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3726 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3727 | return 0; |
| 3728 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3729 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3730 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3731 | "%d, allowed range is [%d, %d]\n", |
| 3732 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3733 | return -EINVAL; |
| 3734 | } |
| 3735 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3736 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3737 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3738 | static DEVICE_ATTR_RW(lpfc_nodev_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3739 | |
| 3740 | /* |
| 3741 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3742 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3743 | # value is 30. |
| 3744 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3745 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3746 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3747 | "Seconds driver will hold I/O waiting " |
| 3748 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3749 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3750 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3751 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3752 | |
| 3753 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3754 | * 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] | 3755 | * @vport: lpfc vport structure pointer. |
| 3756 | * @val: contains the tmo value. |
| 3757 | * |
| 3758 | * Description: |
| 3759 | * If val is in a valid range then set the vport nodev tmo, |
| 3760 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3761 | * Else a kernel error message is printed. |
| 3762 | * |
| 3763 | * Returns: |
| 3764 | * zero if val is in range |
| 3765 | * -EINVAL val out of range |
| 3766 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3767 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3768 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3769 | { |
| 3770 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3771 | vport->cfg_nodev_tmo = val; |
| 3772 | vport->cfg_devloss_tmo = val; |
| 3773 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3774 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3775 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3776 | return 0; |
| 3777 | } |
| 3778 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3779 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3780 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3781 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3782 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3783 | return -EINVAL; |
| 3784 | } |
| 3785 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3786 | lpfc_vport_param_store(devloss_tmo) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3787 | static DEVICE_ATTR_RW(lpfc_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3788 | |
| 3789 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3790 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3791 | * lpfc_suppress_rsp = 0 Disable |
| 3792 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3793 | * |
| 3794 | */ |
| 3795 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3796 | "Enable suppress rsp feature is firmware supports it"); |
| 3797 | |
| 3798 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3799 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3800 | * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3801 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3802 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3803 | * |
| 3804 | */ |
| 3805 | LPFC_ATTR_R(nvmet_mrq, |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3806 | LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3807 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3808 | |
| 3809 | /* |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 3810 | * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post |
| 3811 | * to each NVMET RQ. Range 64 to 2048, default is 512. |
| 3812 | */ |
| 3813 | LPFC_ATTR_R(nvmet_mrq_post, |
| 3814 | LPFC_NVMET_RQE_DEF_POST, LPFC_NVMET_RQE_MIN_POST, |
| 3815 | LPFC_NVMET_RQE_DEF_COUNT, |
| 3816 | "Specify number of RQ buffers to initially post"); |
| 3817 | |
| 3818 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3819 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3820 | * Supported Values: 1 - register just FCP |
| 3821 | * 3 - register both FCP and NVME |
James Smart | b1684a0 | 2019-01-28 11:14:36 -0800 | [diff] [blame] | 3822 | * Supported values are [1,3]. Default value is 3 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3823 | */ |
James Smart | b1684a0 | 2019-01-28 11:14:36 -0800 | [diff] [blame] | 3824 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_BOTH, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3825 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3826 | "Enable FC4 Protocol support - FCP / NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3827 | |
| 3828 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3829 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3830 | # deluged with LOTS of information. |
| 3831 | # 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] | 3832 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3833 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3834 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3835 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3836 | |
| 3837 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3838 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3839 | # objects that have been registered with the nameserver after login. |
| 3840 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3841 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3842 | "Deregister nameserver objects before LOGO"); |
| 3843 | |
| 3844 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3845 | # 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] | 3846 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3847 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3848 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3849 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3850 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3851 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3852 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3853 | |
| 3854 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3855 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3856 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3857 | */ |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 3858 | static uint lpfc_tgt_queue_depth = LPFC_MAX_TGT_QDEPTH; |
| 3859 | module_param(lpfc_tgt_queue_depth, uint, 0444); |
| 3860 | MODULE_PARM_DESC(lpfc_tgt_queue_depth, "Set max Target queue depth"); |
| 3861 | lpfc_vport_param_show(tgt_queue_depth); |
| 3862 | lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH, |
| 3863 | LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH); |
| 3864 | |
| 3865 | /** |
| 3866 | * lpfc_tgt_queue_depth_store: Sets an attribute value. |
| 3867 | * @phba: pointer the the adapter structure. |
| 3868 | * @val: integer attribute value. |
| 3869 | * |
| 3870 | * Description: Sets the parameter to the new value. |
| 3871 | * |
| 3872 | * Returns: |
| 3873 | * zero on success |
| 3874 | * -EINVAL if val is invalid |
| 3875 | */ |
| 3876 | static int |
| 3877 | lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val) |
| 3878 | { |
| 3879 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3880 | struct lpfc_nodelist *ndlp; |
| 3881 | |
| 3882 | if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH)) |
| 3883 | return -EINVAL; |
| 3884 | |
| 3885 | if (val == vport->cfg_tgt_queue_depth) |
| 3886 | return 0; |
| 3887 | |
| 3888 | spin_lock_irq(shost->host_lock); |
| 3889 | vport->cfg_tgt_queue_depth = val; |
| 3890 | |
| 3891 | /* Next loop thru nodelist and change cmd_qdepth */ |
| 3892 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
| 3893 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
| 3894 | |
| 3895 | spin_unlock_irq(shost->host_lock); |
| 3896 | return 0; |
| 3897 | } |
| 3898 | |
| 3899 | lpfc_vport_param_store(tgt_queue_depth); |
| 3900 | static DEVICE_ATTR_RW(lpfc_tgt_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3901 | |
| 3902 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3903 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3904 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3905 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3906 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3907 | # the hba_queue_depth. |
| 3908 | */ |
| 3909 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3910 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3911 | |
| 3912 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3913 | # peer_port_login: This parameter allows/prevents logins |
| 3914 | # between peer ports hosted on the same physical port. |
| 3915 | # When this parameter is set 0 peer ports of same physical port |
| 3916 | # are not allowed to login to each other. |
| 3917 | # When this parameter is set 1 peer ports of same physical port |
| 3918 | # are allowed to login to each other. |
| 3919 | # Default value of this parameter is 0. |
| 3920 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3921 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3922 | "Allow peer ports on the same physical port to login to each " |
| 3923 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3924 | |
| 3925 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3926 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3927 | # between Virtual Ports and remote initiators. |
| 3928 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3929 | # other initiators and will attempt to PLOGI all remote ports. |
| 3930 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3931 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3932 | # This parameter does not restrict to the physical port. |
| 3933 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3934 | # Default value of this parameter is 1. |
| 3935 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3936 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3937 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3938 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3939 | "Restrict virtual ports login to remote initiators."); |
| 3940 | lpfc_vport_param_show(restrict_login); |
| 3941 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3942 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3943 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3944 | * @vport: lpfc vport structure pointer. |
| 3945 | * @val: contains the restrict login value. |
| 3946 | * |
| 3947 | * Description: |
| 3948 | * If val is not in a valid range then log a kernel error message and set |
| 3949 | * the vport restrict login to one. |
| 3950 | * If the port type is physical clear the restrict login flag and return. |
| 3951 | * Else set the restrict login flag to val. |
| 3952 | * |
| 3953 | * Returns: |
| 3954 | * zero if val is in range |
| 3955 | * -EINVAL val out of range |
| 3956 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3957 | static int |
| 3958 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3959 | { |
| 3960 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3961 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3962 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3963 | "be set to %d, allowed range is [0, 1]\n", |
| 3964 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3965 | vport->cfg_restrict_login = 1; |
| 3966 | return -EINVAL; |
| 3967 | } |
| 3968 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3969 | vport->cfg_restrict_login = 0; |
| 3970 | return 0; |
| 3971 | } |
| 3972 | vport->cfg_restrict_login = val; |
| 3973 | return 0; |
| 3974 | } |
| 3975 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3976 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3977 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3978 | * @vport: lpfc vport structure pointer. |
| 3979 | * @val: contains the restrict login value. |
| 3980 | * |
| 3981 | * Description: |
| 3982 | * If val is not in a valid range then log a kernel error message and set |
| 3983 | * the vport restrict login to one. |
| 3984 | * If the port type is physical and the val is not zero log a kernel |
| 3985 | * error message, clear the restrict login flag and return zero. |
| 3986 | * Else set the restrict login flag to val. |
| 3987 | * |
| 3988 | * Returns: |
| 3989 | * zero if val is in range |
| 3990 | * -EINVAL val out of range |
| 3991 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3992 | static int |
| 3993 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3994 | { |
| 3995 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3996 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3997 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3998 | "be set to %d, allowed range is [0, 1]\n", |
| 3999 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4000 | vport->cfg_restrict_login = 1; |
| 4001 | return -EINVAL; |
| 4002 | } |
| 4003 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4004 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4005 | "0468 lpfc_restrict_login must be 0 for " |
| 4006 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4007 | vport->cfg_restrict_login = 0; |
| 4008 | return 0; |
| 4009 | } |
| 4010 | vport->cfg_restrict_login = val; |
| 4011 | return 0; |
| 4012 | } |
| 4013 | lpfc_vport_param_store(restrict_login); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4014 | static DEVICE_ATTR_RW(lpfc_restrict_login); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4015 | |
| 4016 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4017 | # Some disk devices have a "select ID" or "select Target" capability. |
| 4018 | # From a protocol standpoint "select ID" usually means select the |
| 4019 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 4020 | # annex" which contains a table that maps a "select ID" (a number |
| 4021 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 4022 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 4023 | # ALPA. |
| 4024 | # |
| 4025 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 4026 | # cause the lpfc driver to use an inverted table, effectively |
| 4027 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 4028 | # |
| 4029 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 4030 | # and will not work across a fabric. Also this parameter will take |
| 4031 | # effect only in the case when ALPA map is not available.) |
| 4032 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4033 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 4034 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4035 | |
| 4036 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4037 | # lpfc_topology: link topology for init link |
| 4038 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 4039 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4040 | # 0x02 = attempt point-to-point mode only |
| 4041 | # 0x04 = attempt loop mode only |
| 4042 | # 0x06 = attempt point-to-point mode then loop |
| 4043 | # Set point-to-point mode if you want to run as an N_Port. |
| 4044 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 4045 | # Default value is 0. |
| 4046 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 4047 | LPFC_ATTR(topology, 0, 0, 6, |
| 4048 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4049 | |
| 4050 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4051 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4052 | * @phba: lpfc_hba pointer. |
| 4053 | * @val: topology value. |
| 4054 | * |
| 4055 | * Description: |
| 4056 | * If val is in a valid range then set the adapter's topology field and |
| 4057 | * issue a lip; if the lip fails reset the topology to the old value. |
| 4058 | * |
| 4059 | * If the value is not in range log a kernel error message and return an error. |
| 4060 | * |
| 4061 | * Returns: |
| 4062 | * zero if val is in range and lip okay |
| 4063 | * non-zero return value from lpfc_issue_lip() |
| 4064 | * -EINVAL val out of range |
| 4065 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4066 | static ssize_t |
| 4067 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 4068 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4069 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4070 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4071 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4072 | struct lpfc_hba *phba = vport->phba; |
| 4073 | int val = 0; |
| 4074 | int nolip = 0; |
| 4075 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4076 | int err; |
| 4077 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4078 | |
| 4079 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4080 | nolip = 1; |
| 4081 | val_buf = &buf[strlen("nolip ")]; |
| 4082 | } |
| 4083 | |
| 4084 | if (!isdigit(val_buf[0])) |
| 4085 | return -EINVAL; |
| 4086 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4087 | return -EINVAL; |
| 4088 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4089 | if (val >= 0 && val <= 6) { |
| 4090 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4091 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 4092 | val == 4) { |
| 4093 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4094 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4095 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4096 | return -EINVAL; |
| 4097 | } |
James Smart | 76558b2 | 2018-11-29 16:09:38 -0800 | [diff] [blame] | 4098 | if ((phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC || |
| 4099 | phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC) && |
James Smart | f6978f4 | 2019-05-21 17:48:57 -0700 | [diff] [blame] | 4100 | val == 4) { |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4101 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | f6978f4 | 2019-05-21 17:48:57 -0700 | [diff] [blame] | 4102 | "3114 Loop mode not supported\n"); |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4103 | return -EINVAL; |
| 4104 | } |
| 4105 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4106 | if (nolip) |
| 4107 | return strlen(buf); |
| 4108 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4109 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4110 | "3054 lpfc_topology changed from %d to %d\n", |
| 4111 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 4112 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 4113 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4114 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4115 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4116 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4117 | return -EINVAL; |
| 4118 | } else |
| 4119 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4120 | } |
| 4121 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4122 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 4123 | "allowed range is [0, 6]\n", |
| 4124 | phba->brd_no, val); |
| 4125 | return -EINVAL; |
| 4126 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 4127 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4128 | lpfc_param_show(topology) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4129 | static DEVICE_ATTR_RW(lpfc_topology); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4130 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4131 | /** |
| 4132 | * lpfc_static_vport_show: Read callback function for |
| 4133 | * lpfc_static_vport sysfs file. |
| 4134 | * @dev: Pointer to class device object. |
| 4135 | * @attr: device attribute structure. |
| 4136 | * @buf: Data buffer. |
| 4137 | * |
| 4138 | * This function is the read call back function for |
| 4139 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 4140 | * sysfs file report the mageability of the vport. |
| 4141 | **/ |
| 4142 | static ssize_t |
| 4143 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 4144 | char *buf) |
| 4145 | { |
| 4146 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4147 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4148 | if (vport->vport_flag & STATIC_VPORT) |
| 4149 | sprintf(buf, "1\n"); |
| 4150 | else |
| 4151 | sprintf(buf, "0\n"); |
| 4152 | |
| 4153 | return strlen(buf); |
| 4154 | } |
| 4155 | |
| 4156 | /* |
| 4157 | * Sysfs attribute to control the statistical data collection. |
| 4158 | */ |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 4159 | static DEVICE_ATTR_RO(lpfc_static_vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4160 | |
| 4161 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4162 | * 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] | 4163 | * @dev: Pointer to class device. |
| 4164 | * @buf: Data buffer. |
| 4165 | * @count: Size of the data buffer. |
| 4166 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 4167 | * 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] | 4168 | * sysfs file. This function parse the command written to the sysfs file |
| 4169 | * and take appropriate action. These commands are used for controlling |
| 4170 | * driver statistical data collection. |
| 4171 | * Following are the command this function handles. |
| 4172 | * |
| 4173 | * setbucket <bucket_type> <base> <step> |
| 4174 | * = Set the latency buckets. |
| 4175 | * destroybucket = destroy all the buckets. |
| 4176 | * start = start data collection |
| 4177 | * stop = stop data collection |
| 4178 | * reset = reset the collected data |
| 4179 | **/ |
| 4180 | static ssize_t |
| 4181 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 4182 | const char *buf, size_t count) |
| 4183 | { |
| 4184 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4185 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4186 | struct lpfc_hba *phba = vport->phba; |
| 4187 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 4188 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 4189 | unsigned long i; |
| 4190 | char *str_ptr, *token; |
| 4191 | struct lpfc_vport **vports; |
| 4192 | struct Scsi_Host *v_shost; |
| 4193 | char *bucket_type_str, *base_str, *step_str; |
| 4194 | unsigned long base, step, bucket_type; |
| 4195 | |
| 4196 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4197 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4198 | return -EINVAL; |
| 4199 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 4200 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4201 | str_ptr = &bucket_data[0]; |
| 4202 | /* Ignore this token - this is command token */ |
| 4203 | token = strsep(&str_ptr, "\t "); |
| 4204 | if (!token) |
| 4205 | return -EINVAL; |
| 4206 | |
| 4207 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 4208 | if (!bucket_type_str) |
| 4209 | return -EINVAL; |
| 4210 | |
| 4211 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 4212 | bucket_type = LPFC_LINEAR_BUCKET; |
| 4213 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 4214 | bucket_type = LPFC_POWER2_BUCKET; |
| 4215 | else |
| 4216 | return -EINVAL; |
| 4217 | |
| 4218 | base_str = strsep(&str_ptr, "\t "); |
| 4219 | if (!base_str) |
| 4220 | return -EINVAL; |
| 4221 | base = simple_strtoul(base_str, NULL, 0); |
| 4222 | |
| 4223 | step_str = strsep(&str_ptr, "\t "); |
| 4224 | if (!step_str) |
| 4225 | return -EINVAL; |
| 4226 | step = simple_strtoul(step_str, NULL, 0); |
| 4227 | if (!step) |
| 4228 | return -EINVAL; |
| 4229 | |
| 4230 | /* Block the data collection for every vport */ |
| 4231 | vports = lpfc_create_vport_work_array(phba); |
| 4232 | if (vports == NULL) |
| 4233 | return -ENOMEM; |
| 4234 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4235 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4236 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4237 | spin_lock_irq(v_shost->host_lock); |
| 4238 | /* Block and reset data collection */ |
| 4239 | vports[i]->stat_data_blocked = 1; |
| 4240 | if (vports[i]->stat_data_enabled) |
| 4241 | lpfc_vport_reset_stat_data(vports[i]); |
| 4242 | spin_unlock_irq(v_shost->host_lock); |
| 4243 | } |
| 4244 | |
| 4245 | /* Set the bucket attributes */ |
| 4246 | phba->bucket_type = bucket_type; |
| 4247 | phba->bucket_base = base; |
| 4248 | phba->bucket_step = step; |
| 4249 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4250 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4251 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4252 | |
| 4253 | /* Unblock data collection */ |
| 4254 | spin_lock_irq(v_shost->host_lock); |
| 4255 | vports[i]->stat_data_blocked = 0; |
| 4256 | spin_unlock_irq(v_shost->host_lock); |
| 4257 | } |
| 4258 | lpfc_destroy_vport_work_array(phba, vports); |
| 4259 | return strlen(buf); |
| 4260 | } |
| 4261 | |
| 4262 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 4263 | vports = lpfc_create_vport_work_array(phba); |
| 4264 | if (vports == NULL) |
| 4265 | return -ENOMEM; |
| 4266 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4267 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4268 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4269 | spin_lock_irq(shost->host_lock); |
| 4270 | vports[i]->stat_data_blocked = 1; |
| 4271 | lpfc_free_bucket(vport); |
| 4272 | vport->stat_data_enabled = 0; |
| 4273 | vports[i]->stat_data_blocked = 0; |
| 4274 | spin_unlock_irq(shost->host_lock); |
| 4275 | } |
| 4276 | lpfc_destroy_vport_work_array(phba, vports); |
| 4277 | phba->bucket_type = LPFC_NO_BUCKET; |
| 4278 | phba->bucket_base = 0; |
| 4279 | phba->bucket_step = 0; |
| 4280 | return strlen(buf); |
| 4281 | } |
| 4282 | |
| 4283 | if (!strncmp(buf, "start", strlen("start"))) { |
| 4284 | /* If no buckets configured return error */ |
| 4285 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 4286 | return -EINVAL; |
| 4287 | spin_lock_irq(shost->host_lock); |
| 4288 | if (vport->stat_data_enabled) { |
| 4289 | spin_unlock_irq(shost->host_lock); |
| 4290 | return strlen(buf); |
| 4291 | } |
| 4292 | lpfc_alloc_bucket(vport); |
| 4293 | vport->stat_data_enabled = 1; |
| 4294 | spin_unlock_irq(shost->host_lock); |
| 4295 | return strlen(buf); |
| 4296 | } |
| 4297 | |
| 4298 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 4299 | spin_lock_irq(shost->host_lock); |
| 4300 | if (vport->stat_data_enabled == 0) { |
| 4301 | spin_unlock_irq(shost->host_lock); |
| 4302 | return strlen(buf); |
| 4303 | } |
| 4304 | lpfc_free_bucket(vport); |
| 4305 | vport->stat_data_enabled = 0; |
| 4306 | spin_unlock_irq(shost->host_lock); |
| 4307 | return strlen(buf); |
| 4308 | } |
| 4309 | |
| 4310 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 4311 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 4312 | || !vport->stat_data_enabled) |
| 4313 | return strlen(buf); |
| 4314 | spin_lock_irq(shost->host_lock); |
| 4315 | vport->stat_data_blocked = 1; |
| 4316 | lpfc_vport_reset_stat_data(vport); |
| 4317 | vport->stat_data_blocked = 0; |
| 4318 | spin_unlock_irq(shost->host_lock); |
| 4319 | return strlen(buf); |
| 4320 | } |
| 4321 | return -EINVAL; |
| 4322 | } |
| 4323 | |
| 4324 | |
| 4325 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4326 | * 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] | 4327 | * @dev: Pointer to class device object. |
| 4328 | * @buf: Data buffer. |
| 4329 | * |
| 4330 | * This function is the read call back function for |
| 4331 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 4332 | * current statistical data collection state. |
| 4333 | **/ |
| 4334 | static ssize_t |
| 4335 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 4336 | char *buf) |
| 4337 | { |
| 4338 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4339 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4340 | struct lpfc_hba *phba = vport->phba; |
| 4341 | int index = 0; |
| 4342 | int i; |
| 4343 | char *bucket_type; |
| 4344 | unsigned long bucket_value; |
| 4345 | |
| 4346 | switch (phba->bucket_type) { |
| 4347 | case LPFC_LINEAR_BUCKET: |
| 4348 | bucket_type = "linear"; |
| 4349 | break; |
| 4350 | case LPFC_POWER2_BUCKET: |
| 4351 | bucket_type = "power2"; |
| 4352 | break; |
| 4353 | default: |
| 4354 | bucket_type = "No Bucket"; |
| 4355 | break; |
| 4356 | } |
| 4357 | |
| 4358 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 4359 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 4360 | " Bucket step :%d\nLatency Ranges :", |
| 4361 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 4362 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 4363 | index = strlen(buf); |
| 4364 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 4365 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4366 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 4367 | bucket_value = phba->bucket_base + |
| 4368 | phba->bucket_step * i; |
| 4369 | else |
| 4370 | bucket_value = phba->bucket_base + |
| 4371 | (1 << i) * phba->bucket_step; |
| 4372 | |
| 4373 | if (index + 10 > PAGE_SIZE) |
| 4374 | break; |
| 4375 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 4376 | index = strlen(buf); |
| 4377 | } |
| 4378 | } |
| 4379 | sprintf(&buf[index], "\n"); |
| 4380 | return strlen(buf); |
| 4381 | } |
| 4382 | |
| 4383 | /* |
| 4384 | * Sysfs attribute to control the statistical data collection. |
| 4385 | */ |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4386 | static DEVICE_ATTR_RW(lpfc_stat_data_ctrl); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4387 | |
| 4388 | /* |
| 4389 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 4390 | */ |
| 4391 | |
| 4392 | /* |
| 4393 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 4394 | * for each target. |
| 4395 | */ |
| 4396 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 4397 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 4398 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 4399 | |
| 4400 | |
| 4401 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4402 | * 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] | 4403 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4404 | * @kobj: Pointer to the kernel object |
| 4405 | * @bin_attr: Attribute object |
| 4406 | * @buff: Buffer pointer |
| 4407 | * @off: File offset |
| 4408 | * @count: Buffer size |
| 4409 | * |
| 4410 | * This function is the read call back function for lpfc_drvr_stat_data |
| 4411 | * sysfs file. This function export the statistical data to user |
| 4412 | * applications. |
| 4413 | **/ |
| 4414 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4415 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 4416 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4417 | char *buf, loff_t off, size_t count) |
| 4418 | { |
| 4419 | struct device *dev = container_of(kobj, struct device, |
| 4420 | kobj); |
| 4421 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4422 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4423 | struct lpfc_hba *phba = vport->phba; |
| 4424 | int i = 0, index = 0; |
| 4425 | unsigned long nport_index; |
| 4426 | struct lpfc_nodelist *ndlp = NULL; |
| 4427 | nport_index = (unsigned long)off / |
| 4428 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 4429 | |
| 4430 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 4431 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 4432 | return 0; |
| 4433 | |
| 4434 | spin_lock_irq(shost->host_lock); |
| 4435 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 4436 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 4437 | continue; |
| 4438 | |
| 4439 | if (nport_index > 0) { |
| 4440 | nport_index--; |
| 4441 | continue; |
| 4442 | } |
| 4443 | |
| 4444 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 4445 | > count) |
| 4446 | break; |
| 4447 | |
| 4448 | if (!ndlp->lat_data) |
| 4449 | continue; |
| 4450 | |
| 4451 | /* Print the WWN */ |
| 4452 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 4453 | ndlp->nlp_portname.u.wwn[0], |
| 4454 | ndlp->nlp_portname.u.wwn[1], |
| 4455 | ndlp->nlp_portname.u.wwn[2], |
| 4456 | ndlp->nlp_portname.u.wwn[3], |
| 4457 | ndlp->nlp_portname.u.wwn[4], |
| 4458 | ndlp->nlp_portname.u.wwn[5], |
| 4459 | ndlp->nlp_portname.u.wwn[6], |
| 4460 | ndlp->nlp_portname.u.wwn[7]); |
| 4461 | |
| 4462 | index = strlen(buf); |
| 4463 | |
| 4464 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4465 | sprintf(&buf[index], "%010u,", |
| 4466 | ndlp->lat_data[i].cmd_count); |
| 4467 | index = strlen(buf); |
| 4468 | } |
| 4469 | sprintf(&buf[index], "\n"); |
| 4470 | index = strlen(buf); |
| 4471 | } |
| 4472 | spin_unlock_irq(shost->host_lock); |
| 4473 | return index; |
| 4474 | } |
| 4475 | |
| 4476 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4477 | .attr = { |
| 4478 | .name = "lpfc_drvr_stat_data", |
| 4479 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4480 | }, |
| 4481 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4482 | .read = sysfs_drvr_stat_data_read, |
| 4483 | .write = NULL, |
| 4484 | }; |
| 4485 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4486 | /* |
| 4487 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4488 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4489 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4490 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4491 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4492 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4493 | * @phba: lpfc_hba pointer. |
| 4494 | * @val: link speed value. |
| 4495 | * |
| 4496 | * Description: |
| 4497 | * If val is in a valid range then set the adapter's link speed field and |
| 4498 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4499 | * |
| 4500 | * Notes: |
| 4501 | * If the value is not in range log a kernel error message and return an error. |
| 4502 | * |
| 4503 | * Returns: |
| 4504 | * zero if val is in range and lip okay. |
| 4505 | * non-zero return value from lpfc_issue_lip() |
| 4506 | * -EINVAL val out of range |
| 4507 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4508 | static ssize_t |
| 4509 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4510 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4511 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4512 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4513 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4514 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4515 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4516 | int nolip = 0; |
| 4517 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4518 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4519 | uint32_t prev_val, if_type; |
| 4520 | |
| 4521 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame] | 4522 | if (if_type >= LPFC_SLI_INTF_IF_TYPE_2 && |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4523 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4524 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4525 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4526 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4527 | nolip = 1; |
| 4528 | val_buf = &buf[strlen("nolip ")]; |
| 4529 | } |
| 4530 | |
| 4531 | if (!isdigit(val_buf[0])) |
| 4532 | return -EINVAL; |
| 4533 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4534 | return -EINVAL; |
| 4535 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4536 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4537 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4538 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4539 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4540 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4541 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4542 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4543 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4544 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4545 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4546 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) || |
| 4547 | ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4548 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4549 | "2879 lpfc_link_speed attribute cannot be set " |
| 4550 | "to %d. Speed is not supported by this port.\n", |
| 4551 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4552 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4553 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4554 | if (val >= LPFC_USER_LINK_SPEED_16G && |
| 4555 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4556 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4557 | "3112 lpfc_link_speed attribute cannot be set " |
| 4558 | "to %d. Speed is not supported in loop mode.\n", |
| 4559 | val); |
| 4560 | return -EINVAL; |
| 4561 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4562 | |
| 4563 | switch (val) { |
| 4564 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4565 | case LPFC_USER_LINK_SPEED_1G: |
| 4566 | case LPFC_USER_LINK_SPEED_2G: |
| 4567 | case LPFC_USER_LINK_SPEED_4G: |
| 4568 | case LPFC_USER_LINK_SPEED_8G: |
| 4569 | case LPFC_USER_LINK_SPEED_16G: |
| 4570 | case LPFC_USER_LINK_SPEED_32G: |
| 4571 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4572 | prev_val = phba->cfg_link_speed; |
| 4573 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4574 | if (nolip) |
| 4575 | return strlen(buf); |
| 4576 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4577 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4578 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4579 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4580 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4581 | } |
| 4582 | return strlen(buf); |
| 4583 | default: |
| 4584 | break; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4585 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4586 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4587 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4588 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4589 | "allowed values are [%s]\n", |
| 4590 | val, LPFC_LINK_SPEED_STRING); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4591 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4592 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4593 | } |
| 4594 | |
| 4595 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4596 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4597 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4598 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4599 | |
| 4600 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4601 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4602 | * @phba: lpfc_hba pointer. |
| 4603 | * @val: link speed value. |
| 4604 | * |
| 4605 | * Description: |
| 4606 | * If val is in a valid range then set the adapter's link speed field. |
| 4607 | * |
| 4608 | * Notes: |
| 4609 | * If the value is not in range log a kernel error message, clear the link |
| 4610 | * speed and return an error. |
| 4611 | * |
| 4612 | * Returns: |
| 4613 | * zero if val saved. |
| 4614 | * -EINVAL val out of range |
| 4615 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4616 | static int |
| 4617 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4618 | { |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4619 | if (val >= LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4620 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4621 | "3111 lpfc_link_speed of %d cannot " |
| 4622 | "support loop mode, setting topology to default.\n", |
| 4623 | val); |
| 4624 | phba->cfg_topology = 0; |
| 4625 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4626 | |
| 4627 | switch (val) { |
| 4628 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4629 | case LPFC_USER_LINK_SPEED_1G: |
| 4630 | case LPFC_USER_LINK_SPEED_2G: |
| 4631 | case LPFC_USER_LINK_SPEED_4G: |
| 4632 | case LPFC_USER_LINK_SPEED_8G: |
| 4633 | case LPFC_USER_LINK_SPEED_16G: |
| 4634 | case LPFC_USER_LINK_SPEED_32G: |
| 4635 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4636 | phba->cfg_link_speed = val; |
| 4637 | return 0; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4638 | default: |
| 4639 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4640 | "0405 lpfc_link_speed attribute cannot " |
| 4641 | "be set to %d, allowed values are " |
| 4642 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
| 4643 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
| 4644 | return -EINVAL; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4645 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4646 | } |
| 4647 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4648 | static DEVICE_ATTR_RW(lpfc_link_speed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4649 | |
| 4650 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4651 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4652 | # 0 = aer disabled or not supported |
| 4653 | # 1 = aer supported and enabled (default) |
| 4654 | # Value range is [0,1]. Default value is 1. |
| 4655 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4656 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4657 | "Enable PCIe device AER support"); |
| 4658 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4659 | |
| 4660 | /** |
| 4661 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4662 | * |
| 4663 | * @dev: class device that is converted into a Scsi_host. |
| 4664 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4665 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4666 | * @count: unused variable. |
| 4667 | * |
| 4668 | * Description: |
| 4669 | * If the val is 1 and currently the device's AER capability was not |
| 4670 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4671 | * enable the device's AER capability. If the helper routine enabling |
| 4672 | * AER returns success, update the device's cfg_aer_support flag to |
| 4673 | * indicate AER is supported by the device; otherwise, if the device |
| 4674 | * AER capability is already enabled to support AER, then do nothing. |
| 4675 | * |
| 4676 | * If the val is 0 and currently the device's AER support was enabled, |
| 4677 | * invoke the kernel's disable AER helper routine. After that, update |
| 4678 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4679 | * by the device; otherwise, if the device AER capability is already |
| 4680 | * disabled from supporting AER, then do nothing. |
| 4681 | * |
| 4682 | * Returns: |
| 4683 | * length of the buf on success if val is in range the intended mode |
| 4684 | * is supported. |
| 4685 | * -EINVAL if val out of range or intended mode is not supported. |
| 4686 | **/ |
| 4687 | static ssize_t |
| 4688 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4689 | const char *buf, size_t count) |
| 4690 | { |
| 4691 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4692 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4693 | struct lpfc_hba *phba = vport->phba; |
| 4694 | int val = 0, rc = -EINVAL; |
| 4695 | |
| 4696 | if (!isdigit(buf[0])) |
| 4697 | return -EINVAL; |
| 4698 | if (sscanf(buf, "%i", &val) != 1) |
| 4699 | return -EINVAL; |
| 4700 | |
| 4701 | switch (val) { |
| 4702 | case 0: |
| 4703 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4704 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4705 | if (!rc) { |
| 4706 | spin_lock_irq(&phba->hbalock); |
| 4707 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4708 | spin_unlock_irq(&phba->hbalock); |
| 4709 | phba->cfg_aer_support = 0; |
| 4710 | rc = strlen(buf); |
| 4711 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4712 | rc = -EPERM; |
| 4713 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4714 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4715 | rc = strlen(buf); |
| 4716 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4717 | break; |
| 4718 | case 1: |
| 4719 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4720 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4721 | if (!rc) { |
| 4722 | spin_lock_irq(&phba->hbalock); |
| 4723 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4724 | spin_unlock_irq(&phba->hbalock); |
| 4725 | phba->cfg_aer_support = 1; |
| 4726 | rc = strlen(buf); |
| 4727 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4728 | rc = -EPERM; |
| 4729 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4730 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4731 | rc = strlen(buf); |
| 4732 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4733 | break; |
| 4734 | default: |
| 4735 | rc = -EINVAL; |
| 4736 | break; |
| 4737 | } |
| 4738 | return rc; |
| 4739 | } |
| 4740 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4741 | static DEVICE_ATTR_RW(lpfc_aer_support); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4742 | |
| 4743 | /** |
| 4744 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4745 | * @dev: class device that is converted into a Scsi_host. |
| 4746 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4747 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4748 | * @count: unused variable. |
| 4749 | * |
| 4750 | * Description: |
| 4751 | * If the @buf contains 1 and the device currently has the AER support |
| 4752 | * enabled, then invokes the kernel AER helper routine |
| 4753 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4754 | * error status register. |
| 4755 | * |
| 4756 | * Notes: |
| 4757 | * |
| 4758 | * Returns: |
| 4759 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4760 | * enabled with the AER support. |
| 4761 | **/ |
| 4762 | static ssize_t |
| 4763 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4764 | const char *buf, size_t count) |
| 4765 | { |
| 4766 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4767 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4768 | struct lpfc_hba *phba = vport->phba; |
| 4769 | int val, rc = -1; |
| 4770 | |
| 4771 | if (!isdigit(buf[0])) |
| 4772 | return -EINVAL; |
| 4773 | if (sscanf(buf, "%i", &val) != 1) |
| 4774 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4775 | if (val != 1) |
| 4776 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4777 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4778 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4779 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4780 | |
| 4781 | if (rc == 0) |
| 4782 | return strlen(buf); |
| 4783 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4784 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4785 | } |
| 4786 | |
| 4787 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4788 | lpfc_aer_cleanup_state); |
| 4789 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4790 | /** |
| 4791 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4792 | * |
| 4793 | * @dev: class device that is converted into a Scsi_host. |
| 4794 | * @attr: device attribute, not used. |
| 4795 | * @buf: containing the string the number of vfs to be enabled. |
| 4796 | * @count: unused variable. |
| 4797 | * |
| 4798 | * Description: |
| 4799 | * When this api is called either through user sysfs, the driver shall |
| 4800 | * try to enable or disable SR-IOV virtual functions according to the |
| 4801 | * following: |
| 4802 | * |
| 4803 | * If zero virtual function has been enabled to the physical function, |
| 4804 | * the driver shall invoke the pci enable virtual function api trying |
| 4805 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4806 | * than the maximum supported, the maximum virtual function number will |
| 4807 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4808 | * be used for invoking the api. If the api call returned success, the |
| 4809 | * actual number of virtual functions enabled will be set to the driver |
| 4810 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4811 | * cfg_sriov_nr_virtfn remains zero. |
| 4812 | * |
| 4813 | * If none-zero virtual functions have already been enabled to the |
| 4814 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4815 | * -EINVAL will be returned and the driver does nothing; |
| 4816 | * |
| 4817 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4818 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4819 | * disabling virtual function api shall be invoded to disable all the |
| 4820 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4821 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4822 | * nothing. |
| 4823 | * |
| 4824 | * Returns: |
| 4825 | * length of the buf on success if val is in range the intended mode |
| 4826 | * is supported. |
| 4827 | * -EINVAL if val out of range or intended mode is not supported. |
| 4828 | **/ |
| 4829 | static ssize_t |
| 4830 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4831 | const char *buf, size_t count) |
| 4832 | { |
| 4833 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4834 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4835 | struct lpfc_hba *phba = vport->phba; |
| 4836 | struct pci_dev *pdev = phba->pcidev; |
| 4837 | int val = 0, rc = -EINVAL; |
| 4838 | |
| 4839 | /* Sanity check on user data */ |
| 4840 | if (!isdigit(buf[0])) |
| 4841 | return -EINVAL; |
| 4842 | if (sscanf(buf, "%i", &val) != 1) |
| 4843 | return -EINVAL; |
| 4844 | if (val < 0) |
| 4845 | return -EINVAL; |
| 4846 | |
| 4847 | /* Request disabling virtual functions */ |
| 4848 | if (val == 0) { |
| 4849 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4850 | pci_disable_sriov(pdev); |
| 4851 | phba->cfg_sriov_nr_virtfn = 0; |
| 4852 | } |
| 4853 | return strlen(buf); |
| 4854 | } |
| 4855 | |
| 4856 | /* Request enabling virtual functions */ |
| 4857 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4858 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4859 | "3018 There are %d virtual functions " |
| 4860 | "enabled on physical function.\n", |
| 4861 | phba->cfg_sriov_nr_virtfn); |
| 4862 | return -EEXIST; |
| 4863 | } |
| 4864 | |
| 4865 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4866 | phba->cfg_sriov_nr_virtfn = val; |
| 4867 | else { |
| 4868 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4869 | "3019 Enabling %d virtual functions is not " |
| 4870 | "allowed.\n", val); |
| 4871 | return -EINVAL; |
| 4872 | } |
| 4873 | |
| 4874 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4875 | if (rc) { |
| 4876 | phba->cfg_sriov_nr_virtfn = 0; |
| 4877 | rc = -EPERM; |
| 4878 | } else |
| 4879 | rc = strlen(buf); |
| 4880 | |
| 4881 | return rc; |
| 4882 | } |
| 4883 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4884 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4885 | "Enable PCIe device SR-IOV virtual fn"); |
| 4886 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4887 | lpfc_param_show(sriov_nr_virtfn) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4888 | static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4889 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4890 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4891 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4892 | * |
| 4893 | * @dev: class device that is converted into a Scsi_host. |
| 4894 | * @attr: device attribute, not used. |
| 4895 | * @buf: containing the string the number of vfs to be enabled. |
| 4896 | * @count: unused variable. |
| 4897 | * |
| 4898 | * Description: |
| 4899 | * |
| 4900 | * Returns: |
| 4901 | * length of the buf on success if val is in range the intended mode |
| 4902 | * is supported. |
| 4903 | * -EINVAL if val out of range or intended mode is not supported. |
| 4904 | **/ |
| 4905 | static ssize_t |
| 4906 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4907 | struct device_attribute *attr, |
| 4908 | const char *buf, size_t count) |
| 4909 | { |
| 4910 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4911 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4912 | struct lpfc_hba *phba = vport->phba; |
| 4913 | int val = 0, rc = -EINVAL; |
| 4914 | |
| 4915 | /* Sanity check on user data */ |
| 4916 | if (!isdigit(buf[0])) |
| 4917 | return -EINVAL; |
| 4918 | if (sscanf(buf, "%i", &val) != 1) |
| 4919 | return -EINVAL; |
| 4920 | if (val != 1) |
| 4921 | return -EINVAL; |
| 4922 | |
| 4923 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4924 | if (rc) |
| 4925 | rc = -EPERM; |
| 4926 | else |
| 4927 | rc = strlen(buf); |
| 4928 | return rc; |
| 4929 | } |
| 4930 | |
| 4931 | static int lpfc_req_fw_upgrade; |
| 4932 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4933 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4934 | lpfc_param_show(request_firmware_upgrade) |
| 4935 | |
| 4936 | /** |
| 4937 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4938 | * @phba: lpfc_hba pointer. |
| 4939 | * @val: 0 or 1. |
| 4940 | * |
| 4941 | * Description: |
| 4942 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4943 | * |
| 4944 | * Returns: |
| 4945 | * zero if val saved. |
| 4946 | * -EINVAL val out of range |
| 4947 | **/ |
| 4948 | static int |
| 4949 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4950 | { |
| 4951 | if (val >= 0 && val <= 1) { |
| 4952 | phba->cfg_request_firmware_upgrade = val; |
| 4953 | return 0; |
| 4954 | } |
| 4955 | return -EINVAL; |
| 4956 | } |
| 4957 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4958 | lpfc_request_firmware_upgrade_show, |
| 4959 | lpfc_request_firmware_upgrade_store); |
| 4960 | |
| 4961 | /** |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 4962 | * lpfc_force_rscn_store |
| 4963 | * |
| 4964 | * @dev: class device that is converted into a Scsi_host. |
| 4965 | * @attr: device attribute, not used. |
| 4966 | * @buf: unused string |
| 4967 | * @count: unused variable. |
| 4968 | * |
| 4969 | * Description: |
| 4970 | * Force the switch to send a RSCN to all other NPorts in our zone |
| 4971 | * If we are direct connect pt2pt, build the RSCN command ourself |
| 4972 | * and send to the other NPort. Not supported for private loop. |
| 4973 | * |
| 4974 | * Returns: |
| 4975 | * 0 - on success |
| 4976 | * -EIO - if command is not sent |
| 4977 | **/ |
| 4978 | static ssize_t |
| 4979 | lpfc_force_rscn_store(struct device *dev, struct device_attribute *attr, |
| 4980 | const char *buf, size_t count) |
| 4981 | { |
| 4982 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4983 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4984 | int i; |
| 4985 | |
| 4986 | i = lpfc_issue_els_rscn(vport, 0); |
| 4987 | if (i) |
| 4988 | return -EIO; |
| 4989 | return strlen(buf); |
| 4990 | } |
| 4991 | |
| 4992 | /* |
| 4993 | * lpfc_force_rscn: Force an RSCN to be sent to all remote NPorts |
| 4994 | * connected to the HBA. |
| 4995 | * |
| 4996 | * Value range is any ascii value |
| 4997 | */ |
| 4998 | static int lpfc_force_rscn; |
| 4999 | module_param(lpfc_force_rscn, int, 0644); |
| 5000 | MODULE_PARM_DESC(lpfc_force_rscn, |
| 5001 | "Force an RSCN to be sent to all remote NPorts"); |
| 5002 | lpfc_param_show(force_rscn) |
| 5003 | |
| 5004 | /** |
| 5005 | * lpfc_force_rscn_init - Force an RSCN to be sent to all remote NPorts |
| 5006 | * @phba: lpfc_hba pointer. |
| 5007 | * @val: unused value. |
| 5008 | * |
| 5009 | * Returns: |
| 5010 | * zero if val saved. |
| 5011 | **/ |
| 5012 | static int |
| 5013 | lpfc_force_rscn_init(struct lpfc_hba *phba, int val) |
| 5014 | { |
| 5015 | return 0; |
| 5016 | } |
| 5017 | static DEVICE_ATTR_RW(lpfc_force_rscn); |
| 5018 | |
| 5019 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5020 | * lpfc_fcp_imax_store |
| 5021 | * |
| 5022 | * @dev: class device that is converted into a Scsi_host. |
| 5023 | * @attr: device attribute, not used. |
| 5024 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 5025 | * @count: unused variable. |
| 5026 | * |
| 5027 | * Description: |
| 5028 | * If val is in a valid range [636,651042], then set the adapter's |
| 5029 | * maximum number of fast-path FCP interrupts per second. |
| 5030 | * |
| 5031 | * Returns: |
| 5032 | * length of the buf on success if val is in range the intended mode |
| 5033 | * is supported. |
| 5034 | * -EINVAL if val out of range or intended mode is not supported. |
| 5035 | **/ |
| 5036 | static ssize_t |
| 5037 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 5038 | const char *buf, size_t count) |
| 5039 | { |
| 5040 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5041 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5042 | struct lpfc_hba *phba = vport->phba; |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5043 | struct lpfc_eq_intr_info *eqi; |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5044 | uint32_t usdelay; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5045 | int val = 0, i; |
| 5046 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5047 | /* fcp_imax is only valid for SLI4 */ |
| 5048 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5049 | return -EINVAL; |
| 5050 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5051 | /* Sanity check on user data */ |
| 5052 | if (!isdigit(buf[0])) |
| 5053 | return -EINVAL; |
| 5054 | if (sscanf(buf, "%i", &val) != 1) |
| 5055 | return -EINVAL; |
| 5056 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5057 | /* |
| 5058 | * Value range for the HBA is [5000,5000000] |
| 5059 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5060 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5061 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5062 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5063 | return -EINVAL; |
| 5064 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5065 | phba->cfg_auto_imax = (val) ? 0 : 1; |
| 5066 | if (phba->cfg_fcp_imax && !val) { |
| 5067 | queue_delayed_work(phba->wq, &phba->eq_delay_work, |
| 5068 | msecs_to_jiffies(LPFC_EQ_DELAY_MSECS)); |
| 5069 | |
| 5070 | for_each_present_cpu(i) { |
| 5071 | eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); |
| 5072 | eqi->icnt = 0; |
| 5073 | } |
| 5074 | } |
| 5075 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5076 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 5077 | |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5078 | if (phba->cfg_fcp_imax) |
| 5079 | usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; |
| 5080 | else |
| 5081 | usdelay = 0; |
| 5082 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5083 | for (i = 0; i < phba->cfg_irq_chann; i += LPFC_MAX_EQ_DELAY_EQID_CNT) |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5084 | lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT, |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5085 | usdelay); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5086 | |
| 5087 | return strlen(buf); |
| 5088 | } |
| 5089 | |
| 5090 | /* |
| 5091 | # 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] | 5092 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5093 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5094 | # 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] | 5095 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5096 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5097 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 5098 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5099 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5100 | lpfc_param_show(fcp_imax) |
| 5101 | |
| 5102 | /** |
| 5103 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 5104 | * @phba: lpfc_hba pointer. |
| 5105 | * @val: link speed value. |
| 5106 | * |
| 5107 | * Description: |
| 5108 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 5109 | * maximum number of fast-path FCP interrupts per second. |
| 5110 | * |
| 5111 | * Returns: |
| 5112 | * zero if val saved. |
| 5113 | * -EINVAL val out of range |
| 5114 | **/ |
| 5115 | static int |
| 5116 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 5117 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5118 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5119 | phba->cfg_fcp_imax = 0; |
| 5120 | return 0; |
| 5121 | } |
| 5122 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5123 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 5124 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5125 | phba->cfg_fcp_imax = val; |
| 5126 | return 0; |
| 5127 | } |
| 5128 | |
| 5129 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5130 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 5131 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5132 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5133 | |
| 5134 | return 0; |
| 5135 | } |
| 5136 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5137 | static DEVICE_ATTR_RW(lpfc_fcp_imax); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5138 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5139 | /** |
| 5140 | * lpfc_cq_max_proc_limit_store |
| 5141 | * |
| 5142 | * @dev: class device that is converted into a Scsi_host. |
| 5143 | * @attr: device attribute, not used. |
| 5144 | * @buf: string with the cq max processing limit of cqes |
| 5145 | * @count: unused variable. |
| 5146 | * |
| 5147 | * Description: |
| 5148 | * If val is in a valid range, then set value on each cq |
| 5149 | * |
| 5150 | * Returns: |
| 5151 | * The length of the buf: if successful |
| 5152 | * -ERANGE: if val is not in the valid range |
| 5153 | * -EINVAL: if bad value format or intended mode is not supported. |
| 5154 | **/ |
| 5155 | static ssize_t |
| 5156 | lpfc_cq_max_proc_limit_store(struct device *dev, struct device_attribute *attr, |
| 5157 | const char *buf, size_t count) |
| 5158 | { |
| 5159 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5160 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5161 | struct lpfc_hba *phba = vport->phba; |
| 5162 | struct lpfc_queue *eq, *cq; |
| 5163 | unsigned long val; |
| 5164 | int i; |
| 5165 | |
| 5166 | /* cq_max_proc_limit is only valid for SLI4 */ |
| 5167 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5168 | return -EINVAL; |
| 5169 | |
| 5170 | /* Sanity check on user data */ |
| 5171 | if (!isdigit(buf[0])) |
| 5172 | return -EINVAL; |
| 5173 | if (kstrtoul(buf, 0, &val)) |
| 5174 | return -EINVAL; |
| 5175 | |
| 5176 | if (val < LPFC_CQ_MIN_PROC_LIMIT || val > LPFC_CQ_MAX_PROC_LIMIT) |
| 5177 | return -ERANGE; |
| 5178 | |
| 5179 | phba->cfg_cq_max_proc_limit = (uint32_t)val; |
| 5180 | |
| 5181 | /* set the values on the cq's */ |
| 5182 | for (i = 0; i < phba->cfg_irq_chann; i++) { |
James Smart | 657add4 | 2019-05-21 17:49:06 -0700 | [diff] [blame] | 5183 | /* Get the EQ corresponding to the IRQ vector */ |
| 5184 | eq = phba->sli4_hba.hba_eq_hdl[i].eq; |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5185 | if (!eq) |
| 5186 | continue; |
| 5187 | |
| 5188 | list_for_each_entry(cq, &eq->child_list, list) |
| 5189 | cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, |
| 5190 | cq->entry_count); |
| 5191 | } |
| 5192 | |
| 5193 | return strlen(buf); |
| 5194 | } |
| 5195 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5196 | /* |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5197 | * lpfc_cq_max_proc_limit: The maximum number CQE entries processed in an |
| 5198 | * itteration of CQ processing. |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5199 | */ |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5200 | static int lpfc_cq_max_proc_limit = LPFC_CQ_DEF_MAX_PROC_LIMIT; |
| 5201 | module_param(lpfc_cq_max_proc_limit, int, 0644); |
| 5202 | MODULE_PARM_DESC(lpfc_cq_max_proc_limit, |
| 5203 | "Set the maximum number CQEs processed in an iteration of " |
| 5204 | "CQ processing"); |
| 5205 | lpfc_param_show(cq_max_proc_limit) |
| 5206 | |
| 5207 | /* |
| 5208 | * lpfc_cq_poll_threshold: Set the threshold of CQE completions in a |
| 5209 | * single handler call which should request a polled completion rather |
| 5210 | * than re-enabling interrupts. |
| 5211 | */ |
| 5212 | LPFC_ATTR_RW(cq_poll_threshold, LPFC_CQ_DEF_THRESHOLD_TO_POLL, |
| 5213 | LPFC_CQ_MIN_THRESHOLD_TO_POLL, |
| 5214 | LPFC_CQ_MAX_THRESHOLD_TO_POLL, |
| 5215 | "CQE Processing Threshold to enable Polling"); |
| 5216 | |
| 5217 | /** |
| 5218 | * lpfc_cq_max_proc_limit_init - Set the initial cq max_proc_limit |
| 5219 | * @phba: lpfc_hba pointer. |
| 5220 | * @val: entry limit |
| 5221 | * |
| 5222 | * Description: |
| 5223 | * If val is in a valid range, then initialize the adapter's maximum |
| 5224 | * value. |
| 5225 | * |
| 5226 | * Returns: |
| 5227 | * Always returns 0 for success, even if value not always set to |
| 5228 | * requested value. If value out of range or not supported, will fall |
| 5229 | * back to default. |
| 5230 | **/ |
| 5231 | static int |
| 5232 | lpfc_cq_max_proc_limit_init(struct lpfc_hba *phba, int val) |
| 5233 | { |
| 5234 | phba->cfg_cq_max_proc_limit = LPFC_CQ_DEF_MAX_PROC_LIMIT; |
| 5235 | |
| 5236 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5237 | return 0; |
| 5238 | |
| 5239 | if (val >= LPFC_CQ_MIN_PROC_LIMIT && val <= LPFC_CQ_MAX_PROC_LIMIT) { |
| 5240 | phba->cfg_cq_max_proc_limit = val; |
| 5241 | return 0; |
| 5242 | } |
| 5243 | |
| 5244 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 5245 | "0371 "LPFC_DRIVER_NAME"_cq_max_proc_limit: " |
| 5246 | "%d out of range, using default\n", |
| 5247 | phba->cfg_cq_max_proc_limit); |
| 5248 | |
| 5249 | return 0; |
| 5250 | } |
| 5251 | |
| 5252 | static DEVICE_ATTR_RW(lpfc_cq_max_proc_limit); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5253 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5254 | /** |
| 5255 | * lpfc_state_show - Display current driver CPU affinity |
| 5256 | * @dev: class converted to a Scsi_host structure. |
| 5257 | * @attr: device attribute, not used. |
| 5258 | * @buf: on return contains text describing the state of the link. |
| 5259 | * |
| 5260 | * Returns: size of formatted string. |
| 5261 | **/ |
| 5262 | static ssize_t |
| 5263 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 5264 | char *buf) |
| 5265 | { |
| 5266 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5267 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5268 | struct lpfc_hba *phba = vport->phba; |
| 5269 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5270 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5271 | |
| 5272 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 5273 | (phba->intr_type != MSIX)) |
| 5274 | return len; |
| 5275 | |
| 5276 | switch (phba->cfg_fcp_cpu_map) { |
| 5277 | case 0: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5278 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5279 | "fcp_cpu_map: No mapping (%d)\n", |
| 5280 | phba->cfg_fcp_cpu_map); |
| 5281 | return len; |
| 5282 | case 1: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5283 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5284 | "fcp_cpu_map: HBA centric mapping (%d): " |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5285 | "%d of %d CPUs online from %d possible CPUs\n", |
| 5286 | phba->cfg_fcp_cpu_map, num_online_cpus(), |
| 5287 | num_present_cpus(), |
| 5288 | phba->sli4_hba.num_possible_cpu); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5289 | break; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5290 | } |
| 5291 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5292 | while (phba->sli4_hba.curr_disp_cpu < |
| 5293 | phba->sli4_hba.num_possible_cpu) { |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5294 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 5295 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5296 | if (!cpu_present(phba->sli4_hba.curr_disp_cpu)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5297 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5298 | "CPU %02d not present\n", |
| 5299 | phba->sli4_hba.curr_disp_cpu); |
| 5300 | else if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) { |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5301 | if (cpup->hdwq == LPFC_VECTOR_MAP_EMPTY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5302 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5303 | buf + len, PAGE_SIZE - len, |
| 5304 | "CPU %02d hdwq None " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5305 | "physid %d coreid %d ht %d ua %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5306 | phba->sli4_hba.curr_disp_cpu, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5307 | cpup->phys_id, cpup->core_id, |
| 5308 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5309 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5310 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5311 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5312 | buf + len, PAGE_SIZE - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5313 | "CPU %02d EQ %04d hdwq %04d " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5314 | "physid %d coreid %d ht %d ua %d\n", |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5315 | phba->sli4_hba.curr_disp_cpu, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5316 | cpup->eq, cpup->hdwq, cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5317 | cpup->core_id, |
| 5318 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5319 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5320 | } else { |
| 5321 | if (cpup->hdwq == LPFC_VECTOR_MAP_EMPTY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5322 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5323 | buf + len, PAGE_SIZE - len, |
| 5324 | "CPU %02d hdwq None " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5325 | "physid %d coreid %d ht %d ua %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5326 | phba->sli4_hba.curr_disp_cpu, |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5327 | cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5328 | cpup->core_id, |
| 5329 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5330 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN), |
| 5331 | cpup->irq); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5332 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5333 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5334 | buf + len, PAGE_SIZE - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5335 | "CPU %02d EQ %04d hdwq %04d " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5336 | "physid %d coreid %d ht %d ua %d IRQ %d\n", |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5337 | phba->sli4_hba.curr_disp_cpu, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5338 | cpup->eq, cpup->hdwq, cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5339 | cpup->core_id, |
| 5340 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5341 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN), |
| 5342 | cpup->irq); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5343 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5344 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5345 | phba->sli4_hba.curr_disp_cpu++; |
| 5346 | |
| 5347 | /* display max number of CPUs keeping some margin */ |
| 5348 | if (phba->sli4_hba.curr_disp_cpu < |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5349 | phba->sli4_hba.num_possible_cpu && |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5350 | (len >= (PAGE_SIZE - 64))) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5351 | len += scnprintf(buf + len, |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5352 | PAGE_SIZE - len, "more...\n"); |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5353 | break; |
| 5354 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5355 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5356 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5357 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_possible_cpu) |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5358 | phba->sli4_hba.curr_disp_cpu = 0; |
| 5359 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5360 | return len; |
| 5361 | } |
| 5362 | |
| 5363 | /** |
| 5364 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 5365 | * @dev: class device that is converted into a Scsi_host. |
| 5366 | * @attr: device attribute, not used. |
| 5367 | * @buf: one or more lpfc_polling_flags values. |
| 5368 | * @count: not used. |
| 5369 | * |
| 5370 | * Returns: |
| 5371 | * -EINVAL - Not implemented yet. |
| 5372 | **/ |
| 5373 | static ssize_t |
| 5374 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 5375 | const char *buf, size_t count) |
| 5376 | { |
| 5377 | int status = -EINVAL; |
| 5378 | return status; |
| 5379 | } |
| 5380 | |
| 5381 | /* |
| 5382 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 5383 | # for the HBA. |
| 5384 | # |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5385 | # Value range is [0 to 1]. Default value is LPFC_HBA_CPU_MAP (1). |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5386 | # 0 - Do not affinitze IRQ vectors |
| 5387 | # 1 - Affintize HBA vectors with respect to each HBA |
| 5388 | # (start with CPU0 for each HBA) |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5389 | # This also defines how Hardware Queues are mapped to specific CPUs. |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5390 | */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5391 | static int lpfc_fcp_cpu_map = LPFC_HBA_CPU_MAP; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5392 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 5393 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 5394 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 5395 | |
| 5396 | /** |
| 5397 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 5398 | * @phba: lpfc_hba pointer. |
| 5399 | * @val: link speed value. |
| 5400 | * |
| 5401 | * Description: |
| 5402 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 5403 | * MSIX vectors. |
| 5404 | * |
| 5405 | * Returns: |
| 5406 | * zero if val saved. |
| 5407 | * -EINVAL val out of range |
| 5408 | **/ |
| 5409 | static int |
| 5410 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 5411 | { |
| 5412 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5413 | phba->cfg_fcp_cpu_map = 0; |
| 5414 | return 0; |
| 5415 | } |
| 5416 | |
| 5417 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 5418 | phba->cfg_fcp_cpu_map = val; |
| 5419 | return 0; |
| 5420 | } |
| 5421 | |
| 5422 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5423 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 5424 | "default\n", val); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5425 | phba->cfg_fcp_cpu_map = LPFC_HBA_CPU_MAP; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5426 | |
| 5427 | return 0; |
| 5428 | } |
| 5429 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5430 | static DEVICE_ATTR_RW(lpfc_fcp_cpu_map); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5431 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5432 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5433 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 5434 | # Value range is [2,3]. Default value is 3. |
| 5435 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5436 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 5437 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5438 | |
| 5439 | /* |
| 5440 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 5441 | # is [0,1]. Default value is 0. |
| 5442 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5443 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 5444 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5445 | |
| 5446 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5447 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 5448 | # that support first burst. |
| 5449 | # Value range is [0,65536]. Default value is 0. |
| 5450 | */ |
| 5451 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 5452 | "First burst size for Targets that support first burst"); |
| 5453 | |
| 5454 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5455 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 5456 | * When the driver is configured as an NVME target, this value is |
| 5457 | * communicated to the NVME initiator in the PRLI response. It is |
| 5458 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 5459 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5460 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5461 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5462 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5463 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 5464 | "NVME Target mode first burst size in 512B increments."); |
| 5465 | |
| 5466 | /* |
| 5467 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 5468 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 5469 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
| 5470 | * processed by the initiator for subsequent NVME FCP IO. For the target |
| 5471 | * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size |
| 5472 | * driver parameter as the target function's first burst size returned to the |
| 5473 | * initiator in the target's NVME PRLI response. Parameter supported on physical |
| 5474 | * port only - no NPIV support. |
| 5475 | * Value range is [0,1]. Default value is 0 (disabled). |
| 5476 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5477 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
| 5478 | "Enable First Burst feature on I and T functions."); |
| 5479 | |
| 5480 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5481 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 5482 | # depth. Default value is 0. When the value of this parameter is zero the |
| 5483 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 5484 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 5485 | # to limit the I/O completion time to the parameter value. |
| 5486 | # The value is set in milliseconds. |
| 5487 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5488 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5489 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5490 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5491 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5492 | static int |
| 5493 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 5494 | { |
| 5495 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5496 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 5497 | |
| 5498 | if (val == vport->cfg_max_scsicmpl_time) |
| 5499 | return 0; |
| 5500 | if ((val < 0) || (val > 60000)) |
| 5501 | return -EINVAL; |
| 5502 | vport->cfg_max_scsicmpl_time = val; |
| 5503 | |
| 5504 | spin_lock_irq(shost->host_lock); |
| 5505 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 5506 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 5507 | continue; |
| 5508 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 5509 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5510 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5511 | } |
| 5512 | spin_unlock_irq(shost->host_lock); |
| 5513 | return 0; |
| 5514 | } |
| 5515 | lpfc_vport_param_store(max_scsicmpl_time); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5516 | static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5517 | |
| 5518 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5519 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 5520 | # range is [0,1]. Default value is 0. |
| 5521 | */ |
| 5522 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 5523 | |
| 5524 | /* |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 5525 | # lpfc_xri_rebalancing: enable or disable XRI rebalancing feature |
| 5526 | # range is [0,1]. Default value is 1. |
| 5527 | */ |
| 5528 | LPFC_ATTR_R(xri_rebalancing, 1, 0, 1, "Enable/Disable XRI rebalancing"); |
| 5529 | |
| 5530 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5531 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 5532 | * range is [0,1]. Default value is 0. |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5533 | * For [0], FCP commands are issued to Work Queues based on upper layer |
| 5534 | * hardware queue index. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5535 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 5536 | * current CPU. |
| 5537 | * |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5538 | * LPFC_FCP_SCHED_BY_HDWQ == 0 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5539 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 5540 | * |
| 5541 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 5542 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 5543 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 5544 | * through WQs will be used. |
| 5545 | */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5546 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_BY_CPU, |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5547 | LPFC_FCP_SCHED_BY_HDWQ, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5548 | LPFC_FCP_SCHED_BY_CPU, |
| 5549 | "Determine scheduling algorithm for " |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5550 | "issuing commands [0] - Hardware Queue, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5551 | |
| 5552 | /* |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 5553 | * lpfc_ns_query: Determine algrithmn for NameServer queries after RSCN |
| 5554 | * range is [0,1]. Default value is 0. |
| 5555 | * For [0], GID_FT is used for NameServer queries after RSCN (default) |
| 5556 | * For [1], GID_PT is used for NameServer queries after RSCN |
| 5557 | * |
| 5558 | */ |
| 5559 | LPFC_ATTR_RW(ns_query, LPFC_NS_QUERY_GID_FT, |
| 5560 | LPFC_NS_QUERY_GID_FT, LPFC_NS_QUERY_GID_PT, |
| 5561 | "Determine algorithm NameServer queries after RSCN " |
| 5562 | "[0] - GID_FT, [1] - GID_PT"); |
| 5563 | |
| 5564 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5565 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 5566 | # range is [0,1]. Default value is 0. |
| 5567 | # For [0], bus reset issues target reset to ALL devices |
| 5568 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 5569 | */ |
| 5570 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 5571 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 5572 | |
| 5573 | |
| 5574 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5575 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 5576 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5577 | # 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] | 5578 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 5579 | # cr_delay is set to 0. |
| 5580 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5581 | 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] | 5582 | "interrupt response is generated"); |
| 5583 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5584 | 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] | 5585 | "interrupt response is generated"); |
| 5586 | |
| 5587 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5588 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 5589 | # cmd/rsp IOCB entries across. |
| 5590 | # Value range is [1,2]. Default value is 1. |
| 5591 | */ |
| 5592 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 5593 | "SLI rings to spread IOCB entries across"); |
| 5594 | |
| 5595 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5596 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 5597 | # identifies what rctl value to configure the additional ring for. |
| 5598 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 5599 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5600 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5601 | 255, "Identifies RCTL for additional ring configuration"); |
| 5602 | |
| 5603 | /* |
| 5604 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 5605 | # identifies what type value to configure the additional ring for. |
| 5606 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 5607 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5608 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5609 | 255, "Identifies TYPE for additional ring configuration"); |
| 5610 | |
| 5611 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5612 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 5613 | # 0 = SmartSAN functionality disabled (default) |
| 5614 | # 1 = SmartSAN functionality enabled |
| 5615 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 5616 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5617 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5618 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 5619 | |
| 5620 | /* |
| 5621 | # lpfc_fdmi_on: Controls FDMI support. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5622 | # 0 No FDMI support |
| 5623 | # 1 Traditional FDMI support (default) |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 5624 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 5625 | # however, if that fails, it will fallback to FDMI-1. |
| 5626 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 5627 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 5628 | # lpfc_fdmi_on. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5629 | # Value range [0,1]. Default value is 1. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5630 | */ |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5631 | LPFC_ATTR_R(fdmi_on, 1, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5632 | |
| 5633 | /* |
| 5634 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 5635 | # discovery). Value range is [1,64]. Default value = 32. |
| 5636 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5637 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5638 | "during discovery"); |
| 5639 | |
| 5640 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 5641 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 5642 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 5643 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 5644 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 5645 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 5646 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 5647 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 5648 | # on a target can take minutes of wall clock time. Additionally, |
| 5649 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 5650 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 5651 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 5652 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 5653 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 5654 | # devices present, when in fact, there is only 1. |
| 5655 | # A customer that is aware of their target behaviors, and the results as |
| 5656 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 5657 | # As mentioned, this value is not used by the lpfc driver, only the |
| 5658 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 5659 | # Value range is [0,65535]. Default value is 255. |
| 5660 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5661 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 5662 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5663 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5664 | /* |
| 5665 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 5666 | # Value range is [1,255], default value is 10. |
| 5667 | */ |
| 5668 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 5669 | "Milliseconds driver will wait between polling FCP ring"); |
| 5670 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5671 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5672 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 5673 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 5674 | */ |
| 5675 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 5676 | "Maximum time to wait for task management commands to complete"); |
| 5677 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5678 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 5679 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5680 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5681 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5682 | # 2 = MSI-X enabled (default) |
| 5683 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5684 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5685 | 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] | 5686 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5687 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5688 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5689 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5690 | * |
| 5691 | * 0 = NVME OAS disabled |
| 5692 | * 1 = NVME OAS enabled |
| 5693 | * |
| 5694 | * Value range is [0,1]. Default value is 0. |
| 5695 | */ |
| 5696 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 5697 | "Use OAS bit on NVME IOs"); |
| 5698 | |
| 5699 | /* |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5700 | * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs |
| 5701 | * |
| 5702 | * 0 = Put NVME Command in SGL |
| 5703 | * 1 = Embed NVME Command in WQE (unless G7) |
| 5704 | * 2 = Embed NVME Command in WQE (force) |
| 5705 | * |
| 5706 | * Value range is [0,2]. Default value is 1. |
| 5707 | */ |
| 5708 | LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2, |
| 5709 | "Embed NVME Command in WQE"); |
| 5710 | |
| 5711 | /* |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5712 | * lpfc_fcp_mq_threshold: Set the maximum number of Hardware Queues |
| 5713 | * the driver will advertise it supports to the SCSI layer. |
| 5714 | * |
| 5715 | * 0 = Set nr_hw_queues by the number of CPUs or HW queues. |
| 5716 | * 1,128 = Manually specify the maximum nr_hw_queue value to be set, |
| 5717 | * |
| 5718 | * Value range is [0,128]. Default value is 8. |
| 5719 | */ |
| 5720 | LPFC_ATTR_R(fcp_mq_threshold, LPFC_FCP_MQ_THRESHOLD_DEF, |
| 5721 | LPFC_FCP_MQ_THRESHOLD_MIN, LPFC_FCP_MQ_THRESHOLD_MAX, |
| 5722 | "Set the number of SCSI Queues advertised"); |
| 5723 | |
| 5724 | /* |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5725 | * lpfc_hdw_queue: Set the number of Hardware Queues the driver |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5726 | * will advertise it supports to the NVME and SCSI layers. This also |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5727 | * will map to the number of CQ/WQ pairs the driver will create. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5728 | * |
| 5729 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5730 | * hardware queue. The administrative queue will always map to WQ 0 |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5731 | * A hardware IO queue maps (qidx) to a specific driver CQ/WQ. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5732 | * |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5733 | * 0 = Configure the number of hdw queues to the number of active CPUs. |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5734 | * 1,128 = Manually specify how many hdw queues to use. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5735 | * |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5736 | * Value range is [0,128]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5737 | */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5738 | LPFC_ATTR_R(hdw_queue, |
| 5739 | LPFC_HBA_HDWQ_DEF, |
| 5740 | LPFC_HBA_HDWQ_MIN, LPFC_HBA_HDWQ_MAX, |
| 5741 | "Set the number of I/O Hardware Queues"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5742 | |
| 5743 | /* |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5744 | * lpfc_irq_chann: Set the number of IRQ vectors that are available |
| 5745 | * for Hardware Queues to utilize. This also will map to the number |
| 5746 | * of EQ / MSI-X vectors the driver will create. This should never be |
| 5747 | * more than the number of Hardware Queues |
| 5748 | * |
| 5749 | * 0 = Configure number of IRQ Channels to the number of active CPUs. |
| 5750 | * 1,128 = Manually specify how many IRQ Channels to use. |
| 5751 | * |
| 5752 | * Value range is [0,128]. Default value is 0. |
| 5753 | */ |
| 5754 | LPFC_ATTR_R(irq_chann, |
| 5755 | LPFC_HBA_HDWQ_DEF, |
| 5756 | LPFC_HBA_HDWQ_MIN, LPFC_HBA_HDWQ_MAX, |
| 5757 | "Set the number of I/O IRQ Channels"); |
| 5758 | |
| 5759 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5760 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 5761 | # 0 = HBA resets disabled |
| 5762 | # 1 = HBA resets enabled (default) |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 5763 | # 2 = HBA reset via PCI bus reset enabled |
| 5764 | # Value range is [0,2]. Default value is 1. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5765 | */ |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 5766 | LPFC_ATTR_RW(enable_hba_reset, 1, 0, 2, "Enable HBA resets from the driver."); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5767 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5768 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5769 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5770 | # 0 = HBA Heartbeat disabled |
| 5771 | # 1 = HBA Heartbeat enabled (default) |
| 5772 | # Value range is [0,1]. Default value is 1. |
| 5773 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5774 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5775 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5776 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5777 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 5778 | # 0x0 Express Lane Feature disabled |
| 5779 | # 0x1 Express Lane Feature enabled |
| 5780 | # Value range is [0,1]. Default value is 0. |
| 5781 | */ |
| 5782 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 5783 | |
| 5784 | /* |
| 5785 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 5786 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 5787 | # Value range is [0x0,0x7f]. Default value is 0 |
| 5788 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 5789 | 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] | 5790 | |
| 5791 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5792 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 5793 | # 0 = BlockGuard disabled (default) |
| 5794 | # 1 = BlockGuard enabled |
| 5795 | # Value range is [0,1]. Default value is 0. |
| 5796 | */ |
| 5797 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5798 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5799 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5800 | # lpfc_prot_mask: i |
| 5801 | # - Bit mask of host protection capabilities used to register with the |
| 5802 | # SCSI mid-layer |
| 5803 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5804 | # - Allows you to ultimately specify which profiles to use |
| 5805 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5806 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5807 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5808 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5809 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5810 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5811 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5812 | # |
| 5813 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5814 | LPFC_ATTR(prot_mask, |
| 5815 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5816 | SHOST_DIX_TYPE0_PROTECTION | |
| 5817 | SHOST_DIX_TYPE1_PROTECTION), |
| 5818 | 0, |
| 5819 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5820 | SHOST_DIX_TYPE0_PROTECTION | |
| 5821 | SHOST_DIX_TYPE1_PROTECTION), |
| 5822 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5823 | |
| 5824 | /* |
| 5825 | # lpfc_prot_guard: i |
| 5826 | # - 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] | 5827 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5828 | # - Allows you to ultimately specify which profiles to use |
| 5829 | # - Default will result in registering capabilities for all guard types |
| 5830 | # |
| 5831 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5832 | LPFC_ATTR(prot_guard, |
| 5833 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5834 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5835 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5836 | /* |
| 5837 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5838 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5839 | * This parameter can have value 0 or 1. |
| 5840 | * When this parameter is set to 0, no delay is added to the initial |
| 5841 | * discovery. |
| 5842 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5843 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5844 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5845 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5846 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5847 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5848 | * Default value is 0. |
| 5849 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5850 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5851 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5852 | |
| 5853 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5854 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5855 | * This value can be set to values between 64 and 4096. The default value |
| 5856 | * is 64, but may be increased to allow for larger Max I/O sizes. The scsi |
| 5857 | * and nvme layers will allow I/O sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5858 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5859 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5860 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5861 | */ |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5862 | static uint lpfc_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 5863 | module_param(lpfc_sg_seg_cnt, uint, 0444); |
| 5864 | MODULE_PARM_DESC(lpfc_sg_seg_cnt, "Max Scatter Gather Segment Count"); |
| 5865 | |
| 5866 | /** |
| 5867 | * lpfc_sg_seg_cnt_show - Display the scatter/gather list sizes |
| 5868 | * configured for the adapter |
| 5869 | * @dev: class converted to a Scsi_host structure. |
| 5870 | * @attr: device attribute, not used. |
| 5871 | * @buf: on return contains a string with the list sizes |
| 5872 | * |
| 5873 | * Returns: size of formatted string. |
| 5874 | **/ |
| 5875 | static ssize_t |
| 5876 | lpfc_sg_seg_cnt_show(struct device *dev, struct device_attribute *attr, |
| 5877 | char *buf) |
| 5878 | { |
| 5879 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5880 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5881 | struct lpfc_hba *phba = vport->phba; |
| 5882 | int len; |
| 5883 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5884 | len = scnprintf(buf, PAGE_SIZE, "SGL sz: %d total SGEs: %d\n", |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5885 | phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt); |
| 5886 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5887 | len += scnprintf(buf + len, PAGE_SIZE, "Cfg: %d SCSI: %d NVME: %d\n", |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5888 | phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt, |
| 5889 | phba->cfg_nvme_seg_cnt); |
| 5890 | return len; |
| 5891 | } |
| 5892 | |
| 5893 | static DEVICE_ATTR_RO(lpfc_sg_seg_cnt); |
| 5894 | |
| 5895 | /** |
| 5896 | * lpfc_sg_seg_cnt_init - Set the hba sg_seg_cnt initial value |
| 5897 | * @phba: lpfc_hba pointer. |
| 5898 | * @val: contains the initial value |
| 5899 | * |
| 5900 | * Description: |
| 5901 | * Validates the initial value is within range and assigns it to the |
| 5902 | * adapter. If not in range, an error message is posted and the |
| 5903 | * default value is assigned. |
| 5904 | * |
| 5905 | * Returns: |
| 5906 | * zero if value is in range and is set |
| 5907 | * -EINVAL if value was out of range |
| 5908 | **/ |
| 5909 | static int |
| 5910 | lpfc_sg_seg_cnt_init(struct lpfc_hba *phba, int val) |
| 5911 | { |
| 5912 | if (val >= LPFC_MIN_SG_SEG_CNT && val <= LPFC_MAX_SG_SEG_CNT) { |
| 5913 | phba->cfg_sg_seg_cnt = val; |
| 5914 | return 0; |
| 5915 | } |
| 5916 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 5917 | "0409 "LPFC_DRIVER_NAME"_sg_seg_cnt attribute cannot " |
| 5918 | "be set to %d, allowed range is [%d, %d]\n", |
| 5919 | val, LPFC_MIN_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT); |
| 5920 | phba->cfg_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 5921 | return -EINVAL; |
| 5922 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5923 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5924 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5925 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 5926 | * 0 = MDS Diagnostics disabled (default) |
| 5927 | * 1 = MDS Diagnostics enabled |
| 5928 | * Value range is [0,1]. Default value is 0. |
| 5929 | */ |
| 5930 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 5931 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5932 | /* |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 5933 | * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size |
| 5934 | * 0 = Disable firmware logging (default) |
| 5935 | * [1-4] = Multiple of 1/4th Mb of host memory for FW logging |
| 5936 | * Value range [0..4]. Default value is 0 |
| 5937 | */ |
| 5938 | LPFC_ATTR_RW(ras_fwlog_buffsize, 0, 0, 4, "Host memory for FW logging"); |
| 5939 | |
| 5940 | /* |
| 5941 | * lpfc_ras_fwlog_level: Firmware logging verbosity level |
| 5942 | * Valid only if firmware logging is enabled |
| 5943 | * 0(Least Verbosity) 4 (most verbosity) |
| 5944 | * Value range is [0..4]. Default value is 0 |
| 5945 | */ |
| 5946 | LPFC_ATTR_RW(ras_fwlog_level, 0, 0, 4, "Firmware Logging Level"); |
| 5947 | |
| 5948 | /* |
| 5949 | * lpfc_ras_fwlog_func: Firmware logging enabled on function number |
| 5950 | * Default function which has RAS support : 0 |
| 5951 | * Value Range is [0..7]. |
| 5952 | * FW logging is a global action and enablement is via a specific |
| 5953 | * port. |
| 5954 | */ |
| 5955 | LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function"); |
| 5956 | |
| 5957 | /* |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5958 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 5959 | * 0 = BB Credit Recovery disabled |
| 5960 | * 1 = BB Credit Recovery enabled (default) |
| 5961 | * Value range is [0,1]. Default value is 1. |
| 5962 | */ |
| 5963 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 5964 | |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 5965 | /* |
| 5966 | * lpfc_enable_dpp: Enable DPP on G7 |
| 5967 | * 0 = DPP on G7 disabled |
| 5968 | * 1 = DPP on G7 enabled (default) |
| 5969 | * Value range is [0,1]. Default value is 1. |
| 5970 | */ |
| 5971 | LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); |
| 5972 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5973 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5974 | &dev_attr_nvme_info, |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 5975 | &dev_attr_scsi_stat, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5976 | &dev_attr_bg_info, |
| 5977 | &dev_attr_bg_guard_err, |
| 5978 | &dev_attr_bg_apptag_err, |
| 5979 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5980 | &dev_attr_info, |
| 5981 | &dev_attr_serialnum, |
| 5982 | &dev_attr_modeldesc, |
| 5983 | &dev_attr_modelname, |
| 5984 | &dev_attr_programtype, |
| 5985 | &dev_attr_portnum, |
| 5986 | &dev_attr_fwrev, |
| 5987 | &dev_attr_hdw, |
| 5988 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5989 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5990 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 5991 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5992 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5993 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5994 | &dev_attr_lpfc_temp_sensor, |
| 5995 | &dev_attr_lpfc_log_verbose, |
| 5996 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5997 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5998 | &dev_attr_lpfc_hba_queue_depth, |
| 5999 | &dev_attr_lpfc_peer_port_login, |
| 6000 | &dev_attr_lpfc_nodev_tmo, |
| 6001 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6002 | &dev_attr_lpfc_enable_fc4_type, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6003 | &dev_attr_lpfc_fcp_class, |
| 6004 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6005 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6006 | &dev_attr_lpfc_ack0, |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 6007 | &dev_attr_lpfc_xri_rebalancing, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6008 | &dev_attr_lpfc_topology, |
| 6009 | &dev_attr_lpfc_scan_down, |
| 6010 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6011 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 6012 | &dev_attr_lpfc_ns_query, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6013 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6014 | &dev_attr_lpfc_cr_delay, |
| 6015 | &dev_attr_lpfc_cr_count, |
| 6016 | &dev_attr_lpfc_multi_ring_support, |
| 6017 | &dev_attr_lpfc_multi_ring_rctl, |
| 6018 | &dev_attr_lpfc_multi_ring_type, |
| 6019 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6020 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6021 | &dev_attr_lpfc_max_luns, |
| 6022 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6023 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6024 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6025 | &dev_attr_nport_evt_cnt, |
| 6026 | &dev_attr_board_mode, |
| 6027 | &dev_attr_max_vpi, |
| 6028 | &dev_attr_used_vpi, |
| 6029 | &dev_attr_max_rpi, |
| 6030 | &dev_attr_used_rpi, |
| 6031 | &dev_attr_max_xri, |
| 6032 | &dev_attr_used_xri, |
| 6033 | &dev_attr_npiv_info, |
| 6034 | &dev_attr_issue_reset, |
| 6035 | &dev_attr_lpfc_poll, |
| 6036 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6037 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6038 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6039 | &dev_attr_lpfc_nvme_oas, |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 6040 | &dev_attr_lpfc_nvme_embed_cmd, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6041 | &dev_attr_lpfc_fcp_imax, |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 6042 | &dev_attr_lpfc_force_rscn, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 6043 | &dev_attr_lpfc_cq_poll_threshold, |
| 6044 | &dev_attr_lpfc_cq_max_proc_limit, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6045 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 6046 | &dev_attr_lpfc_fcp_mq_threshold, |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 6047 | &dev_attr_lpfc_hdw_queue, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 6048 | &dev_attr_lpfc_irq_chann, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6049 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6050 | &dev_attr_lpfc_nvmet_mrq, |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 6051 | &dev_attr_lpfc_nvmet_mrq_post, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6052 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6053 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6054 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6055 | &dev_attr_lpfc_soft_wwnn, |
| 6056 | &dev_attr_lpfc_soft_wwpn, |
| 6057 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6058 | &dev_attr_lpfc_enable_hba_reset, |
| 6059 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6060 | &dev_attr_lpfc_EnableXLane, |
| 6061 | &dev_attr_lpfc_XLanePriority, |
| 6062 | &dev_attr_lpfc_xlane_lun, |
| 6063 | &dev_attr_lpfc_xlane_tgt, |
| 6064 | &dev_attr_lpfc_xlane_vpt, |
| 6065 | &dev_attr_lpfc_xlane_lun_state, |
| 6066 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6067 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6068 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6069 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6070 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6071 | &dev_attr_lpfc_aer_support, |
| 6072 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6073 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6074 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6075 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6076 | &dev_attr_lpfc_iocb_cnt, |
| 6077 | &dev_attr_iocb_hw, |
| 6078 | &dev_attr_txq_hw, |
| 6079 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 6080 | &dev_attr_lpfc_fips_level, |
| 6081 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6082 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6083 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6084 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6085 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6086 | &dev_attr_lpfc_enable_mds_diags, |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6087 | &dev_attr_lpfc_ras_fwlog_buffsize, |
| 6088 | &dev_attr_lpfc_ras_fwlog_level, |
| 6089 | &dev_attr_lpfc_ras_fwlog_func, |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6090 | &dev_attr_lpfc_enable_bbcr, |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 6091 | &dev_attr_lpfc_enable_dpp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6092 | NULL, |
| 6093 | }; |
| 6094 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6095 | struct device_attribute *lpfc_vport_attrs[] = { |
| 6096 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 6097 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6098 | &dev_attr_num_discovered_ports, |
| 6099 | &dev_attr_lpfc_drvr_version, |
| 6100 | &dev_attr_lpfc_log_verbose, |
| 6101 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6102 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6103 | &dev_attr_lpfc_nodev_tmo, |
| 6104 | &dev_attr_lpfc_devloss_tmo, |
| 6105 | &dev_attr_lpfc_hba_queue_depth, |
| 6106 | &dev_attr_lpfc_peer_port_login, |
| 6107 | &dev_attr_lpfc_restrict_login, |
| 6108 | &dev_attr_lpfc_fcp_class, |
| 6109 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6110 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6111 | &dev_attr_lpfc_max_luns, |
| 6112 | &dev_attr_nport_evt_cnt, |
| 6113 | &dev_attr_npiv_info, |
| 6114 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6115 | &dev_attr_lpfc_max_scsicmpl_time, |
| 6116 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 6117 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 6118 | &dev_attr_lpfc_fips_level, |
| 6119 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6120 | NULL, |
| 6121 | }; |
| 6122 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6123 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6124 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6125 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6126 | * @kobj: kernel kobject that contains the kernel class device. |
| 6127 | * @bin_attr: kernel attributes passed to us. |
| 6128 | * @buf: contains the data to be written to the adapter IOREG space. |
| 6129 | * @off: offset into buffer to beginning of data. |
| 6130 | * @count: bytes to transfer. |
| 6131 | * |
| 6132 | * Description: |
| 6133 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 6134 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 6135 | * |
| 6136 | * Returns: |
| 6137 | * -ERANGE off and count combo out of range |
| 6138 | * -EINVAL off, count or buff address invalid |
| 6139 | * -EPERM adapter is offline |
| 6140 | * value of count, buf contents written |
| 6141 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6142 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6143 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 6144 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6145 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6146 | { |
| 6147 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6148 | struct device *dev = container_of(kobj, struct device, kobj); |
| 6149 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6150 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6151 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6152 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6153 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 6154 | return -EPERM; |
| 6155 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6156 | if ((off + count) > FF_REG_AREA_SIZE) |
| 6157 | return -ERANGE; |
| 6158 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6159 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 6160 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6161 | |
| 6162 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 6163 | return -EINVAL; |
| 6164 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6165 | /* This is to protect HBA registers from accidental writes. */ |
| 6166 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 6167 | return -EINVAL; |
| 6168 | |
| 6169 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6170 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6171 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6172 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6173 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 6174 | buf_off += sizeof(uint32_t)) |
| 6175 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6176 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 6177 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6178 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6179 | |
| 6180 | return count; |
| 6181 | } |
| 6182 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6183 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6184 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6185 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6186 | * @kobj: kernel kobject that contains the kernel class device. |
| 6187 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 6188 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6189 | * @off: offset into buffer to beginning of data. |
| 6190 | * @count: bytes to transfer. |
| 6191 | * |
| 6192 | * Description: |
| 6193 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 6194 | * Uses the adapter io control registers to read data into buf. |
| 6195 | * |
| 6196 | * Returns: |
| 6197 | * -ERANGE off and count combo out of range |
| 6198 | * -EINVAL off, count or buff address invalid |
| 6199 | * value of count, buf contents read |
| 6200 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6201 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6202 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 6203 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6204 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6205 | { |
| 6206 | size_t buf_off; |
| 6207 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6208 | struct device *dev = container_of(kobj, struct device, kobj); |
| 6209 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6210 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6211 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6212 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6213 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 6214 | return -EPERM; |
| 6215 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6216 | if (off > FF_REG_AREA_SIZE) |
| 6217 | return -ERANGE; |
| 6218 | |
| 6219 | if ((off + count) > FF_REG_AREA_SIZE) |
| 6220 | count = FF_REG_AREA_SIZE - off; |
| 6221 | |
| 6222 | if (count == 0) return 0; |
| 6223 | |
| 6224 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 6225 | return -EINVAL; |
| 6226 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6227 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6228 | |
| 6229 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 6230 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 6231 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 6232 | } |
| 6233 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6234 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6235 | |
| 6236 | return count; |
| 6237 | } |
| 6238 | |
| 6239 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 6240 | .attr = { |
| 6241 | .name = "ctlreg", |
| 6242 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6243 | }, |
| 6244 | .size = 256, |
| 6245 | .read = sysfs_ctlreg_read, |
| 6246 | .write = sysfs_ctlreg_write, |
| 6247 | }; |
| 6248 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6249 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6250 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6251 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6252 | * @kobj: kernel kobject that contains the kernel class device. |
| 6253 | * @bin_attr: kernel attributes passed to us. |
| 6254 | * @buf: contains the data to be written to sysfs mbox. |
| 6255 | * @off: offset into buffer to beginning of data. |
| 6256 | * @count: bytes to transfer. |
| 6257 | * |
| 6258 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6259 | * Deprecated function. All mailbox access from user space is performed via the |
| 6260 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6261 | * |
| 6262 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6263 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6264 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6265 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6266 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 6267 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6268 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6269 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6270 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6271 | } |
| 6272 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6273 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6274 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6275 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6276 | * @kobj: kernel kobject that contains the kernel class device. |
| 6277 | * @bin_attr: kernel attributes passed to us. |
| 6278 | * @buf: contains the data to be read from sysfs mbox. |
| 6279 | * @off: offset into buffer to beginning of data. |
| 6280 | * @count: bytes to transfer. |
| 6281 | * |
| 6282 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6283 | * Deprecated function. All mailbox access from user space is performed via the |
| 6284 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6285 | * |
| 6286 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6287 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6288 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6289 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6290 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 6291 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6292 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6293 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6294 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6295 | } |
| 6296 | |
| 6297 | static struct bin_attribute sysfs_mbox_attr = { |
| 6298 | .attr = { |
| 6299 | .name = "mbox", |
| 6300 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6301 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 6302 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6303 | .read = sysfs_mbox_read, |
| 6304 | .write = sysfs_mbox_write, |
| 6305 | }; |
| 6306 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6307 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6308 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6309 | * @vport: address of lpfc vport structure. |
| 6310 | * |
| 6311 | * Return codes: |
| 6312 | * zero on success |
| 6313 | * error return code from sysfs_create_bin_file() |
| 6314 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6315 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6316 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6317 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6318 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6319 | int error; |
| 6320 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6321 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6322 | &sysfs_drvr_stat_data_attr); |
| 6323 | |
| 6324 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 6325 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 6326 | goto out; |
| 6327 | |
| 6328 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6329 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6330 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6331 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6332 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6333 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6334 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6335 | if (error) |
| 6336 | goto out_remove_ctlreg_attr; |
| 6337 | |
| 6338 | return 0; |
| 6339 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6340 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6341 | out_remove_stat_attr: |
| 6342 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 6343 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6344 | out: |
| 6345 | return error; |
| 6346 | } |
| 6347 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6348 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6349 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6350 | * @vport: address of lpfc vport structure. |
| 6351 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6352 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6353 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6354 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6355 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6356 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 6357 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6358 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 6359 | if (vport->port_type == LPFC_NPIV_PORT) |
| 6360 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6361 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 6362 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6363 | } |
| 6364 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6365 | /* |
| 6366 | * Dynamic FC Host Attributes Support |
| 6367 | */ |
| 6368 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6369 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6370 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 6371 | * @shost: kernel scsi host pointer. |
| 6372 | **/ |
| 6373 | static void |
| 6374 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 6375 | { |
| 6376 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 6377 | |
| 6378 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 6379 | sizeof fc_host_symbolic_name(shost)); |
| 6380 | } |
| 6381 | |
| 6382 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6383 | * 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] | 6384 | * @shost: kernel scsi host pointer. |
| 6385 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6386 | static void |
| 6387 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 6388 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6389 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6390 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6391 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6392 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6393 | } |
| 6394 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6395 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6396 | * 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] | 6397 | * @shost: kernel scsi host pointer. |
| 6398 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6399 | static void |
| 6400 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 6401 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6402 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6403 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6404 | |
| 6405 | spin_lock_irq(shost->host_lock); |
| 6406 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6407 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 6408 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 6409 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6410 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6411 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6412 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 6413 | else |
| 6414 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 6415 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6416 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6417 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 6418 | else |
| 6419 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 6420 | } |
| 6421 | } else |
| 6422 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 6423 | |
| 6424 | spin_unlock_irq(shost->host_lock); |
| 6425 | } |
| 6426 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6427 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6428 | * 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] | 6429 | * @shost: kernel scsi host pointer. |
| 6430 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6431 | static void |
| 6432 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 6433 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6434 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6435 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6436 | |
| 6437 | spin_lock_irq(shost->host_lock); |
| 6438 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6439 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6440 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 6441 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6442 | switch (phba->link_state) { |
| 6443 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6444 | case LPFC_LINK_DOWN: |
| 6445 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 6446 | break; |
| 6447 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6448 | case LPFC_CLEAR_LA: |
| 6449 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6450 | /* Links up, reports port state accordingly */ |
| 6451 | if (vport->port_state < LPFC_VPORT_READY) |
| 6452 | fc_host_port_state(shost) = |
| 6453 | FC_PORTSTATE_BYPASSED; |
| 6454 | else |
| 6455 | fc_host_port_state(shost) = |
| 6456 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6457 | break; |
| 6458 | case LPFC_HBA_ERROR: |
| 6459 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 6460 | break; |
| 6461 | default: |
| 6462 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 6463 | break; |
| 6464 | } |
| 6465 | } |
| 6466 | |
| 6467 | spin_unlock_irq(shost->host_lock); |
| 6468 | } |
| 6469 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6470 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6471 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6472 | * @shost: kernel scsi host pointer. |
| 6473 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6474 | static void |
| 6475 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 6476 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6477 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6478 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6479 | |
| 6480 | spin_lock_irq(shost->host_lock); |
| 6481 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 6482 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6483 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6484 | case LPFC_LINK_SPEED_1GHZ: |
| 6485 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6486 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6487 | case LPFC_LINK_SPEED_2GHZ: |
| 6488 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6489 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6490 | case LPFC_LINK_SPEED_4GHZ: |
| 6491 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6492 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6493 | case LPFC_LINK_SPEED_8GHZ: |
| 6494 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 6495 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6496 | case LPFC_LINK_SPEED_10GHZ: |
| 6497 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6498 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6499 | case LPFC_LINK_SPEED_16GHZ: |
| 6500 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 6501 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 6502 | case LPFC_LINK_SPEED_32GHZ: |
| 6503 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 6504 | break; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 6505 | case LPFC_LINK_SPEED_64GHZ: |
| 6506 | fc_host_speed(shost) = FC_PORTSPEED_64GBIT; |
| 6507 | break; |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 6508 | case LPFC_LINK_SPEED_128GHZ: |
| 6509 | fc_host_speed(shost) = FC_PORTSPEED_128GBIT; |
| 6510 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6511 | default: |
| 6512 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6513 | break; |
| 6514 | } |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame] | 6515 | } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) { |
| 6516 | switch (phba->fc_linkspeed) { |
| 6517 | case LPFC_ASYNC_LINK_SPEED_10GBPS: |
| 6518 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
| 6519 | break; |
| 6520 | case LPFC_ASYNC_LINK_SPEED_25GBPS: |
| 6521 | fc_host_speed(shost) = FC_PORTSPEED_25GBIT; |
| 6522 | break; |
| 6523 | case LPFC_ASYNC_LINK_SPEED_40GBPS: |
| 6524 | fc_host_speed(shost) = FC_PORTSPEED_40GBIT; |
| 6525 | break; |
| 6526 | case LPFC_ASYNC_LINK_SPEED_100GBPS: |
| 6527 | fc_host_speed(shost) = FC_PORTSPEED_100GBIT; |
| 6528 | break; |
| 6529 | default: |
| 6530 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| 6531 | break; |
| 6532 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6533 | } else |
| 6534 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6535 | |
| 6536 | spin_unlock_irq(shost->host_lock); |
| 6537 | } |
| 6538 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6539 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6540 | * 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] | 6541 | * @shost: kernel scsi host pointer. |
| 6542 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6543 | static void |
| 6544 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 6545 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6546 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6547 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 6548 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6549 | |
| 6550 | spin_lock_irq(shost->host_lock); |
| 6551 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6552 | if ((vport->port_state > LPFC_FLOGI) && |
| 6553 | ((vport->fc_flag & FC_FABRIC) || |
| 6554 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 6555 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 6556 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6557 | else |
| 6558 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6559 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6560 | |
| 6561 | spin_unlock_irq(shost->host_lock); |
| 6562 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 6563 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6564 | } |
| 6565 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6566 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6567 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6568 | * @shost: kernel scsi host pointer. |
| 6569 | * |
| 6570 | * Notes: |
| 6571 | * NULL on error for link down, no mbox pool, sli2 active, |
| 6572 | * management not allowed, memory allocation error, or mbox error. |
| 6573 | * |
| 6574 | * Returns: |
| 6575 | * NULL for error |
| 6576 | * address of the adapter host statistics |
| 6577 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6578 | static struct fc_host_statistics * |
| 6579 | lpfc_get_stats(struct Scsi_Host *shost) |
| 6580 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6581 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6582 | struct lpfc_hba *phba = vport->phba; |
| 6583 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6584 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6585 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6586 | LPFC_MBOXQ_t *pmboxq; |
| 6587 | MAILBOX_t *pmb; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6588 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6589 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6590 | /* |
| 6591 | * prevent udev from issuing mailbox commands until the port is |
| 6592 | * configured. |
| 6593 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6594 | if (phba->link_state < LPFC_LINK_DOWN || |
| 6595 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6596 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6597 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6598 | |
| 6599 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6600 | return NULL; |
| 6601 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6602 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6603 | if (!pmboxq) |
| 6604 | return NULL; |
| 6605 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 6606 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6607 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6608 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6609 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6610 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6611 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6612 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6613 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6614 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6615 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6616 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6617 | |
| 6618 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6619 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6620 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6621 | return NULL; |
| 6622 | } |
| 6623 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6624 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 6625 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6626 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6627 | /* |
| 6628 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 6629 | * converted to words |
| 6630 | */ |
| 6631 | hs->tx_words = (uint64_t) |
| 6632 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 6633 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6634 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6635 | hs->rx_words = (uint64_t) |
| 6636 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 6637 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6638 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6639 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6640 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6641 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6642 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6643 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6644 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6645 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6646 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6647 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6648 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6649 | |
| 6650 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6651 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6652 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6653 | return NULL; |
| 6654 | } |
| 6655 | |
| 6656 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6657 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6658 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6659 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6660 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6661 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6662 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 6663 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6664 | hs->link_failure_count -= lso->link_failure_count; |
| 6665 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 6666 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 6667 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 6668 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 6669 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 6670 | hs->error_frames -= lso->error_frames; |
| 6671 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6672 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6673 | hs->lip_count = -1; |
| 6674 | hs->nos_count = (phba->link_events >> 1); |
| 6675 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6676 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6677 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6678 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6679 | hs->nos_count = -1; |
| 6680 | } else { |
| 6681 | hs->lip_count = -1; |
| 6682 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6683 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6684 | } |
| 6685 | |
| 6686 | hs->dumped_frames = -1; |
| 6687 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6688 | hs->seconds_since_last_reset = ktime_get_seconds() - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6689 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6690 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6691 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6692 | return hs; |
| 6693 | } |
| 6694 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6695 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6696 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6697 | * @shost: kernel scsi host pointer. |
| 6698 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6699 | static void |
| 6700 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 6701 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6702 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6703 | struct lpfc_hba *phba = vport->phba; |
| 6704 | struct lpfc_sli *psli = &phba->sli; |
| 6705 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6706 | LPFC_MBOXQ_t *pmboxq; |
| 6707 | MAILBOX_t *pmb; |
| 6708 | int rc = 0; |
| 6709 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6710 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6711 | return; |
| 6712 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6713 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6714 | if (!pmboxq) |
| 6715 | return; |
| 6716 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6717 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6718 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6719 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6720 | pmb->mbxOwner = OWN_HOST; |
| 6721 | pmb->un.varWords[0] = 0x1; /* reset request */ |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6722 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6723 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6724 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6725 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6726 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6727 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6728 | else |
| 6729 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6730 | |
| 6731 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6732 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6733 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6734 | return; |
| 6735 | } |
| 6736 | |
| 6737 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6738 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6739 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6740 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6741 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6742 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6743 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6744 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6745 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6746 | else |
| 6747 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6748 | |
| 6749 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6750 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6751 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 6752 | return; |
| 6753 | } |
| 6754 | |
| 6755 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6756 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6757 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6758 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6759 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6760 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6761 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6762 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6763 | lso->link_events = (phba->link_events >> 1); |
| 6764 | else |
| 6765 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6766 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6767 | psli->stats_start = ktime_get_seconds(); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6768 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6769 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6770 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6771 | return; |
| 6772 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6773 | |
| 6774 | /* |
| 6775 | * The LPFC driver treats linkdown handling as target loss events so there |
| 6776 | * are no sysfs handlers for link_down_tmo. |
| 6777 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6778 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6779 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6780 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6781 | * @starget: kernel scsi target pointer. |
| 6782 | * |
| 6783 | * Returns: |
| 6784 | * address of the node list if found |
| 6785 | * NULL target not found |
| 6786 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6787 | static struct lpfc_nodelist * |
| 6788 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6789 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6790 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 6791 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6792 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6793 | |
| 6794 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6795 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6796 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6797 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 6798 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6799 | starget->id == ndlp->nlp_sid) { |
| 6800 | spin_unlock_irq(shost->host_lock); |
| 6801 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6802 | } |
| 6803 | } |
| 6804 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6805 | return NULL; |
| 6806 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6807 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6808 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6809 | * 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] | 6810 | * @starget: kernel scsi target pointer. |
| 6811 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6812 | static void |
| 6813 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 6814 | { |
| 6815 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 6816 | |
| 6817 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6818 | } |
| 6819 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6820 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6821 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6822 | * @starget: kernel scsi target pointer. |
| 6823 | * |
| 6824 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 6825 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6826 | static void |
| 6827 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 6828 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6829 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6830 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6831 | fc_starget_node_name(starget) = |
| 6832 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6833 | } |
| 6834 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6835 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6836 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6837 | * @starget: kernel scsi target pointer. |
| 6838 | * |
| 6839 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 6840 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6841 | static void |
| 6842 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 6843 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6844 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6845 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6846 | fc_starget_port_name(starget) = |
| 6847 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6848 | } |
| 6849 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6850 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6851 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6852 | * @rport: fc rport address. |
| 6853 | * @timeout: new value for dev loss tmo. |
| 6854 | * |
| 6855 | * Description: |
| 6856 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 6857 | * dev_loss_tmo to one. |
| 6858 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6859 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6860 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 6861 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6862 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6863 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6864 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6865 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6866 | } |
| 6867 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6868 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6869 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6870 | * |
| 6871 | * Description: |
| 6872 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 6873 | * |
| 6874 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 6875 | * @cdev: class converted to an fc_rport. |
| 6876 | * @buf: on return contains the target_field or zero. |
| 6877 | * |
| 6878 | * Returns: size of formatted string. |
| 6879 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6880 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 6881 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6882 | lpfc_show_rport_##field (struct device *dev, \ |
| 6883 | struct device_attribute *attr, \ |
| 6884 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6885 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6886 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6887 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 6888 | return scnprintf(buf, sz, format_string, \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6889 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 6890 | } |
| 6891 | |
| 6892 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 6893 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 6894 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 6895 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6896 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6897 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6898 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 6899 | * |
| 6900 | * Description: |
| 6901 | * This function is called by the transport after the @fc_vport's symbolic name |
| 6902 | * 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] | 6903 | * 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] | 6904 | **/ |
| 6905 | static void |
| 6906 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 6907 | { |
| 6908 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 6909 | |
| 6910 | if (vport->port_state == LPFC_VPORT_READY) |
| 6911 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 6912 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6913 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6914 | /** |
| 6915 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 6916 | * @phba: Pointer to lpfc_hba struct. |
| 6917 | * |
| 6918 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 6919 | * 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] | 6920 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6921 | * before hba port or vport created. |
| 6922 | **/ |
| 6923 | static void |
| 6924 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 6925 | { |
| 6926 | phba->cfg_log_verbose = verbose; |
| 6927 | } |
| 6928 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6929 | struct fc_function_template lpfc_transport_functions = { |
| 6930 | /* fixed attributes the driver supports */ |
| 6931 | .show_host_node_name = 1, |
| 6932 | .show_host_port_name = 1, |
| 6933 | .show_host_supported_classes = 1, |
| 6934 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6935 | .show_host_supported_speeds = 1, |
| 6936 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6937 | |
| 6938 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6939 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6940 | |
| 6941 | /* dynamic attributes the driver supports */ |
| 6942 | .get_host_port_id = lpfc_get_host_port_id, |
| 6943 | .show_host_port_id = 1, |
| 6944 | |
| 6945 | .get_host_port_type = lpfc_get_host_port_type, |
| 6946 | .show_host_port_type = 1, |
| 6947 | |
| 6948 | .get_host_port_state = lpfc_get_host_port_state, |
| 6949 | .show_host_port_state = 1, |
| 6950 | |
| 6951 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6952 | .show_host_active_fc4s = 1, |
| 6953 | |
| 6954 | .get_host_speed = lpfc_get_host_speed, |
| 6955 | .show_host_speed = 1, |
| 6956 | |
| 6957 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6958 | .show_host_fabric_name = 1, |
| 6959 | |
| 6960 | /* |
| 6961 | * The LPFC driver treats linkdown handling as target loss events |
| 6962 | * so there are no sysfs handlers for link_down_tmo. |
| 6963 | */ |
| 6964 | |
| 6965 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6966 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6967 | |
| 6968 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6969 | .show_rport_maxframe_size = 1, |
| 6970 | .show_rport_supported_classes = 1, |
| 6971 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6972 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6973 | .show_rport_dev_loss_tmo = 1, |
| 6974 | |
| 6975 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6976 | .show_starget_port_id = 1, |
| 6977 | |
| 6978 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6979 | .show_starget_node_name = 1, |
| 6980 | |
| 6981 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6982 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 6983 | |
| 6984 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6985 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6986 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6987 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6988 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6989 | |
| 6990 | .vport_disable = lpfc_vport_disable, |
| 6991 | |
| 6992 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 6993 | |
| 6994 | .bsg_request = lpfc_bsg_request, |
| 6995 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6996 | }; |
| 6997 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6998 | struct fc_function_template lpfc_vport_transport_functions = { |
| 6999 | /* fixed attributes the driver supports */ |
| 7000 | .show_host_node_name = 1, |
| 7001 | .show_host_port_name = 1, |
| 7002 | .show_host_supported_classes = 1, |
| 7003 | .show_host_supported_fc4s = 1, |
| 7004 | .show_host_supported_speeds = 1, |
| 7005 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 7006 | |
| 7007 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7008 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7009 | |
| 7010 | /* dynamic attributes the driver supports */ |
| 7011 | .get_host_port_id = lpfc_get_host_port_id, |
| 7012 | .show_host_port_id = 1, |
| 7013 | |
| 7014 | .get_host_port_type = lpfc_get_host_port_type, |
| 7015 | .show_host_port_type = 1, |
| 7016 | |
| 7017 | .get_host_port_state = lpfc_get_host_port_state, |
| 7018 | .show_host_port_state = 1, |
| 7019 | |
| 7020 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 7021 | .show_host_active_fc4s = 1, |
| 7022 | |
| 7023 | .get_host_speed = lpfc_get_host_speed, |
| 7024 | .show_host_speed = 1, |
| 7025 | |
| 7026 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 7027 | .show_host_fabric_name = 1, |
| 7028 | |
| 7029 | /* |
| 7030 | * The LPFC driver treats linkdown handling as target loss events |
| 7031 | * so there are no sysfs handlers for link_down_tmo. |
| 7032 | */ |
| 7033 | |
| 7034 | .get_fc_host_stats = lpfc_get_stats, |
| 7035 | .reset_fc_host_stats = lpfc_reset_stats, |
| 7036 | |
| 7037 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 7038 | .show_rport_maxframe_size = 1, |
| 7039 | .show_rport_supported_classes = 1, |
| 7040 | |
| 7041 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 7042 | .show_rport_dev_loss_tmo = 1, |
| 7043 | |
| 7044 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 7045 | .show_starget_port_id = 1, |
| 7046 | |
| 7047 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 7048 | .show_starget_node_name = 1, |
| 7049 | |
| 7050 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 7051 | .show_starget_port_name = 1, |
| 7052 | |
| 7053 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 7054 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 7055 | |
| 7056 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7057 | |
| 7058 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7059 | }; |
| 7060 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7061 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7062 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7063 | * @phba: lpfc_hba pointer. |
| 7064 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7065 | void |
| 7066 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 7067 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 7068 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 7069 | lpfc_ns_query_init(phba, lpfc_ns_query); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 7070 | 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] | 7071 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 7072 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 7073 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 7074 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 7075 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7076 | lpfc_ack0_init(phba, lpfc_ack0); |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 7077 | lpfc_xri_rebalancing_init(phba, lpfc_xri_rebalancing); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7078 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7079 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 7080 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 7081 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 7082 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 7083 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 7084 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7085 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 7086 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 7087 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7088 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 7089 | lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 7090 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 7091 | lpfc_force_rscn_init(phba, lpfc_force_rscn); |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 7092 | lpfc_cq_poll_threshold_init(phba, lpfc_cq_poll_threshold); |
| 7093 | lpfc_cq_max_proc_limit_init(phba, lpfc_cq_max_proc_limit); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 7094 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 7095 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 7096 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 7097 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7098 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 7099 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 7100 | phba->cfg_EnableXLane = 0; |
| 7101 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 7102 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7103 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 7104 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 7105 | phba->cfg_oas_lun_state = 0; |
| 7106 | phba->cfg_oas_lun_status = 0; |
| 7107 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 7108 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 7109 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 7110 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 7111 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 7112 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7113 | phba->cfg_poll = 0; |
| 7114 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7115 | phba->cfg_poll = lpfc_poll; |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7116 | |
| 7117 | if (phba->cfg_enable_bg) |
| 7118 | phba->sli3_options |= LPFC_SLI3_BG_ENABLED; |
| 7119 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7120 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7121 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7122 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7123 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 7124 | lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7125 | |
| 7126 | /* Initialize first burst. Target vs Initiator are different. */ |
| 7127 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7128 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 7129 | lpfc_fcp_mq_threshold_init(phba, lpfc_fcp_mq_threshold); |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7130 | lpfc_hdw_queue_init(phba, lpfc_hdw_queue); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7131 | lpfc_irq_chann_init(phba, lpfc_irq_chann); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 7132 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 7133 | lpfc_enable_dpp_init(phba, lpfc_enable_dpp); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7134 | |
| 7135 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 7136 | /* NVME only supported on SLI4 */ |
| 7137 | phba->nvmet_support = 0; |
James Smart | 982ab12 | 2019-03-12 16:30:10 -0700 | [diff] [blame] | 7138 | phba->cfg_nvmet_mrq = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7139 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 7140 | phba->cfg_enable_bbcr = 0; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 7141 | phba->cfg_xri_rebalancing = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7142 | } else { |
| 7143 | /* We MUST have FCP support */ |
| 7144 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 7145 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 7146 | } |
| 7147 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 7148 | phba->cfg_auto_imax = (phba->cfg_fcp_imax) ? 0 : 1; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 7149 | |
James Smart | 06b6fa38 | 2018-07-31 17:23:24 -0700 | [diff] [blame] | 7150 | phba->cfg_enable_pbde = 0; |
| 7151 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7152 | /* A value of 0 means use the number of CPUs found in the system */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7153 | if (phba->cfg_hdw_queue == 0) |
| 7154 | phba->cfg_hdw_queue = phba->sli4_hba.num_present_cpu; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7155 | if (phba->cfg_irq_chann == 0) |
| 7156 | phba->cfg_irq_chann = phba->sli4_hba.num_present_cpu; |
| 7157 | if (phba->cfg_irq_chann > phba->cfg_hdw_queue) |
| 7158 | phba->cfg_irq_chann = phba->cfg_hdw_queue; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7159 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 7160 | phba->cfg_soft_wwnn = 0L; |
| 7161 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 7162 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 7163 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7164 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 7165 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 7166 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 7167 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 7168 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 7169 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 7170 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 7171 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 7172 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 7173 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 7174 | lpfc_ras_fwlog_buffsize_init(phba, lpfc_ras_fwlog_buffsize); |
| 7175 | lpfc_ras_fwlog_level_init(phba, lpfc_ras_fwlog_level); |
| 7176 | lpfc_ras_fwlog_func_init(phba, lpfc_ras_fwlog_func); |
| 7177 | |
James Smart | faf0a5f | 2018-09-10 10:30:43 -0700 | [diff] [blame] | 7178 | |
| 7179 | /* If the NVME FC4 type is enabled, scale the sg_seg_cnt to |
| 7180 | * accommodate 512K and 1M IOs in a single nvme buf and supply |
| 7181 | * enough NVME LS iocb buffers for larger connectivity counts. |
| 7182 | */ |
| 7183 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { |
| 7184 | phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; |
| 7185 | phba->cfg_iocb_cnt = 5; |
| 7186 | } |
| 7187 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7188 | return; |
| 7189 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 7190 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7191 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7192 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 7193 | * dependencies between protocols and roles. |
| 7194 | * @phba: lpfc_hba pointer. |
| 7195 | **/ |
| 7196 | void |
| 7197 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 7198 | { |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7199 | if (phba->cfg_hdw_queue > phba->sli4_hba.num_present_cpu) |
| 7200 | phba->cfg_hdw_queue = phba->sli4_hba.num_present_cpu; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7201 | if (phba->cfg_irq_chann > phba->sli4_hba.num_present_cpu) |
| 7202 | phba->cfg_irq_chann = phba->sli4_hba.num_present_cpu; |
| 7203 | if (phba->cfg_irq_chann > phba->cfg_hdw_queue) |
| 7204 | phba->cfg_irq_chann = phba->cfg_hdw_queue; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7205 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7206 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 7207 | phba->nvmet_support) { |
| 7208 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7209 | |
| 7210 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 7211 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 7212 | "NVME Target PRLI ACC enable_fb ", |
| 7213 | phba->cfg_nvme_enable_fb, |
| 7214 | phba->cfg_nvmet_fb_size, |
| 7215 | LPFC_NVMET_FB_SZ_MAX); |
| 7216 | |
| 7217 | if (phba->cfg_nvme_enable_fb == 0) |
| 7218 | phba->cfg_nvmet_fb_size = 0; |
| 7219 | else { |
| 7220 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 7221 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 7222 | } |
| 7223 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7224 | if (!phba->cfg_nvmet_mrq) |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7225 | phba->cfg_nvmet_mrq = phba->cfg_irq_chann; |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7226 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7227 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7228 | if (phba->cfg_nvmet_mrq > phba->cfg_irq_chann) { |
| 7229 | phba->cfg_nvmet_mrq = phba->cfg_irq_chann; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7230 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 7231 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 7232 | phba->cfg_nvmet_mrq); |
| 7233 | } |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7234 | if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) |
| 7235 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; |
| 7236 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7237 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7238 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 7239 | phba->nvmet_support = 0; |
James Smart | 982ab12 | 2019-03-12 16:30:10 -0700 | [diff] [blame] | 7240 | phba->cfg_nvmet_mrq = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7241 | phba->cfg_nvmet_fb_size = 0; |
| 7242 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7243 | } |
| 7244 | |
| 7245 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7246 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7247 | * @vport: lpfc_vport pointer. |
| 7248 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7249 | void |
| 7250 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 7251 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7252 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7253 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 7254 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7255 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 7256 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 7257 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 7258 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 7259 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 7260 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 7261 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 7262 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7263 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 7264 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 7265 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 7266 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7267 | return; |
| 7268 | } |