| 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 | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 179 | |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 180 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 181 | len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 182 | return len; |
| 183 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 184 | if (phba->nvmet_support) { |
| 185 | if (!phba->targetport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 186 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 187 | "NVME Target: x%llx is not allocated\n", |
| 188 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 189 | return len; |
| 190 | } |
| 191 | /* Port state is only one of two values for now. */ |
| 192 | if (phba->targetport->port_id) |
| 193 | statep = "REGISTERED"; |
| 194 | else |
| 195 | statep = "INIT"; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 196 | scnprintf(tmp, sizeof(tmp), |
| 197 | "NVME Target Enabled State %s\n", |
| 198 | statep); |
| 199 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 200 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 201 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 202 | scnprintf(tmp, sizeof(tmp), |
| 203 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 204 | "NVME Target: lpfc", |
| 205 | phba->brd_no, |
| 206 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 207 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 208 | phba->targetport->port_id); |
| 209 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 210 | goto buffer_done; |
| 211 | |
| 212 | if (strlcat(buf, "\nNVME Target: Statistics\n", PAGE_SIZE) |
| 213 | >= PAGE_SIZE) |
| 214 | goto buffer_done; |
| 215 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 216 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 217 | scnprintf(tmp, sizeof(tmp), |
| 218 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 219 | atomic_read(&tgtp->rcv_ls_req_in), |
| 220 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 221 | atomic_read(&tgtp->xmt_ls_abort)); |
| 222 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 223 | goto buffer_done; |
| 224 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 225 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 226 | atomic_read(&tgtp->rcv_ls_req_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 227 | scnprintf(tmp, sizeof(tmp), |
| 228 | "Rcv LS: in %08x != out %08x\n", |
| 229 | atomic_read(&tgtp->rcv_ls_req_in), |
| 230 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 231 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 232 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 233 | } |
| 234 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 235 | scnprintf(tmp, sizeof(tmp), |
| 236 | "LS: Xmt %08x Drop %08x Cmpl %08x\n", |
| 237 | atomic_read(&tgtp->xmt_ls_rsp), |
| 238 | atomic_read(&tgtp->xmt_ls_drop), |
| 239 | atomic_read(&tgtp->xmt_ls_rsp_cmpl)); |
| 240 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 241 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 242 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 243 | scnprintf(tmp, sizeof(tmp), |
| 244 | "LS: RSP Abort %08x xb %08x Err %08x\n", |
| 245 | atomic_read(&tgtp->xmt_ls_rsp_aborted), |
| 246 | atomic_read(&tgtp->xmt_ls_rsp_xb_set), |
| 247 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 248 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 249 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 250 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 251 | scnprintf(tmp, sizeof(tmp), |
| 252 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 253 | "Drop %08x\n", |
| 254 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 255 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
| 256 | atomic_read(&tgtp->xmt_fcp_release), |
| 257 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 258 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 259 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 260 | |
| 261 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 262 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 263 | scnprintf(tmp, sizeof(tmp), |
| 264 | "Rcv FCP: in %08x != out %08x\n", |
| 265 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 266 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 267 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 268 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 269 | } |
| 270 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 271 | scnprintf(tmp, sizeof(tmp), |
| 272 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " |
| 273 | "drop %08x\n", |
| 274 | atomic_read(&tgtp->xmt_fcp_read), |
| 275 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 276 | atomic_read(&tgtp->xmt_fcp_write), |
| 277 | atomic_read(&tgtp->xmt_fcp_rsp), |
| 278 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 279 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 280 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 281 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 282 | scnprintf(tmp, sizeof(tmp), |
| 283 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 284 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 285 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 286 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 287 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 288 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 289 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 290 | scnprintf(tmp, sizeof(tmp), |
| 291 | "FCP Rsp Abort: %08x xb %08x xricqe %08x\n", |
| 292 | atomic_read(&tgtp->xmt_fcp_rsp_aborted), |
| 293 | atomic_read(&tgtp->xmt_fcp_rsp_xb_set), |
| 294 | atomic_read(&tgtp->xmt_fcp_xri_abort_cqe)); |
| 295 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 296 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 297 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 298 | scnprintf(tmp, sizeof(tmp), |
| 299 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 300 | atomic_read(&tgtp->xmt_fcp_abort), |
| 301 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 302 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 303 | goto buffer_done; |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 304 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 305 | scnprintf(tmp, sizeof(tmp), |
| 306 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n", |
| 307 | atomic_read(&tgtp->xmt_abort_sol), |
| 308 | atomic_read(&tgtp->xmt_abort_unsol), |
| 309 | atomic_read(&tgtp->xmt_abort_rsp), |
| 310 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
| 311 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 312 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 313 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 314 | scnprintf(tmp, sizeof(tmp), |
| 315 | "DELAY: ctx %08x fod %08x wqfull %08x\n", |
| 316 | atomic_read(&tgtp->defer_ctx), |
| 317 | atomic_read(&tgtp->defer_fod), |
| 318 | atomic_read(&tgtp->defer_wqfull)); |
| 319 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 320 | goto buffer_done; |
James Smart | 411de51 | 2018-01-30 15:58:52 -0800 | [diff] [blame] | 321 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 322 | /* Calculate outstanding IOs */ |
| 323 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 324 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 325 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 326 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 327 | scnprintf(tmp, sizeof(tmp), |
| 328 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 329 | "CTX Outstanding %08llx\n\n", |
| 330 | phba->sli4_hba.nvmet_xri_cnt, |
| 331 | phba->sli4_hba.nvmet_io_wait_cnt, |
| 332 | phba->sli4_hba.nvmet_io_wait_total, |
| 333 | tot); |
| 334 | strlcat(buf, tmp, PAGE_SIZE); |
| 335 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 336 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 337 | |
| 338 | localport = vport->localport; |
| 339 | if (!localport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 340 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 341 | "NVME Initiator x%llx is not allocated\n", |
| 342 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 343 | return len; |
| 344 | } |
Colin Ian King | 5c665ae | 2017-12-22 00:28:52 +0000 | [diff] [blame] | 345 | lport = (struct lpfc_nvme_lport *)localport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 346 | if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE) |
| 347 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 348 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 349 | scnprintf(tmp, sizeof(tmp), |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 350 | "XRI Dist lpfc%d Total %d IO %d ELS %d\n", |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 351 | phba->brd_no, |
| 352 | phba->sli4_hba.max_cfg_param.max_xri, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 353 | phba->sli4_hba.io_xri_max, |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 354 | lpfc_sli4_get_els_iocb_cnt(phba)); |
| 355 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 356 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 357 | |
| 358 | /* Port state is only one of two values for now. */ |
| 359 | if (localport->port_id) |
| 360 | statep = "ONLINE"; |
| 361 | else |
| 362 | statep = "UNKNOWN "; |
| 363 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 364 | scnprintf(tmp, sizeof(tmp), |
| 365 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 366 | "NVME LPORT lpfc", |
| 367 | phba->brd_no, |
| 368 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 369 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 370 | localport->port_id, statep); |
| 371 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 372 | goto buffer_done; |
| 373 | |
| 374 | spin_lock_irq(shost->host_lock); |
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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 378 | spin_lock(&vport->phba->hbalock); |
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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 382 | spin_unlock(&vport->phba->hbalock); |
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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 401 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 404 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 410 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 415 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 420 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 425 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 429 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 433 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 441 | goto 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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 446 | goto unlock_buf_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 447 | } |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 448 | spin_unlock_irq(shost->host_lock); |
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 | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 508 | /* host_lock is already unlocked. */ |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 509 | goto buffer_done; |
| 510 | |
James Smart | 6c1e803 | 2019-11-04 16:57:00 -0800 | [diff] [blame] | 511 | unlock_buf_done: |
| 512 | spin_unlock_irq(shost->host_lock); |
James Smart | 79080d3 | 2019-05-06 17:26:48 -0700 | [diff] [blame] | 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); |
James Smart | ec76242 | 2019-08-14 16:57:07 -0700 | [diff] [blame] | 844 | return scnprintf(buf, PAGE_SIZE, "%s %08x %08x\n", hdw, |
| 845 | vp->rev.smRev, vp->rev.smFwRev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 846 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 847 | |
| 848 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 849 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 850 | * @dev: class converted to a Scsi_host structure. |
| 851 | * @attr: device attribute, not used. |
| 852 | * @buf: on return contains the ROM and FCode ascii strings. |
| 853 | * |
| 854 | * Returns: size of formatted string. |
| 855 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 856 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 857 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 858 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 859 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 860 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 861 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 862 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 863 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 864 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 865 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 866 | return scnprintf(buf, PAGE_SIZE, "%s\n", |
| 867 | phba->OptionROMVersion); |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 868 | |
| 869 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 870 | return scnprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 871 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 872 | |
| 873 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 874 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 875 | * @dev: class converted to a Scsi_host structure. |
| 876 | * @attr: device attribute, not used. |
| 877 | * @buf: on return contains text describing the state of the link. |
| 878 | * |
| 879 | * Notes: |
| 880 | * The switch statement has no default so zero will be returned. |
| 881 | * |
| 882 | * Returns: size of formatted string. |
| 883 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 884 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 885 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 886 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 887 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 888 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 889 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 890 | struct lpfc_hba *phba = vport->phba; |
| 891 | int len = 0; |
| 892 | |
| 893 | switch (phba->link_state) { |
| 894 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 895 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 896 | case LPFC_INIT_START: |
| 897 | case LPFC_INIT_MBX_CMDS: |
| 898 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 899 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 900 | if (phba->hba_flag & LINK_DISABLED) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 901 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 902 | "Link Down - User disabled\n"); |
| 903 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 904 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 905 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 906 | break; |
| 907 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 908 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 909 | case LPFC_HBA_READY: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 910 | len += scnprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 911 | |
| 912 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 913 | case LPFC_LOCAL_CFG_LINK: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 914 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 915 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 916 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 917 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 918 | case LPFC_FLOGI: |
| 919 | case LPFC_FABRIC_CFG_LINK: |
| 920 | case LPFC_NS_REG: |
| 921 | case LPFC_NS_QRY: |
| 922 | case LPFC_BUILD_DISC_LIST: |
| 923 | case LPFC_DISC_AUTH: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 924 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 925 | "Discovery\n"); |
| 926 | break; |
| 927 | case LPFC_VPORT_READY: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 928 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 929 | "Ready\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 930 | break; |
| 931 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 932 | case LPFC_VPORT_FAILED: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 933 | len += scnprintf(buf + len, PAGE_SIZE - len, |
| 934 | "Failed\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 935 | break; |
| 936 | |
| 937 | case LPFC_VPORT_UNKNOWN: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 938 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 939 | "Unknown\n"); |
| 940 | break; |
| 941 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 942 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 943 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 944 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 945 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 946 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 947 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 948 | " Public Loop\n"); |
| 949 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 950 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 951 | " Private Loop\n"); |
| 952 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 953 | if (vport->fc_flag & FC_FABRIC) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 954 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 955 | " Fabric\n"); |
| 956 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 957 | len += scnprintf(buf + len, PAGE_SIZE-len, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 958 | " Point-2-Point\n"); |
| 959 | } |
| 960 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 961 | |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 962 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 963 | ((bf_get(lpfc_sli_intf_if_type, |
| 964 | &phba->sli4_hba.sli_intf) == |
| 965 | LPFC_SLI_INTF_IF_TYPE_6))) { |
| 966 | struct lpfc_trunk_link link = phba->trunk_link; |
| 967 | |
| 968 | if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 969 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 970 | "Trunk port 0: Link %s %s\n", |
| 971 | (link.link0.state == LPFC_LINK_UP) ? |
| 972 | "Up" : "Down. ", |
| 973 | trunk_errmsg[link.link0.fault]); |
| 974 | |
| 975 | if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 976 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 977 | "Trunk port 1: Link %s %s\n", |
| 978 | (link.link1.state == LPFC_LINK_UP) ? |
| 979 | "Up" : "Down. ", |
| 980 | trunk_errmsg[link.link1.fault]); |
| 981 | |
| 982 | if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 983 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 984 | "Trunk port 2: Link %s %s\n", |
| 985 | (link.link2.state == LPFC_LINK_UP) ? |
| 986 | "Up" : "Down. ", |
| 987 | trunk_errmsg[link.link2.fault]); |
| 988 | |
| 989 | if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 990 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 991 | "Trunk port 3: Link %s %s\n", |
| 992 | (link.link3.state == LPFC_LINK_UP) ? |
| 993 | "Up" : "Down. ", |
| 994 | trunk_errmsg[link.link3.fault]); |
| 995 | |
| 996 | } |
| 997 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 998 | return len; |
| 999 | } |
| 1000 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1001 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1002 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 1003 | * @dev: class unused variable. |
| 1004 | * @attr: device attribute, not used. |
| 1005 | * @buf: on return contains the module description text. |
| 1006 | * |
| 1007 | * Returns: size of formatted string. |
| 1008 | **/ |
| 1009 | static ssize_t |
| 1010 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 1011 | char *buf) |
| 1012 | { |
| 1013 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1014 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1015 | struct lpfc_hba *phba = vport->phba; |
| 1016 | |
| 1017 | if (phba->sli_rev < LPFC_SLI_REV4) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1018 | return scnprintf(buf, PAGE_SIZE, "fc\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1019 | |
| 1020 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 1021 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1022 | return scnprintf(buf, PAGE_SIZE, "fcoe\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1023 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1024 | return scnprintf(buf, PAGE_SIZE, "fc\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1025 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1026 | return scnprintf(buf, PAGE_SIZE, "unknown\n"); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1030 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 1031 | * (OAS) is supported. |
| 1032 | * @dev: class unused variable. |
| 1033 | * @attr: device attribute, not used. |
| 1034 | * @buf: on return contains the module description text. |
| 1035 | * |
| 1036 | * Returns: size of formatted string. |
| 1037 | **/ |
| 1038 | static ssize_t |
| 1039 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 1040 | char *buf) |
| 1041 | { |
| 1042 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1043 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 1044 | struct lpfc_hba *phba = vport->phba; |
| 1045 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1046 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 1047 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 1048 | } |
| 1049 | |
| 1050 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1051 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 1052 | * @dev: class device that is converted into a Scsi_host. |
| 1053 | * @attr: device attribute, not used. |
| 1054 | * @buf: one or more lpfc_polling_flags values. |
| 1055 | * @count: not used. |
| 1056 | * |
| 1057 | * Returns: |
| 1058 | * -EINVAL if the buffer is not "up" or "down" |
| 1059 | * return from link state change function if non-zero |
| 1060 | * length of the buf on success |
| 1061 | **/ |
| 1062 | static ssize_t |
| 1063 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 1064 | const char *buf, size_t count) |
| 1065 | { |
| 1066 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1067 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1068 | struct lpfc_hba *phba = vport->phba; |
| 1069 | |
| 1070 | int status = -EINVAL; |
| 1071 | |
| 1072 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 1073 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1074 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1075 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 1076 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1077 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1078 | |
| 1079 | if (status == 0) |
| 1080 | return strlen(buf); |
| 1081 | else |
| 1082 | return status; |
| 1083 | } |
| 1084 | |
| 1085 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1086 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1087 | * @dev: class device that is converted into a Scsi_host. |
| 1088 | * @attr: device attribute, not used. |
| 1089 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 1090 | * |
| 1091 | * Description: |
| 1092 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 1093 | * vport counts. |
| 1094 | * |
| 1095 | * Returns: size of formatted string. |
| 1096 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1097 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1098 | lpfc_num_discovered_ports_show(struct device *dev, |
| 1099 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1100 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1101 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1102 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1103 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1104 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1105 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1106 | } |
| 1107 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1108 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1109 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1110 | * @shost: Scsi_Host pointer. |
| 1111 | * |
| 1112 | * Description: |
| 1113 | * Bring the link down gracefully then re-init the link. The firmware will |
| 1114 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 1115 | * |
| 1116 | * Returns: |
| 1117 | * -EPERM port offline or management commands are being blocked |
| 1118 | * -ENOMEM cannot allocate memory for the mailbox command |
| 1119 | * -EIO error sending the mailbox command |
| 1120 | * zero for success |
| 1121 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1122 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1123 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1124 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1125 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1126 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1127 | LPFC_MBOXQ_t *pmboxq; |
| 1128 | int mbxstatus = MBXERR_ERROR; |
| 1129 | |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1130 | /* |
| 1131 | * If the link is offline, disabled or BLOCK_MGMT_IO |
| 1132 | * it doesn't make any sense to allow issue_lip |
| 1133 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1134 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1135 | (phba->hba_flag & LINK_DISABLED) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 1136 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1137 | return -EPERM; |
| 1138 | |
| 1139 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 1140 | |
| 1141 | if (!pmboxq) |
| 1142 | return -ENOMEM; |
| 1143 | |
| 1144 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1145 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 1146 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1147 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 1148 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1149 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1150 | if ((mbxstatus == MBX_SUCCESS) && |
| 1151 | (pmboxq->u.mb.mbxStatus == 0 || |
| 1152 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1153 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1154 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 1155 | phba->cfg_link_speed); |
| 1156 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 1157 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 1158 | if ((mbxstatus == MBX_SUCCESS) && |
| 1159 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 1160 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 1161 | "2859 SLI authentication is required " |
| 1162 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1163 | } |
| 1164 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 1165 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1166 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1167 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1168 | |
| 1169 | if (mbxstatus == MBXERR_ERROR) |
| 1170 | return -EIO; |
| 1171 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1172 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1173 | } |
| 1174 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1175 | int |
| 1176 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 1177 | { |
| 1178 | int cnt = 0; |
| 1179 | |
| 1180 | spin_lock_irq(lock); |
| 1181 | while (!list_empty(q)) { |
| 1182 | spin_unlock_irq(lock); |
| 1183 | msleep(20); |
| 1184 | if (cnt++ > 250) { /* 5 secs */ |
| 1185 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 1186 | "0466 %s %s\n", |
| 1187 | "Outstanding IO when ", |
| 1188 | "bringing Adapter offline\n"); |
| 1189 | return 0; |
| 1190 | } |
| 1191 | spin_lock_irq(lock); |
| 1192 | } |
| 1193 | spin_unlock_irq(lock); |
| 1194 | return 1; |
| 1195 | } |
| 1196 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1197 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1198 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1199 | * @phba: lpfc_hba pointer. |
| 1200 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 1201 | * |
| 1202 | * Notes: |
| 1203 | * Assumes any error from lpfc_do_offline() will be negative. |
| 1204 | * Can wait up to 5 seconds for the port ring buffers count |
| 1205 | * 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] | 1206 | * 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] | 1207 | * |
| 1208 | * Returns: |
| 1209 | * -EIO error posting the event |
| 1210 | * zero for success |
| 1211 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1212 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1213 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 1214 | { |
| 1215 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1216 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1217 | struct lpfc_sli_ring *pring; |
| 1218 | struct lpfc_sli *psli; |
| 1219 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1220 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1221 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1222 | |
| 1223 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1224 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1225 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1226 | if (rc == 0) |
| 1227 | return -ENOMEM; |
| 1228 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1229 | wait_for_completion(&online_compl); |
| 1230 | |
| 1231 | if (status != 0) |
| 1232 | return -EIO; |
| 1233 | |
| 1234 | psli = &phba->sli; |
| 1235 | |
James Smart | 4645f7b | 2019-03-12 16:30:14 -0700 | [diff] [blame] | 1236 | /* |
| 1237 | * If freeing the queues have already started, don't access them. |
| 1238 | * Otherwise set FREE_WAIT to indicate that queues are being used |
| 1239 | * to hold the freeing process until we finish. |
| 1240 | */ |
| 1241 | spin_lock_irq(&phba->hbalock); |
| 1242 | if (!(psli->sli_flag & LPFC_QUEUE_FREE_INIT)) { |
| 1243 | psli->sli_flag |= LPFC_QUEUE_FREE_WAIT; |
| 1244 | } else { |
| 1245 | spin_unlock_irq(&phba->hbalock); |
| 1246 | goto skip_wait; |
| 1247 | } |
| 1248 | spin_unlock_irq(&phba->hbalock); |
| 1249 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1250 | /* Wait a little for things to settle down, but not |
| 1251 | * long enough for dev loss timeout to expire. |
| 1252 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1253 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 1254 | for (i = 0; i < psli->num_rings; i++) { |
| 1255 | pring = &psli->sli3_ring[i]; |
| 1256 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1257 | &phba->hbalock)) |
| 1258 | goto out; |
| 1259 | } |
| 1260 | } else { |
| 1261 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 1262 | pring = qp->pring; |
| 1263 | if (!pring) |
| 1264 | continue; |
| 1265 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1266 | &pring->ring_lock)) |
| 1267 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1268 | } |
| 1269 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1270 | out: |
James Smart | 4645f7b | 2019-03-12 16:30:14 -0700 | [diff] [blame] | 1271 | spin_lock_irq(&phba->hbalock); |
| 1272 | psli->sli_flag &= ~LPFC_QUEUE_FREE_WAIT; |
| 1273 | spin_unlock_irq(&phba->hbalock); |
| 1274 | |
| 1275 | skip_wait: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1276 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1277 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 1278 | if (rc == 0) |
| 1279 | return -ENOMEM; |
| 1280 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1281 | wait_for_completion(&online_compl); |
| 1282 | |
| 1283 | if (status != 0) |
| 1284 | return -EIO; |
| 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1289 | /** |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1290 | * lpfc_reset_pci_bus - resets PCI bridge controller's secondary bus of an HBA |
| 1291 | * @phba: lpfc_hba pointer. |
| 1292 | * |
| 1293 | * Description: |
| 1294 | * Issues a PCI secondary bus reset for the phba->pcidev. |
| 1295 | * |
| 1296 | * Notes: |
| 1297 | * First walks the bus_list to ensure only PCI devices with Emulex |
| 1298 | * vendor id, device ids that support hot reset, only one occurrence |
| 1299 | * of function 0, and all ports on the bus are in offline mode to ensure the |
| 1300 | * hot reset only affects one valid HBA. |
| 1301 | * |
| 1302 | * Returns: |
| 1303 | * -ENOTSUPP, cfg_enable_hba_reset must be of value 2 |
| 1304 | * -ENODEV, NULL ptr to pcidev |
| 1305 | * -EBADSLT, detected invalid device |
| 1306 | * -EBUSY, port is not in offline state |
| 1307 | * 0, successful |
| 1308 | */ |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 1309 | static int |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1310 | lpfc_reset_pci_bus(struct lpfc_hba *phba) |
| 1311 | { |
| 1312 | struct pci_dev *pdev = phba->pcidev; |
| 1313 | struct Scsi_Host *shost = NULL; |
| 1314 | struct lpfc_hba *phba_other = NULL; |
| 1315 | struct pci_dev *ptr = NULL; |
| 1316 | int res; |
| 1317 | |
| 1318 | if (phba->cfg_enable_hba_reset != 2) |
| 1319 | return -ENOTSUPP; |
| 1320 | |
| 1321 | if (!pdev) { |
| 1322 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "8345 pdev NULL!\n"); |
| 1323 | return -ENODEV; |
| 1324 | } |
| 1325 | |
| 1326 | res = lpfc_check_pci_resettable(phba); |
| 1327 | if (res) |
| 1328 | return res; |
| 1329 | |
| 1330 | /* Walk the list of devices on the pci_dev's bus */ |
| 1331 | list_for_each_entry(ptr, &pdev->bus->devices, bus_list) { |
| 1332 | /* Check port is offline */ |
| 1333 | shost = pci_get_drvdata(ptr); |
| 1334 | if (shost) { |
| 1335 | phba_other = |
| 1336 | ((struct lpfc_vport *)shost->hostdata)->phba; |
| 1337 | if (!(phba_other->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1338 | lpfc_printf_log(phba_other, KERN_INFO, LOG_INIT, |
| 1339 | "8349 WWPN = 0x%02x%02x%02x%02x" |
| 1340 | "%02x%02x%02x%02x is not " |
| 1341 | "offline!\n", |
| 1342 | phba_other->wwpn[0], |
| 1343 | phba_other->wwpn[1], |
| 1344 | phba_other->wwpn[2], |
| 1345 | phba_other->wwpn[3], |
| 1346 | phba_other->wwpn[4], |
| 1347 | phba_other->wwpn[5], |
| 1348 | phba_other->wwpn[6], |
| 1349 | phba_other->wwpn[7]); |
| 1350 | return -EBUSY; |
| 1351 | } |
| 1352 | } |
| 1353 | } |
| 1354 | |
| 1355 | /* Issue PCI bus reset */ |
| 1356 | res = pci_reset_bus(pdev); |
| 1357 | if (res) { |
| 1358 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1359 | "8350 PCI reset bus failed: %d\n", res); |
| 1360 | } |
| 1361 | |
| 1362 | return res; |
| 1363 | } |
| 1364 | |
| 1365 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1366 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1367 | * @phba: lpfc_hba pointer. |
| 1368 | * |
| 1369 | * Description: |
| 1370 | * If the port is configured to allow a reset then the hba is brought |
| 1371 | * offline then online. |
| 1372 | * |
| 1373 | * Notes: |
| 1374 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1375 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1376 | * |
| 1377 | * Returns: |
| 1378 | * lpfc_do_offline() return code if not zero |
| 1379 | * -EIO reset not configured or error posting the event |
| 1380 | * zero for success |
| 1381 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1382 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1383 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1384 | { |
| 1385 | struct completion online_compl; |
| 1386 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1387 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1388 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1389 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1390 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1391 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1392 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1393 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1394 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1395 | if (status != 0) |
| 1396 | return status; |
| 1397 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1398 | |
| 1399 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1400 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1401 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1402 | if (rc == 0) |
| 1403 | return -ENOMEM; |
| 1404 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1405 | wait_for_completion(&online_compl); |
| 1406 | |
| 1407 | if (status != 0) |
| 1408 | return -EIO; |
| 1409 | |
| 1410 | return 0; |
| 1411 | } |
| 1412 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1413 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1414 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1415 | * @dev: class device that is converted into a Scsi_host. |
| 1416 | * @attr: device attribute, not used. |
| 1417 | * @buf: containing the string "selective". |
| 1418 | * @count: unused variable. |
| 1419 | * |
| 1420 | * Description: |
| 1421 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1422 | * is called to perform the reset. |
| 1423 | * |
| 1424 | * Notes: |
| 1425 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1426 | * 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] | 1427 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1428 | * |
| 1429 | * Returns: |
| 1430 | * -EINVAL if the buffer does not contain the string "selective" |
| 1431 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1432 | * return value of lpfc_selective_reset() if the call fails |
| 1433 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1434 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1435 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1436 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1437 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1438 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1439 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1440 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1441 | int status = -EINVAL; |
| 1442 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1443 | if (!phba->cfg_enable_hba_reset) |
| 1444 | return -EACCES; |
| 1445 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1446 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1447 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1448 | |
| 1449 | if (status == 0) |
| 1450 | return strlen(buf); |
| 1451 | else |
| 1452 | return status; |
| 1453 | } |
| 1454 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1455 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1456 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1457 | * @phba: lpfc_hba pointer. |
| 1458 | * |
| 1459 | * Description: |
| 1460 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1461 | * the readyness after performing a firmware reset. |
| 1462 | * |
| 1463 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1464 | * 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] | 1465 | * reset, -EIO when port timeout from recovering from the reset. |
| 1466 | * |
| 1467 | * Note: |
| 1468 | * As the caller will interpret the return code by value, be careful in making |
| 1469 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1470 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1471 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1472 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1473 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1474 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1475 | int i; |
| 1476 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1477 | msleep(100); |
James Smart | b7b95fb | 2019-09-21 20:58:49 -0700 | [diff] [blame] | 1478 | if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1479 | &portstat_reg.word0)) |
| 1480 | return -EIO; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1481 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1482 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1483 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1484 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1485 | return -EPERM; |
| 1486 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1487 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1488 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1489 | msleep(10); |
James Smart | b7b95fb | 2019-09-21 20:58:49 -0700 | [diff] [blame] | 1490 | if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1491 | &portstat_reg.word0)) |
| 1492 | continue; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1493 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1494 | continue; |
| 1495 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1496 | continue; |
| 1497 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1498 | continue; |
| 1499 | break; |
| 1500 | } |
| 1501 | |
| 1502 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1503 | return 0; |
| 1504 | else |
| 1505 | return -EIO; |
| 1506 | } |
| 1507 | |
| 1508 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1509 | * 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] | 1510 | * @phba: lpfc_hba pointer. |
| 1511 | * |
| 1512 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1513 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1514 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1515 | * |
| 1516 | * Returns: |
| 1517 | * zero for success |
| 1518 | **/ |
| 1519 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1520 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1521 | { |
| 1522 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1523 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1524 | uint32_t before_fc_flag; |
| 1525 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1526 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1527 | int status = 0, rc = 0; |
| 1528 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1529 | |
| 1530 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1531 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1532 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1533 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame] | 1534 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1535 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1536 | return -EPERM; |
| 1537 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1538 | /* Keep state if we need to restore back */ |
| 1539 | before_fc_flag = phba->pport->fc_flag; |
| 1540 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1541 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1542 | /* Disable SR-IOV virtual functions if enabled */ |
| 1543 | if (phba->cfg_sriov_nr_virtfn) { |
| 1544 | pci_disable_sriov(pdev); |
| 1545 | phba->cfg_sriov_nr_virtfn = 0; |
| 1546 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1547 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1548 | if (opcode == LPFC_FW_DUMP) |
| 1549 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1550 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1551 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1552 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1553 | if (status != 0) { |
| 1554 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1555 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1556 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1557 | |
| 1558 | /* wait for the device to be quiesced before firmware reset */ |
| 1559 | msleep(100); |
| 1560 | |
| 1561 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1562 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1563 | |
| 1564 | if (opcode == LPFC_FW_DUMP) |
| 1565 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1566 | else if (opcode == LPFC_FW_RESET) |
| 1567 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1568 | else if (opcode == LPFC_DV_RESET) |
| 1569 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1570 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1571 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1572 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1573 | /* flush */ |
| 1574 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1575 | |
| 1576 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1577 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1578 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1579 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1580 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1581 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1582 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1583 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1584 | } else if (rc == -EIO) { |
| 1585 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1586 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1587 | "3153 Fail to perform the requested " |
| 1588 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1589 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1590 | } |
| 1591 | |
| 1592 | /* keep the original port state */ |
| 1593 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1594 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1595 | |
| 1596 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1597 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1598 | LPFC_EVT_ONLINE); |
| 1599 | if (!job_posted) |
| 1600 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1601 | |
| 1602 | wait_for_completion(&online_compl); |
| 1603 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1604 | out: |
| 1605 | /* in any case, restore the virtual functions enabled as before */ |
| 1606 | if (sriov_nr_virtfn) { |
| 1607 | sriov_err = |
| 1608 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1609 | if (!sriov_err) |
| 1610 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1611 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1612 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1613 | /* return proper error code */ |
| 1614 | if (!rc) { |
| 1615 | if (!job_posted) |
| 1616 | rc = -ENOMEM; |
| 1617 | else if (status) |
| 1618 | rc = -EIO; |
| 1619 | } |
| 1620 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1624 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1625 | * @dev: class device that is converted into a Scsi_host. |
| 1626 | * @attr: device attribute, not used. |
| 1627 | * @buf: on return contains the ascii number of nport events. |
| 1628 | * |
| 1629 | * Returns: size of formatted string. |
| 1630 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1631 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1632 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1633 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1634 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1635 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1636 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1637 | struct lpfc_hba *phba = vport->phba; |
| 1638 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1639 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1640 | } |
| 1641 | |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 1642 | static int |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1643 | lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out) |
| 1644 | { |
| 1645 | LPFC_MBOXQ_t *mbox = NULL; |
| 1646 | unsigned long val = 0; |
Saurav Girepunje | 2c7fb46 | 2019-10-24 08:27:29 +0530 | [diff] [blame] | 1647 | char *pval = NULL; |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1648 | int rc = 0; |
| 1649 | |
| 1650 | if (!strncmp("enable", buff_out, |
| 1651 | strlen("enable"))) { |
| 1652 | pval = buff_out + strlen("enable") + 1; |
| 1653 | rc = kstrtoul(pval, 0, &val); |
| 1654 | if (rc) |
| 1655 | return rc; /* Invalid number */ |
| 1656 | } else if (!strncmp("disable", buff_out, |
| 1657 | strlen("disable"))) { |
| 1658 | val = 0; |
| 1659 | } else { |
| 1660 | return -EINVAL; /* Invalid command */ |
| 1661 | } |
| 1662 | |
| 1663 | switch (val) { |
| 1664 | case 0: |
| 1665 | val = 0x0; /* Disable */ |
| 1666 | break; |
| 1667 | case 2: |
| 1668 | val = 0x1; /* Enable two port trunk */ |
| 1669 | break; |
| 1670 | case 4: |
| 1671 | val = 0x2; /* Enable four port trunk */ |
| 1672 | break; |
| 1673 | default: |
| 1674 | return -EINVAL; |
| 1675 | } |
| 1676 | |
| 1677 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1678 | "0070 Set trunk mode with val %ld ", val); |
| 1679 | |
| 1680 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1681 | if (!mbox) |
| 1682 | return -ENOMEM; |
| 1683 | |
| 1684 | lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE, |
| 1685 | LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE, |
| 1686 | 12, LPFC_SLI4_MBX_EMBED); |
| 1687 | |
| 1688 | bf_set(lpfc_mbx_set_trunk_mode, |
| 1689 | &mbox->u.mqe.un.set_trunk_mode, |
| 1690 | val); |
| 1691 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); |
| 1692 | if (rc) |
| 1693 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1694 | "0071 Set trunk mode failed with status: %d", |
| 1695 | rc); |
| 1696 | if (rc != MBX_TIMEOUT) |
| 1697 | mempool_free(mbox, phba->mbox_mem_pool); |
| 1698 | |
| 1699 | return 0; |
| 1700 | } |
| 1701 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1702 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1703 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1704 | * @dev: class device that is converted into a Scsi_host. |
| 1705 | * @attr: device attribute, not used. |
| 1706 | * @buf: on return contains the state of the adapter. |
| 1707 | * |
| 1708 | * Returns: size of formatted string. |
| 1709 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1710 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1711 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1712 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1713 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1714 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1715 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1716 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1717 | char * state; |
| 1718 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1719 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1720 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1721 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1722 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1723 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1724 | state = "offline"; |
| 1725 | else |
| 1726 | state = "online"; |
| 1727 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1728 | return scnprintf(buf, PAGE_SIZE, "%s\n", state); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1729 | } |
| 1730 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1731 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1732 | * 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] | 1733 | * @dev: class device that is converted into a Scsi_host. |
| 1734 | * @attr: device attribute, not used. |
| 1735 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1736 | * @count: unused variable. |
| 1737 | * |
| 1738 | * Returns: |
| 1739 | * -EACCES if enable hba reset not enabled |
| 1740 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1741 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1742 | * buf length greater than zero indicates success |
| 1743 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1744 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1745 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1746 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1747 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1748 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1749 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1750 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1751 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1752 | char *board_mode_str = NULL; |
| 1753 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1754 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1755 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1756 | if (!phba->cfg_enable_hba_reset) { |
| 1757 | status = -EACCES; |
| 1758 | goto board_mode_out; |
| 1759 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1760 | |
| 1761 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1762 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1763 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1764 | init_completion(&online_compl); |
| 1765 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1766 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1767 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1768 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1769 | if (rc == 0) { |
| 1770 | status = -ENOMEM; |
| 1771 | goto board_mode_out; |
| 1772 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1773 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1774 | if (status) |
| 1775 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1776 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1777 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1778 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1779 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1780 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1781 | else |
| 1782 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1783 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1784 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1785 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1786 | else |
| 1787 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1788 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1789 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1790 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1791 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1792 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1793 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 1794 | else if (strncmp(buf, "pci_bus_reset", sizeof("pci_bus_reset") - 1) |
| 1795 | == 0) |
| 1796 | status = lpfc_reset_pci_bus(phba); |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1797 | else if (strncmp(buf, "trunk", sizeof("trunk") - 1) == 0) |
| 1798 | status = lpfc_set_trunking(phba, (char *)buf + sizeof("trunk")); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1799 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1800 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1801 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1802 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1803 | if (!status) |
| 1804 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1805 | else { |
| 1806 | board_mode_str = strchr(buf, '\n'); |
| 1807 | if (board_mode_str) |
| 1808 | *board_mode_str = '\0'; |
| 1809 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1810 | "3097 Failed \"%s\", status(%d), " |
| 1811 | "fc_flag(x%x)\n", |
| 1812 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1813 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1814 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1815 | } |
| 1816 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1817 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1818 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1819 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1820 | * @mxri: max xri count. |
| 1821 | * @axri: available xri count. |
| 1822 | * @mrpi: max rpi count. |
| 1823 | * @arpi: available rpi count. |
| 1824 | * @mvpi: max vpi count. |
| 1825 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1826 | * |
| 1827 | * Description: |
| 1828 | * If an integer pointer for an count is not null then the value for the |
| 1829 | * count is returned. |
| 1830 | * |
| 1831 | * Returns: |
| 1832 | * zero on error |
| 1833 | * one for success |
| 1834 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1835 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1836 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1837 | uint32_t *mxri, uint32_t *axri, |
| 1838 | uint32_t *mrpi, uint32_t *arpi, |
| 1839 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1840 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1841 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1842 | LPFC_MBOXQ_t *pmboxq; |
| 1843 | MAILBOX_t *pmb; |
| 1844 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1845 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1846 | |
| 1847 | /* |
| 1848 | * prevent udev from issuing mailbox commands until the port is |
| 1849 | * configured. |
| 1850 | */ |
| 1851 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1852 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1853 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1854 | return 0; |
| 1855 | |
| 1856 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1857 | return 0; |
| 1858 | |
| 1859 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1860 | if (!pmboxq) |
| 1861 | return 0; |
| 1862 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1863 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1864 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1865 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1866 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 1867 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1868 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1869 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1870 | rc = MBX_NOT_FINISHED; |
| 1871 | else |
| 1872 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1873 | |
| 1874 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1875 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1876 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1877 | return 0; |
| 1878 | } |
| 1879 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1880 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1881 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1882 | if (mrpi) |
| 1883 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1884 | if (arpi) |
| 1885 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1886 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1887 | if (mxri) |
| 1888 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1889 | if (axri) |
| 1890 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1891 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1892 | |
| 1893 | /* Account for differences with SLI-3. Get vpi count from |
| 1894 | * mailbox data and subtract one for max vpi value. |
| 1895 | */ |
| 1896 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1897 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1898 | |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 1899 | /* Limit the max we support */ |
| 1900 | if (max_vpi > LPFC_MAX_VPI) |
| 1901 | max_vpi = LPFC_MAX_VPI; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1902 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1903 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1904 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1905 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1906 | } else { |
| 1907 | if (mrpi) |
| 1908 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1909 | if (arpi) |
| 1910 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1911 | if (mxri) |
| 1912 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1913 | if (axri) |
| 1914 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1915 | if (mvpi) |
| 1916 | *mvpi = pmb->un.varRdConfig.max_vpi; |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 1917 | if (avpi) { |
| 1918 | /* avail_vpi is only valid if link is up and ready */ |
| 1919 | if (phba->link_state == LPFC_HBA_READY) |
| 1920 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1921 | else |
| 1922 | *avpi = pmb->un.varRdConfig.max_vpi; |
| 1923 | } |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1924 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1925 | |
| 1926 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1927 | return 1; |
| 1928 | } |
| 1929 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1930 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1931 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1932 | * @dev: class device that is converted into a Scsi_host. |
| 1933 | * @attr: device attribute, not used. |
| 1934 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1935 | * |
| 1936 | * Description: |
| 1937 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1938 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1939 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1940 | * must check for "Unknown" in the buffer to detect a failure. |
| 1941 | * |
| 1942 | * Returns: size of formatted string. |
| 1943 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1944 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1945 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1946 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1947 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1948 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1949 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1950 | struct lpfc_hba *phba = vport->phba; |
| 1951 | uint32_t cnt; |
| 1952 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1953 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1954 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1955 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1956 | } |
| 1957 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1958 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1959 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1960 | * @dev: class device that is converted into a Scsi_host. |
| 1961 | * @attr: device attribute, not used. |
| 1962 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1963 | * |
| 1964 | * Description: |
| 1965 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1966 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1967 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1968 | * must check for "Unknown" in the buffer to detect a failure. |
| 1969 | * |
| 1970 | * Returns: size of formatted string. |
| 1971 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1972 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1973 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1974 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1975 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1976 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1977 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1978 | struct lpfc_hba *phba = vport->phba; |
| 1979 | uint32_t cnt, acnt; |
| 1980 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1981 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1982 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1983 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1984 | } |
| 1985 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1986 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1987 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1988 | * @dev: class device that is converted into a Scsi_host. |
| 1989 | * @attr: device attribute, not used. |
| 1990 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1991 | * |
| 1992 | * Description: |
| 1993 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1994 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1995 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1996 | * must check for "Unknown" in the buffer to detect a failure. |
| 1997 | * |
| 1998 | * Returns: size of formatted string. |
| 1999 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2000 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2001 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 2002 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2003 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2004 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2005 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2006 | struct lpfc_hba *phba = vport->phba; |
| 2007 | uint32_t cnt; |
| 2008 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2009 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2010 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2011 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2012 | } |
| 2013 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2014 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2015 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2016 | * @dev: class device that is converted into a Scsi_host. |
| 2017 | * @attr: device attribute, not used. |
| 2018 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 2019 | * |
| 2020 | * Description: |
| 2021 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 2022 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2023 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2024 | * must check for "Unknown" in the buffer to detect a failure. |
| 2025 | * |
| 2026 | * Returns: size of formatted string. |
| 2027 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2028 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2029 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 2030 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2031 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2032 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2033 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2034 | struct lpfc_hba *phba = vport->phba; |
| 2035 | uint32_t cnt, acnt; |
| 2036 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2037 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2038 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2039 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2040 | } |
| 2041 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2042 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2043 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2044 | * @dev: class device that is converted into a Scsi_host. |
| 2045 | * @attr: device attribute, not used. |
| 2046 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 2047 | * |
| 2048 | * Description: |
| 2049 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 2050 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2051 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2052 | * must check for "Unknown" in the buffer to detect a failure. |
| 2053 | * |
| 2054 | * Returns: size of formatted string. |
| 2055 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2056 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2057 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 2058 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2059 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2060 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2061 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2062 | struct lpfc_hba *phba = vport->phba; |
| 2063 | uint32_t cnt; |
| 2064 | |
| 2065 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2066 | return scnprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 2067 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2068 | } |
| 2069 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2070 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2071 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2072 | * @dev: class device that is converted into a Scsi_host. |
| 2073 | * @attr: device attribute, not used. |
| 2074 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 2075 | * |
| 2076 | * Description: |
| 2077 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 2078 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 2079 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 2080 | * must check for "Unknown" in the buffer to detect a failure. |
| 2081 | * |
| 2082 | * Returns: size of formatted string. |
| 2083 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2084 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2085 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 2086 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2087 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2088 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2089 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2090 | struct lpfc_hba *phba = vport->phba; |
| 2091 | uint32_t cnt, acnt; |
| 2092 | |
| 2093 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2094 | return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 2095 | return scnprintf(buf, PAGE_SIZE, "Unknown\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2096 | } |
| 2097 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2098 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2099 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2100 | * @dev: class device that is converted into a Scsi_host. |
| 2101 | * @attr: device attribute, not used. |
| 2102 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 2103 | * |
| 2104 | * Description: |
| 2105 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 2106 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 2107 | * the id of the vport. |
| 2108 | * |
| 2109 | * Returns: size of formatted string. |
| 2110 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2111 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2112 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 2113 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2114 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2115 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2116 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2117 | struct lpfc_hba *phba = vport->phba; |
| 2118 | |
| 2119 | if (!(phba->max_vpi)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2120 | return scnprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2121 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2122 | return scnprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 2123 | return scnprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2124 | } |
| 2125 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2126 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2127 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2128 | * @dev: class device that is converted into a Scsi_host. |
| 2129 | * @attr: device attribute, not used. |
| 2130 | * @buf: on return contains the cfg_poll in hex. |
| 2131 | * |
| 2132 | * Notes: |
| 2133 | * cfg_poll should be a lpfc_polling_flags type. |
| 2134 | * |
| 2135 | * Returns: size of formatted string. |
| 2136 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 2137 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2138 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 2139 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2140 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2141 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2142 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2143 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2144 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2145 | return scnprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2146 | } |
| 2147 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2148 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2149 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2150 | * @dev: class device that is converted into a Scsi_host. |
| 2151 | * @attr: device attribute, not used. |
| 2152 | * @buf: one or more lpfc_polling_flags values. |
| 2153 | * @count: not used. |
| 2154 | * |
| 2155 | * Notes: |
| 2156 | * buf contents converted to integer and checked for a valid value. |
| 2157 | * |
| 2158 | * Returns: |
| 2159 | * -EINVAL if the buffer connot be converted or is out of range |
| 2160 | * length of the buf on success |
| 2161 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2162 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2163 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 2164 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2165 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2166 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2167 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2168 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2169 | uint32_t creg_val; |
| 2170 | uint32_t old_val; |
| 2171 | int val=0; |
| 2172 | |
| 2173 | if (!isdigit(buf[0])) |
| 2174 | return -EINVAL; |
| 2175 | |
| 2176 | if (sscanf(buf, "%i", &val) != 1) |
| 2177 | return -EINVAL; |
| 2178 | |
| 2179 | if ((val & 0x3) != val) |
| 2180 | return -EINVAL; |
| 2181 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 2182 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 2183 | val = 0; |
| 2184 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2185 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2186 | "3051 lpfc_poll changed from %d to %d\n", |
| 2187 | phba->cfg_poll, val); |
| 2188 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2189 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2190 | |
| 2191 | old_val = phba->cfg_poll; |
| 2192 | |
| 2193 | if (val & ENABLE_FCP_RING_POLLING) { |
| 2194 | if ((val & DISABLE_FCP_RING_INT) && |
| 2195 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2196 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2197 | spin_unlock_irq(&phba->hbalock); |
| 2198 | return -EINVAL; |
| 2199 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2200 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 2201 | writel(creg_val, phba->HCregaddr); |
| 2202 | readl(phba->HCregaddr); /* flush */ |
| 2203 | |
| 2204 | lpfc_poll_start_timer(phba); |
| 2205 | } |
| 2206 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2207 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2208 | return -EINVAL; |
| 2209 | } |
| 2210 | |
| 2211 | if (!(val & DISABLE_FCP_RING_INT) && |
| 2212 | (old_val & DISABLE_FCP_RING_INT)) |
| 2213 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2214 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2215 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2216 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2217 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2218 | spin_unlock_irq(&phba->hbalock); |
| 2219 | return -EINVAL; |
| 2220 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2221 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 2222 | writel(creg_val, phba->HCregaddr); |
| 2223 | readl(phba->HCregaddr); /* flush */ |
| 2224 | } |
| 2225 | |
| 2226 | phba->cfg_poll = val; |
| 2227 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2228 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2229 | |
| 2230 | return strlen(buf); |
| 2231 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2232 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2233 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2234 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 2235 | * @dev: class unused variable. |
| 2236 | * @attr: device attribute, not used. |
| 2237 | * @buf: on return contains the module description text. |
| 2238 | * |
| 2239 | * Returns: size of formatted string. |
| 2240 | **/ |
| 2241 | static ssize_t |
| 2242 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 2243 | char *buf) |
| 2244 | { |
| 2245 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2246 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2247 | struct lpfc_hba *phba = vport->phba; |
| 2248 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2249 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2250 | } |
| 2251 | |
| 2252 | /** |
| 2253 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 2254 | * @dev: class unused variable. |
| 2255 | * @attr: device attribute, not used. |
| 2256 | * @buf: on return contains the module description text. |
| 2257 | * |
| 2258 | * Returns: size of formatted string. |
| 2259 | **/ |
| 2260 | static ssize_t |
| 2261 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 2262 | char *buf) |
| 2263 | { |
| 2264 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2265 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2266 | struct lpfc_hba *phba = vport->phba; |
| 2267 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2268 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2269 | } |
| 2270 | |
| 2271 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2272 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 2273 | * @dev: class converted to a Scsi_host structure. |
| 2274 | * @attr: device attribute, not used. |
| 2275 | * @buf: on return contains the formatted text. |
| 2276 | * |
| 2277 | * Returns: size of formatted string. |
| 2278 | **/ |
| 2279 | static ssize_t |
| 2280 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 2281 | char *buf) |
| 2282 | { |
| 2283 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2284 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2285 | struct lpfc_hba *phba = vport->phba; |
| 2286 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2287 | return scnprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2288 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 2289 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 2290 | "" : "Not "); |
| 2291 | } |
| 2292 | |
| 2293 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2294 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 2295 | * @dev: class converted to a Scsi_host structure. |
| 2296 | * @attr: device attribute, not used. |
| 2297 | * @buf: on return contains the formatted support level. |
| 2298 | * |
| 2299 | * Description: |
| 2300 | * Returns the maximum number of virtual functions a physical function can |
| 2301 | * support, 0 will be returned if called on virtual function. |
| 2302 | * |
| 2303 | * Returns: size of formatted string. |
| 2304 | **/ |
| 2305 | static ssize_t |
| 2306 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 2307 | struct device_attribute *attr, |
| 2308 | char *buf) |
| 2309 | { |
| 2310 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2311 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2312 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2313 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2314 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2315 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2316 | return scnprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2317 | } |
| 2318 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2319 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 2320 | { |
| 2321 | return val >= min && val <= max; |
| 2322 | } |
| 2323 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2324 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2325 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 2326 | * @phba: pointer the the adapter structure. |
| 2327 | * @val: integer attribute value. |
| 2328 | * |
| 2329 | * Description: |
| 2330 | * Validates the min and max values then sets the |
| 2331 | * adapter config field if in the valid range. prints error message |
| 2332 | * and does not set the parameter if invalid. |
| 2333 | * |
| 2334 | * Returns: |
| 2335 | * zero on success |
| 2336 | * -EINVAL if val is invalid |
| 2337 | */ |
| 2338 | static ssize_t |
| 2339 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 2340 | { |
| 2341 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 2342 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2343 | "3068 %s_enable_bbcr changed from %d to %d\n", |
| 2344 | LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val); |
| 2345 | phba->cfg_enable_bbcr = val; |
| 2346 | return 0; |
| 2347 | } |
| 2348 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2349 | "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n", |
| 2350 | LPFC_DRIVER_NAME, val); |
| 2351 | return -EINVAL; |
| 2352 | } |
| 2353 | |
| 2354 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2355 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2356 | * |
| 2357 | * Description: |
| 2358 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2359 | * into a function with the name lpfc_hba_queue_depth_show. |
| 2360 | * |
| 2361 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 2362 | * @dev: class device that is converted into a Scsi_host. |
| 2363 | * @attr: device attribute, not used. |
| 2364 | * @buf: on return contains the attribute value in decimal. |
| 2365 | * |
| 2366 | * Returns: size of formatted string. |
| 2367 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2368 | #define lpfc_param_show(attr) \ |
| 2369 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2370 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2371 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2372 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2373 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2374 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2375 | struct lpfc_hba *phba = vport->phba;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2376 | return scnprintf(buf, PAGE_SIZE, "%d\n",\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2377 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2378 | } |
| 2379 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2380 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2381 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2382 | * |
| 2383 | * Description: |
| 2384 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2385 | * into a function with the name lpfc_hba_queue_depth_show |
| 2386 | * |
| 2387 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 2388 | * @dev: class device that is converted into a Scsi_host. |
| 2389 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2390 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2391 | * |
| 2392 | * Returns: size of formatted string. |
| 2393 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2394 | #define lpfc_param_hex_show(attr) \ |
| 2395 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2396 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2397 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2398 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2399 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2400 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2401 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2402 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2403 | val = phba->cfg_##attr;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2404 | return scnprintf(buf, PAGE_SIZE, "%#x\n",\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2405 | phba->cfg_##attr);\ |
| 2406 | } |
| 2407 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2408 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 2409 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2410 | * |
| 2411 | * Description: |
| 2412 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2413 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2414 | * takes a default argument, a minimum and maximum argument. |
| 2415 | * |
| 2416 | * lpfc_##attr##_init: Initializes an attribute. |
| 2417 | * @phba: pointer the the adapter structure. |
| 2418 | * @val: integer attribute value. |
| 2419 | * |
| 2420 | * Validates the min and max values then sets the adapter config field |
| 2421 | * accordingly, or uses the default if out of range and prints an error message. |
| 2422 | * |
| 2423 | * Returns: |
| 2424 | * zero on success |
| 2425 | * -EINVAL if default used |
| 2426 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2427 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 2428 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2429 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2430 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2431 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2432 | phba->cfg_##attr = val;\ |
| 2433 | return 0;\ |
| 2434 | }\ |
| 2435 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2436 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2437 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2438 | phba->cfg_##attr = default;\ |
| 2439 | return -EINVAL;\ |
| 2440 | } |
| 2441 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2442 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2443 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2444 | * |
| 2445 | * Description: |
| 2446 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2447 | * into a function with the name lpfc_hba_queue_depth_set |
| 2448 | * |
| 2449 | * lpfc_##attr##_set: Sets an attribute value. |
| 2450 | * @phba: pointer the the adapter structure. |
| 2451 | * @val: integer attribute value. |
| 2452 | * |
| 2453 | * Description: |
| 2454 | * Validates the min and max values then sets the |
| 2455 | * adapter config field if in the valid range. prints error message |
| 2456 | * and does not set the parameter if invalid. |
| 2457 | * |
| 2458 | * Returns: |
| 2459 | * zero on success |
| 2460 | * -EINVAL if val is invalid |
| 2461 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2462 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2463 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2464 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2465 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2466 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2467 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2468 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2469 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2470 | phba->cfg_##attr = val;\ |
| 2471 | return 0;\ |
| 2472 | }\ |
| 2473 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2474 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2475 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2476 | return -EINVAL;\ |
| 2477 | } |
| 2478 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2479 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2480 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2481 | * |
| 2482 | * Description: |
| 2483 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2484 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2485 | * |
| 2486 | * lpfc_##attr##_store: Set an sttribute value. |
| 2487 | * @dev: class device that is converted into a Scsi_host. |
| 2488 | * @attr: device attribute, not used. |
| 2489 | * @buf: contains the attribute value in ascii. |
| 2490 | * @count: not used. |
| 2491 | * |
| 2492 | * Description: |
| 2493 | * Convert the ascii text number to an integer, then |
| 2494 | * use the lpfc_##attr##_set function to set the value. |
| 2495 | * |
| 2496 | * Returns: |
| 2497 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2498 | * length of buffer upon success. |
| 2499 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2500 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2501 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2502 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2503 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2504 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2505 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2506 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2507 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2508 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2509 | if (!isdigit(buf[0]))\ |
| 2510 | return -EINVAL;\ |
| 2511 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2512 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2513 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2514 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2515 | else \ |
| 2516 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2517 | } |
| 2518 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2519 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2520 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2521 | * |
| 2522 | * Description: |
| 2523 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2524 | * into a function with the name lpfc_hba_queue_depth_show |
| 2525 | * |
| 2526 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2527 | * @dev: class device that is converted into a Scsi_host. |
| 2528 | * @attr: device attribute, not used. |
| 2529 | * @buf: on return contains the attribute value in decimal. |
| 2530 | * |
| 2531 | * Returns: length of formatted string. |
| 2532 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2533 | #define lpfc_vport_param_show(attr) \ |
| 2534 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2535 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2536 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2537 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2538 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2539 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2540 | return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2541 | } |
| 2542 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2543 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2544 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2545 | * |
| 2546 | * Description: |
| 2547 | * Macro that given an attr e.g. |
| 2548 | * hba_queue_depth expands into a function with the name |
| 2549 | * lpfc_hba_queue_depth_show |
| 2550 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2551 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2552 | * @dev: class device that is converted into a Scsi_host. |
| 2553 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2554 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2555 | * |
| 2556 | * Returns: length of formatted string. |
| 2557 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2558 | #define lpfc_vport_param_hex_show(attr) \ |
| 2559 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2560 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2561 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2562 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2563 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2564 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2565 | return scnprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2566 | } |
| 2567 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2568 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2569 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2570 | * |
| 2571 | * Description: |
| 2572 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2573 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2574 | * takes a default argument, a minimum and maximum argument. |
| 2575 | * |
| 2576 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2577 | * adapter config field accordingly, or uses the default if out of range |
| 2578 | * and prints an error message. |
| 2579 | * @phba: pointer the the adapter structure. |
| 2580 | * @val: integer attribute value. |
| 2581 | * |
| 2582 | * Returns: |
| 2583 | * zero on success |
| 2584 | * -EINVAL if default used |
| 2585 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2586 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2587 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2588 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2589 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2590 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2591 | vport->cfg_##attr = val;\ |
| 2592 | return 0;\ |
| 2593 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2594 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2595 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2596 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2597 | vport->cfg_##attr = default;\ |
| 2598 | return -EINVAL;\ |
| 2599 | } |
| 2600 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2601 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2602 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2603 | * |
| 2604 | * Description: |
| 2605 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2606 | * into a function with the name lpfc_hba_queue_depth_set |
| 2607 | * |
| 2608 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2609 | * adapter config field if in the valid range. prints error message |
| 2610 | * and does not set the parameter if invalid. |
| 2611 | * @phba: pointer the the adapter structure. |
| 2612 | * @val: integer attribute value. |
| 2613 | * |
| 2614 | * Returns: |
| 2615 | * zero on success |
| 2616 | * -EINVAL if val is invalid |
| 2617 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2618 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2619 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2620 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2621 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2622 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2623 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2624 | "3053 lpfc_" #attr \ |
| 2625 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2626 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2627 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2628 | vport->cfg_##attr = val;\ |
| 2629 | return 0;\ |
| 2630 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2631 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2632 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2633 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2634 | return -EINVAL;\ |
| 2635 | } |
| 2636 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2637 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2638 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2639 | * |
| 2640 | * Description: |
| 2641 | * Macro that given an attr e.g. hba_queue_depth |
| 2642 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2643 | * |
| 2644 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2645 | * use the lpfc_##attr##_set function to set the value. |
| 2646 | * @cdev: class device that is converted into a Scsi_host. |
| 2647 | * @buf: contains the attribute value in decimal. |
| 2648 | * @count: not used. |
| 2649 | * |
| 2650 | * Returns: |
| 2651 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2652 | * length of buffer upon success. |
| 2653 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2654 | #define lpfc_vport_param_store(attr) \ |
| 2655 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2656 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2657 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2658 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2659 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2660 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2661 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2662 | if (!isdigit(buf[0]))\ |
| 2663 | return -EINVAL;\ |
| 2664 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2665 | return -EINVAL;\ |
| 2666 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2667 | return strlen(buf);\ |
| 2668 | else \ |
| 2669 | return -EINVAL;\ |
| 2670 | } |
| 2671 | |
| 2672 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2673 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 2674 | static DEVICE_ATTR(scsi_stat, 0444, lpfc_scsi_stat_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2675 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2676 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2677 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2678 | 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] | 2679 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2680 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2681 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2682 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2683 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2684 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2685 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2686 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2687 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2688 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2689 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2690 | lpfc_option_rom_version_show, NULL); |
| 2691 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2692 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2693 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2694 | 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] | 2695 | static DEVICE_ATTR_RO(lpfc_drvr_version); |
| 2696 | static DEVICE_ATTR_RO(lpfc_enable_fip); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2697 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2698 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2699 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2700 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2701 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2702 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2703 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2704 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2705 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2706 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2707 | static DEVICE_ATTR_RO(lpfc_temp_sensor); |
| 2708 | static DEVICE_ATTR_RO(lpfc_fips_level); |
| 2709 | static DEVICE_ATTR_RO(lpfc_fips_rev); |
| 2710 | static DEVICE_ATTR_RO(lpfc_dss); |
| 2711 | static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2712 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2713 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2714 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2715 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2716 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2717 | #define WWN_SZ 8 |
| 2718 | /** |
| 2719 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2720 | * @buf: WWN string. |
| 2721 | * @cnt: Length of string. |
| 2722 | * @wwn: Array to receive converted wwn value. |
| 2723 | * |
| 2724 | * Returns: |
| 2725 | * -EINVAL if the buffer does not contain a valid wwn |
| 2726 | * 0 success |
| 2727 | **/ |
| 2728 | static size_t |
| 2729 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2730 | { |
| 2731 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2732 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2733 | /* Count may include a LF at end of string */ |
| 2734 | if (buf[cnt-1] == '\n') |
| 2735 | cnt--; |
| 2736 | |
| 2737 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2738 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2739 | return -EINVAL; |
| 2740 | |
| 2741 | memset(wwn, 0, WWN_SZ); |
| 2742 | |
| 2743 | /* Validate and store the new name */ |
| 2744 | for (i = 0, j = 0; i < 16; i++) { |
| 2745 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2746 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2747 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2748 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2749 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2750 | j = ((j << 4) | (*buf++ - '0')); |
| 2751 | else |
| 2752 | return -EINVAL; |
| 2753 | if (i % 2) { |
| 2754 | wwn[i/2] = j & 0xff; |
| 2755 | j = 0; |
| 2756 | } |
| 2757 | } |
| 2758 | return 0; |
| 2759 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2760 | /** |
| 2761 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2762 | * @dev: class device that is converted into a Scsi_host. |
| 2763 | * @attr: device attribute, not used. |
| 2764 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2765 | * @count: must be size of lpfc_soft_wwn_key. |
| 2766 | * |
| 2767 | * Returns: |
| 2768 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2769 | * length of buf indicates success |
| 2770 | **/ |
| 2771 | static ssize_t |
| 2772 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2773 | const char *buf, size_t count) |
| 2774 | { |
| 2775 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2776 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2777 | struct lpfc_hba *phba = vport->phba; |
| 2778 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2779 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2780 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2781 | |
| 2782 | /* |
| 2783 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2784 | * We require that the user write a specific key to enable |
| 2785 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2786 | * is written, the enable key resets. If further updates are |
| 2787 | * desired, the key must be written again to re-enable the |
| 2788 | * attribute. |
| 2789 | * |
| 2790 | * The "key" is not secret - it is a hardcoded string shown |
| 2791 | * here. The intent is to protect against the random user or |
| 2792 | * application that is just writing attributes. |
| 2793 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2794 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2795 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2796 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2797 | " be enabled: fawwpn is enabled\n"); |
| 2798 | return -EINVAL; |
| 2799 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2800 | |
| 2801 | /* count may include a LF at end of string */ |
| 2802 | if (buf[cnt-1] == '\n') |
| 2803 | cnt--; |
| 2804 | |
| 2805 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2806 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2807 | return -EINVAL; |
| 2808 | |
| 2809 | phba->soft_wwn_enable = 1; |
| 2810 | |
| 2811 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2812 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2813 | phba->brd_no); |
| 2814 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2815 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2816 | |
| 2817 | return count; |
| 2818 | } |
Joe Perches | 6cbaefb | 2017-12-19 10:15:09 -0800 | [diff] [blame] | 2819 | static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2820 | |
| 2821 | /** |
| 2822 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2823 | * @dev: class device that is converted into a Scsi_host. |
| 2824 | * @attr: device attribute, not used. |
| 2825 | * @buf: on return contains the wwpn in hexadecimal. |
| 2826 | * |
| 2827 | * Returns: size of formatted string. |
| 2828 | **/ |
| 2829 | static ssize_t |
| 2830 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2831 | char *buf) |
| 2832 | { |
| 2833 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2834 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2835 | struct lpfc_hba *phba = vport->phba; |
| 2836 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2837 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2838 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2839 | } |
| 2840 | |
| 2841 | /** |
| 2842 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2843 | * @dev class device that is converted into a Scsi_host. |
| 2844 | * @attr: device attribute, not used. |
| 2845 | * @buf: contains the wwpn in hexadecimal. |
| 2846 | * @count: number of wwpn bytes in buf |
| 2847 | * |
| 2848 | * Returns: |
| 2849 | * -EACCES hba reset not enabled, adapter over temp |
| 2850 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2851 | * -EIO error taking adapter offline or online |
| 2852 | * value of count on success |
| 2853 | **/ |
| 2854 | static ssize_t |
| 2855 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2856 | const char *buf, size_t count) |
| 2857 | { |
| 2858 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2859 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2860 | struct lpfc_hba *phba = vport->phba; |
| 2861 | struct completion online_compl; |
| 2862 | int stat1 = 0, stat2 = 0; |
| 2863 | unsigned int cnt = count; |
| 2864 | u8 wwpn[WWN_SZ]; |
| 2865 | int rc; |
| 2866 | |
| 2867 | if (!phba->cfg_enable_hba_reset) |
| 2868 | return -EACCES; |
| 2869 | spin_lock_irq(&phba->hbalock); |
| 2870 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2871 | spin_unlock_irq(&phba->hbalock); |
| 2872 | return -EACCES; |
| 2873 | } |
| 2874 | spin_unlock_irq(&phba->hbalock); |
| 2875 | /* count may include a LF at end of string */ |
| 2876 | if (buf[cnt-1] == '\n') |
| 2877 | cnt--; |
| 2878 | |
| 2879 | if (!phba->soft_wwn_enable) |
| 2880 | return -EINVAL; |
| 2881 | |
| 2882 | /* lock setting wwpn, wwnn down */ |
| 2883 | phba->soft_wwn_enable = 0; |
| 2884 | |
| 2885 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2886 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2887 | /* not able to set wwpn, unlock it */ |
| 2888 | phba->soft_wwn_enable = 1; |
| 2889 | return rc; |
| 2890 | } |
| 2891 | |
| 2892 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2893 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2894 | if (phba->cfg_soft_wwnn) |
| 2895 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2896 | |
| 2897 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2898 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2899 | |
| 2900 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2901 | if (stat1) |
| 2902 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2903 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2904 | "reinit adapter - %d\n", stat1); |
| 2905 | init_completion(&online_compl); |
| 2906 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2907 | LPFC_EVT_ONLINE); |
| 2908 | if (rc == 0) |
| 2909 | return -ENOMEM; |
| 2910 | |
| 2911 | wait_for_completion(&online_compl); |
| 2912 | if (stat2) |
| 2913 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2914 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2915 | "reinit adapter - %d\n", stat2); |
| 2916 | return (stat1 || stat2) ? -EIO : count; |
| 2917 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2918 | static DEVICE_ATTR_RW(lpfc_soft_wwpn); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2919 | |
| 2920 | /** |
| 2921 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2922 | * @dev: class device that is converted into a Scsi_host. |
| 2923 | * @attr: device attribute, not used. |
| 2924 | * @buf: on return contains the wwnn in hexadecimal. |
| 2925 | * |
| 2926 | * Returns: size of formatted string. |
| 2927 | **/ |
| 2928 | static ssize_t |
| 2929 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2930 | char *buf) |
| 2931 | { |
| 2932 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2933 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2934 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2935 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2936 | } |
| 2937 | |
| 2938 | /** |
| 2939 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2940 | * @cdev: class device that is converted into a Scsi_host. |
| 2941 | * @buf: contains the ww node name in hexadecimal. |
| 2942 | * @count: number of wwnn bytes in buf. |
| 2943 | * |
| 2944 | * Returns: |
| 2945 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2946 | * value of count on success |
| 2947 | **/ |
| 2948 | static ssize_t |
| 2949 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2950 | const char *buf, size_t count) |
| 2951 | { |
| 2952 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2953 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2954 | unsigned int cnt = count; |
| 2955 | u8 wwnn[WWN_SZ]; |
| 2956 | int rc; |
| 2957 | |
| 2958 | /* count may include a LF at end of string */ |
| 2959 | if (buf[cnt-1] == '\n') |
| 2960 | cnt--; |
| 2961 | |
| 2962 | if (!phba->soft_wwn_enable) |
| 2963 | return -EINVAL; |
| 2964 | |
| 2965 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2966 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2967 | /* Allow wwnn to be set many times, as long as the enable |
| 2968 | * is set. However, once the wwpn is set, everything locks. |
| 2969 | */ |
| 2970 | return rc; |
| 2971 | } |
| 2972 | |
| 2973 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2974 | |
| 2975 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2976 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2977 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2978 | |
| 2979 | return count; |
| 2980 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2981 | static DEVICE_ATTR_RW(lpfc_soft_wwnn); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2982 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2983 | /** |
| 2984 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2985 | * Optimized Access Storage (OAS) operations. |
| 2986 | * @dev: class device that is converted into a Scsi_host. |
| 2987 | * @attr: device attribute, not used. |
| 2988 | * @buf: buffer for passing information. |
| 2989 | * |
| 2990 | * Returns: |
| 2991 | * value of count |
| 2992 | **/ |
| 2993 | static ssize_t |
| 2994 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2995 | char *buf) |
| 2996 | { |
| 2997 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2998 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2999 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3000 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3001 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 3002 | } |
| 3003 | |
| 3004 | /** |
| 3005 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 3006 | * Optimized Access Storage (OAS) operations. |
| 3007 | * @dev: class device that is converted into a Scsi_host. |
| 3008 | * @attr: device attribute, not used. |
| 3009 | * @buf: buffer for passing information. |
| 3010 | * @count: Size of the data buffer. |
| 3011 | * |
| 3012 | * Returns: |
| 3013 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3014 | * -EPERM oas is not supported by hba |
| 3015 | * value of count on success |
| 3016 | **/ |
| 3017 | static ssize_t |
| 3018 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 3019 | const char *buf, size_t count) |
| 3020 | { |
| 3021 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3022 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3023 | unsigned int cnt = count; |
| 3024 | uint8_t wwpn[WWN_SZ]; |
| 3025 | int rc; |
| 3026 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3027 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3028 | return -EPERM; |
| 3029 | |
| 3030 | /* count may include a LF at end of string */ |
| 3031 | if (buf[cnt-1] == '\n') |
| 3032 | cnt--; |
| 3033 | |
| 3034 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 3035 | if (rc) |
| 3036 | return rc; |
| 3037 | |
| 3038 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3039 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3040 | if (wwn_to_u64(wwpn) == 0) |
| 3041 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 3042 | else |
| 3043 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 3044 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 3045 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3046 | return count; |
| 3047 | } |
| 3048 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 3049 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 3050 | |
| 3051 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3052 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 3053 | * Optimized Access Storage (OAS) operations. |
| 3054 | * @dev: class device that is converted into a Scsi_host. |
| 3055 | * @attr: device attribute, not used. |
| 3056 | * @buf: buffer for passing information. |
| 3057 | * |
| 3058 | * Returns: |
| 3059 | * value of count |
| 3060 | **/ |
| 3061 | static ssize_t |
| 3062 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 3063 | char *buf) |
| 3064 | { |
| 3065 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3066 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3067 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3068 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3069 | } |
| 3070 | |
| 3071 | /** |
| 3072 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 3073 | * Optimized Access Storage (OAS) operations. |
| 3074 | * @dev: class device that is converted into a Scsi_host. |
| 3075 | * @attr: device attribute, not used. |
| 3076 | * @buf: buffer for passing information. |
| 3077 | * @count: Size of the data buffer. |
| 3078 | * |
| 3079 | * Returns: |
| 3080 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3081 | * -EPERM oas is not supported by hba |
| 3082 | * value of count on success |
| 3083 | **/ |
| 3084 | static ssize_t |
| 3085 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 3086 | const char *buf, size_t count) |
| 3087 | { |
| 3088 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3089 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3090 | unsigned int cnt = count; |
| 3091 | unsigned long val; |
| 3092 | int ret; |
| 3093 | |
| 3094 | if (!phba->cfg_fof) |
| 3095 | return -EPERM; |
| 3096 | |
| 3097 | /* count may include a LF at end of string */ |
| 3098 | if (buf[cnt-1] == '\n') |
| 3099 | cnt--; |
| 3100 | |
| 3101 | ret = kstrtoul(buf, 0, &val); |
| 3102 | if (ret || (val > 0x7f)) |
| 3103 | return -EINVAL; |
| 3104 | |
| 3105 | if (val) |
| 3106 | phba->cfg_oas_priority = (uint8_t)val; |
| 3107 | else |
| 3108 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 3109 | return count; |
| 3110 | } |
| 3111 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 3112 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 3113 | |
| 3114 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3115 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 3116 | * for Optimized Access Storage (OAS) operations. |
| 3117 | * @dev: class device that is converted into a Scsi_host. |
| 3118 | * @attr: device attribute, not used. |
| 3119 | * @buf: buffer for passing information. |
| 3120 | * |
| 3121 | * Returns: |
| 3122 | * value of count on success |
| 3123 | **/ |
| 3124 | static ssize_t |
| 3125 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 3126 | char *buf) |
| 3127 | { |
| 3128 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3129 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3130 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3131 | return scnprintf(buf, PAGE_SIZE, "0x%llx\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3132 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 3133 | } |
| 3134 | |
| 3135 | /** |
| 3136 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 3137 | * for Optimized Access Storage (OAS) operations. |
| 3138 | * @dev: class device that is converted into a Scsi_host. |
| 3139 | * @attr: device attribute, not used. |
| 3140 | * @buf: buffer for passing information. |
| 3141 | * @count: Size of the data buffer. |
| 3142 | * |
| 3143 | * Returns: |
| 3144 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3145 | * -EPERM oas is not supported by hba |
| 3146 | * value of count on success |
| 3147 | **/ |
| 3148 | static ssize_t |
| 3149 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 3150 | const char *buf, size_t count) |
| 3151 | { |
| 3152 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3153 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3154 | unsigned int cnt = count; |
| 3155 | uint8_t wwpn[WWN_SZ]; |
| 3156 | int rc; |
| 3157 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3158 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3159 | return -EPERM; |
| 3160 | |
| 3161 | /* count may include a LF at end of string */ |
| 3162 | if (buf[cnt-1] == '\n') |
| 3163 | cnt--; |
| 3164 | |
| 3165 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 3166 | if (rc) |
| 3167 | return rc; |
| 3168 | |
| 3169 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3170 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 3171 | if (wwn_to_u64(wwpn) == 0) |
| 3172 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 3173 | else |
| 3174 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 3175 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3176 | if (phba->cfg_oas_priority == 0) |
| 3177 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3178 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3179 | return count; |
| 3180 | } |
| 3181 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 3182 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 3183 | |
| 3184 | /** |
| 3185 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 3186 | * of whether luns will be enabled or disabled |
| 3187 | * for Optimized Access Storage (OAS) operations. |
| 3188 | * @dev: class device that is converted into a Scsi_host. |
| 3189 | * @attr: device attribute, not used. |
| 3190 | * @buf: buffer for passing information. |
| 3191 | * |
| 3192 | * Returns: |
| 3193 | * size of formatted string. |
| 3194 | **/ |
| 3195 | static ssize_t |
| 3196 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 3197 | char *buf) |
| 3198 | { |
| 3199 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3200 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3201 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3202 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3203 | } |
| 3204 | |
| 3205 | /** |
| 3206 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 3207 | * of whether luns will be enabled or disabled |
| 3208 | * for Optimized Access Storage (OAS) operations. |
| 3209 | * @dev: class device that is converted into a Scsi_host. |
| 3210 | * @attr: device attribute, not used. |
| 3211 | * @buf: buffer for passing information. |
| 3212 | * @count: Size of the data buffer. |
| 3213 | * |
| 3214 | * Returns: |
| 3215 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3216 | * -EPERM oas is not supported by hba |
| 3217 | * value of count on success |
| 3218 | **/ |
| 3219 | static ssize_t |
| 3220 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 3221 | const char *buf, size_t count) |
| 3222 | { |
| 3223 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3224 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3225 | int val = 0; |
| 3226 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3227 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3228 | return -EPERM; |
| 3229 | |
| 3230 | if (!isdigit(buf[0])) |
| 3231 | return -EINVAL; |
| 3232 | |
| 3233 | if (sscanf(buf, "%i", &val) != 1) |
| 3234 | return -EINVAL; |
| 3235 | |
| 3236 | if ((val != 0) && (val != 1)) |
| 3237 | return -EINVAL; |
| 3238 | |
| 3239 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3240 | return strlen(buf); |
| 3241 | } |
| 3242 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 3243 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 3244 | |
| 3245 | /** |
| 3246 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 3247 | * Storage (OAS) lun returned by the |
| 3248 | * lpfc_oas_lun_show function. |
| 3249 | * @dev: class device that is converted into a Scsi_host. |
| 3250 | * @attr: device attribute, not used. |
| 3251 | * @buf: buffer for passing information. |
| 3252 | * |
| 3253 | * Returns: |
| 3254 | * size of formatted string. |
| 3255 | **/ |
| 3256 | static ssize_t |
| 3257 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 3258 | char *buf) |
| 3259 | { |
| 3260 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3261 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3262 | |
| 3263 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 3264 | return -EFAULT; |
| 3265 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3266 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3267 | } |
| 3268 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 3269 | lpfc_oas_lun_status_show, NULL); |
| 3270 | |
| 3271 | |
| 3272 | /** |
| 3273 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 3274 | * (OAS) operations. |
| 3275 | * @phba: lpfc_hba pointer. |
| 3276 | * @ndlp: pointer to fcp target node. |
| 3277 | * @lun: the fc lun for setting oas state. |
| 3278 | * @oas_state: the oas state to be set to the lun. |
| 3279 | * |
| 3280 | * Returns: |
| 3281 | * SUCCESS : 0 |
| 3282 | * -EPERM OAS is not enabled or not supported by this port. |
| 3283 | * |
| 3284 | */ |
| 3285 | static size_t |
| 3286 | 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] | 3287 | uint8_t tgt_wwpn[], uint64_t lun, |
| 3288 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3289 | { |
| 3290 | |
| 3291 | int rc = 0; |
| 3292 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3293 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3294 | return -EPERM; |
| 3295 | |
| 3296 | if (oas_state) { |
| 3297 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3298 | (struct lpfc_name *)tgt_wwpn, |
| 3299 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3300 | rc = -ENOMEM; |
| 3301 | } else { |
| 3302 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3303 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3304 | } |
| 3305 | return rc; |
| 3306 | |
| 3307 | } |
| 3308 | |
| 3309 | /** |
| 3310 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 3311 | * Access Storage (OAS) operations. |
| 3312 | * @phba: lpfc_hba pointer. |
| 3313 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 3314 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 3315 | * @lun_status: status of the lun returned lun |
| 3316 | * |
| 3317 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 3318 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 3319 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 3320 | * |
| 3321 | * Return: |
| 3322 | * lun that is OAS enabled for the vport/target |
| 3323 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 3324 | */ |
| 3325 | static uint64_t |
| 3326 | 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] | 3327 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 3328 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3329 | { |
| 3330 | uint64_t found_lun; |
| 3331 | |
| 3332 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 3333 | return NOT_OAS_ENABLED_LUN; |
| 3334 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 3335 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 3336 | (struct lpfc_name *) |
| 3337 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 3338 | &phba->sli4_hba.oas_next_lun, |
| 3339 | (struct lpfc_name *)vpt_wwpn, |
| 3340 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3341 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3342 | return found_lun; |
| 3343 | else |
| 3344 | return NOT_OAS_ENABLED_LUN; |
| 3345 | } |
| 3346 | |
| 3347 | /** |
| 3348 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 3349 | * @phba: lpfc_hba pointer. |
| 3350 | * @vpt_wwpn: vport wwpn by reference. |
| 3351 | * @tgt_wwpn: target wwpn by reference. |
| 3352 | * @lun: the fc lun for setting oas state. |
| 3353 | * @oas_state: the oas state to be set to the oas_lun. |
| 3354 | * |
| 3355 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 3356 | * a lun for OAS operations. |
| 3357 | * |
| 3358 | * Return: |
| 3359 | * SUCCESS: 0 |
| 3360 | * -ENOMEM: failed to enable an lun for OAS operations |
| 3361 | * -EPERM: OAS is not enabled |
| 3362 | */ |
| 3363 | static ssize_t |
| 3364 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 3365 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3366 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3367 | { |
| 3368 | |
| 3369 | int rc; |
| 3370 | |
| 3371 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3372 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3373 | return rc; |
| 3374 | } |
| 3375 | |
| 3376 | /** |
| 3377 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 3378 | * @dev: class device that is converted into a Scsi_host. |
| 3379 | * @attr: device attribute, not used. |
| 3380 | * @buf: buffer for passing information. |
| 3381 | * |
| 3382 | * This routine returns a lun enabled for OAS each time the function |
| 3383 | * is called. |
| 3384 | * |
| 3385 | * Returns: |
| 3386 | * SUCCESS: size of formatted string. |
| 3387 | * -EFAULT: target or vport wwpn was not set properly. |
| 3388 | * -EPERM: oas is not enabled. |
| 3389 | **/ |
| 3390 | static ssize_t |
| 3391 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 3392 | char *buf) |
| 3393 | { |
| 3394 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3395 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3396 | |
| 3397 | uint64_t oas_lun; |
| 3398 | int len = 0; |
| 3399 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3400 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3401 | return -EPERM; |
| 3402 | |
| 3403 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3404 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 3405 | return -EFAULT; |
| 3406 | |
| 3407 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3408 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 3409 | return -EFAULT; |
| 3410 | |
| 3411 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 3412 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3413 | &phba->cfg_oas_lun_status, |
| 3414 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3415 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 3416 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 3417 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3418 | len += scnprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3419 | |
| 3420 | return len; |
| 3421 | } |
| 3422 | |
| 3423 | /** |
| 3424 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 3425 | * @dev: class device that is converted into a Scsi_host. |
| 3426 | * @attr: device attribute, not used. |
| 3427 | * @buf: buffer for passing information. |
| 3428 | * |
| 3429 | * This function sets the OAS state for lun. Before this function is called, |
| 3430 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3431 | * |
| 3432 | * Returns: |
| 3433 | * SUCCESS: size of formatted string. |
| 3434 | * -EFAULT: target or vport wwpn was not set properly. |
| 3435 | * -EPERM: oas is not enabled. |
| 3436 | * size of formatted string. |
| 3437 | **/ |
| 3438 | static ssize_t |
| 3439 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3440 | const char *buf, size_t count) |
| 3441 | { |
| 3442 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3443 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3444 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3445 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3446 | ssize_t rc; |
| 3447 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3448 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3449 | return -EPERM; |
| 3450 | |
| 3451 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3452 | return -EFAULT; |
| 3453 | |
| 3454 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3455 | return -EFAULT; |
| 3456 | |
| 3457 | if (!isdigit(buf[0])) |
| 3458 | return -EINVAL; |
| 3459 | |
| 3460 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3461 | return -EINVAL; |
| 3462 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3463 | pri = phba->cfg_oas_priority; |
| 3464 | if (pri == 0) |
| 3465 | pri = phba->cfg_XLanePriority; |
| 3466 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3467 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3468 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3469 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3470 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3471 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3472 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3473 | |
| 3474 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3475 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3476 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3477 | if (rc) |
| 3478 | return rc; |
| 3479 | |
| 3480 | return count; |
| 3481 | } |
| 3482 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3483 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3484 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3485 | int lpfc_enable_nvmet_cnt; |
| 3486 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3487 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3488 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3489 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3490 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3491 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3492 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3493 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3494 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3495 | " 0 - none," |
| 3496 | " 1 - poll with interrupts enabled" |
| 3497 | " 3 - poll and disable FCP ring interrupts"); |
| 3498 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3499 | static DEVICE_ATTR_RW(lpfc_poll); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3500 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3501 | int lpfc_no_hba_reset_cnt; |
| 3502 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3503 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3504 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3505 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3506 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3507 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3508 | "SLI mode selector:" |
| 3509 | " 0 - auto (SLI-3 if supported)," |
| 3510 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3511 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3512 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3513 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3514 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3515 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3516 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3517 | "FCF Fast failover=1 Priority failover=2"); |
| 3518 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3519 | /* |
| 3520 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3521 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3522 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3523 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3524 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3525 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3526 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3527 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3528 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3529 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3530 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3531 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3532 | # 0x2 = never bring up link |
| 3533 | # Default value is 0. |
| 3534 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3535 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3536 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3537 | "Suppress Link Up at initialization"); |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 3538 | |
| 3539 | static ssize_t |
| 3540 | lpfc_pls_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3541 | { |
| 3542 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3543 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3544 | |
| 3545 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
| 3546 | phba->sli4_hba.pc_sli4_params.pls); |
| 3547 | } |
| 3548 | static DEVICE_ATTR(pls, 0444, |
| 3549 | lpfc_pls_show, NULL); |
| 3550 | |
| 3551 | static ssize_t |
| 3552 | lpfc_pt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3553 | { |
| 3554 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3555 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3556 | |
| 3557 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
| 3558 | (phba->hba_flag & HBA_PERSISTENT_TOPO) ? 1 : 0); |
| 3559 | } |
| 3560 | static DEVICE_ATTR(pt, 0444, |
| 3561 | lpfc_pt_show, NULL); |
| 3562 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3563 | /* |
| 3564 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3565 | # 1 - (1024) |
| 3566 | # 2 - (2048) |
| 3567 | # 3 - (3072) |
| 3568 | # 4 - (4096) |
| 3569 | # 5 - (5120) |
| 3570 | */ |
| 3571 | static ssize_t |
| 3572 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3573 | { |
| 3574 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3575 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3576 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3577 | return scnprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3578 | } |
| 3579 | |
| 3580 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3581 | lpfc_iocb_hw_show, NULL); |
| 3582 | static ssize_t |
| 3583 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3584 | { |
| 3585 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3586 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3587 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3588 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3589 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3590 | pring ? pring->txq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3591 | } |
| 3592 | |
| 3593 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3594 | lpfc_txq_hw_show, NULL); |
| 3595 | static ssize_t |
| 3596 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3597 | char *buf) |
| 3598 | { |
| 3599 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3600 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3601 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3602 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3603 | return scnprintf(buf, PAGE_SIZE, "%d\n", |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3604 | pring ? pring->txcmplq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3605 | } |
| 3606 | |
| 3607 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3608 | lpfc_txcmplq_hw_show, NULL); |
| 3609 | |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3610 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3611 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3612 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3613 | */ |
| 3614 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3615 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3616 | module_param(lpfc_nodev_tmo, int, 0); |
| 3617 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3618 | "Seconds driver will hold I/O waiting " |
| 3619 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3620 | |
| 3621 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3622 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3623 | * @dev: class converted to a Scsi_host structure. |
| 3624 | * @attr: device attribute, not used. |
| 3625 | * @buf: on return contains the dev loss timeout in decimal. |
| 3626 | * |
| 3627 | * Returns: size of formatted string. |
| 3628 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3629 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3630 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3631 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3632 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3633 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3634 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3635 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3636 | return scnprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3637 | } |
| 3638 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3639 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3640 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3641 | * @vport: lpfc vport structure pointer. |
| 3642 | * @val: contains the nodev timeout value. |
| 3643 | * |
| 3644 | * Description: |
| 3645 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3646 | * a kernel error message is printed and zero is returned. |
| 3647 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3648 | * Otherwise nodev tmo is set to the default value. |
| 3649 | * |
| 3650 | * Returns: |
| 3651 | * zero if already set or if val is in range |
| 3652 | * -EINVAL val out of range |
| 3653 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3654 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3655 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3656 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3657 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3658 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3659 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3660 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3661 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3662 | "parameter because lpfc_devloss_tmo " |
| 3663 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3664 | return 0; |
| 3665 | } |
| 3666 | |
| 3667 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3668 | vport->cfg_nodev_tmo = val; |
| 3669 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3670 | return 0; |
| 3671 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3672 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3673 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3674 | " %d, allowed range is [%d, %d]\n", |
| 3675 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3676 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3677 | return -EINVAL; |
| 3678 | } |
| 3679 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3680 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3681 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3682 | * @vport: lpfc vport structure pointer. |
| 3683 | * |
| 3684 | * Description: |
| 3685 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3686 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3687 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3688 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3689 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3690 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3691 | struct lpfc_nodelist *ndlp; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3692 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3693 | struct lpfc_nvme_rport *rport; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3694 | struct nvme_fc_remote_port *remoteport = NULL; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3695 | #endif |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3696 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3697 | shost = lpfc_shost_from_vport(vport); |
| 3698 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3699 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3700 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3701 | continue; |
| 3702 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3703 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3704 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3705 | spin_lock(&vport->phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3706 | rport = lpfc_ndlp_get_nrport(ndlp); |
| 3707 | if (rport) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3708 | remoteport = rport->remoteport; |
| 3709 | spin_unlock(&vport->phba->hbalock); |
James Smart | 07f5099 | 2019-08-14 16:56:45 -0700 | [diff] [blame] | 3710 | if (rport && remoteport) |
| 3711 | nvme_fc_set_remoteport_devloss(remoteport, |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3712 | vport->cfg_devloss_tmo); |
| 3713 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3714 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3715 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3716 | } |
| 3717 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3718 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3719 | * 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] | 3720 | * @vport: lpfc vport structure pointer. |
| 3721 | * @val: contains the tmo value. |
| 3722 | * |
| 3723 | * Description: |
| 3724 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3725 | * then a kernel error message is printed and zero is returned. |
| 3726 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3727 | * Otherwise nodev tmo is set to the default value. |
| 3728 | * |
| 3729 | * Returns: |
| 3730 | * zero if already set or if val is in range |
| 3731 | * -EINVAL val out of range |
| 3732 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3733 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3734 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3735 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3736 | if (vport->dev_loss_tmo_changed || |
| 3737 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3738 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3739 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3740 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3741 | return 0; |
| 3742 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3743 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3744 | vport->cfg_nodev_tmo = val; |
| 3745 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3746 | /* |
| 3747 | * For compat: set the fc_host dev loss so new rports |
| 3748 | * will get the value. |
| 3749 | */ |
| 3750 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3751 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3752 | return 0; |
| 3753 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3754 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3755 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3756 | "%d, allowed range is [%d, %d]\n", |
| 3757 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3758 | return -EINVAL; |
| 3759 | } |
| 3760 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3761 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3762 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3763 | static DEVICE_ATTR_RW(lpfc_nodev_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3764 | |
| 3765 | /* |
| 3766 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3767 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3768 | # value is 30. |
| 3769 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3770 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3771 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3772 | "Seconds driver will hold I/O waiting " |
| 3773 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3774 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3775 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3776 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3777 | |
| 3778 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3779 | * 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] | 3780 | * @vport: lpfc vport structure pointer. |
| 3781 | * @val: contains the tmo value. |
| 3782 | * |
| 3783 | * Description: |
| 3784 | * If val is in a valid range then set the vport nodev tmo, |
| 3785 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3786 | * Else a kernel error message is printed. |
| 3787 | * |
| 3788 | * Returns: |
| 3789 | * zero if val is in range |
| 3790 | * -EINVAL val out of range |
| 3791 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3792 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3793 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3794 | { |
| 3795 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3796 | vport->cfg_nodev_tmo = val; |
| 3797 | vport->cfg_devloss_tmo = val; |
| 3798 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3799 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3800 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3801 | return 0; |
| 3802 | } |
| 3803 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3804 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3805 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3806 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3807 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3808 | return -EINVAL; |
| 3809 | } |
| 3810 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3811 | lpfc_vport_param_store(devloss_tmo) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3812 | static DEVICE_ATTR_RW(lpfc_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3813 | |
| 3814 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3815 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3816 | * lpfc_suppress_rsp = 0 Disable |
| 3817 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3818 | * |
| 3819 | */ |
| 3820 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3821 | "Enable suppress rsp feature is firmware supports it"); |
| 3822 | |
| 3823 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3824 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3825 | * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3826 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3827 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3828 | * |
| 3829 | */ |
| 3830 | LPFC_ATTR_R(nvmet_mrq, |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3831 | LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3832 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3833 | |
| 3834 | /* |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 3835 | * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post |
| 3836 | * to each NVMET RQ. Range 64 to 2048, default is 512. |
| 3837 | */ |
| 3838 | LPFC_ATTR_R(nvmet_mrq_post, |
| 3839 | LPFC_NVMET_RQE_DEF_POST, LPFC_NVMET_RQE_MIN_POST, |
| 3840 | LPFC_NVMET_RQE_DEF_COUNT, |
| 3841 | "Specify number of RQ buffers to initially post"); |
| 3842 | |
| 3843 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3844 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3845 | * Supported Values: 1 - register just FCP |
| 3846 | * 3 - register both FCP and NVME |
James Smart | b1684a0 | 2019-01-28 11:14:36 -0800 | [diff] [blame] | 3847 | * Supported values are [1,3]. Default value is 3 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3848 | */ |
James Smart | b1684a0 | 2019-01-28 11:14:36 -0800 | [diff] [blame] | 3849 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_BOTH, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3850 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3851 | "Enable FC4 Protocol support - FCP / NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3852 | |
| 3853 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3854 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3855 | # deluged with LOTS of information. |
| 3856 | # 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] | 3857 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3858 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3859 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3860 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3861 | |
| 3862 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3863 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3864 | # objects that have been registered with the nameserver after login. |
| 3865 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3866 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3867 | "Deregister nameserver objects before LOGO"); |
| 3868 | |
| 3869 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3870 | # 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] | 3871 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3872 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3873 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3874 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3875 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3876 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3877 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3878 | |
| 3879 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3880 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3881 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3882 | */ |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 3883 | static uint lpfc_tgt_queue_depth = LPFC_MAX_TGT_QDEPTH; |
| 3884 | module_param(lpfc_tgt_queue_depth, uint, 0444); |
| 3885 | MODULE_PARM_DESC(lpfc_tgt_queue_depth, "Set max Target queue depth"); |
| 3886 | lpfc_vport_param_show(tgt_queue_depth); |
| 3887 | lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH, |
| 3888 | LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH); |
| 3889 | |
| 3890 | /** |
| 3891 | * lpfc_tgt_queue_depth_store: Sets an attribute value. |
| 3892 | * @phba: pointer the the adapter structure. |
| 3893 | * @val: integer attribute value. |
| 3894 | * |
| 3895 | * Description: Sets the parameter to the new value. |
| 3896 | * |
| 3897 | * Returns: |
| 3898 | * zero on success |
| 3899 | * -EINVAL if val is invalid |
| 3900 | */ |
| 3901 | static int |
| 3902 | lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val) |
| 3903 | { |
| 3904 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3905 | struct lpfc_nodelist *ndlp; |
| 3906 | |
| 3907 | if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH)) |
| 3908 | return -EINVAL; |
| 3909 | |
| 3910 | if (val == vport->cfg_tgt_queue_depth) |
| 3911 | return 0; |
| 3912 | |
| 3913 | spin_lock_irq(shost->host_lock); |
| 3914 | vport->cfg_tgt_queue_depth = val; |
| 3915 | |
| 3916 | /* Next loop thru nodelist and change cmd_qdepth */ |
| 3917 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
| 3918 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
| 3919 | |
| 3920 | spin_unlock_irq(shost->host_lock); |
| 3921 | return 0; |
| 3922 | } |
| 3923 | |
| 3924 | lpfc_vport_param_store(tgt_queue_depth); |
| 3925 | static DEVICE_ATTR_RW(lpfc_tgt_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3926 | |
| 3927 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3928 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3929 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3930 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3931 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3932 | # the hba_queue_depth. |
| 3933 | */ |
| 3934 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3935 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3936 | |
| 3937 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3938 | # peer_port_login: This parameter allows/prevents logins |
| 3939 | # between peer ports hosted on the same physical port. |
| 3940 | # When this parameter is set 0 peer ports of same physical port |
| 3941 | # are not allowed to login to each other. |
| 3942 | # When this parameter is set 1 peer ports of same physical port |
| 3943 | # are allowed to login to each other. |
| 3944 | # Default value of this parameter is 0. |
| 3945 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3946 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3947 | "Allow peer ports on the same physical port to login to each " |
| 3948 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3949 | |
| 3950 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3951 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3952 | # between Virtual Ports and remote initiators. |
| 3953 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3954 | # other initiators and will attempt to PLOGI all remote ports. |
| 3955 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3956 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3957 | # This parameter does not restrict to the physical port. |
| 3958 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3959 | # Default value of this parameter is 1. |
| 3960 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3961 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3962 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3963 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3964 | "Restrict virtual ports login to remote initiators."); |
| 3965 | lpfc_vport_param_show(restrict_login); |
| 3966 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3967 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3968 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3969 | * @vport: lpfc vport structure pointer. |
| 3970 | * @val: contains the restrict login value. |
| 3971 | * |
| 3972 | * Description: |
| 3973 | * If val is not in a valid range then log a kernel error message and set |
| 3974 | * the vport restrict login to one. |
| 3975 | * If the port type is physical clear the restrict login flag and return. |
| 3976 | * Else set the restrict login flag to val. |
| 3977 | * |
| 3978 | * Returns: |
| 3979 | * zero if val is in range |
| 3980 | * -EINVAL val out of range |
| 3981 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3982 | static int |
| 3983 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3984 | { |
| 3985 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3986 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3987 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3988 | "be set to %d, allowed range is [0, 1]\n", |
| 3989 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3990 | vport->cfg_restrict_login = 1; |
| 3991 | return -EINVAL; |
| 3992 | } |
| 3993 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3994 | vport->cfg_restrict_login = 0; |
| 3995 | return 0; |
| 3996 | } |
| 3997 | vport->cfg_restrict_login = val; |
| 3998 | return 0; |
| 3999 | } |
| 4000 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4001 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4002 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4003 | * @vport: lpfc vport structure pointer. |
| 4004 | * @val: contains the restrict login value. |
| 4005 | * |
| 4006 | * Description: |
| 4007 | * If val is not in a valid range then log a kernel error message and set |
| 4008 | * the vport restrict login to one. |
| 4009 | * If the port type is physical and the val is not zero log a kernel |
| 4010 | * error message, clear the restrict login flag and return zero. |
| 4011 | * Else set the restrict login flag to val. |
| 4012 | * |
| 4013 | * Returns: |
| 4014 | * zero if val is in range |
| 4015 | * -EINVAL val out of range |
| 4016 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4017 | static int |
| 4018 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 4019 | { |
| 4020 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4021 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4022 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4023 | "be set to %d, allowed range is [0, 1]\n", |
| 4024 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4025 | vport->cfg_restrict_login = 1; |
| 4026 | return -EINVAL; |
| 4027 | } |
| 4028 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4029 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4030 | "0468 lpfc_restrict_login must be 0 for " |
| 4031 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4032 | vport->cfg_restrict_login = 0; |
| 4033 | return 0; |
| 4034 | } |
| 4035 | vport->cfg_restrict_login = val; |
| 4036 | return 0; |
| 4037 | } |
| 4038 | lpfc_vport_param_store(restrict_login); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4039 | static DEVICE_ATTR_RW(lpfc_restrict_login); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4040 | |
| 4041 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4042 | # Some disk devices have a "select ID" or "select Target" capability. |
| 4043 | # From a protocol standpoint "select ID" usually means select the |
| 4044 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 4045 | # annex" which contains a table that maps a "select ID" (a number |
| 4046 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 4047 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 4048 | # ALPA. |
| 4049 | # |
| 4050 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 4051 | # cause the lpfc driver to use an inverted table, effectively |
| 4052 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 4053 | # |
| 4054 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 4055 | # and will not work across a fabric. Also this parameter will take |
| 4056 | # effect only in the case when ALPA map is not available.) |
| 4057 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4058 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 4059 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4060 | |
| 4061 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4062 | # lpfc_topology: link topology for init link |
| 4063 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 4064 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4065 | # 0x02 = attempt point-to-point mode only |
| 4066 | # 0x04 = attempt loop mode only |
| 4067 | # 0x06 = attempt point-to-point mode then loop |
| 4068 | # Set point-to-point mode if you want to run as an N_Port. |
| 4069 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 4070 | # Default value is 0. |
| 4071 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 4072 | LPFC_ATTR(topology, 0, 0, 6, |
| 4073 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4074 | |
| 4075 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4076 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4077 | * @phba: lpfc_hba pointer. |
| 4078 | * @val: topology value. |
| 4079 | * |
| 4080 | * Description: |
| 4081 | * If val is in a valid range then set the adapter's topology field and |
| 4082 | * issue a lip; if the lip fails reset the topology to the old value. |
| 4083 | * |
| 4084 | * If the value is not in range log a kernel error message and return an error. |
| 4085 | * |
| 4086 | * Returns: |
| 4087 | * zero if val is in range and lip okay |
| 4088 | * non-zero return value from lpfc_issue_lip() |
| 4089 | * -EINVAL val out of range |
| 4090 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4091 | static ssize_t |
| 4092 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 4093 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4094 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4095 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4096 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4097 | struct lpfc_hba *phba = vport->phba; |
| 4098 | int val = 0; |
| 4099 | int nolip = 0; |
| 4100 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4101 | int err; |
| 4102 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4103 | |
| 4104 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4105 | nolip = 1; |
| 4106 | val_buf = &buf[strlen("nolip ")]; |
| 4107 | } |
| 4108 | |
| 4109 | if (!isdigit(val_buf[0])) |
| 4110 | return -EINVAL; |
| 4111 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4112 | return -EINVAL; |
| 4113 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4114 | if (val >= 0 && val <= 6) { |
| 4115 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4116 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 4117 | val == 4) { |
| 4118 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4119 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4120 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4121 | return -EINVAL; |
| 4122 | } |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 4123 | /* |
| 4124 | * The 'topology' is not a configurable parameter if : |
| 4125 | * - persistent topology enabled |
James Smart | a052ce8 | 2019-12-18 15:58:04 -0800 | [diff] [blame^] | 4126 | * - G7/G6 with no private loop support |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 4127 | */ |
| 4128 | |
James Smart | a052ce8 | 2019-12-18 15:58:04 -0800 | [diff] [blame^] | 4129 | if ((phba->hba_flag & HBA_PERSISTENT_TOPO || |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 4130 | (!phba->sli4_hba.pc_sli4_params.pls && |
James Smart | a052ce8 | 2019-12-18 15:58:04 -0800 | [diff] [blame^] | 4131 | (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC || |
| 4132 | phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC))) && |
James Smart | f6978f4 | 2019-05-21 17:48:57 -0700 | [diff] [blame] | 4133 | val == 4) { |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4134 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | f6978f4 | 2019-05-21 17:48:57 -0700 | [diff] [blame] | 4135 | "3114 Loop mode not supported\n"); |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4136 | return -EINVAL; |
| 4137 | } |
| 4138 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4139 | if (nolip) |
| 4140 | return strlen(buf); |
| 4141 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4142 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4143 | "3054 lpfc_topology changed from %d to %d\n", |
| 4144 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 4145 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 4146 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4147 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4148 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4149 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4150 | return -EINVAL; |
| 4151 | } else |
| 4152 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4153 | } |
| 4154 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4155 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 4156 | "allowed range is [0, 6]\n", |
| 4157 | phba->brd_no, val); |
| 4158 | return -EINVAL; |
| 4159 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 4160 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4161 | lpfc_param_show(topology) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4162 | static DEVICE_ATTR_RW(lpfc_topology); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4163 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 4164 | /** |
| 4165 | * lpfc_static_vport_show: Read callback function for |
| 4166 | * lpfc_static_vport sysfs file. |
| 4167 | * @dev: Pointer to class device object. |
| 4168 | * @attr: device attribute structure. |
| 4169 | * @buf: Data buffer. |
| 4170 | * |
| 4171 | * This function is the read call back function for |
| 4172 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 4173 | * sysfs file report the mageability of the vport. |
| 4174 | **/ |
| 4175 | static ssize_t |
| 4176 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 4177 | char *buf) |
| 4178 | { |
| 4179 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4180 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4181 | if (vport->vport_flag & STATIC_VPORT) |
| 4182 | sprintf(buf, "1\n"); |
| 4183 | else |
| 4184 | sprintf(buf, "0\n"); |
| 4185 | |
| 4186 | return strlen(buf); |
| 4187 | } |
| 4188 | |
| 4189 | /* |
| 4190 | * Sysfs attribute to control the statistical data collection. |
| 4191 | */ |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 4192 | static DEVICE_ATTR_RO(lpfc_static_vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4193 | |
| 4194 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4195 | * 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] | 4196 | * @dev: Pointer to class device. |
| 4197 | * @buf: Data buffer. |
| 4198 | * @count: Size of the data buffer. |
| 4199 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 4200 | * 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] | 4201 | * sysfs file. This function parse the command written to the sysfs file |
| 4202 | * and take appropriate action. These commands are used for controlling |
| 4203 | * driver statistical data collection. |
| 4204 | * Following are the command this function handles. |
| 4205 | * |
| 4206 | * setbucket <bucket_type> <base> <step> |
| 4207 | * = Set the latency buckets. |
| 4208 | * destroybucket = destroy all the buckets. |
| 4209 | * start = start data collection |
| 4210 | * stop = stop data collection |
| 4211 | * reset = reset the collected data |
| 4212 | **/ |
| 4213 | static ssize_t |
| 4214 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 4215 | const char *buf, size_t count) |
| 4216 | { |
| 4217 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4218 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4219 | struct lpfc_hba *phba = vport->phba; |
| 4220 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 4221 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 4222 | unsigned long i; |
| 4223 | char *str_ptr, *token; |
| 4224 | struct lpfc_vport **vports; |
| 4225 | struct Scsi_Host *v_shost; |
| 4226 | char *bucket_type_str, *base_str, *step_str; |
| 4227 | unsigned long base, step, bucket_type; |
| 4228 | |
| 4229 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4230 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4231 | return -EINVAL; |
| 4232 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 4233 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4234 | str_ptr = &bucket_data[0]; |
| 4235 | /* Ignore this token - this is command token */ |
| 4236 | token = strsep(&str_ptr, "\t "); |
| 4237 | if (!token) |
| 4238 | return -EINVAL; |
| 4239 | |
| 4240 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 4241 | if (!bucket_type_str) |
| 4242 | return -EINVAL; |
| 4243 | |
| 4244 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 4245 | bucket_type = LPFC_LINEAR_BUCKET; |
| 4246 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 4247 | bucket_type = LPFC_POWER2_BUCKET; |
| 4248 | else |
| 4249 | return -EINVAL; |
| 4250 | |
| 4251 | base_str = strsep(&str_ptr, "\t "); |
| 4252 | if (!base_str) |
| 4253 | return -EINVAL; |
| 4254 | base = simple_strtoul(base_str, NULL, 0); |
| 4255 | |
| 4256 | step_str = strsep(&str_ptr, "\t "); |
| 4257 | if (!step_str) |
| 4258 | return -EINVAL; |
| 4259 | step = simple_strtoul(step_str, NULL, 0); |
| 4260 | if (!step) |
| 4261 | return -EINVAL; |
| 4262 | |
| 4263 | /* Block the data collection for every vport */ |
| 4264 | vports = lpfc_create_vport_work_array(phba); |
| 4265 | if (vports == NULL) |
| 4266 | return -ENOMEM; |
| 4267 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4268 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4269 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4270 | spin_lock_irq(v_shost->host_lock); |
| 4271 | /* Block and reset data collection */ |
| 4272 | vports[i]->stat_data_blocked = 1; |
| 4273 | if (vports[i]->stat_data_enabled) |
| 4274 | lpfc_vport_reset_stat_data(vports[i]); |
| 4275 | spin_unlock_irq(v_shost->host_lock); |
| 4276 | } |
| 4277 | |
| 4278 | /* Set the bucket attributes */ |
| 4279 | phba->bucket_type = bucket_type; |
| 4280 | phba->bucket_base = base; |
| 4281 | phba->bucket_step = step; |
| 4282 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4283 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4284 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4285 | |
| 4286 | /* Unblock data collection */ |
| 4287 | spin_lock_irq(v_shost->host_lock); |
| 4288 | vports[i]->stat_data_blocked = 0; |
| 4289 | spin_unlock_irq(v_shost->host_lock); |
| 4290 | } |
| 4291 | lpfc_destroy_vport_work_array(phba, vports); |
| 4292 | return strlen(buf); |
| 4293 | } |
| 4294 | |
| 4295 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 4296 | vports = lpfc_create_vport_work_array(phba); |
| 4297 | if (vports == NULL) |
| 4298 | return -ENOMEM; |
| 4299 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4300 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4301 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4302 | spin_lock_irq(shost->host_lock); |
| 4303 | vports[i]->stat_data_blocked = 1; |
| 4304 | lpfc_free_bucket(vport); |
| 4305 | vport->stat_data_enabled = 0; |
| 4306 | vports[i]->stat_data_blocked = 0; |
| 4307 | spin_unlock_irq(shost->host_lock); |
| 4308 | } |
| 4309 | lpfc_destroy_vport_work_array(phba, vports); |
| 4310 | phba->bucket_type = LPFC_NO_BUCKET; |
| 4311 | phba->bucket_base = 0; |
| 4312 | phba->bucket_step = 0; |
| 4313 | return strlen(buf); |
| 4314 | } |
| 4315 | |
| 4316 | if (!strncmp(buf, "start", strlen("start"))) { |
| 4317 | /* If no buckets configured return error */ |
| 4318 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 4319 | return -EINVAL; |
| 4320 | spin_lock_irq(shost->host_lock); |
| 4321 | if (vport->stat_data_enabled) { |
| 4322 | spin_unlock_irq(shost->host_lock); |
| 4323 | return strlen(buf); |
| 4324 | } |
| 4325 | lpfc_alloc_bucket(vport); |
| 4326 | vport->stat_data_enabled = 1; |
| 4327 | spin_unlock_irq(shost->host_lock); |
| 4328 | return strlen(buf); |
| 4329 | } |
| 4330 | |
| 4331 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 4332 | spin_lock_irq(shost->host_lock); |
| 4333 | if (vport->stat_data_enabled == 0) { |
| 4334 | spin_unlock_irq(shost->host_lock); |
| 4335 | return strlen(buf); |
| 4336 | } |
| 4337 | lpfc_free_bucket(vport); |
| 4338 | vport->stat_data_enabled = 0; |
| 4339 | spin_unlock_irq(shost->host_lock); |
| 4340 | return strlen(buf); |
| 4341 | } |
| 4342 | |
| 4343 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 4344 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 4345 | || !vport->stat_data_enabled) |
| 4346 | return strlen(buf); |
| 4347 | spin_lock_irq(shost->host_lock); |
| 4348 | vport->stat_data_blocked = 1; |
| 4349 | lpfc_vport_reset_stat_data(vport); |
| 4350 | vport->stat_data_blocked = 0; |
| 4351 | spin_unlock_irq(shost->host_lock); |
| 4352 | return strlen(buf); |
| 4353 | } |
| 4354 | return -EINVAL; |
| 4355 | } |
| 4356 | |
| 4357 | |
| 4358 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4359 | * 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] | 4360 | * @dev: Pointer to class device object. |
| 4361 | * @buf: Data buffer. |
| 4362 | * |
| 4363 | * This function is the read call back function for |
| 4364 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 4365 | * current statistical data collection state. |
| 4366 | **/ |
| 4367 | static ssize_t |
| 4368 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 4369 | char *buf) |
| 4370 | { |
| 4371 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4372 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4373 | struct lpfc_hba *phba = vport->phba; |
| 4374 | int index = 0; |
| 4375 | int i; |
| 4376 | char *bucket_type; |
| 4377 | unsigned long bucket_value; |
| 4378 | |
| 4379 | switch (phba->bucket_type) { |
| 4380 | case LPFC_LINEAR_BUCKET: |
| 4381 | bucket_type = "linear"; |
| 4382 | break; |
| 4383 | case LPFC_POWER2_BUCKET: |
| 4384 | bucket_type = "power2"; |
| 4385 | break; |
| 4386 | default: |
| 4387 | bucket_type = "No Bucket"; |
| 4388 | break; |
| 4389 | } |
| 4390 | |
| 4391 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 4392 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 4393 | " Bucket step :%d\nLatency Ranges :", |
| 4394 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 4395 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 4396 | index = strlen(buf); |
| 4397 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 4398 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4399 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 4400 | bucket_value = phba->bucket_base + |
| 4401 | phba->bucket_step * i; |
| 4402 | else |
| 4403 | bucket_value = phba->bucket_base + |
| 4404 | (1 << i) * phba->bucket_step; |
| 4405 | |
| 4406 | if (index + 10 > PAGE_SIZE) |
| 4407 | break; |
| 4408 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 4409 | index = strlen(buf); |
| 4410 | } |
| 4411 | } |
| 4412 | sprintf(&buf[index], "\n"); |
| 4413 | return strlen(buf); |
| 4414 | } |
| 4415 | |
| 4416 | /* |
| 4417 | * Sysfs attribute to control the statistical data collection. |
| 4418 | */ |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4419 | static DEVICE_ATTR_RW(lpfc_stat_data_ctrl); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4420 | |
| 4421 | /* |
| 4422 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 4423 | */ |
| 4424 | |
| 4425 | /* |
| 4426 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 4427 | * for each target. |
| 4428 | */ |
| 4429 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 4430 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 4431 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 4432 | |
| 4433 | |
| 4434 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4435 | * 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] | 4436 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4437 | * @kobj: Pointer to the kernel object |
| 4438 | * @bin_attr: Attribute object |
| 4439 | * @buff: Buffer pointer |
| 4440 | * @off: File offset |
| 4441 | * @count: Buffer size |
| 4442 | * |
| 4443 | * This function is the read call back function for lpfc_drvr_stat_data |
| 4444 | * sysfs file. This function export the statistical data to user |
| 4445 | * applications. |
| 4446 | **/ |
| 4447 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4448 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 4449 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4450 | char *buf, loff_t off, size_t count) |
| 4451 | { |
| 4452 | struct device *dev = container_of(kobj, struct device, |
| 4453 | kobj); |
| 4454 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4455 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4456 | struct lpfc_hba *phba = vport->phba; |
| 4457 | int i = 0, index = 0; |
| 4458 | unsigned long nport_index; |
| 4459 | struct lpfc_nodelist *ndlp = NULL; |
| 4460 | nport_index = (unsigned long)off / |
| 4461 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 4462 | |
| 4463 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 4464 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 4465 | return 0; |
| 4466 | |
| 4467 | spin_lock_irq(shost->host_lock); |
| 4468 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 4469 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 4470 | continue; |
| 4471 | |
| 4472 | if (nport_index > 0) { |
| 4473 | nport_index--; |
| 4474 | continue; |
| 4475 | } |
| 4476 | |
| 4477 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 4478 | > count) |
| 4479 | break; |
| 4480 | |
| 4481 | if (!ndlp->lat_data) |
| 4482 | continue; |
| 4483 | |
| 4484 | /* Print the WWN */ |
| 4485 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 4486 | ndlp->nlp_portname.u.wwn[0], |
| 4487 | ndlp->nlp_portname.u.wwn[1], |
| 4488 | ndlp->nlp_portname.u.wwn[2], |
| 4489 | ndlp->nlp_portname.u.wwn[3], |
| 4490 | ndlp->nlp_portname.u.wwn[4], |
| 4491 | ndlp->nlp_portname.u.wwn[5], |
| 4492 | ndlp->nlp_portname.u.wwn[6], |
| 4493 | ndlp->nlp_portname.u.wwn[7]); |
| 4494 | |
| 4495 | index = strlen(buf); |
| 4496 | |
| 4497 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4498 | sprintf(&buf[index], "%010u,", |
| 4499 | ndlp->lat_data[i].cmd_count); |
| 4500 | index = strlen(buf); |
| 4501 | } |
| 4502 | sprintf(&buf[index], "\n"); |
| 4503 | index = strlen(buf); |
| 4504 | } |
| 4505 | spin_unlock_irq(shost->host_lock); |
| 4506 | return index; |
| 4507 | } |
| 4508 | |
| 4509 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4510 | .attr = { |
| 4511 | .name = "lpfc_drvr_stat_data", |
| 4512 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4513 | }, |
| 4514 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4515 | .read = sysfs_drvr_stat_data_read, |
| 4516 | .write = NULL, |
| 4517 | }; |
| 4518 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4519 | /* |
| 4520 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4521 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4522 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4523 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4524 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4525 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4526 | * @phba: lpfc_hba pointer. |
| 4527 | * @val: link speed value. |
| 4528 | * |
| 4529 | * Description: |
| 4530 | * If val is in a valid range then set the adapter's link speed field and |
| 4531 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4532 | * |
| 4533 | * Notes: |
| 4534 | * If the value is not in range log a kernel error message and return an error. |
| 4535 | * |
| 4536 | * Returns: |
| 4537 | * zero if val is in range and lip okay. |
| 4538 | * non-zero return value from lpfc_issue_lip() |
| 4539 | * -EINVAL val out of range |
| 4540 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4541 | static ssize_t |
| 4542 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4543 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4544 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4545 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4546 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4547 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4548 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4549 | int nolip = 0; |
| 4550 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4551 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4552 | uint32_t prev_val, if_type; |
| 4553 | |
| 4554 | 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] | 4555 | if (if_type >= LPFC_SLI_INTF_IF_TYPE_2 && |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4556 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4557 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4558 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4559 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4560 | nolip = 1; |
| 4561 | val_buf = &buf[strlen("nolip ")]; |
| 4562 | } |
| 4563 | |
| 4564 | if (!isdigit(val_buf[0])) |
| 4565 | return -EINVAL; |
| 4566 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4567 | return -EINVAL; |
| 4568 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4569 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4570 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4571 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4572 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4573 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4574 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4575 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4576 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4577 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4578 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4579 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) || |
| 4580 | ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4581 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4582 | "2879 lpfc_link_speed attribute cannot be set " |
| 4583 | "to %d. Speed is not supported by this port.\n", |
| 4584 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4585 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4586 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4587 | if (val >= LPFC_USER_LINK_SPEED_16G && |
| 4588 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4589 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4590 | "3112 lpfc_link_speed attribute cannot be set " |
| 4591 | "to %d. Speed is not supported in loop mode.\n", |
| 4592 | val); |
| 4593 | return -EINVAL; |
| 4594 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4595 | |
| 4596 | switch (val) { |
| 4597 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4598 | case LPFC_USER_LINK_SPEED_1G: |
| 4599 | case LPFC_USER_LINK_SPEED_2G: |
| 4600 | case LPFC_USER_LINK_SPEED_4G: |
| 4601 | case LPFC_USER_LINK_SPEED_8G: |
| 4602 | case LPFC_USER_LINK_SPEED_16G: |
| 4603 | case LPFC_USER_LINK_SPEED_32G: |
| 4604 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4605 | prev_val = phba->cfg_link_speed; |
| 4606 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4607 | if (nolip) |
| 4608 | return strlen(buf); |
| 4609 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4610 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4611 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4612 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4613 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4614 | } |
| 4615 | return strlen(buf); |
| 4616 | default: |
| 4617 | break; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4618 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4619 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4620 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4621 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4622 | "allowed values are [%s]\n", |
| 4623 | val, LPFC_LINK_SPEED_STRING); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4624 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4625 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4626 | } |
| 4627 | |
| 4628 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4629 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4630 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4631 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4632 | |
| 4633 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4634 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4635 | * @phba: lpfc_hba pointer. |
| 4636 | * @val: link speed value. |
| 4637 | * |
| 4638 | * Description: |
| 4639 | * If val is in a valid range then set the adapter's link speed field. |
| 4640 | * |
| 4641 | * Notes: |
| 4642 | * If the value is not in range log a kernel error message, clear the link |
| 4643 | * speed and return an error. |
| 4644 | * |
| 4645 | * Returns: |
| 4646 | * zero if val saved. |
| 4647 | * -EINVAL val out of range |
| 4648 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4649 | static int |
| 4650 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4651 | { |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4652 | if (val >= LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4653 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4654 | "3111 lpfc_link_speed of %d cannot " |
| 4655 | "support loop mode, setting topology to default.\n", |
| 4656 | val); |
| 4657 | phba->cfg_topology = 0; |
| 4658 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4659 | |
| 4660 | switch (val) { |
| 4661 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4662 | case LPFC_USER_LINK_SPEED_1G: |
| 4663 | case LPFC_USER_LINK_SPEED_2G: |
| 4664 | case LPFC_USER_LINK_SPEED_4G: |
| 4665 | case LPFC_USER_LINK_SPEED_8G: |
| 4666 | case LPFC_USER_LINK_SPEED_16G: |
| 4667 | case LPFC_USER_LINK_SPEED_32G: |
| 4668 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4669 | phba->cfg_link_speed = val; |
| 4670 | return 0; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4671 | default: |
| 4672 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4673 | "0405 lpfc_link_speed attribute cannot " |
| 4674 | "be set to %d, allowed values are " |
| 4675 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
| 4676 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
| 4677 | return -EINVAL; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4678 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4679 | } |
| 4680 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4681 | static DEVICE_ATTR_RW(lpfc_link_speed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4682 | |
| 4683 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4684 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4685 | # 0 = aer disabled or not supported |
| 4686 | # 1 = aer supported and enabled (default) |
| 4687 | # Value range is [0,1]. Default value is 1. |
| 4688 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4689 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4690 | "Enable PCIe device AER support"); |
| 4691 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4692 | |
| 4693 | /** |
| 4694 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4695 | * |
| 4696 | * @dev: class device that is converted into a Scsi_host. |
| 4697 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4698 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4699 | * @count: unused variable. |
| 4700 | * |
| 4701 | * Description: |
| 4702 | * If the val is 1 and currently the device's AER capability was not |
| 4703 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4704 | * enable the device's AER capability. If the helper routine enabling |
| 4705 | * AER returns success, update the device's cfg_aer_support flag to |
| 4706 | * indicate AER is supported by the device; otherwise, if the device |
| 4707 | * AER capability is already enabled to support AER, then do nothing. |
| 4708 | * |
| 4709 | * If the val is 0 and currently the device's AER support was enabled, |
| 4710 | * invoke the kernel's disable AER helper routine. After that, update |
| 4711 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4712 | * by the device; otherwise, if the device AER capability is already |
| 4713 | * disabled from supporting AER, then do nothing. |
| 4714 | * |
| 4715 | * Returns: |
| 4716 | * length of the buf on success if val is in range the intended mode |
| 4717 | * is supported. |
| 4718 | * -EINVAL if val out of range or intended mode is not supported. |
| 4719 | **/ |
| 4720 | static ssize_t |
| 4721 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4722 | const char *buf, size_t count) |
| 4723 | { |
| 4724 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4725 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4726 | struct lpfc_hba *phba = vport->phba; |
| 4727 | int val = 0, rc = -EINVAL; |
| 4728 | |
| 4729 | if (!isdigit(buf[0])) |
| 4730 | return -EINVAL; |
| 4731 | if (sscanf(buf, "%i", &val) != 1) |
| 4732 | return -EINVAL; |
| 4733 | |
| 4734 | switch (val) { |
| 4735 | case 0: |
| 4736 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4737 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4738 | if (!rc) { |
| 4739 | spin_lock_irq(&phba->hbalock); |
| 4740 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4741 | spin_unlock_irq(&phba->hbalock); |
| 4742 | phba->cfg_aer_support = 0; |
| 4743 | rc = strlen(buf); |
| 4744 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4745 | rc = -EPERM; |
| 4746 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4747 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4748 | rc = strlen(buf); |
| 4749 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4750 | break; |
| 4751 | case 1: |
| 4752 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4753 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4754 | if (!rc) { |
| 4755 | spin_lock_irq(&phba->hbalock); |
| 4756 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4757 | spin_unlock_irq(&phba->hbalock); |
| 4758 | phba->cfg_aer_support = 1; |
| 4759 | rc = strlen(buf); |
| 4760 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4761 | rc = -EPERM; |
| 4762 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4763 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4764 | rc = strlen(buf); |
| 4765 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4766 | break; |
| 4767 | default: |
| 4768 | rc = -EINVAL; |
| 4769 | break; |
| 4770 | } |
| 4771 | return rc; |
| 4772 | } |
| 4773 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4774 | static DEVICE_ATTR_RW(lpfc_aer_support); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4775 | |
| 4776 | /** |
| 4777 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4778 | * @dev: class device that is converted into a Scsi_host. |
| 4779 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4780 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4781 | * @count: unused variable. |
| 4782 | * |
| 4783 | * Description: |
| 4784 | * If the @buf contains 1 and the device currently has the AER support |
| 4785 | * enabled, then invokes the kernel AER helper routine |
| 4786 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4787 | * error status register. |
| 4788 | * |
| 4789 | * Notes: |
| 4790 | * |
| 4791 | * Returns: |
| 4792 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4793 | * enabled with the AER support. |
| 4794 | **/ |
| 4795 | static ssize_t |
| 4796 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4797 | const char *buf, size_t count) |
| 4798 | { |
| 4799 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4800 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4801 | struct lpfc_hba *phba = vport->phba; |
| 4802 | int val, rc = -1; |
| 4803 | |
| 4804 | if (!isdigit(buf[0])) |
| 4805 | return -EINVAL; |
| 4806 | if (sscanf(buf, "%i", &val) != 1) |
| 4807 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4808 | if (val != 1) |
| 4809 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4810 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4811 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4812 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4813 | |
| 4814 | if (rc == 0) |
| 4815 | return strlen(buf); |
| 4816 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4817 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4818 | } |
| 4819 | |
| 4820 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4821 | lpfc_aer_cleanup_state); |
| 4822 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4823 | /** |
| 4824 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4825 | * |
| 4826 | * @dev: class device that is converted into a Scsi_host. |
| 4827 | * @attr: device attribute, not used. |
| 4828 | * @buf: containing the string the number of vfs to be enabled. |
| 4829 | * @count: unused variable. |
| 4830 | * |
| 4831 | * Description: |
| 4832 | * When this api is called either through user sysfs, the driver shall |
| 4833 | * try to enable or disable SR-IOV virtual functions according to the |
| 4834 | * following: |
| 4835 | * |
| 4836 | * If zero virtual function has been enabled to the physical function, |
| 4837 | * the driver shall invoke the pci enable virtual function api trying |
| 4838 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4839 | * than the maximum supported, the maximum virtual function number will |
| 4840 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4841 | * be used for invoking the api. If the api call returned success, the |
| 4842 | * actual number of virtual functions enabled will be set to the driver |
| 4843 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4844 | * cfg_sriov_nr_virtfn remains zero. |
| 4845 | * |
| 4846 | * If none-zero virtual functions have already been enabled to the |
| 4847 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4848 | * -EINVAL will be returned and the driver does nothing; |
| 4849 | * |
| 4850 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4851 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4852 | * disabling virtual function api shall be invoded to disable all the |
| 4853 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4854 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4855 | * nothing. |
| 4856 | * |
| 4857 | * Returns: |
| 4858 | * length of the buf on success if val is in range the intended mode |
| 4859 | * is supported. |
| 4860 | * -EINVAL if val out of range or intended mode is not supported. |
| 4861 | **/ |
| 4862 | static ssize_t |
| 4863 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4864 | const char *buf, size_t count) |
| 4865 | { |
| 4866 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4867 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4868 | struct lpfc_hba *phba = vport->phba; |
| 4869 | struct pci_dev *pdev = phba->pcidev; |
| 4870 | int val = 0, rc = -EINVAL; |
| 4871 | |
| 4872 | /* Sanity check on user data */ |
| 4873 | if (!isdigit(buf[0])) |
| 4874 | return -EINVAL; |
| 4875 | if (sscanf(buf, "%i", &val) != 1) |
| 4876 | return -EINVAL; |
| 4877 | if (val < 0) |
| 4878 | return -EINVAL; |
| 4879 | |
| 4880 | /* Request disabling virtual functions */ |
| 4881 | if (val == 0) { |
| 4882 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4883 | pci_disable_sriov(pdev); |
| 4884 | phba->cfg_sriov_nr_virtfn = 0; |
| 4885 | } |
| 4886 | return strlen(buf); |
| 4887 | } |
| 4888 | |
| 4889 | /* Request enabling virtual functions */ |
| 4890 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4891 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4892 | "3018 There are %d virtual functions " |
| 4893 | "enabled on physical function.\n", |
| 4894 | phba->cfg_sriov_nr_virtfn); |
| 4895 | return -EEXIST; |
| 4896 | } |
| 4897 | |
| 4898 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4899 | phba->cfg_sriov_nr_virtfn = val; |
| 4900 | else { |
| 4901 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4902 | "3019 Enabling %d virtual functions is not " |
| 4903 | "allowed.\n", val); |
| 4904 | return -EINVAL; |
| 4905 | } |
| 4906 | |
| 4907 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4908 | if (rc) { |
| 4909 | phba->cfg_sriov_nr_virtfn = 0; |
| 4910 | rc = -EPERM; |
| 4911 | } else |
| 4912 | rc = strlen(buf); |
| 4913 | |
| 4914 | return rc; |
| 4915 | } |
| 4916 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4917 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4918 | "Enable PCIe device SR-IOV virtual fn"); |
| 4919 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4920 | lpfc_param_show(sriov_nr_virtfn) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4921 | static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4922 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4923 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4924 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4925 | * |
| 4926 | * @dev: class device that is converted into a Scsi_host. |
| 4927 | * @attr: device attribute, not used. |
| 4928 | * @buf: containing the string the number of vfs to be enabled. |
| 4929 | * @count: unused variable. |
| 4930 | * |
| 4931 | * Description: |
| 4932 | * |
| 4933 | * Returns: |
| 4934 | * length of the buf on success if val is in range the intended mode |
| 4935 | * is supported. |
| 4936 | * -EINVAL if val out of range or intended mode is not supported. |
| 4937 | **/ |
| 4938 | static ssize_t |
| 4939 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4940 | struct device_attribute *attr, |
| 4941 | const char *buf, size_t count) |
| 4942 | { |
| 4943 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4944 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4945 | struct lpfc_hba *phba = vport->phba; |
| 4946 | int val = 0, rc = -EINVAL; |
| 4947 | |
| 4948 | /* Sanity check on user data */ |
| 4949 | if (!isdigit(buf[0])) |
| 4950 | return -EINVAL; |
| 4951 | if (sscanf(buf, "%i", &val) != 1) |
| 4952 | return -EINVAL; |
| 4953 | if (val != 1) |
| 4954 | return -EINVAL; |
| 4955 | |
| 4956 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4957 | if (rc) |
| 4958 | rc = -EPERM; |
| 4959 | else |
| 4960 | rc = strlen(buf); |
| 4961 | return rc; |
| 4962 | } |
| 4963 | |
| 4964 | static int lpfc_req_fw_upgrade; |
| 4965 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4966 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4967 | lpfc_param_show(request_firmware_upgrade) |
| 4968 | |
| 4969 | /** |
| 4970 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4971 | * @phba: lpfc_hba pointer. |
| 4972 | * @val: 0 or 1. |
| 4973 | * |
| 4974 | * Description: |
| 4975 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4976 | * |
| 4977 | * Returns: |
| 4978 | * zero if val saved. |
| 4979 | * -EINVAL val out of range |
| 4980 | **/ |
| 4981 | static int |
| 4982 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4983 | { |
| 4984 | if (val >= 0 && val <= 1) { |
| 4985 | phba->cfg_request_firmware_upgrade = val; |
| 4986 | return 0; |
| 4987 | } |
| 4988 | return -EINVAL; |
| 4989 | } |
| 4990 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4991 | lpfc_request_firmware_upgrade_show, |
| 4992 | lpfc_request_firmware_upgrade_store); |
| 4993 | |
| 4994 | /** |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 4995 | * lpfc_force_rscn_store |
| 4996 | * |
| 4997 | * @dev: class device that is converted into a Scsi_host. |
| 4998 | * @attr: device attribute, not used. |
| 4999 | * @buf: unused string |
| 5000 | * @count: unused variable. |
| 5001 | * |
| 5002 | * Description: |
| 5003 | * Force the switch to send a RSCN to all other NPorts in our zone |
| 5004 | * If we are direct connect pt2pt, build the RSCN command ourself |
| 5005 | * and send to the other NPort. Not supported for private loop. |
| 5006 | * |
| 5007 | * Returns: |
| 5008 | * 0 - on success |
| 5009 | * -EIO - if command is not sent |
| 5010 | **/ |
| 5011 | static ssize_t |
| 5012 | lpfc_force_rscn_store(struct device *dev, struct device_attribute *attr, |
| 5013 | const char *buf, size_t count) |
| 5014 | { |
| 5015 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5016 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5017 | int i; |
| 5018 | |
| 5019 | i = lpfc_issue_els_rscn(vport, 0); |
| 5020 | if (i) |
| 5021 | return -EIO; |
| 5022 | return strlen(buf); |
| 5023 | } |
| 5024 | |
| 5025 | /* |
| 5026 | * lpfc_force_rscn: Force an RSCN to be sent to all remote NPorts |
| 5027 | * connected to the HBA. |
| 5028 | * |
| 5029 | * Value range is any ascii value |
| 5030 | */ |
| 5031 | static int lpfc_force_rscn; |
| 5032 | module_param(lpfc_force_rscn, int, 0644); |
| 5033 | MODULE_PARM_DESC(lpfc_force_rscn, |
| 5034 | "Force an RSCN to be sent to all remote NPorts"); |
| 5035 | lpfc_param_show(force_rscn) |
| 5036 | |
| 5037 | /** |
| 5038 | * lpfc_force_rscn_init - Force an RSCN to be sent to all remote NPorts |
| 5039 | * @phba: lpfc_hba pointer. |
| 5040 | * @val: unused value. |
| 5041 | * |
| 5042 | * Returns: |
| 5043 | * zero if val saved. |
| 5044 | **/ |
| 5045 | static int |
| 5046 | lpfc_force_rscn_init(struct lpfc_hba *phba, int val) |
| 5047 | { |
| 5048 | return 0; |
| 5049 | } |
| 5050 | static DEVICE_ATTR_RW(lpfc_force_rscn); |
| 5051 | |
| 5052 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5053 | * lpfc_fcp_imax_store |
| 5054 | * |
| 5055 | * @dev: class device that is converted into a Scsi_host. |
| 5056 | * @attr: device attribute, not used. |
| 5057 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 5058 | * @count: unused variable. |
| 5059 | * |
| 5060 | * Description: |
| 5061 | * If val is in a valid range [636,651042], then set the adapter's |
| 5062 | * maximum number of fast-path FCP interrupts per second. |
| 5063 | * |
| 5064 | * Returns: |
| 5065 | * length of the buf on success if val is in range the intended mode |
| 5066 | * is supported. |
| 5067 | * -EINVAL if val out of range or intended mode is not supported. |
| 5068 | **/ |
| 5069 | static ssize_t |
| 5070 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 5071 | const char *buf, size_t count) |
| 5072 | { |
| 5073 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5074 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5075 | struct lpfc_hba *phba = vport->phba; |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5076 | struct lpfc_eq_intr_info *eqi; |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5077 | uint32_t usdelay; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5078 | int val = 0, i; |
| 5079 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5080 | /* fcp_imax is only valid for SLI4 */ |
| 5081 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5082 | return -EINVAL; |
| 5083 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5084 | /* Sanity check on user data */ |
| 5085 | if (!isdigit(buf[0])) |
| 5086 | return -EINVAL; |
| 5087 | if (sscanf(buf, "%i", &val) != 1) |
| 5088 | return -EINVAL; |
| 5089 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5090 | /* |
| 5091 | * Value range for the HBA is [5000,5000000] |
| 5092 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5093 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5094 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5095 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5096 | return -EINVAL; |
| 5097 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5098 | phba->cfg_auto_imax = (val) ? 0 : 1; |
| 5099 | if (phba->cfg_fcp_imax && !val) { |
| 5100 | queue_delayed_work(phba->wq, &phba->eq_delay_work, |
| 5101 | msecs_to_jiffies(LPFC_EQ_DELAY_MSECS)); |
| 5102 | |
| 5103 | for_each_present_cpu(i) { |
| 5104 | eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); |
| 5105 | eqi->icnt = 0; |
| 5106 | } |
| 5107 | } |
| 5108 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5109 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 5110 | |
James Smart | cb733e3 | 2019-01-28 11:14:32 -0800 | [diff] [blame] | 5111 | if (phba->cfg_fcp_imax) |
| 5112 | usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; |
| 5113 | else |
| 5114 | usdelay = 0; |
| 5115 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5116 | 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] | 5117 | 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] | 5118 | usdelay); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5119 | |
| 5120 | return strlen(buf); |
| 5121 | } |
| 5122 | |
| 5123 | /* |
| 5124 | # 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] | 5125 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5126 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5127 | # 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] | 5128 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5129 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5130 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 5131 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5132 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5133 | lpfc_param_show(fcp_imax) |
| 5134 | |
| 5135 | /** |
| 5136 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 5137 | * @phba: lpfc_hba pointer. |
| 5138 | * @val: link speed value. |
| 5139 | * |
| 5140 | * Description: |
| 5141 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 5142 | * maximum number of fast-path FCP interrupts per second. |
| 5143 | * |
| 5144 | * Returns: |
| 5145 | * zero if val saved. |
| 5146 | * -EINVAL val out of range |
| 5147 | **/ |
| 5148 | static int |
| 5149 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 5150 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5151 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5152 | phba->cfg_fcp_imax = 0; |
| 5153 | return 0; |
| 5154 | } |
| 5155 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5156 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 5157 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5158 | phba->cfg_fcp_imax = val; |
| 5159 | return 0; |
| 5160 | } |
| 5161 | |
| 5162 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5163 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 5164 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 5165 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5166 | |
| 5167 | return 0; |
| 5168 | } |
| 5169 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5170 | static DEVICE_ATTR_RW(lpfc_fcp_imax); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 5171 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5172 | /** |
| 5173 | * lpfc_cq_max_proc_limit_store |
| 5174 | * |
| 5175 | * @dev: class device that is converted into a Scsi_host. |
| 5176 | * @attr: device attribute, not used. |
| 5177 | * @buf: string with the cq max processing limit of cqes |
| 5178 | * @count: unused variable. |
| 5179 | * |
| 5180 | * Description: |
| 5181 | * If val is in a valid range, then set value on each cq |
| 5182 | * |
| 5183 | * Returns: |
| 5184 | * The length of the buf: if successful |
| 5185 | * -ERANGE: if val is not in the valid range |
| 5186 | * -EINVAL: if bad value format or intended mode is not supported. |
| 5187 | **/ |
| 5188 | static ssize_t |
| 5189 | lpfc_cq_max_proc_limit_store(struct device *dev, struct device_attribute *attr, |
| 5190 | const char *buf, size_t count) |
| 5191 | { |
| 5192 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5193 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5194 | struct lpfc_hba *phba = vport->phba; |
| 5195 | struct lpfc_queue *eq, *cq; |
| 5196 | unsigned long val; |
| 5197 | int i; |
| 5198 | |
| 5199 | /* cq_max_proc_limit is only valid for SLI4 */ |
| 5200 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5201 | return -EINVAL; |
| 5202 | |
| 5203 | /* Sanity check on user data */ |
| 5204 | if (!isdigit(buf[0])) |
| 5205 | return -EINVAL; |
| 5206 | if (kstrtoul(buf, 0, &val)) |
| 5207 | return -EINVAL; |
| 5208 | |
| 5209 | if (val < LPFC_CQ_MIN_PROC_LIMIT || val > LPFC_CQ_MAX_PROC_LIMIT) |
| 5210 | return -ERANGE; |
| 5211 | |
| 5212 | phba->cfg_cq_max_proc_limit = (uint32_t)val; |
| 5213 | |
| 5214 | /* set the values on the cq's */ |
| 5215 | for (i = 0; i < phba->cfg_irq_chann; i++) { |
James Smart | 657add4 | 2019-05-21 17:49:06 -0700 | [diff] [blame] | 5216 | /* Get the EQ corresponding to the IRQ vector */ |
| 5217 | eq = phba->sli4_hba.hba_eq_hdl[i].eq; |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5218 | if (!eq) |
| 5219 | continue; |
| 5220 | |
| 5221 | list_for_each_entry(cq, &eq->child_list, list) |
| 5222 | cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, |
| 5223 | cq->entry_count); |
| 5224 | } |
| 5225 | |
| 5226 | return strlen(buf); |
| 5227 | } |
| 5228 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5229 | /* |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5230 | * lpfc_cq_max_proc_limit: The maximum number CQE entries processed in an |
| 5231 | * itteration of CQ processing. |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5232 | */ |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 5233 | static int lpfc_cq_max_proc_limit = LPFC_CQ_DEF_MAX_PROC_LIMIT; |
| 5234 | module_param(lpfc_cq_max_proc_limit, int, 0644); |
| 5235 | MODULE_PARM_DESC(lpfc_cq_max_proc_limit, |
| 5236 | "Set the maximum number CQEs processed in an iteration of " |
| 5237 | "CQ processing"); |
| 5238 | lpfc_param_show(cq_max_proc_limit) |
| 5239 | |
| 5240 | /* |
| 5241 | * lpfc_cq_poll_threshold: Set the threshold of CQE completions in a |
| 5242 | * single handler call which should request a polled completion rather |
| 5243 | * than re-enabling interrupts. |
| 5244 | */ |
| 5245 | LPFC_ATTR_RW(cq_poll_threshold, LPFC_CQ_DEF_THRESHOLD_TO_POLL, |
| 5246 | LPFC_CQ_MIN_THRESHOLD_TO_POLL, |
| 5247 | LPFC_CQ_MAX_THRESHOLD_TO_POLL, |
| 5248 | "CQE Processing Threshold to enable Polling"); |
| 5249 | |
| 5250 | /** |
| 5251 | * lpfc_cq_max_proc_limit_init - Set the initial cq max_proc_limit |
| 5252 | * @phba: lpfc_hba pointer. |
| 5253 | * @val: entry limit |
| 5254 | * |
| 5255 | * Description: |
| 5256 | * If val is in a valid range, then initialize the adapter's maximum |
| 5257 | * value. |
| 5258 | * |
| 5259 | * Returns: |
| 5260 | * Always returns 0 for success, even if value not always set to |
| 5261 | * requested value. If value out of range or not supported, will fall |
| 5262 | * back to default. |
| 5263 | **/ |
| 5264 | static int |
| 5265 | lpfc_cq_max_proc_limit_init(struct lpfc_hba *phba, int val) |
| 5266 | { |
| 5267 | phba->cfg_cq_max_proc_limit = LPFC_CQ_DEF_MAX_PROC_LIMIT; |
| 5268 | |
| 5269 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 5270 | return 0; |
| 5271 | |
| 5272 | if (val >= LPFC_CQ_MIN_PROC_LIMIT && val <= LPFC_CQ_MAX_PROC_LIMIT) { |
| 5273 | phba->cfg_cq_max_proc_limit = val; |
| 5274 | return 0; |
| 5275 | } |
| 5276 | |
| 5277 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 5278 | "0371 "LPFC_DRIVER_NAME"_cq_max_proc_limit: " |
| 5279 | "%d out of range, using default\n", |
| 5280 | phba->cfg_cq_max_proc_limit); |
| 5281 | |
| 5282 | return 0; |
| 5283 | } |
| 5284 | |
| 5285 | static DEVICE_ATTR_RW(lpfc_cq_max_proc_limit); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5286 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5287 | /** |
| 5288 | * lpfc_state_show - Display current driver CPU affinity |
| 5289 | * @dev: class converted to a Scsi_host structure. |
| 5290 | * @attr: device attribute, not used. |
| 5291 | * @buf: on return contains text describing the state of the link. |
| 5292 | * |
| 5293 | * Returns: size of formatted string. |
| 5294 | **/ |
| 5295 | static ssize_t |
| 5296 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 5297 | char *buf) |
| 5298 | { |
| 5299 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5300 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5301 | struct lpfc_hba *phba = vport->phba; |
| 5302 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5303 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5304 | |
| 5305 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 5306 | (phba->intr_type != MSIX)) |
| 5307 | return len; |
| 5308 | |
| 5309 | switch (phba->cfg_fcp_cpu_map) { |
| 5310 | case 0: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5311 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5312 | "fcp_cpu_map: No mapping (%d)\n", |
| 5313 | phba->cfg_fcp_cpu_map); |
| 5314 | return len; |
| 5315 | case 1: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5316 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5317 | "fcp_cpu_map: HBA centric mapping (%d): " |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5318 | "%d of %d CPUs online from %d possible CPUs\n", |
| 5319 | phba->cfg_fcp_cpu_map, num_online_cpus(), |
| 5320 | num_present_cpus(), |
| 5321 | phba->sli4_hba.num_possible_cpu); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5322 | break; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5323 | } |
| 5324 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5325 | while (phba->sli4_hba.curr_disp_cpu < |
| 5326 | phba->sli4_hba.num_possible_cpu) { |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5327 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 5328 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5329 | if (!cpu_present(phba->sli4_hba.curr_disp_cpu)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5330 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5331 | "CPU %02d not present\n", |
| 5332 | phba->sli4_hba.curr_disp_cpu); |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5333 | else if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5334 | if (cpup->hdwq == LPFC_VECTOR_MAP_EMPTY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5335 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5336 | buf + len, PAGE_SIZE - len, |
| 5337 | "CPU %02d hdwq None " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5338 | "physid %d coreid %d ht %d ua %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5339 | phba->sli4_hba.curr_disp_cpu, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5340 | cpup->phys_id, cpup->core_id, |
| 5341 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5342 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5343 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5344 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5345 | buf + len, PAGE_SIZE - len, |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5346 | "CPU %02d EQ None hdwq %04d " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5347 | "physid %d coreid %d ht %d ua %d\n", |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5348 | phba->sli4_hba.curr_disp_cpu, |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5349 | cpup->hdwq, cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5350 | cpup->core_id, |
| 5351 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5352 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5353 | } else { |
| 5354 | if (cpup->hdwq == LPFC_VECTOR_MAP_EMPTY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5355 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5356 | buf + len, PAGE_SIZE - len, |
| 5357 | "CPU %02d hdwq None " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5358 | "physid %d coreid %d ht %d ua %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5359 | phba->sli4_hba.curr_disp_cpu, |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5360 | cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5361 | cpup->core_id, |
| 5362 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5363 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN), |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5364 | lpfc_get_irq(cpup->eq)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5365 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5366 | len += scnprintf( |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5367 | buf + len, PAGE_SIZE - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5368 | "CPU %02d EQ %04d hdwq %04d " |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5369 | "physid %d coreid %d ht %d ua %d IRQ %d\n", |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5370 | phba->sli4_hba.curr_disp_cpu, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5371 | cpup->eq, cpup->hdwq, cpup->phys_id, |
James Smart | d9954a2 | 2019-05-21 17:49:05 -0700 | [diff] [blame] | 5372 | cpup->core_id, |
| 5373 | (cpup->flag & LPFC_CPU_MAP_HYPER), |
| 5374 | (cpup->flag & LPFC_CPU_MAP_UNASSIGN), |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5375 | lpfc_get_irq(cpup->eq)); |
James Smart | b3295c2 | 2019-01-28 11:14:30 -0800 | [diff] [blame] | 5376 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5377 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5378 | phba->sli4_hba.curr_disp_cpu++; |
| 5379 | |
| 5380 | /* display max number of CPUs keeping some margin */ |
| 5381 | if (phba->sli4_hba.curr_disp_cpu < |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5382 | phba->sli4_hba.num_possible_cpu && |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5383 | (len >= (PAGE_SIZE - 64))) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5384 | len += scnprintf(buf + len, |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5385 | PAGE_SIZE - len, "more...\n"); |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5386 | break; |
| 5387 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5388 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 5389 | |
James Smart | 222e923 | 2019-01-28 11:14:35 -0800 | [diff] [blame] | 5390 | 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] | 5391 | phba->sli4_hba.curr_disp_cpu = 0; |
| 5392 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5393 | return len; |
| 5394 | } |
| 5395 | |
| 5396 | /** |
| 5397 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 5398 | * @dev: class device that is converted into a Scsi_host. |
| 5399 | * @attr: device attribute, not used. |
| 5400 | * @buf: one or more lpfc_polling_flags values. |
| 5401 | * @count: not used. |
| 5402 | * |
| 5403 | * Returns: |
| 5404 | * -EINVAL - Not implemented yet. |
| 5405 | **/ |
| 5406 | static ssize_t |
| 5407 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 5408 | const char *buf, size_t count) |
| 5409 | { |
| 5410 | int status = -EINVAL; |
| 5411 | return status; |
| 5412 | } |
| 5413 | |
| 5414 | /* |
| 5415 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 5416 | # for the HBA. |
| 5417 | # |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5418 | # 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] | 5419 | # 0 - Do not affinitze IRQ vectors |
| 5420 | # 1 - Affintize HBA vectors with respect to each HBA |
| 5421 | # (start with CPU0 for each HBA) |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5422 | # This also defines how Hardware Queues are mapped to specific CPUs. |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5423 | */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5424 | static int lpfc_fcp_cpu_map = LPFC_HBA_CPU_MAP; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5425 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 5426 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 5427 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 5428 | |
| 5429 | /** |
| 5430 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 5431 | * @phba: lpfc_hba pointer. |
| 5432 | * @val: link speed value. |
| 5433 | * |
| 5434 | * Description: |
| 5435 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 5436 | * MSIX vectors. |
| 5437 | * |
| 5438 | * Returns: |
| 5439 | * zero if val saved. |
| 5440 | * -EINVAL val out of range |
| 5441 | **/ |
| 5442 | static int |
| 5443 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 5444 | { |
| 5445 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5446 | phba->cfg_fcp_cpu_map = 0; |
| 5447 | return 0; |
| 5448 | } |
| 5449 | |
| 5450 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 5451 | phba->cfg_fcp_cpu_map = val; |
| 5452 | return 0; |
| 5453 | } |
| 5454 | |
| 5455 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5456 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 5457 | "default\n", val); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5458 | phba->cfg_fcp_cpu_map = LPFC_HBA_CPU_MAP; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5459 | |
| 5460 | return 0; |
| 5461 | } |
| 5462 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5463 | static DEVICE_ATTR_RW(lpfc_fcp_cpu_map); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5464 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5465 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5466 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 5467 | # Value range is [2,3]. Default value is 3. |
| 5468 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5469 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 5470 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5471 | |
| 5472 | /* |
| 5473 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 5474 | # is [0,1]. Default value is 0. |
| 5475 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5476 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 5477 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5478 | |
| 5479 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5480 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 5481 | # that support first burst. |
| 5482 | # Value range is [0,65536]. Default value is 0. |
| 5483 | */ |
| 5484 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 5485 | "First burst size for Targets that support first burst"); |
| 5486 | |
| 5487 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5488 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 5489 | * When the driver is configured as an NVME target, this value is |
| 5490 | * communicated to the NVME initiator in the PRLI response. It is |
| 5491 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 5492 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5493 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5494 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5495 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5496 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 5497 | "NVME Target mode first burst size in 512B increments."); |
| 5498 | |
| 5499 | /* |
| 5500 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 5501 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 5502 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
James Smart | db197bc | 2019-08-14 16:57:03 -0700 | [diff] [blame] | 5503 | * processed by the initiator for subsequent NVME FCP IO. |
| 5504 | * Currently, this feature is not supported on the NVME target |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5505 | * Value range is [0,1]. Default value is 0 (disabled). |
| 5506 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5507 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
James Smart | db197bc | 2019-08-14 16:57:03 -0700 | [diff] [blame] | 5508 | "Enable First Burst feature for NVME Initiator."); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5509 | |
| 5510 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5511 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 5512 | # depth. Default value is 0. When the value of this parameter is zero the |
| 5513 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 5514 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 5515 | # to limit the I/O completion time to the parameter value. |
| 5516 | # The value is set in milliseconds. |
| 5517 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5518 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5519 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5520 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5521 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5522 | static int |
| 5523 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 5524 | { |
| 5525 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5526 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 5527 | |
| 5528 | if (val == vport->cfg_max_scsicmpl_time) |
| 5529 | return 0; |
| 5530 | if ((val < 0) || (val > 60000)) |
| 5531 | return -EINVAL; |
| 5532 | vport->cfg_max_scsicmpl_time = val; |
| 5533 | |
| 5534 | spin_lock_irq(shost->host_lock); |
| 5535 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 5536 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 5537 | continue; |
| 5538 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 5539 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5540 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5541 | } |
| 5542 | spin_unlock_irq(shost->host_lock); |
| 5543 | return 0; |
| 5544 | } |
| 5545 | lpfc_vport_param_store(max_scsicmpl_time); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5546 | static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5547 | |
| 5548 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5549 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 5550 | # range is [0,1]. Default value is 0. |
| 5551 | */ |
| 5552 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 5553 | |
| 5554 | /* |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 5555 | # lpfc_xri_rebalancing: enable or disable XRI rebalancing feature |
| 5556 | # range is [0,1]. Default value is 1. |
| 5557 | */ |
| 5558 | LPFC_ATTR_R(xri_rebalancing, 1, 0, 1, "Enable/Disable XRI rebalancing"); |
| 5559 | |
| 5560 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5561 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 5562 | * range is [0,1]. Default value is 0. |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5563 | * For [0], FCP commands are issued to Work Queues based on upper layer |
| 5564 | * hardware queue index. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5565 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 5566 | * current CPU. |
| 5567 | * |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5568 | * LPFC_FCP_SCHED_BY_HDWQ == 0 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5569 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 5570 | * |
| 5571 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 5572 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 5573 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 5574 | * through WQs will be used. |
| 5575 | */ |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5576 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_BY_CPU, |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5577 | LPFC_FCP_SCHED_BY_HDWQ, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5578 | LPFC_FCP_SCHED_BY_CPU, |
| 5579 | "Determine scheduling algorithm for " |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 5580 | "issuing commands [0] - Hardware Queue, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5581 | |
| 5582 | /* |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 5583 | * lpfc_ns_query: Determine algrithmn for NameServer queries after RSCN |
| 5584 | * range is [0,1]. Default value is 0. |
| 5585 | * For [0], GID_FT is used for NameServer queries after RSCN (default) |
| 5586 | * For [1], GID_PT is used for NameServer queries after RSCN |
| 5587 | * |
| 5588 | */ |
| 5589 | LPFC_ATTR_RW(ns_query, LPFC_NS_QUERY_GID_FT, |
| 5590 | LPFC_NS_QUERY_GID_FT, LPFC_NS_QUERY_GID_PT, |
| 5591 | "Determine algorithm NameServer queries after RSCN " |
| 5592 | "[0] - GID_FT, [1] - GID_PT"); |
| 5593 | |
| 5594 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5595 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 5596 | # range is [0,1]. Default value is 0. |
| 5597 | # For [0], bus reset issues target reset to ALL devices |
| 5598 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 5599 | */ |
| 5600 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 5601 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 5602 | |
| 5603 | |
| 5604 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5605 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 5606 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5607 | # 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] | 5608 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 5609 | # cr_delay is set to 0. |
| 5610 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5611 | 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] | 5612 | "interrupt response is generated"); |
| 5613 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5614 | 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] | 5615 | "interrupt response is generated"); |
| 5616 | |
| 5617 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5618 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 5619 | # cmd/rsp IOCB entries across. |
| 5620 | # Value range is [1,2]. Default value is 1. |
| 5621 | */ |
| 5622 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 5623 | "SLI rings to spread IOCB entries across"); |
| 5624 | |
| 5625 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5626 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 5627 | # identifies what rctl value to configure the additional ring for. |
| 5628 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 5629 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5630 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5631 | 255, "Identifies RCTL for additional ring configuration"); |
| 5632 | |
| 5633 | /* |
| 5634 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 5635 | # identifies what type value to configure the additional ring for. |
| 5636 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 5637 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5638 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5639 | 255, "Identifies TYPE for additional ring configuration"); |
| 5640 | |
| 5641 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5642 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 5643 | # 0 = SmartSAN functionality disabled (default) |
| 5644 | # 1 = SmartSAN functionality enabled |
| 5645 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 5646 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5647 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5648 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 5649 | |
| 5650 | /* |
| 5651 | # lpfc_fdmi_on: Controls FDMI support. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5652 | # 0 No FDMI support |
| 5653 | # 1 Traditional FDMI support (default) |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 5654 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 5655 | # however, if that fails, it will fallback to FDMI-1. |
| 5656 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 5657 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 5658 | # lpfc_fdmi_on. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5659 | # Value range [0,1]. Default value is 1. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5660 | */ |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5661 | LPFC_ATTR_R(fdmi_on, 1, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5662 | |
| 5663 | /* |
| 5664 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 5665 | # discovery). Value range is [1,64]. Default value = 32. |
| 5666 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5667 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5668 | "during discovery"); |
| 5669 | |
| 5670 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 5671 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 5672 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 5673 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 5674 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 5675 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 5676 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 5677 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 5678 | # on a target can take minutes of wall clock time. Additionally, |
| 5679 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 5680 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 5681 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 5682 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 5683 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 5684 | # devices present, when in fact, there is only 1. |
| 5685 | # A customer that is aware of their target behaviors, and the results as |
| 5686 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 5687 | # As mentioned, this value is not used by the lpfc driver, only the |
| 5688 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 5689 | # Value range is [0,65535]. Default value is 255. |
| 5690 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5691 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 5692 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5693 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5694 | /* |
| 5695 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 5696 | # Value range is [1,255], default value is 10. |
| 5697 | */ |
| 5698 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 5699 | "Milliseconds driver will wait between polling FCP ring"); |
| 5700 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5701 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5702 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 5703 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 5704 | */ |
| 5705 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 5706 | "Maximum time to wait for task management commands to complete"); |
| 5707 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5708 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 5709 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5710 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5711 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5712 | # 2 = MSI-X enabled (default) |
| 5713 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5714 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5715 | 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] | 5716 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5717 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5718 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5719 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5720 | * |
| 5721 | * 0 = NVME OAS disabled |
| 5722 | * 1 = NVME OAS enabled |
| 5723 | * |
| 5724 | * Value range is [0,1]. Default value is 0. |
| 5725 | */ |
| 5726 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 5727 | "Use OAS bit on NVME IOs"); |
| 5728 | |
| 5729 | /* |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5730 | * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs |
| 5731 | * |
| 5732 | * 0 = Put NVME Command in SGL |
| 5733 | * 1 = Embed NVME Command in WQE (unless G7) |
| 5734 | * 2 = Embed NVME Command in WQE (force) |
| 5735 | * |
| 5736 | * Value range is [0,2]. Default value is 1. |
| 5737 | */ |
| 5738 | LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2, |
| 5739 | "Embed NVME Command in WQE"); |
| 5740 | |
| 5741 | /* |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5742 | * lpfc_fcp_mq_threshold: Set the maximum number of Hardware Queues |
| 5743 | * the driver will advertise it supports to the SCSI layer. |
| 5744 | * |
| 5745 | * 0 = Set nr_hw_queues by the number of CPUs or HW queues. |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5746 | * 1,256 = Manually specify nr_hw_queue value to be advertised, |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5747 | * |
James Smart | 0622800 | 2019-08-27 14:28:23 -0700 | [diff] [blame] | 5748 | * Value range is [0,256]. Default value is 8. |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 5749 | */ |
| 5750 | LPFC_ATTR_R(fcp_mq_threshold, LPFC_FCP_MQ_THRESHOLD_DEF, |
| 5751 | LPFC_FCP_MQ_THRESHOLD_MIN, LPFC_FCP_MQ_THRESHOLD_MAX, |
| 5752 | "Set the number of SCSI Queues advertised"); |
| 5753 | |
| 5754 | /* |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5755 | * lpfc_hdw_queue: Set the number of Hardware Queues the driver |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5756 | * will advertise it supports to the NVME and SCSI layers. This also |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5757 | * 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] | 5758 | * |
| 5759 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5760 | * hardware queue. The administrative queue will always map to WQ 0 |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5761 | * A hardware IO queue maps (qidx) to a specific driver CQ/WQ. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5762 | * |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5763 | * 0 = Configure the number of hdw queues to the number of active CPUs. |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5764 | * 1,256 = Manually specify how many hdw queues to use. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5765 | * |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5766 | * Value range is [0,256]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5767 | */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 5768 | LPFC_ATTR_R(hdw_queue, |
| 5769 | LPFC_HBA_HDWQ_DEF, |
| 5770 | LPFC_HBA_HDWQ_MIN, LPFC_HBA_HDWQ_MAX, |
| 5771 | "Set the number of I/O Hardware Queues"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5772 | |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5773 | static inline void |
| 5774 | lpfc_assign_default_irq_numa(struct lpfc_hba *phba) |
| 5775 | { |
| 5776 | #if IS_ENABLED(CONFIG_X86) |
| 5777 | /* If AMD architecture, then default is LPFC_IRQ_CHANN_NUMA */ |
| 5778 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) |
| 5779 | phba->cfg_irq_numa = 1; |
| 5780 | else |
| 5781 | phba->cfg_irq_numa = 0; |
| 5782 | #else |
| 5783 | phba->cfg_irq_numa = 0; |
| 5784 | #endif |
| 5785 | } |
| 5786 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5787 | /* |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5788 | * lpfc_irq_chann: Set the number of IRQ vectors that are available |
| 5789 | * for Hardware Queues to utilize. This also will map to the number |
| 5790 | * of EQ / MSI-X vectors the driver will create. This should never be |
| 5791 | * more than the number of Hardware Queues |
| 5792 | * |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5793 | * 0 = Configure number of IRQ Channels to: |
| 5794 | * if AMD architecture, number of CPUs on HBA's NUMA node |
| 5795 | * otherwise, number of active CPUs. |
| 5796 | * [1,256] = Manually specify how many IRQ Channels to use. |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5797 | * |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5798 | * Value range is [0,256]. Default value is [0]. |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5799 | */ |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 5800 | static uint lpfc_irq_chann = LPFC_IRQ_CHANN_DEF; |
| 5801 | module_param(lpfc_irq_chann, uint, 0444); |
| 5802 | MODULE_PARM_DESC(lpfc_irq_chann, "Set number of interrupt vectors to allocate"); |
| 5803 | |
| 5804 | /* lpfc_irq_chann_init - Set the hba irq_chann initial value |
| 5805 | * @phba: lpfc_hba pointer. |
| 5806 | * @val: contains the initial value |
| 5807 | * |
| 5808 | * Description: |
| 5809 | * Validates the initial value is within range and assigns it to the |
| 5810 | * adapter. If not in range, an error message is posted and the |
| 5811 | * default value is assigned. |
| 5812 | * |
| 5813 | * Returns: |
| 5814 | * zero if value is in range and is set |
| 5815 | * -EINVAL if value was out of range |
| 5816 | **/ |
| 5817 | static int |
| 5818 | lpfc_irq_chann_init(struct lpfc_hba *phba, uint32_t val) |
| 5819 | { |
| 5820 | const struct cpumask *numa_mask; |
| 5821 | |
| 5822 | if (phba->cfg_use_msi != 2) { |
| 5823 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 5824 | "8532 use_msi = %u ignoring cfg_irq_numa\n", |
| 5825 | phba->cfg_use_msi); |
| 5826 | phba->cfg_irq_numa = 0; |
| 5827 | phba->cfg_irq_chann = LPFC_IRQ_CHANN_MIN; |
| 5828 | return 0; |
| 5829 | } |
| 5830 | |
| 5831 | /* Check if default setting was passed */ |
| 5832 | if (val == LPFC_IRQ_CHANN_DEF) |
| 5833 | lpfc_assign_default_irq_numa(phba); |
| 5834 | |
| 5835 | if (phba->cfg_irq_numa) { |
| 5836 | numa_mask = &phba->sli4_hba.numa_mask; |
| 5837 | |
| 5838 | if (cpumask_empty(numa_mask)) { |
| 5839 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 5840 | "8533 Could not identify NUMA node, " |
| 5841 | "ignoring cfg_irq_numa\n"); |
| 5842 | phba->cfg_irq_numa = 0; |
| 5843 | phba->cfg_irq_chann = LPFC_IRQ_CHANN_MIN; |
| 5844 | } else { |
| 5845 | phba->cfg_irq_chann = cpumask_weight(numa_mask); |
| 5846 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 5847 | "8543 lpfc_irq_chann set to %u " |
| 5848 | "(numa)\n", phba->cfg_irq_chann); |
| 5849 | } |
| 5850 | } else { |
| 5851 | if (val > LPFC_IRQ_CHANN_MAX) { |
| 5852 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 5853 | "8545 lpfc_irq_chann attribute cannot " |
| 5854 | "be set to %u, allowed range is " |
| 5855 | "[%u,%u]\n", |
| 5856 | val, |
| 5857 | LPFC_IRQ_CHANN_MIN, |
| 5858 | LPFC_IRQ_CHANN_MAX); |
| 5859 | phba->cfg_irq_chann = LPFC_IRQ_CHANN_MIN; |
| 5860 | return -EINVAL; |
| 5861 | } |
| 5862 | phba->cfg_irq_chann = val; |
| 5863 | } |
| 5864 | |
| 5865 | return 0; |
| 5866 | } |
| 5867 | |
| 5868 | /** |
| 5869 | * lpfc_irq_chann_show - Display value of irq_chann |
| 5870 | * @dev: class converted to a Scsi_host structure. |
| 5871 | * @attr: device attribute, not used. |
| 5872 | * @buf: on return contains a string with the list sizes |
| 5873 | * |
| 5874 | * Returns: size of formatted string. |
| 5875 | **/ |
| 5876 | static ssize_t |
| 5877 | lpfc_irq_chann_show(struct device *dev, struct device_attribute *attr, |
| 5878 | char *buf) |
| 5879 | { |
| 5880 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5881 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5882 | struct lpfc_hba *phba = vport->phba; |
| 5883 | |
| 5884 | return scnprintf(buf, PAGE_SIZE, "%u\n", phba->cfg_irq_chann); |
| 5885 | } |
| 5886 | |
| 5887 | static DEVICE_ATTR_RO(lpfc_irq_chann); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5888 | |
| 5889 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5890 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 5891 | # 0 = HBA resets disabled |
| 5892 | # 1 = HBA resets enabled (default) |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 5893 | # 2 = HBA reset via PCI bus reset enabled |
| 5894 | # Value range is [0,2]. Default value is 1. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5895 | */ |
James Smart | 5021267 | 2018-12-13 15:17:57 -0800 | [diff] [blame] | 5896 | 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] | 5897 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5898 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5899 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5900 | # 0 = HBA Heartbeat disabled |
| 5901 | # 1 = HBA Heartbeat enabled (default) |
| 5902 | # Value range is [0,1]. Default value is 1. |
| 5903 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5904 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5905 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5906 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5907 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 5908 | # 0x0 Express Lane Feature disabled |
| 5909 | # 0x1 Express Lane Feature enabled |
| 5910 | # Value range is [0,1]. Default value is 0. |
| 5911 | */ |
| 5912 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 5913 | |
| 5914 | /* |
| 5915 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 5916 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 5917 | # Value range is [0x0,0x7f]. Default value is 0 |
| 5918 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 5919 | 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] | 5920 | |
| 5921 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5922 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 5923 | # 0 = BlockGuard disabled (default) |
| 5924 | # 1 = BlockGuard enabled |
| 5925 | # Value range is [0,1]. Default value is 0. |
| 5926 | */ |
| 5927 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5928 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5929 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5930 | # lpfc_prot_mask: i |
| 5931 | # - Bit mask of host protection capabilities used to register with the |
| 5932 | # SCSI mid-layer |
| 5933 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5934 | # - Allows you to ultimately specify which profiles to use |
| 5935 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5936 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5937 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5938 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5939 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5940 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5941 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5942 | # |
| 5943 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5944 | LPFC_ATTR(prot_mask, |
| 5945 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5946 | SHOST_DIX_TYPE0_PROTECTION | |
| 5947 | SHOST_DIX_TYPE1_PROTECTION), |
| 5948 | 0, |
| 5949 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5950 | SHOST_DIX_TYPE0_PROTECTION | |
| 5951 | SHOST_DIX_TYPE1_PROTECTION), |
| 5952 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5953 | |
| 5954 | /* |
| 5955 | # lpfc_prot_guard: i |
| 5956 | # - 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] | 5957 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5958 | # - Allows you to ultimately specify which profiles to use |
| 5959 | # - Default will result in registering capabilities for all guard types |
| 5960 | # |
| 5961 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5962 | LPFC_ATTR(prot_guard, |
| 5963 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5964 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5965 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5966 | /* |
| 5967 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5968 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5969 | * This parameter can have value 0 or 1. |
| 5970 | * When this parameter is set to 0, no delay is added to the initial |
| 5971 | * discovery. |
| 5972 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5973 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5974 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5975 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5976 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5977 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5978 | * Default value is 0. |
| 5979 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5980 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5981 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5982 | |
| 5983 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5984 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5985 | * This value can be set to values between 64 and 4096. The default value |
| 5986 | * is 64, but may be increased to allow for larger Max I/O sizes. The scsi |
| 5987 | * 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] | 5988 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5989 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5990 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5991 | */ |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5992 | static uint lpfc_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 5993 | module_param(lpfc_sg_seg_cnt, uint, 0444); |
| 5994 | MODULE_PARM_DESC(lpfc_sg_seg_cnt, "Max Scatter Gather Segment Count"); |
| 5995 | |
| 5996 | /** |
| 5997 | * lpfc_sg_seg_cnt_show - Display the scatter/gather list sizes |
| 5998 | * configured for the adapter |
| 5999 | * @dev: class converted to a Scsi_host structure. |
| 6000 | * @attr: device attribute, not used. |
| 6001 | * @buf: on return contains a string with the list sizes |
| 6002 | * |
| 6003 | * Returns: size of formatted string. |
| 6004 | **/ |
| 6005 | static ssize_t |
| 6006 | lpfc_sg_seg_cnt_show(struct device *dev, struct device_attribute *attr, |
| 6007 | char *buf) |
| 6008 | { |
| 6009 | struct Scsi_Host *shost = class_to_shost(dev); |
| 6010 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 6011 | struct lpfc_hba *phba = vport->phba; |
| 6012 | int len; |
| 6013 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 6014 | len = scnprintf(buf, PAGE_SIZE, "SGL sz: %d total SGEs: %d\n", |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 6015 | phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt); |
| 6016 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 6017 | 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] | 6018 | phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt, |
| 6019 | phba->cfg_nvme_seg_cnt); |
| 6020 | return len; |
| 6021 | } |
| 6022 | |
| 6023 | static DEVICE_ATTR_RO(lpfc_sg_seg_cnt); |
| 6024 | |
| 6025 | /** |
| 6026 | * lpfc_sg_seg_cnt_init - Set the hba sg_seg_cnt initial value |
| 6027 | * @phba: lpfc_hba pointer. |
| 6028 | * @val: contains the initial value |
| 6029 | * |
| 6030 | * Description: |
| 6031 | * Validates the initial value is within range and assigns it to the |
| 6032 | * adapter. If not in range, an error message is posted and the |
| 6033 | * default value is assigned. |
| 6034 | * |
| 6035 | * Returns: |
| 6036 | * zero if value is in range and is set |
| 6037 | * -EINVAL if value was out of range |
| 6038 | **/ |
| 6039 | static int |
| 6040 | lpfc_sg_seg_cnt_init(struct lpfc_hba *phba, int val) |
| 6041 | { |
| 6042 | if (val >= LPFC_MIN_SG_SEG_CNT && val <= LPFC_MAX_SG_SEG_CNT) { |
| 6043 | phba->cfg_sg_seg_cnt = val; |
| 6044 | return 0; |
| 6045 | } |
| 6046 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 6047 | "0409 "LPFC_DRIVER_NAME"_sg_seg_cnt attribute cannot " |
| 6048 | "be set to %d, allowed range is [%d, %d]\n", |
| 6049 | val, LPFC_MIN_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT); |
| 6050 | phba->cfg_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 6051 | return -EINVAL; |
| 6052 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6053 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 6054 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6055 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 6056 | * 0 = MDS Diagnostics disabled (default) |
| 6057 | * 1 = MDS Diagnostics enabled |
| 6058 | * Value range is [0,1]. Default value is 0. |
| 6059 | */ |
James Smart | e62245d | 2019-08-14 16:57:08 -0700 | [diff] [blame] | 6060 | LPFC_ATTR_RW(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6061 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6062 | /* |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6063 | * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size |
| 6064 | * 0 = Disable firmware logging (default) |
| 6065 | * [1-4] = Multiple of 1/4th Mb of host memory for FW logging |
| 6066 | * Value range [0..4]. Default value is 0 |
| 6067 | */ |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 6068 | LPFC_ATTR(ras_fwlog_buffsize, 0, 0, 4, "Host memory for FW logging"); |
| 6069 | lpfc_param_show(ras_fwlog_buffsize); |
| 6070 | |
| 6071 | static ssize_t |
| 6072 | lpfc_ras_fwlog_buffsize_set(struct lpfc_hba *phba, uint val) |
| 6073 | { |
| 6074 | int ret = 0; |
| 6075 | enum ras_state state; |
| 6076 | |
| 6077 | if (!lpfc_rangecheck(val, 0, 4)) |
| 6078 | return -EINVAL; |
| 6079 | |
| 6080 | if (phba->cfg_ras_fwlog_buffsize == val) |
| 6081 | return 0; |
| 6082 | |
James Smart | dda5bdf | 2019-11-04 16:57:02 -0800 | [diff] [blame] | 6083 | if (phba->cfg_ras_fwlog_func != PCI_FUNC(phba->pcidev->devfn)) |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 6084 | return -EINVAL; |
| 6085 | |
| 6086 | spin_lock_irq(&phba->hbalock); |
| 6087 | state = phba->ras_fwlog.state; |
| 6088 | spin_unlock_irq(&phba->hbalock); |
| 6089 | |
| 6090 | if (state == REG_INPROGRESS) { |
| 6091 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "6147 RAS Logging " |
| 6092 | "registration is in progress\n"); |
| 6093 | return -EBUSY; |
| 6094 | } |
| 6095 | |
| 6096 | /* For disable logging: stop the logs and free the DMA. |
| 6097 | * For ras_fwlog_buffsize size change we still need to free and |
| 6098 | * reallocate the DMA in lpfc_sli4_ras_fwlog_init. |
| 6099 | */ |
| 6100 | phba->cfg_ras_fwlog_buffsize = val; |
| 6101 | if (state == ACTIVE) { |
| 6102 | lpfc_ras_stop_fwlog(phba); |
| 6103 | lpfc_sli4_ras_dma_free(phba); |
| 6104 | } |
| 6105 | |
| 6106 | lpfc_sli4_ras_init(phba); |
| 6107 | if (phba->ras_fwlog.ras_enabled) |
| 6108 | ret = lpfc_sli4_ras_fwlog_init(phba, phba->cfg_ras_fwlog_level, |
| 6109 | LPFC_RAS_ENABLE_LOGGING); |
| 6110 | return ret; |
| 6111 | } |
| 6112 | |
| 6113 | lpfc_param_store(ras_fwlog_buffsize); |
| 6114 | static DEVICE_ATTR_RW(lpfc_ras_fwlog_buffsize); |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6115 | |
| 6116 | /* |
| 6117 | * lpfc_ras_fwlog_level: Firmware logging verbosity level |
| 6118 | * Valid only if firmware logging is enabled |
| 6119 | * 0(Least Verbosity) 4 (most verbosity) |
| 6120 | * Value range is [0..4]. Default value is 0 |
| 6121 | */ |
| 6122 | LPFC_ATTR_RW(ras_fwlog_level, 0, 0, 4, "Firmware Logging Level"); |
| 6123 | |
| 6124 | /* |
| 6125 | * lpfc_ras_fwlog_func: Firmware logging enabled on function number |
| 6126 | * Default function which has RAS support : 0 |
| 6127 | * Value Range is [0..7]. |
| 6128 | * FW logging is a global action and enablement is via a specific |
| 6129 | * port. |
| 6130 | */ |
| 6131 | LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function"); |
| 6132 | |
| 6133 | /* |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6134 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 6135 | * 0 = BB Credit Recovery disabled |
| 6136 | * 1 = BB Credit Recovery enabled (default) |
| 6137 | * Value range is [0,1]. Default value is 1. |
| 6138 | */ |
| 6139 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 6140 | |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 6141 | /* |
| 6142 | * lpfc_enable_dpp: Enable DPP on G7 |
| 6143 | * 0 = DPP on G7 disabled |
| 6144 | * 1 = DPP on G7 enabled (default) |
| 6145 | * Value range is [0,1]. Default value is 1. |
| 6146 | */ |
| 6147 | LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); |
| 6148 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6149 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6150 | &dev_attr_nvme_info, |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 6151 | &dev_attr_scsi_stat, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6152 | &dev_attr_bg_info, |
| 6153 | &dev_attr_bg_guard_err, |
| 6154 | &dev_attr_bg_apptag_err, |
| 6155 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6156 | &dev_attr_info, |
| 6157 | &dev_attr_serialnum, |
| 6158 | &dev_attr_modeldesc, |
| 6159 | &dev_attr_modelname, |
| 6160 | &dev_attr_programtype, |
| 6161 | &dev_attr_portnum, |
| 6162 | &dev_attr_fwrev, |
| 6163 | &dev_attr_hdw, |
| 6164 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 6165 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6166 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 6167 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6168 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 6169 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6170 | &dev_attr_lpfc_temp_sensor, |
| 6171 | &dev_attr_lpfc_log_verbose, |
| 6172 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6173 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6174 | &dev_attr_lpfc_hba_queue_depth, |
| 6175 | &dev_attr_lpfc_peer_port_login, |
| 6176 | &dev_attr_lpfc_nodev_tmo, |
| 6177 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6178 | &dev_attr_lpfc_enable_fc4_type, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6179 | &dev_attr_lpfc_fcp_class, |
| 6180 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6181 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6182 | &dev_attr_lpfc_ack0, |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 6183 | &dev_attr_lpfc_xri_rebalancing, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6184 | &dev_attr_lpfc_topology, |
| 6185 | &dev_attr_lpfc_scan_down, |
| 6186 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6187 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 6188 | &dev_attr_lpfc_ns_query, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6189 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6190 | &dev_attr_lpfc_cr_delay, |
| 6191 | &dev_attr_lpfc_cr_count, |
| 6192 | &dev_attr_lpfc_multi_ring_support, |
| 6193 | &dev_attr_lpfc_multi_ring_rctl, |
| 6194 | &dev_attr_lpfc_multi_ring_type, |
| 6195 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6196 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6197 | &dev_attr_lpfc_max_luns, |
| 6198 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6199 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6200 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6201 | &dev_attr_nport_evt_cnt, |
| 6202 | &dev_attr_board_mode, |
| 6203 | &dev_attr_max_vpi, |
| 6204 | &dev_attr_used_vpi, |
| 6205 | &dev_attr_max_rpi, |
| 6206 | &dev_attr_used_rpi, |
| 6207 | &dev_attr_max_xri, |
| 6208 | &dev_attr_used_xri, |
| 6209 | &dev_attr_npiv_info, |
| 6210 | &dev_attr_issue_reset, |
| 6211 | &dev_attr_lpfc_poll, |
| 6212 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6213 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6214 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6215 | &dev_attr_lpfc_nvme_oas, |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 6216 | &dev_attr_lpfc_nvme_embed_cmd, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6217 | &dev_attr_lpfc_fcp_imax, |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 6218 | &dev_attr_lpfc_force_rscn, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 6219 | &dev_attr_lpfc_cq_poll_threshold, |
| 6220 | &dev_attr_lpfc_cq_max_proc_limit, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6221 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 6222 | &dev_attr_lpfc_fcp_mq_threshold, |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 6223 | &dev_attr_lpfc_hdw_queue, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 6224 | &dev_attr_lpfc_irq_chann, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6225 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6226 | &dev_attr_lpfc_nvmet_mrq, |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 6227 | &dev_attr_lpfc_nvmet_mrq_post, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6228 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6229 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6230 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6231 | &dev_attr_lpfc_soft_wwnn, |
| 6232 | &dev_attr_lpfc_soft_wwpn, |
| 6233 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6234 | &dev_attr_lpfc_enable_hba_reset, |
| 6235 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6236 | &dev_attr_lpfc_EnableXLane, |
| 6237 | &dev_attr_lpfc_XLanePriority, |
| 6238 | &dev_attr_lpfc_xlane_lun, |
| 6239 | &dev_attr_lpfc_xlane_tgt, |
| 6240 | &dev_attr_lpfc_xlane_vpt, |
| 6241 | &dev_attr_lpfc_xlane_lun_state, |
| 6242 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6243 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6244 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6245 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6246 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6247 | &dev_attr_lpfc_aer_support, |
| 6248 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6249 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6250 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6251 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6252 | &dev_attr_iocb_hw, |
James Smart | 83c6cb1 | 2019-10-18 14:18:30 -0700 | [diff] [blame] | 6253 | &dev_attr_pls, |
| 6254 | &dev_attr_pt, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6255 | &dev_attr_txq_hw, |
| 6256 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 6257 | &dev_attr_lpfc_fips_level, |
| 6258 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6259 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6260 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6261 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6262 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6263 | &dev_attr_lpfc_enable_mds_diags, |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6264 | &dev_attr_lpfc_ras_fwlog_buffsize, |
| 6265 | &dev_attr_lpfc_ras_fwlog_level, |
| 6266 | &dev_attr_lpfc_ras_fwlog_func, |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6267 | &dev_attr_lpfc_enable_bbcr, |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 6268 | &dev_attr_lpfc_enable_dpp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6269 | NULL, |
| 6270 | }; |
| 6271 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6272 | struct device_attribute *lpfc_vport_attrs[] = { |
| 6273 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 6274 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6275 | &dev_attr_num_discovered_ports, |
| 6276 | &dev_attr_lpfc_drvr_version, |
| 6277 | &dev_attr_lpfc_log_verbose, |
| 6278 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6279 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6280 | &dev_attr_lpfc_nodev_tmo, |
| 6281 | &dev_attr_lpfc_devloss_tmo, |
| 6282 | &dev_attr_lpfc_hba_queue_depth, |
| 6283 | &dev_attr_lpfc_peer_port_login, |
| 6284 | &dev_attr_lpfc_restrict_login, |
| 6285 | &dev_attr_lpfc_fcp_class, |
| 6286 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6287 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6288 | &dev_attr_lpfc_max_luns, |
| 6289 | &dev_attr_nport_evt_cnt, |
| 6290 | &dev_attr_npiv_info, |
| 6291 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6292 | &dev_attr_lpfc_max_scsicmpl_time, |
| 6293 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 6294 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 6295 | &dev_attr_lpfc_fips_level, |
| 6296 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6297 | NULL, |
| 6298 | }; |
| 6299 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6300 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6301 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6302 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6303 | * @kobj: kernel kobject that contains the kernel class device. |
| 6304 | * @bin_attr: kernel attributes passed to us. |
| 6305 | * @buf: contains the data to be written to the adapter IOREG space. |
| 6306 | * @off: offset into buffer to beginning of data. |
| 6307 | * @count: bytes to transfer. |
| 6308 | * |
| 6309 | * Description: |
| 6310 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 6311 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 6312 | * |
| 6313 | * Returns: |
| 6314 | * -ERANGE off and count combo out of range |
| 6315 | * -EINVAL off, count or buff address invalid |
| 6316 | * -EPERM adapter is offline |
| 6317 | * value of count, buf contents written |
| 6318 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6319 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6320 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 6321 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6322 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6323 | { |
| 6324 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6325 | struct device *dev = container_of(kobj, struct device, kobj); |
| 6326 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6327 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6328 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6329 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6330 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 6331 | return -EPERM; |
| 6332 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6333 | if ((off + count) > FF_REG_AREA_SIZE) |
| 6334 | return -ERANGE; |
| 6335 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6336 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 6337 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6338 | |
| 6339 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 6340 | return -EINVAL; |
| 6341 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6342 | /* This is to protect HBA registers from accidental writes. */ |
| 6343 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 6344 | return -EINVAL; |
| 6345 | |
| 6346 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6347 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6348 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6349 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 6350 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 6351 | buf_off += sizeof(uint32_t)) |
| 6352 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6353 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 6354 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6355 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6356 | |
| 6357 | return count; |
| 6358 | } |
| 6359 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6360 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6361 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6362 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6363 | * @kobj: kernel kobject that contains the kernel class device. |
| 6364 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 6365 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6366 | * @off: offset into buffer to beginning of data. |
| 6367 | * @count: bytes to transfer. |
| 6368 | * |
| 6369 | * Description: |
| 6370 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 6371 | * Uses the adapter io control registers to read data into buf. |
| 6372 | * |
| 6373 | * Returns: |
| 6374 | * -ERANGE off and count combo out of range |
| 6375 | * -EINVAL off, count or buff address invalid |
| 6376 | * value of count, buf contents read |
| 6377 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6378 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6379 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 6380 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6381 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6382 | { |
| 6383 | size_t buf_off; |
| 6384 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6385 | struct device *dev = container_of(kobj, struct device, kobj); |
| 6386 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6387 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6388 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6389 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6390 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 6391 | return -EPERM; |
| 6392 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6393 | if (off > FF_REG_AREA_SIZE) |
| 6394 | return -ERANGE; |
| 6395 | |
| 6396 | if ((off + count) > FF_REG_AREA_SIZE) |
| 6397 | count = FF_REG_AREA_SIZE - off; |
| 6398 | |
| 6399 | if (count == 0) return 0; |
| 6400 | |
| 6401 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 6402 | return -EINVAL; |
| 6403 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6404 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6405 | |
| 6406 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 6407 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 6408 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 6409 | } |
| 6410 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6411 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6412 | |
| 6413 | return count; |
| 6414 | } |
| 6415 | |
| 6416 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 6417 | .attr = { |
| 6418 | .name = "ctlreg", |
| 6419 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6420 | }, |
| 6421 | .size = 256, |
| 6422 | .read = sysfs_ctlreg_read, |
| 6423 | .write = sysfs_ctlreg_write, |
| 6424 | }; |
| 6425 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6426 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6427 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6428 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6429 | * @kobj: kernel kobject that contains the kernel class device. |
| 6430 | * @bin_attr: kernel attributes passed to us. |
| 6431 | * @buf: contains the data to be written to sysfs mbox. |
| 6432 | * @off: offset into buffer to beginning of data. |
| 6433 | * @count: bytes to transfer. |
| 6434 | * |
| 6435 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6436 | * Deprecated function. All mailbox access from user space is performed via the |
| 6437 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6438 | * |
| 6439 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6440 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6441 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6442 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6443 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 6444 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6445 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6446 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6447 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6448 | } |
| 6449 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6450 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6451 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6452 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6453 | * @kobj: kernel kobject that contains the kernel class device. |
| 6454 | * @bin_attr: kernel attributes passed to us. |
| 6455 | * @buf: contains the data to be read from sysfs mbox. |
| 6456 | * @off: offset into buffer to beginning of data. |
| 6457 | * @count: bytes to transfer. |
| 6458 | * |
| 6459 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6460 | * Deprecated function. All mailbox access from user space is performed via the |
| 6461 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6462 | * |
| 6463 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6464 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6465 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6466 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 6467 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 6468 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 6469 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6470 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6471 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6472 | } |
| 6473 | |
| 6474 | static struct bin_attribute sysfs_mbox_attr = { |
| 6475 | .attr = { |
| 6476 | .name = "mbox", |
| 6477 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6478 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 6479 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6480 | .read = sysfs_mbox_read, |
| 6481 | .write = sysfs_mbox_write, |
| 6482 | }; |
| 6483 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6484 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6485 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6486 | * @vport: address of lpfc vport structure. |
| 6487 | * |
| 6488 | * Return codes: |
| 6489 | * zero on success |
| 6490 | * error return code from sysfs_create_bin_file() |
| 6491 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6492 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6493 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6494 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6495 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6496 | int error; |
| 6497 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6498 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6499 | &sysfs_drvr_stat_data_attr); |
| 6500 | |
| 6501 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 6502 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 6503 | goto out; |
| 6504 | |
| 6505 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6506 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6507 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6508 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6509 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6510 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6511 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6512 | if (error) |
| 6513 | goto out_remove_ctlreg_attr; |
| 6514 | |
| 6515 | return 0; |
| 6516 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6517 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6518 | out_remove_stat_attr: |
| 6519 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 6520 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6521 | out: |
| 6522 | return error; |
| 6523 | } |
| 6524 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6525 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6526 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6527 | * @vport: address of lpfc vport structure. |
| 6528 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6529 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6530 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6531 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6532 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6533 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 6534 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6535 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 6536 | if (vport->port_type == LPFC_NPIV_PORT) |
| 6537 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6538 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 6539 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6540 | } |
| 6541 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6542 | /* |
| 6543 | * Dynamic FC Host Attributes Support |
| 6544 | */ |
| 6545 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6546 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6547 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 6548 | * @shost: kernel scsi host pointer. |
| 6549 | **/ |
| 6550 | static void |
| 6551 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 6552 | { |
| 6553 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 6554 | |
| 6555 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 6556 | sizeof fc_host_symbolic_name(shost)); |
| 6557 | } |
| 6558 | |
| 6559 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6560 | * 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] | 6561 | * @shost: kernel scsi host pointer. |
| 6562 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6563 | static void |
| 6564 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 6565 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6566 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6567 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6568 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6569 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6570 | } |
| 6571 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6572 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6573 | * 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] | 6574 | * @shost: kernel scsi host pointer. |
| 6575 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6576 | static void |
| 6577 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 6578 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6579 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6580 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6581 | |
| 6582 | spin_lock_irq(shost->host_lock); |
| 6583 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6584 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 6585 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 6586 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6587 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6588 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6589 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 6590 | else |
| 6591 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 6592 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6593 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6594 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 6595 | else |
| 6596 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 6597 | } |
| 6598 | } else |
| 6599 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 6600 | |
| 6601 | spin_unlock_irq(shost->host_lock); |
| 6602 | } |
| 6603 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6604 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6605 | * 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] | 6606 | * @shost: kernel scsi host pointer. |
| 6607 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6608 | static void |
| 6609 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 6610 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6611 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6612 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6613 | |
| 6614 | spin_lock_irq(shost->host_lock); |
| 6615 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6616 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6617 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 6618 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6619 | switch (phba->link_state) { |
| 6620 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6621 | case LPFC_LINK_DOWN: |
| 6622 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 6623 | break; |
| 6624 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6625 | case LPFC_CLEAR_LA: |
| 6626 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6627 | /* Links up, reports port state accordingly */ |
| 6628 | if (vport->port_state < LPFC_VPORT_READY) |
| 6629 | fc_host_port_state(shost) = |
| 6630 | FC_PORTSTATE_BYPASSED; |
| 6631 | else |
| 6632 | fc_host_port_state(shost) = |
| 6633 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6634 | break; |
| 6635 | case LPFC_HBA_ERROR: |
| 6636 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 6637 | break; |
| 6638 | default: |
| 6639 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 6640 | break; |
| 6641 | } |
| 6642 | } |
| 6643 | |
| 6644 | spin_unlock_irq(shost->host_lock); |
| 6645 | } |
| 6646 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6647 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6648 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6649 | * @shost: kernel scsi host pointer. |
| 6650 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6651 | static void |
| 6652 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 6653 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6654 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6655 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6656 | |
| 6657 | spin_lock_irq(shost->host_lock); |
| 6658 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 6659 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6660 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6661 | case LPFC_LINK_SPEED_1GHZ: |
| 6662 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6663 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6664 | case LPFC_LINK_SPEED_2GHZ: |
| 6665 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6666 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6667 | case LPFC_LINK_SPEED_4GHZ: |
| 6668 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6669 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6670 | case LPFC_LINK_SPEED_8GHZ: |
| 6671 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 6672 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6673 | case LPFC_LINK_SPEED_10GHZ: |
| 6674 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6675 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6676 | case LPFC_LINK_SPEED_16GHZ: |
| 6677 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 6678 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 6679 | case LPFC_LINK_SPEED_32GHZ: |
| 6680 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 6681 | break; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 6682 | case LPFC_LINK_SPEED_64GHZ: |
| 6683 | fc_host_speed(shost) = FC_PORTSPEED_64GBIT; |
| 6684 | break; |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 6685 | case LPFC_LINK_SPEED_128GHZ: |
| 6686 | fc_host_speed(shost) = FC_PORTSPEED_128GBIT; |
| 6687 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6688 | default: |
| 6689 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6690 | break; |
| 6691 | } |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame] | 6692 | } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) { |
| 6693 | switch (phba->fc_linkspeed) { |
| 6694 | case LPFC_ASYNC_LINK_SPEED_10GBPS: |
| 6695 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
| 6696 | break; |
| 6697 | case LPFC_ASYNC_LINK_SPEED_25GBPS: |
| 6698 | fc_host_speed(shost) = FC_PORTSPEED_25GBIT; |
| 6699 | break; |
| 6700 | case LPFC_ASYNC_LINK_SPEED_40GBPS: |
| 6701 | fc_host_speed(shost) = FC_PORTSPEED_40GBIT; |
| 6702 | break; |
| 6703 | case LPFC_ASYNC_LINK_SPEED_100GBPS: |
| 6704 | fc_host_speed(shost) = FC_PORTSPEED_100GBIT; |
| 6705 | break; |
| 6706 | default: |
| 6707 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| 6708 | break; |
| 6709 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6710 | } else |
| 6711 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6712 | |
| 6713 | spin_unlock_irq(shost->host_lock); |
| 6714 | } |
| 6715 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6716 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6717 | * 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] | 6718 | * @shost: kernel scsi host pointer. |
| 6719 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6720 | static void |
| 6721 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 6722 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6723 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6724 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 6725 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6726 | |
| 6727 | spin_lock_irq(shost->host_lock); |
| 6728 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6729 | if ((vport->port_state > LPFC_FLOGI) && |
| 6730 | ((vport->fc_flag & FC_FABRIC) || |
| 6731 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 6732 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 6733 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6734 | else |
| 6735 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6736 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6737 | |
| 6738 | spin_unlock_irq(shost->host_lock); |
| 6739 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 6740 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6741 | } |
| 6742 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6743 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6744 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6745 | * @shost: kernel scsi host pointer. |
| 6746 | * |
| 6747 | * Notes: |
| 6748 | * NULL on error for link down, no mbox pool, sli2 active, |
| 6749 | * management not allowed, memory allocation error, or mbox error. |
| 6750 | * |
| 6751 | * Returns: |
| 6752 | * NULL for error |
| 6753 | * address of the adapter host statistics |
| 6754 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6755 | static struct fc_host_statistics * |
| 6756 | lpfc_get_stats(struct Scsi_Host *shost) |
| 6757 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6758 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6759 | struct lpfc_hba *phba = vport->phba; |
| 6760 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6761 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6762 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6763 | LPFC_MBOXQ_t *pmboxq; |
| 6764 | MAILBOX_t *pmb; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6765 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6766 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6767 | /* |
| 6768 | * prevent udev from issuing mailbox commands until the port is |
| 6769 | * configured. |
| 6770 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6771 | if (phba->link_state < LPFC_LINK_DOWN || |
| 6772 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6773 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6774 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6775 | |
| 6776 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6777 | return NULL; |
| 6778 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6779 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6780 | if (!pmboxq) |
| 6781 | return NULL; |
| 6782 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 6783 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6784 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6785 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6786 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6787 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6788 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6789 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6790 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6791 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6792 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6793 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6794 | |
| 6795 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6796 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6797 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6798 | return NULL; |
| 6799 | } |
| 6800 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6801 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 6802 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6803 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6804 | /* |
| 6805 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 6806 | * converted to words |
| 6807 | */ |
| 6808 | hs->tx_words = (uint64_t) |
| 6809 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 6810 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6811 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6812 | hs->rx_words = (uint64_t) |
| 6813 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 6814 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6815 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6816 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6817 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6818 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6819 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6820 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6821 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6822 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6823 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6824 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6825 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6826 | |
| 6827 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6828 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6829 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6830 | return NULL; |
| 6831 | } |
| 6832 | |
| 6833 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6834 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6835 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6836 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6837 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6838 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6839 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 6840 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6841 | hs->link_failure_count -= lso->link_failure_count; |
| 6842 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 6843 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 6844 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 6845 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 6846 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 6847 | hs->error_frames -= lso->error_frames; |
| 6848 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6849 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6850 | hs->lip_count = -1; |
| 6851 | hs->nos_count = (phba->link_events >> 1); |
| 6852 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6853 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6854 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6855 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6856 | hs->nos_count = -1; |
| 6857 | } else { |
| 6858 | hs->lip_count = -1; |
| 6859 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6860 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6861 | } |
| 6862 | |
| 6863 | hs->dumped_frames = -1; |
| 6864 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6865 | hs->seconds_since_last_reset = ktime_get_seconds() - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6866 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6867 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6868 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6869 | return hs; |
| 6870 | } |
| 6871 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6872 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6873 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6874 | * @shost: kernel scsi host pointer. |
| 6875 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6876 | static void |
| 6877 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 6878 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6879 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6880 | struct lpfc_hba *phba = vport->phba; |
| 6881 | struct lpfc_sli *psli = &phba->sli; |
| 6882 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6883 | LPFC_MBOXQ_t *pmboxq; |
| 6884 | MAILBOX_t *pmb; |
| 6885 | int rc = 0; |
| 6886 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6887 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6888 | return; |
| 6889 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6890 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6891 | if (!pmboxq) |
| 6892 | return; |
| 6893 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6894 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6895 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6896 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6897 | pmb->mbxOwner = OWN_HOST; |
| 6898 | pmb->un.varWords[0] = 0x1; /* reset request */ |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6899 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6900 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6901 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6902 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6903 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6904 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6905 | else |
| 6906 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6907 | |
| 6908 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6909 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6910 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6911 | return; |
| 6912 | } |
| 6913 | |
| 6914 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6915 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6916 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6917 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6918 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6919 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6920 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6921 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6922 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6923 | else |
| 6924 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6925 | |
| 6926 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6927 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6928 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 6929 | return; |
| 6930 | } |
| 6931 | |
| 6932 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6933 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6934 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6935 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6936 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6937 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6938 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6939 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6940 | lso->link_events = (phba->link_events >> 1); |
| 6941 | else |
| 6942 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6943 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6944 | psli->stats_start = ktime_get_seconds(); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6945 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6946 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6947 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6948 | return; |
| 6949 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6950 | |
| 6951 | /* |
| 6952 | * The LPFC driver treats linkdown handling as target loss events so there |
| 6953 | * are no sysfs handlers for link_down_tmo. |
| 6954 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6955 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6956 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6957 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6958 | * @starget: kernel scsi target pointer. |
| 6959 | * |
| 6960 | * Returns: |
| 6961 | * address of the node list if found |
| 6962 | * NULL target not found |
| 6963 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6964 | static struct lpfc_nodelist * |
| 6965 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6966 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6967 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 6968 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6969 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6970 | |
| 6971 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6972 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6973 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6974 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 6975 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6976 | starget->id == ndlp->nlp_sid) { |
| 6977 | spin_unlock_irq(shost->host_lock); |
| 6978 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6979 | } |
| 6980 | } |
| 6981 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6982 | return NULL; |
| 6983 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6984 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6985 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6986 | * 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] | 6987 | * @starget: kernel scsi target pointer. |
| 6988 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6989 | static void |
| 6990 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 6991 | { |
| 6992 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 6993 | |
| 6994 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6995 | } |
| 6996 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6997 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6998 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6999 | * @starget: kernel scsi target pointer. |
| 7000 | * |
| 7001 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 7002 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7003 | static void |
| 7004 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 7005 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7006 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7007 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7008 | fc_starget_node_name(starget) = |
| 7009 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7010 | } |
| 7011 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7012 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7013 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7014 | * @starget: kernel scsi target pointer. |
| 7015 | * |
| 7016 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 7017 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7018 | static void |
| 7019 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 7020 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7021 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7022 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 7023 | fc_starget_port_name(starget) = |
| 7024 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7025 | } |
| 7026 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7027 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7028 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7029 | * @rport: fc rport address. |
| 7030 | * @timeout: new value for dev loss tmo. |
| 7031 | * |
| 7032 | * Description: |
| 7033 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 7034 | * dev_loss_tmo to one. |
| 7035 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7036 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7037 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 7038 | { |
James Smart | a643c6d | 2019-08-14 16:56:48 -0700 | [diff] [blame] | 7039 | struct lpfc_rport_data *rdata = rport->dd_data; |
| 7040 | struct lpfc_nodelist *ndlp = rdata->pnode; |
| 7041 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 7042 | struct lpfc_nvme_rport *nrport = NULL; |
| 7043 | #endif |
| 7044 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7045 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 7046 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7047 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 7048 | rport->dev_loss_tmo = 1; |
James Smart | a643c6d | 2019-08-14 16:56:48 -0700 | [diff] [blame] | 7049 | |
| 7050 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
| 7051 | dev_info(&rport->dev, "Cannot find remote node to " |
| 7052 | "set rport dev loss tmo, port_id x%x\n", |
| 7053 | rport->port_id); |
| 7054 | return; |
| 7055 | } |
| 7056 | |
| 7057 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 7058 | nrport = lpfc_ndlp_get_nrport(ndlp); |
| 7059 | |
| 7060 | if (nrport && nrport->remoteport) |
| 7061 | nvme_fc_set_remoteport_devloss(nrport->remoteport, |
| 7062 | rport->dev_loss_tmo); |
| 7063 | #endif |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7064 | } |
| 7065 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7066 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7067 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7068 | * |
| 7069 | * Description: |
| 7070 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 7071 | * |
| 7072 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 7073 | * @cdev: class converted to an fc_rport. |
| 7074 | * @buf: on return contains the target_field or zero. |
| 7075 | * |
| 7076 | * Returns: size of formatted string. |
| 7077 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7078 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 7079 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 7080 | lpfc_show_rport_##field (struct device *dev, \ |
| 7081 | struct device_attribute *attr, \ |
| 7082 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7083 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 7084 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7085 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 7086 | return scnprintf(buf, sz, format_string, \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7087 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 7088 | } |
| 7089 | |
| 7090 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 7091 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 7092 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 7093 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7094 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7095 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7096 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 7097 | * |
| 7098 | * Description: |
| 7099 | * This function is called by the transport after the @fc_vport's symbolic name |
| 7100 | * 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] | 7101 | * 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] | 7102 | **/ |
| 7103 | static void |
| 7104 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 7105 | { |
| 7106 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 7107 | |
| 7108 | if (vport->port_state == LPFC_VPORT_READY) |
| 7109 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 7110 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7111 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 7112 | /** |
| 7113 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 7114 | * @phba: Pointer to lpfc_hba struct. |
| 7115 | * |
| 7116 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 7117 | * 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] | 7118 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 7119 | * before hba port or vport created. |
| 7120 | **/ |
| 7121 | static void |
| 7122 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 7123 | { |
| 7124 | phba->cfg_log_verbose = verbose; |
| 7125 | } |
| 7126 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7127 | struct fc_function_template lpfc_transport_functions = { |
| 7128 | /* fixed attributes the driver supports */ |
| 7129 | .show_host_node_name = 1, |
| 7130 | .show_host_port_name = 1, |
| 7131 | .show_host_supported_classes = 1, |
| 7132 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7133 | .show_host_supported_speeds = 1, |
| 7134 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 7135 | |
| 7136 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7137 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7138 | |
| 7139 | /* dynamic attributes the driver supports */ |
| 7140 | .get_host_port_id = lpfc_get_host_port_id, |
| 7141 | .show_host_port_id = 1, |
| 7142 | |
| 7143 | .get_host_port_type = lpfc_get_host_port_type, |
| 7144 | .show_host_port_type = 1, |
| 7145 | |
| 7146 | .get_host_port_state = lpfc_get_host_port_state, |
| 7147 | .show_host_port_state = 1, |
| 7148 | |
| 7149 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 7150 | .show_host_active_fc4s = 1, |
| 7151 | |
| 7152 | .get_host_speed = lpfc_get_host_speed, |
| 7153 | .show_host_speed = 1, |
| 7154 | |
| 7155 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 7156 | .show_host_fabric_name = 1, |
| 7157 | |
| 7158 | /* |
| 7159 | * The LPFC driver treats linkdown handling as target loss events |
| 7160 | * so there are no sysfs handlers for link_down_tmo. |
| 7161 | */ |
| 7162 | |
| 7163 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 7164 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7165 | |
| 7166 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 7167 | .show_rport_maxframe_size = 1, |
| 7168 | .show_rport_supported_classes = 1, |
| 7169 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7170 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 7171 | .show_rport_dev_loss_tmo = 1, |
| 7172 | |
| 7173 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 7174 | .show_starget_port_id = 1, |
| 7175 | |
| 7176 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 7177 | .show_starget_node_name = 1, |
| 7178 | |
| 7179 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 7180 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 7181 | |
| 7182 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 7183 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 7184 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7185 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7186 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7187 | |
| 7188 | .vport_disable = lpfc_vport_disable, |
| 7189 | |
| 7190 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 7191 | |
| 7192 | .bsg_request = lpfc_bsg_request, |
| 7193 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7194 | }; |
| 7195 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7196 | struct fc_function_template lpfc_vport_transport_functions = { |
| 7197 | /* fixed attributes the driver supports */ |
| 7198 | .show_host_node_name = 1, |
| 7199 | .show_host_port_name = 1, |
| 7200 | .show_host_supported_classes = 1, |
| 7201 | .show_host_supported_fc4s = 1, |
| 7202 | .show_host_supported_speeds = 1, |
| 7203 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 7204 | |
| 7205 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7206 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7207 | |
| 7208 | /* dynamic attributes the driver supports */ |
| 7209 | .get_host_port_id = lpfc_get_host_port_id, |
| 7210 | .show_host_port_id = 1, |
| 7211 | |
| 7212 | .get_host_port_type = lpfc_get_host_port_type, |
| 7213 | .show_host_port_type = 1, |
| 7214 | |
| 7215 | .get_host_port_state = lpfc_get_host_port_state, |
| 7216 | .show_host_port_state = 1, |
| 7217 | |
| 7218 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 7219 | .show_host_active_fc4s = 1, |
| 7220 | |
| 7221 | .get_host_speed = lpfc_get_host_speed, |
| 7222 | .show_host_speed = 1, |
| 7223 | |
| 7224 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 7225 | .show_host_fabric_name = 1, |
| 7226 | |
| 7227 | /* |
| 7228 | * The LPFC driver treats linkdown handling as target loss events |
| 7229 | * so there are no sysfs handlers for link_down_tmo. |
| 7230 | */ |
| 7231 | |
| 7232 | .get_fc_host_stats = lpfc_get_stats, |
| 7233 | .reset_fc_host_stats = lpfc_reset_stats, |
| 7234 | |
| 7235 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 7236 | .show_rport_maxframe_size = 1, |
| 7237 | .show_rport_supported_classes = 1, |
| 7238 | |
| 7239 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 7240 | .show_rport_dev_loss_tmo = 1, |
| 7241 | |
| 7242 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 7243 | .show_starget_port_id = 1, |
| 7244 | |
| 7245 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 7246 | .show_starget_node_name = 1, |
| 7247 | |
| 7248 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 7249 | .show_starget_port_name = 1, |
| 7250 | |
| 7251 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 7252 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 7253 | |
| 7254 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 7255 | |
| 7256 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7257 | }; |
| 7258 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7259 | /** |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7260 | * lpfc_get_hba_function_mode - Used to determine the HBA function in FCoE |
| 7261 | * Mode |
| 7262 | * @phba: lpfc_hba pointer. |
| 7263 | **/ |
| 7264 | static void |
| 7265 | lpfc_get_hba_function_mode(struct lpfc_hba *phba) |
| 7266 | { |
James Smart | 412e737 | 2019-09-21 20:59:04 -0700 | [diff] [blame] | 7267 | /* If the adapter supports FCoE mode */ |
| 7268 | switch (phba->pcidev->device) { |
| 7269 | case PCI_DEVICE_ID_SKYHAWK: |
| 7270 | case PCI_DEVICE_ID_SKYHAWK_VF: |
| 7271 | case PCI_DEVICE_ID_LANCER_FCOE: |
| 7272 | case PCI_DEVICE_ID_LANCER_FCOE_VF: |
| 7273 | case PCI_DEVICE_ID_ZEPHYR_DCSP: |
| 7274 | case PCI_DEVICE_ID_HORNET: |
| 7275 | case PCI_DEVICE_ID_TIGERSHARK: |
| 7276 | case PCI_DEVICE_ID_TOMCAT: |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7277 | phba->hba_flag |= HBA_FCOE_MODE; |
James Smart | 412e737 | 2019-09-21 20:59:04 -0700 | [diff] [blame] | 7278 | break; |
| 7279 | default: |
| 7280 | /* for others, clear the flag */ |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7281 | phba->hba_flag &= ~HBA_FCOE_MODE; |
James Smart | 412e737 | 2019-09-21 20:59:04 -0700 | [diff] [blame] | 7282 | } |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7283 | } |
| 7284 | |
| 7285 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7286 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7287 | * @phba: lpfc_hba pointer. |
| 7288 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7289 | void |
| 7290 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 7291 | { |
James Smart | dcaa213 | 2019-11-04 16:57:06 -0800 | [diff] [blame] | 7292 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 7293 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 7294 | lpfc_ns_query_init(phba, lpfc_ns_query); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 7295 | 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] | 7296 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 7297 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 7298 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 7299 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 7300 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7301 | lpfc_ack0_init(phba, lpfc_ack0); |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 7302 | lpfc_xri_rebalancing_init(phba, lpfc_xri_rebalancing); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7303 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 7304 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 7305 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 7306 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 7307 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 7308 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 7309 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7310 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 7311 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 7312 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7313 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 7314 | lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 7315 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 41b194b | 2019-05-14 14:58:08 -0700 | [diff] [blame] | 7316 | lpfc_force_rscn_init(phba, lpfc_force_rscn); |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 7317 | lpfc_cq_poll_threshold_init(phba, lpfc_cq_poll_threshold); |
| 7318 | lpfc_cq_max_proc_limit_init(phba, lpfc_cq_max_proc_limit); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 7319 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 7320 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 7321 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 7322 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7323 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 7324 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 7325 | phba->cfg_EnableXLane = 0; |
| 7326 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 7327 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7328 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 7329 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 7330 | phba->cfg_oas_lun_state = 0; |
| 7331 | phba->cfg_oas_lun_status = 0; |
| 7332 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 7333 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 7334 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 7335 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 7336 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 7337 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7338 | phba->cfg_poll = 0; |
| 7339 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 7340 | phba->cfg_poll = lpfc_poll; |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7341 | |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7342 | /* Get the function mode */ |
| 7343 | lpfc_get_hba_function_mode(phba); |
| 7344 | |
| 7345 | /* BlockGuard allowed for FC only. */ |
| 7346 | if (phba->cfg_enable_bg && phba->hba_flag & HBA_FCOE_MODE) { |
| 7347 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
| 7348 | "0581 BlockGuard feature not supported\n"); |
| 7349 | /* If set, clear the BlockGuard support param */ |
| 7350 | phba->cfg_enable_bg = 0; |
| 7351 | } else if (phba->cfg_enable_bg) { |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7352 | phba->sli3_options |= LPFC_SLI3_BG_ENABLED; |
James Smart | 4945c0f | 2019-08-14 16:57:02 -0700 | [diff] [blame] | 7353 | } |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 7354 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7355 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7356 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7357 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7358 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 7359 | lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7360 | |
| 7361 | /* Initialize first burst. Target vs Initiator are different. */ |
| 7362 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7363 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 77ffd34 | 2019-08-15 19:36:49 -0700 | [diff] [blame] | 7364 | lpfc_fcp_mq_threshold_init(phba, lpfc_fcp_mq_threshold); |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7365 | lpfc_hdw_queue_init(phba, lpfc_hdw_queue); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7366 | lpfc_irq_chann_init(phba, lpfc_irq_chann); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 7367 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 7368 | lpfc_enable_dpp_init(phba, lpfc_enable_dpp); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7369 | |
| 7370 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 7371 | /* NVME only supported on SLI4 */ |
| 7372 | phba->nvmet_support = 0; |
James Smart | 982ab12 | 2019-03-12 16:30:10 -0700 | [diff] [blame] | 7373 | phba->cfg_nvmet_mrq = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7374 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 7375 | phba->cfg_enable_bbcr = 0; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 7376 | phba->cfg_xri_rebalancing = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7377 | } else { |
| 7378 | /* We MUST have FCP support */ |
| 7379 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 7380 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 7381 | } |
| 7382 | |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 7383 | phba->cfg_auto_imax = (phba->cfg_fcp_imax) ? 0 : 1; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 7384 | |
James Smart | 06b6fa38 | 2018-07-31 17:23:24 -0700 | [diff] [blame] | 7385 | phba->cfg_enable_pbde = 0; |
| 7386 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7387 | /* 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] | 7388 | if (phba->cfg_hdw_queue == 0) |
| 7389 | phba->cfg_hdw_queue = phba->sli4_hba.num_present_cpu; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7390 | if (phba->cfg_irq_chann == 0) |
| 7391 | phba->cfg_irq_chann = phba->sli4_hba.num_present_cpu; |
| 7392 | if (phba->cfg_irq_chann > phba->cfg_hdw_queue) |
| 7393 | phba->cfg_irq_chann = phba->cfg_hdw_queue; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 7394 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 7395 | phba->cfg_soft_wwnn = 0L; |
| 7396 | phba->cfg_soft_wwpn = 0L; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 7397 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 7398 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 7399 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 7400 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 7401 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 7402 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 7403 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 7404 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 7405 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 7406 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 7407 | lpfc_ras_fwlog_buffsize_init(phba, lpfc_ras_fwlog_buffsize); |
| 7408 | lpfc_ras_fwlog_level_init(phba, lpfc_ras_fwlog_level); |
| 7409 | lpfc_ras_fwlog_func_init(phba, lpfc_ras_fwlog_func); |
| 7410 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7411 | return; |
| 7412 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 7413 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7414 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7415 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 7416 | * dependencies between protocols and roles. |
| 7417 | * @phba: lpfc_hba pointer. |
| 7418 | **/ |
| 7419 | void |
| 7420 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 7421 | { |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 7422 | if (phba->cfg_hdw_queue > phba->sli4_hba.num_present_cpu) |
| 7423 | phba->cfg_hdw_queue = phba->sli4_hba.num_present_cpu; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 7424 | if (phba->cfg_irq_chann > phba->sli4_hba.num_present_cpu) |
| 7425 | phba->cfg_irq_chann = phba->sli4_hba.num_present_cpu; |
| 7426 | if (phba->cfg_irq_chann > phba->cfg_hdw_queue) |
| 7427 | phba->cfg_irq_chann = phba->cfg_hdw_queue; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7428 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7429 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 7430 | phba->nvmet_support) { |
| 7431 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7432 | |
| 7433 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 7434 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 7435 | "NVME Target PRLI ACC enable_fb ", |
| 7436 | phba->cfg_nvme_enable_fb, |
| 7437 | phba->cfg_nvmet_fb_size, |
| 7438 | LPFC_NVMET_FB_SZ_MAX); |
| 7439 | |
| 7440 | if (phba->cfg_nvme_enable_fb == 0) |
| 7441 | phba->cfg_nvmet_fb_size = 0; |
| 7442 | else { |
| 7443 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 7444 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 7445 | } |
| 7446 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7447 | if (!phba->cfg_nvmet_mrq) |
James Smart | 97a9ed3 | 2019-10-18 14:18:17 -0700 | [diff] [blame] | 7448 | phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7449 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7450 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
James Smart | 97a9ed3 | 2019-10-18 14:18:17 -0700 | [diff] [blame] | 7451 | if (phba->cfg_nvmet_mrq > phba->cfg_hdw_queue) { |
| 7452 | phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7453 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 7454 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 7455 | phba->cfg_nvmet_mrq); |
| 7456 | } |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 7457 | if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) |
| 7458 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; |
| 7459 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7460 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 7461 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 7462 | phba->nvmet_support = 0; |
James Smart | 982ab12 | 2019-03-12 16:30:10 -0700 | [diff] [blame] | 7463 | phba->cfg_nvmet_mrq = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 7464 | phba->cfg_nvmet_fb_size = 0; |
| 7465 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 7466 | } |
| 7467 | |
| 7468 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7469 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7470 | * @vport: lpfc_vport pointer. |
| 7471 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7472 | void |
| 7473 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 7474 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7475 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7476 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 7477 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7478 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 7479 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 7480 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 7481 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 7482 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 7483 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 7484 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 7485 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7486 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 7487 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 7488 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 7489 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7490 | return; |
| 7491 | } |