| 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 | 128bdda | 2018-01-30 15:59:03 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017-2018 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 | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 67 | #define LPFC_MAX_NVME_INFO_TMP_LEN 100 |
| 68 | #define LPFC_NVME_INFO_MORE_STR "\nCould be more info...\n" |
| 69 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 70 | /* |
| 71 | * Write key size should be multiple of 4. If write key is changed |
| 72 | * make sure that library write key is also changed. |
| 73 | */ |
| 74 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 75 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 76 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 77 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 78 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 79 | * @incr: integer to convert. |
| 80 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 81 | * |
| 82 | * Description: |
| 83 | * JEDEC Joint Electron Device Engineering Council. |
| 84 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 85 | * character string. The string is then terminated with a NULL in byte 9. |
| 86 | * Hex 0-9 becomes ascii '0' to '9'. |
| 87 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 88 | * |
| 89 | * Notes: |
| 90 | * Coded for 32 bit integers only. |
| 91 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 92 | static void |
| 93 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 94 | { |
| 95 | int i, j; |
| 96 | for (i = 0; i < 8; i++) { |
| 97 | j = (incr & 0xf); |
| 98 | if (j <= 9) |
| 99 | hdw[7 - i] = 0x30 + j; |
| 100 | else |
| 101 | hdw[7 - i] = 0x61 + j - 10; |
| 102 | incr = (incr >> 4); |
| 103 | } |
| 104 | hdw[8] = 0; |
| 105 | return; |
| 106 | } |
| 107 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 108 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 109 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 110 | * @dev: class unused variable. |
| 111 | * @attr: device attribute, not used. |
| 112 | * @buf: on return contains the module description text. |
| 113 | * |
| 114 | * Returns: size of formatted string. |
| 115 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 116 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 117 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 118 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 119 | { |
| 120 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 121 | } |
| 122 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 123 | /** |
| 124 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 125 | * @dev: class unused variable. |
| 126 | * @attr: device attribute, not used. |
| 127 | * @buf: on return contains the module description text. |
| 128 | * |
| 129 | * Returns: size of formatted string. |
| 130 | **/ |
| 131 | static ssize_t |
| 132 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 133 | char *buf) |
| 134 | { |
| 135 | struct Scsi_Host *shost = class_to_shost(dev); |
| 136 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 137 | struct lpfc_hba *phba = vport->phba; |
| 138 | |
| 139 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 140 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 141 | else |
| 142 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 143 | } |
| 144 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 145 | static ssize_t |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 146 | lpfc_nvme_info_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 = shost_priv(shost); |
| 151 | struct lpfc_hba *phba = vport->phba; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 152 | struct lpfc_nvmet_tgtport *tgtp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 153 | struct nvme_fc_local_port *localport; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 154 | struct lpfc_nvme_lport *lport; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 155 | struct lpfc_nvme_rport *rport; |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 156 | struct lpfc_nodelist *ndlp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 157 | struct nvme_fc_remote_port *nrport; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 158 | struct lpfc_nvme_ctrl_stat *cstat; |
| 159 | uint64_t data1, data2, data3; |
| 160 | uint64_t totin, totout, tot; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 161 | char *statep; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 162 | int i; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 163 | int len = 0; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 164 | char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0}; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 165 | |
| 166 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 167 | len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 168 | return len; |
| 169 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 170 | if (phba->nvmet_support) { |
| 171 | if (!phba->targetport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 172 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 173 | "NVME Target: x%llx is not allocated\n", |
| 174 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 175 | return len; |
| 176 | } |
| 177 | /* Port state is only one of two values for now. */ |
| 178 | if (phba->targetport->port_id) |
| 179 | statep = "REGISTERED"; |
| 180 | else |
| 181 | statep = "INIT"; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 182 | scnprintf(tmp, sizeof(tmp), |
| 183 | "NVME Target Enabled State %s\n", |
| 184 | statep); |
| 185 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 186 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 187 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 188 | scnprintf(tmp, sizeof(tmp), |
| 189 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 190 | "NVME Target: lpfc", |
| 191 | phba->brd_no, |
| 192 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 193 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 194 | phba->targetport->port_id); |
| 195 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 196 | goto buffer_done; |
| 197 | |
| 198 | if (strlcat(buf, "\nNVME Target: Statistics\n", PAGE_SIZE) |
| 199 | >= PAGE_SIZE) |
| 200 | goto buffer_done; |
| 201 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 202 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 203 | scnprintf(tmp, sizeof(tmp), |
| 204 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 205 | atomic_read(&tgtp->rcv_ls_req_in), |
| 206 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 207 | atomic_read(&tgtp->xmt_ls_abort)); |
| 208 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 209 | goto buffer_done; |
| 210 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 211 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 212 | atomic_read(&tgtp->rcv_ls_req_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 213 | scnprintf(tmp, sizeof(tmp), |
| 214 | "Rcv LS: in %08x != out %08x\n", |
| 215 | atomic_read(&tgtp->rcv_ls_req_in), |
| 216 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 217 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 218 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 219 | } |
| 220 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 221 | scnprintf(tmp, sizeof(tmp), |
| 222 | "LS: Xmt %08x Drop %08x Cmpl %08x\n", |
| 223 | atomic_read(&tgtp->xmt_ls_rsp), |
| 224 | atomic_read(&tgtp->xmt_ls_drop), |
| 225 | atomic_read(&tgtp->xmt_ls_rsp_cmpl)); |
| 226 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 227 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 228 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 229 | scnprintf(tmp, sizeof(tmp), |
| 230 | "LS: RSP Abort %08x xb %08x Err %08x\n", |
| 231 | atomic_read(&tgtp->xmt_ls_rsp_aborted), |
| 232 | atomic_read(&tgtp->xmt_ls_rsp_xb_set), |
| 233 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 234 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 235 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 236 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 237 | scnprintf(tmp, sizeof(tmp), |
| 238 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 239 | "Drop %08x\n", |
| 240 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 241 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
| 242 | atomic_read(&tgtp->xmt_fcp_release), |
| 243 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 244 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 245 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 246 | |
| 247 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 248 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 249 | scnprintf(tmp, sizeof(tmp), |
| 250 | "Rcv FCP: in %08x != out %08x\n", |
| 251 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 252 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 253 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 254 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 255 | } |
| 256 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 257 | scnprintf(tmp, sizeof(tmp), |
| 258 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " |
| 259 | "drop %08x\n", |
| 260 | atomic_read(&tgtp->xmt_fcp_read), |
| 261 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 262 | atomic_read(&tgtp->xmt_fcp_write), |
| 263 | atomic_read(&tgtp->xmt_fcp_rsp), |
| 264 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 265 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 266 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 267 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 268 | scnprintf(tmp, sizeof(tmp), |
| 269 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 270 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 271 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 272 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 273 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 274 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 275 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 276 | scnprintf(tmp, sizeof(tmp), |
| 277 | "FCP Rsp Abort: %08x xb %08x xricqe %08x\n", |
| 278 | atomic_read(&tgtp->xmt_fcp_rsp_aborted), |
| 279 | atomic_read(&tgtp->xmt_fcp_rsp_xb_set), |
| 280 | atomic_read(&tgtp->xmt_fcp_xri_abort_cqe)); |
| 281 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 282 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 283 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 284 | scnprintf(tmp, sizeof(tmp), |
| 285 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 286 | atomic_read(&tgtp->xmt_fcp_abort), |
| 287 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 288 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 289 | goto buffer_done; |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 290 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 291 | scnprintf(tmp, sizeof(tmp), |
| 292 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x\n", |
| 293 | atomic_read(&tgtp->xmt_abort_sol), |
| 294 | atomic_read(&tgtp->xmt_abort_unsol), |
| 295 | atomic_read(&tgtp->xmt_abort_rsp), |
| 296 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
| 297 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 298 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 299 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 300 | scnprintf(tmp, sizeof(tmp), |
| 301 | "DELAY: ctx %08x fod %08x wqfull %08x\n", |
| 302 | atomic_read(&tgtp->defer_ctx), |
| 303 | atomic_read(&tgtp->defer_fod), |
| 304 | atomic_read(&tgtp->defer_wqfull)); |
| 305 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 306 | goto buffer_done; |
James Smart | 411de51 | 2018-01-30 15:58:52 -0800 | [diff] [blame] | 307 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 308 | /* Calculate outstanding IOs */ |
| 309 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 310 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 311 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 312 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 313 | scnprintf(tmp, sizeof(tmp), |
| 314 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 315 | "CTX Outstanding %08llx\n\n", |
| 316 | phba->sli4_hba.nvmet_xri_cnt, |
| 317 | phba->sli4_hba.nvmet_io_wait_cnt, |
| 318 | phba->sli4_hba.nvmet_io_wait_total, |
| 319 | tot); |
| 320 | strlcat(buf, tmp, PAGE_SIZE); |
| 321 | goto buffer_done; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 322 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 323 | |
| 324 | localport = vport->localport; |
| 325 | if (!localport) { |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 326 | len = scnprintf(buf, PAGE_SIZE, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 327 | "NVME Initiator x%llx is not allocated\n", |
| 328 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 329 | return len; |
| 330 | } |
Colin Ian King | 5c665ae | 2017-12-22 00:28:52 +0000 | [diff] [blame] | 331 | lport = (struct lpfc_nvme_lport *)localport->private; |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 332 | if (strlcat(buf, "\nNVME Initiator Enabled\n", PAGE_SIZE) >= PAGE_SIZE) |
| 333 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 334 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 335 | rcu_read_lock(); |
| 336 | scnprintf(tmp, sizeof(tmp), |
| 337 | "XRI Dist lpfc%d Total %d NVME %d SCSI %d ELS %d\n", |
| 338 | phba->brd_no, |
| 339 | phba->sli4_hba.max_cfg_param.max_xri, |
| 340 | phba->sli4_hba.nvme_xri_max, |
| 341 | phba->sli4_hba.scsi_xri_max, |
| 342 | lpfc_sli4_get_els_iocb_cnt(phba)); |
| 343 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 344 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 345 | |
| 346 | /* Port state is only one of two values for now. */ |
| 347 | if (localport->port_id) |
| 348 | statep = "ONLINE"; |
| 349 | else |
| 350 | statep = "UNKNOWN "; |
| 351 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 352 | scnprintf(tmp, sizeof(tmp), |
| 353 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 354 | "NVME LPORT lpfc", |
| 355 | phba->brd_no, |
| 356 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 357 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 358 | localport->port_id, statep); |
| 359 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 360 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 361 | |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 362 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 363 | rport = lpfc_ndlp_get_nrport(ndlp); |
| 364 | if (!rport) |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 365 | continue; |
| 366 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 367 | /* local short-hand pointer. */ |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 368 | nrport = rport->remoteport; |
| 369 | if (!nrport) |
| 370 | continue; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 371 | |
| 372 | /* Port state is only one of two values for now. */ |
| 373 | switch (nrport->port_state) { |
| 374 | case FC_OBJSTATE_ONLINE: |
| 375 | statep = "ONLINE"; |
| 376 | break; |
| 377 | case FC_OBJSTATE_UNKNOWN: |
| 378 | statep = "UNKNOWN "; |
| 379 | break; |
| 380 | default: |
| 381 | statep = "UNSUPPORTED"; |
| 382 | break; |
| 383 | } |
| 384 | |
| 385 | /* Tab in to show lport ownership. */ |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 386 | if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE) |
| 387 | goto buffer_done; |
| 388 | if (phba->brd_no >= 10) { |
| 389 | if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE) |
| 390 | goto buffer_done; |
| 391 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 392 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 393 | scnprintf(tmp, sizeof(tmp), "WWPN x%llx ", |
| 394 | nrport->port_name); |
| 395 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 396 | goto buffer_done; |
| 397 | |
| 398 | scnprintf(tmp, sizeof(tmp), "WWNN x%llx ", |
| 399 | nrport->node_name); |
| 400 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 401 | goto buffer_done; |
| 402 | |
| 403 | scnprintf(tmp, sizeof(tmp), "DID x%06x ", |
| 404 | nrport->port_id); |
| 405 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 406 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 407 | |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 408 | /* An NVME rport can have multiple roles. */ |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 409 | if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) { |
| 410 | if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE) |
| 411 | goto buffer_done; |
| 412 | } |
| 413 | if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) { |
| 414 | if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE) |
| 415 | goto buffer_done; |
| 416 | } |
| 417 | if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) { |
| 418 | if (strlcat(buf, "DISCSRVC ", PAGE_SIZE) >= PAGE_SIZE) |
| 419 | goto buffer_done; |
| 420 | } |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 421 | if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | |
| 422 | FC_PORT_ROLE_NVME_TARGET | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 423 | FC_PORT_ROLE_NVME_DISCOVERY)) { |
| 424 | scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x", |
| 425 | nrport->port_role); |
| 426 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 427 | goto buffer_done; |
| 428 | } |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 429 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 430 | scnprintf(tmp, sizeof(tmp), "%s\n", statep); |
| 431 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 432 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 433 | } |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 434 | rcu_read_unlock(); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 435 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 436 | if (!lport) |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 437 | goto buffer_done; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 438 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 439 | if (strlcat(buf, "\nNVME Statistics\n", PAGE_SIZE) >= PAGE_SIZE) |
| 440 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 441 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 442 | scnprintf(tmp, sizeof(tmp), |
| 443 | "LS: Xmt %010x Cmpl %010x Abort %08x\n", |
| 444 | atomic_read(&lport->fc4NvmeLsRequests), |
| 445 | atomic_read(&lport->fc4NvmeLsCmpls), |
| 446 | atomic_read(&lport->xmt_ls_abort)); |
| 447 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 448 | goto buffer_done; |
| 449 | |
| 450 | scnprintf(tmp, sizeof(tmp), |
| 451 | "LS XMIT: Err %08x CMPL: xb %08x Err %08x\n", |
| 452 | atomic_read(&lport->xmt_ls_err), |
| 453 | atomic_read(&lport->cmpl_ls_xb), |
| 454 | atomic_read(&lport->cmpl_ls_err)); |
| 455 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 456 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 457 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 458 | totin = 0; |
| 459 | totout = 0; |
| 460 | for (i = 0; i < phba->cfg_nvme_io_channel; i++) { |
| 461 | cstat = &lport->cstat[i]; |
| 462 | tot = atomic_read(&cstat->fc4NvmeIoCmpls); |
| 463 | totin += tot; |
| 464 | data1 = atomic_read(&cstat->fc4NvmeInputRequests); |
| 465 | data2 = atomic_read(&cstat->fc4NvmeOutputRequests); |
| 466 | data3 = atomic_read(&cstat->fc4NvmeControlRequests); |
| 467 | totout += (data1 + data2 + data3); |
| 468 | } |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 469 | scnprintf(tmp, sizeof(tmp), |
| 470 | "Total FCP Cmpl %016llx Issue %016llx " |
| 471 | "OutIO %016llx\n", |
| 472 | totin, totout, totout - totin); |
| 473 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 474 | goto buffer_done; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 475 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 476 | scnprintf(tmp, sizeof(tmp), |
| 477 | "\tabort %08x noxri %08x nondlp %08x qdepth %08x " |
| 478 | "wqerr %08x err %08x\n", |
| 479 | atomic_read(&lport->xmt_fcp_abort), |
| 480 | atomic_read(&lport->xmt_fcp_noxri), |
| 481 | atomic_read(&lport->xmt_fcp_bad_ndlp), |
| 482 | atomic_read(&lport->xmt_fcp_qdepth), |
| 483 | atomic_read(&lport->xmt_fcp_err), |
| 484 | atomic_read(&lport->xmt_fcp_wqerr)); |
| 485 | if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) |
| 486 | goto buffer_done; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 487 | |
James Smart | afff0d2 | 2018-06-26 08:24:22 -0700 | [diff] [blame] | 488 | scnprintf(tmp, sizeof(tmp), |
| 489 | "FCP CMPL: xb %08x Err %08x\n", |
| 490 | atomic_read(&lport->cmpl_fcp_xb), |
| 491 | atomic_read(&lport->cmpl_fcp_err)); |
| 492 | strlcat(buf, tmp, PAGE_SIZE); |
| 493 | |
| 494 | buffer_done: |
| 495 | len = strnlen(buf, PAGE_SIZE); |
| 496 | |
| 497 | if (unlikely(len >= (PAGE_SIZE - 1))) { |
| 498 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME, |
| 499 | "6314 Catching potential buffer " |
| 500 | "overflow > PAGE_SIZE = %lu bytes\n", |
| 501 | PAGE_SIZE); |
| 502 | strlcpy(buf + PAGE_SIZE - 1 - |
| 503 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1), |
| 504 | LPFC_NVME_INFO_MORE_STR, |
| 505 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1) |
| 506 | + 1); |
| 507 | } |
| 508 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 509 | return len; |
| 510 | } |
| 511 | |
| 512 | static ssize_t |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 513 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 514 | char *buf) |
| 515 | { |
| 516 | struct Scsi_Host *shost = class_to_shost(dev); |
| 517 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 518 | struct lpfc_hba *phba = vport->phba; |
| 519 | |
| 520 | if (phba->cfg_enable_bg) |
| 521 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 522 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 523 | else |
| 524 | return snprintf(buf, PAGE_SIZE, |
| 525 | "BlockGuard Not Supported\n"); |
| 526 | else |
| 527 | return snprintf(buf, PAGE_SIZE, |
| 528 | "BlockGuard Disabled\n"); |
| 529 | } |
| 530 | |
| 531 | static ssize_t |
| 532 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 533 | char *buf) |
| 534 | { |
| 535 | struct Scsi_Host *shost = class_to_shost(dev); |
| 536 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 537 | struct lpfc_hba *phba = vport->phba; |
| 538 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 539 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 540 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | static ssize_t |
| 544 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 545 | char *buf) |
| 546 | { |
| 547 | struct Scsi_Host *shost = class_to_shost(dev); |
| 548 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 549 | struct lpfc_hba *phba = vport->phba; |
| 550 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 551 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 552 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | static ssize_t |
| 556 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 557 | char *buf) |
| 558 | { |
| 559 | struct Scsi_Host *shost = class_to_shost(dev); |
| 560 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 561 | struct lpfc_hba *phba = vport->phba; |
| 562 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 563 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 564 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 565 | } |
| 566 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 567 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 568 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 569 | * @dev: class converted to a Scsi_host structure. |
| 570 | * @attr: device attribute, not used. |
| 571 | * @buf: on return contains the formatted text from lpfc_info(). |
| 572 | * |
| 573 | * Returns: size of formatted string. |
| 574 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 575 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 576 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 577 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 578 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 579 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 580 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 581 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 582 | } |
| 583 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 584 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 585 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 586 | * @dev: class converted to a Scsi_host structure. |
| 587 | * @attr: device attribute, not used. |
| 588 | * @buf: on return contains the formatted text serial number. |
| 589 | * |
| 590 | * Returns: size of formatted string. |
| 591 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 592 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 593 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 594 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 595 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 596 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 597 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 598 | struct lpfc_hba *phba = vport->phba; |
| 599 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 600 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 601 | } |
| 602 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 603 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 604 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 605 | * @dev: class converted to a Scsi_host structure. |
| 606 | * @attr: device attribute, not used. |
| 607 | * @buf: on return contains the formatted support level. |
| 608 | * |
| 609 | * Description: |
| 610 | * Returns a number indicating the temperature sensor level currently |
| 611 | * supported, zero or one in ascii. |
| 612 | * |
| 613 | * Returns: size of formatted string. |
| 614 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 615 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 616 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 617 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 618 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 619 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 620 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 621 | struct lpfc_hba *phba = vport->phba; |
| 622 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 623 | } |
| 624 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 625 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 626 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 627 | * @dev: class converted to a Scsi_host structure. |
| 628 | * @attr: device attribute, not used. |
| 629 | * @buf: on return contains the scsi vpd model description. |
| 630 | * |
| 631 | * Returns: size of formatted string. |
| 632 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 633 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 634 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 635 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 636 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 637 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 638 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 639 | struct lpfc_hba *phba = vport->phba; |
| 640 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 641 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 642 | } |
| 643 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 644 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 645 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 646 | * @dev: class converted to a Scsi_host structure. |
| 647 | * @attr: device attribute, not used. |
| 648 | * @buf: on return contains the scsi vpd model name. |
| 649 | * |
| 650 | * Returns: size of formatted string. |
| 651 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 652 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 653 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 654 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 655 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 656 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 657 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 658 | struct lpfc_hba *phba = vport->phba; |
| 659 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 660 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 661 | } |
| 662 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 663 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 664 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 665 | * @dev: class converted to a Scsi_host structure. |
| 666 | * @attr: device attribute, not used. |
| 667 | * @buf: on return contains the scsi vpd program type. |
| 668 | * |
| 669 | * Returns: size of formatted string. |
| 670 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 671 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 672 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 673 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 674 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 675 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 676 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 677 | struct lpfc_hba *phba = vport->phba; |
| 678 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 679 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 680 | } |
| 681 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 682 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 683 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 684 | * @dev: class converted to a Scsi_host structure. |
| 685 | * @attr: device attribute, not used. |
| 686 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 687 | * |
| 688 | * Returns: size of formatted string. |
| 689 | **/ |
| 690 | static ssize_t |
| 691 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 692 | { |
| 693 | struct Scsi_Host *shost = class_to_shost(dev); |
| 694 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 695 | struct lpfc_hba *phba = vport->phba; |
| 696 | |
| 697 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 698 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 699 | } |
| 700 | |
| 701 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 702 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 703 | * @dev: class converted to a Scsi_host structure. |
| 704 | * @attr: device attribute, not used. |
| 705 | * @buf: on return contains scsi vpd program type. |
| 706 | * |
| 707 | * Returns: size of formatted string. |
| 708 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 709 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 710 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 711 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 712 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 713 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 714 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 715 | struct lpfc_hba *phba = vport->phba; |
| 716 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 717 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 718 | } |
| 719 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 720 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 721 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 722 | * @dev: class converted to a Scsi_host structure. |
| 723 | * @attr: device attribute, not used. |
| 724 | * @buf: on return contains the scsi vpd program type. |
| 725 | * |
| 726 | * Returns: size of formatted string. |
| 727 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 728 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 729 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 730 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 731 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 732 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 733 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 734 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 735 | uint32_t if_type; |
| 736 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 737 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 738 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 739 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 740 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 741 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 742 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 743 | |
| 744 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 745 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 746 | fwrev, phba->sli_rev); |
| 747 | else |
| 748 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 749 | fwrev, phba->sli_rev, if_type, sli_family); |
| 750 | |
| 751 | return len; |
| 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_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 756 | * @dev: class converted to a Scsi_host structure. |
| 757 | * @attr: device attribute, not used. |
| 758 | * @buf: on return contains the scsi vpd program type. |
| 759 | * |
| 760 | * Returns: size of formatted string. |
| 761 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 762 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 763 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 764 | { |
| 765 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 766 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 767 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 768 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 769 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 770 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 771 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 772 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 773 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 774 | |
| 775 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 776 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 777 | * @dev: class converted to a Scsi_host structure. |
| 778 | * @attr: device attribute, not used. |
| 779 | * @buf: on return contains the ROM and FCode ascii strings. |
| 780 | * |
| 781 | * Returns: size of formatted string. |
| 782 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 783 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 784 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 785 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 786 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 787 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 788 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 789 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 790 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 791 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 792 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 793 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 794 | |
| 795 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
| 796 | return snprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 797 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 798 | |
| 799 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 800 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 801 | * @dev: class converted to a Scsi_host structure. |
| 802 | * @attr: device attribute, not used. |
| 803 | * @buf: on return contains text describing the state of the link. |
| 804 | * |
| 805 | * Notes: |
| 806 | * The switch statement has no default so zero will be returned. |
| 807 | * |
| 808 | * Returns: size of formatted string. |
| 809 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 810 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 811 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 812 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 813 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 814 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 815 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 816 | struct lpfc_hba *phba = vport->phba; |
| 817 | int len = 0; |
| 818 | |
| 819 | switch (phba->link_state) { |
| 820 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 821 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 822 | case LPFC_INIT_START: |
| 823 | case LPFC_INIT_MBX_CMDS: |
| 824 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 825 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 826 | if (phba->hba_flag & LINK_DISABLED) |
| 827 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 828 | "Link Down - User disabled\n"); |
| 829 | else |
| 830 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 831 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 832 | break; |
| 833 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 834 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 835 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 836 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 837 | |
| 838 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 839 | case LPFC_LOCAL_CFG_LINK: |
| 840 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 841 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 842 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 843 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 844 | case LPFC_FLOGI: |
| 845 | case LPFC_FABRIC_CFG_LINK: |
| 846 | case LPFC_NS_REG: |
| 847 | case LPFC_NS_QRY: |
| 848 | case LPFC_BUILD_DISC_LIST: |
| 849 | case LPFC_DISC_AUTH: |
| 850 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 851 | "Discovery\n"); |
| 852 | break; |
| 853 | case LPFC_VPORT_READY: |
| 854 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 855 | break; |
| 856 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 857 | case LPFC_VPORT_FAILED: |
| 858 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 859 | break; |
| 860 | |
| 861 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 862 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 863 | "Unknown\n"); |
| 864 | break; |
| 865 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 866 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 867 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 868 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 869 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 870 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 871 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 872 | " Public Loop\n"); |
| 873 | else |
| 874 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 875 | " Private Loop\n"); |
| 876 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 877 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 878 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 879 | " Fabric\n"); |
| 880 | else |
| 881 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 882 | " Point-2-Point\n"); |
| 883 | } |
| 884 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 885 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 886 | return len; |
| 887 | } |
| 888 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 889 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 890 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 891 | * @dev: class unused variable. |
| 892 | * @attr: device attribute, not used. |
| 893 | * @buf: on return contains the module description text. |
| 894 | * |
| 895 | * Returns: size of formatted string. |
| 896 | **/ |
| 897 | static ssize_t |
| 898 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 899 | char *buf) |
| 900 | { |
| 901 | struct Scsi_Host *shost = class_to_shost(dev); |
| 902 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 903 | struct lpfc_hba *phba = vport->phba; |
| 904 | |
| 905 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 906 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 907 | |
| 908 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 909 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 910 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 911 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 912 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 913 | } |
| 914 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 915 | } |
| 916 | |
| 917 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 918 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 919 | * (OAS) is supported. |
| 920 | * @dev: class unused variable. |
| 921 | * @attr: device attribute, not used. |
| 922 | * @buf: on return contains the module description text. |
| 923 | * |
| 924 | * Returns: size of formatted string. |
| 925 | **/ |
| 926 | static ssize_t |
| 927 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 928 | char *buf) |
| 929 | { |
| 930 | struct Scsi_Host *shost = class_to_shost(dev); |
| 931 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 932 | struct lpfc_hba *phba = vport->phba; |
| 933 | |
| 934 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 935 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 936 | } |
| 937 | |
| 938 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 939 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 940 | * @dev: class device that is converted into a Scsi_host. |
| 941 | * @attr: device attribute, not used. |
| 942 | * @buf: one or more lpfc_polling_flags values. |
| 943 | * @count: not used. |
| 944 | * |
| 945 | * Returns: |
| 946 | * -EINVAL if the buffer is not "up" or "down" |
| 947 | * return from link state change function if non-zero |
| 948 | * length of the buf on success |
| 949 | **/ |
| 950 | static ssize_t |
| 951 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 952 | const char *buf, size_t count) |
| 953 | { |
| 954 | struct Scsi_Host *shost = class_to_shost(dev); |
| 955 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 956 | struct lpfc_hba *phba = vport->phba; |
| 957 | |
| 958 | int status = -EINVAL; |
| 959 | |
| 960 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 961 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 962 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 963 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 964 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 965 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 966 | |
| 967 | if (status == 0) |
| 968 | return strlen(buf); |
| 969 | else |
| 970 | return status; |
| 971 | } |
| 972 | |
| 973 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 974 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 975 | * @dev: class device that is converted into a Scsi_host. |
| 976 | * @attr: device attribute, not used. |
| 977 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 978 | * |
| 979 | * Description: |
| 980 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 981 | * vport counts. |
| 982 | * |
| 983 | * Returns: size of formatted string. |
| 984 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 985 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 986 | lpfc_num_discovered_ports_show(struct device *dev, |
| 987 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 988 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 989 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 990 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 991 | |
| 992 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 993 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 994 | } |
| 995 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 996 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 997 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 998 | * @shost: Scsi_Host pointer. |
| 999 | * |
| 1000 | * Description: |
| 1001 | * Bring the link down gracefully then re-init the link. The firmware will |
| 1002 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 1003 | * |
| 1004 | * Returns: |
| 1005 | * -EPERM port offline or management commands are being blocked |
| 1006 | * -ENOMEM cannot allocate memory for the mailbox command |
| 1007 | * -EIO error sending the mailbox command |
| 1008 | * zero for success |
| 1009 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1010 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1011 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1012 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1013 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1014 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1015 | LPFC_MBOXQ_t *pmboxq; |
| 1016 | int mbxstatus = MBXERR_ERROR; |
| 1017 | |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1018 | /* |
| 1019 | * If the link is offline, disabled or BLOCK_MGMT_IO |
| 1020 | * it doesn't make any sense to allow issue_lip |
| 1021 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1022 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1023 | (phba->hba_flag & LINK_DISABLED) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 1024 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1025 | return -EPERM; |
| 1026 | |
| 1027 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 1028 | |
| 1029 | if (!pmboxq) |
| 1030 | return -ENOMEM; |
| 1031 | |
| 1032 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1033 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 1034 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1035 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 1036 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1037 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1038 | if ((mbxstatus == MBX_SUCCESS) && |
| 1039 | (pmboxq->u.mb.mbxStatus == 0 || |
| 1040 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1041 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1042 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 1043 | phba->cfg_link_speed); |
| 1044 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 1045 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 1046 | if ((mbxstatus == MBX_SUCCESS) && |
| 1047 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 1048 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 1049 | "2859 SLI authentication is required " |
| 1050 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1051 | } |
| 1052 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 1053 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1054 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1055 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1056 | |
| 1057 | if (mbxstatus == MBXERR_ERROR) |
| 1058 | return -EIO; |
| 1059 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1060 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1061 | } |
| 1062 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1063 | int |
| 1064 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 1065 | { |
| 1066 | int cnt = 0; |
| 1067 | |
| 1068 | spin_lock_irq(lock); |
| 1069 | while (!list_empty(q)) { |
| 1070 | spin_unlock_irq(lock); |
| 1071 | msleep(20); |
| 1072 | if (cnt++ > 250) { /* 5 secs */ |
| 1073 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 1074 | "0466 %s %s\n", |
| 1075 | "Outstanding IO when ", |
| 1076 | "bringing Adapter offline\n"); |
| 1077 | return 0; |
| 1078 | } |
| 1079 | spin_lock_irq(lock); |
| 1080 | } |
| 1081 | spin_unlock_irq(lock); |
| 1082 | return 1; |
| 1083 | } |
| 1084 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1085 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1086 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1087 | * @phba: lpfc_hba pointer. |
| 1088 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 1089 | * |
| 1090 | * Notes: |
| 1091 | * Assumes any error from lpfc_do_offline() will be negative. |
| 1092 | * Can wait up to 5 seconds for the port ring buffers count |
| 1093 | * 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] | 1094 | * 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] | 1095 | * |
| 1096 | * Returns: |
| 1097 | * -EIO error posting the event |
| 1098 | * zero for success |
| 1099 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1100 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1101 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 1102 | { |
| 1103 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1104 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1105 | struct lpfc_sli_ring *pring; |
| 1106 | struct lpfc_sli *psli; |
| 1107 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1108 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1109 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1110 | |
| 1111 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1112 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1113 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1114 | if (rc == 0) |
| 1115 | return -ENOMEM; |
| 1116 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1117 | wait_for_completion(&online_compl); |
| 1118 | |
| 1119 | if (status != 0) |
| 1120 | return -EIO; |
| 1121 | |
| 1122 | psli = &phba->sli; |
| 1123 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1124 | /* Wait a little for things to settle down, but not |
| 1125 | * long enough for dev loss timeout to expire. |
| 1126 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1127 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 1128 | for (i = 0; i < psli->num_rings; i++) { |
| 1129 | pring = &psli->sli3_ring[i]; |
| 1130 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1131 | &phba->hbalock)) |
| 1132 | goto out; |
| 1133 | } |
| 1134 | } else { |
| 1135 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 1136 | pring = qp->pring; |
| 1137 | if (!pring) |
| 1138 | continue; |
| 1139 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1140 | &pring->ring_lock)) |
| 1141 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1142 | } |
| 1143 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1144 | out: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1145 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1146 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 1147 | if (rc == 0) |
| 1148 | return -ENOMEM; |
| 1149 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1150 | wait_for_completion(&online_compl); |
| 1151 | |
| 1152 | if (status != 0) |
| 1153 | return -EIO; |
| 1154 | |
| 1155 | return 0; |
| 1156 | } |
| 1157 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1158 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1159 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1160 | * @phba: lpfc_hba pointer. |
| 1161 | * |
| 1162 | * Description: |
| 1163 | * If the port is configured to allow a reset then the hba is brought |
| 1164 | * offline then online. |
| 1165 | * |
| 1166 | * Notes: |
| 1167 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1168 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1169 | * |
| 1170 | * Returns: |
| 1171 | * lpfc_do_offline() return code if not zero |
| 1172 | * -EIO reset not configured or error posting the event |
| 1173 | * zero for success |
| 1174 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1175 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1176 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1177 | { |
| 1178 | struct completion online_compl; |
| 1179 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1180 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1181 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1182 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1183 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1184 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1185 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1186 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1187 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1188 | if (status != 0) |
| 1189 | return status; |
| 1190 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1191 | |
| 1192 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1193 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1194 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1195 | if (rc == 0) |
| 1196 | return -ENOMEM; |
| 1197 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1198 | wait_for_completion(&online_compl); |
| 1199 | |
| 1200 | if (status != 0) |
| 1201 | return -EIO; |
| 1202 | |
| 1203 | return 0; |
| 1204 | } |
| 1205 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1206 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1207 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1208 | * @dev: class device that is converted into a Scsi_host. |
| 1209 | * @attr: device attribute, not used. |
| 1210 | * @buf: containing the string "selective". |
| 1211 | * @count: unused variable. |
| 1212 | * |
| 1213 | * Description: |
| 1214 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1215 | * is called to perform the reset. |
| 1216 | * |
| 1217 | * Notes: |
| 1218 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1219 | * 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] | 1220 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1221 | * |
| 1222 | * Returns: |
| 1223 | * -EINVAL if the buffer does not contain the string "selective" |
| 1224 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1225 | * return value of lpfc_selective_reset() if the call fails |
| 1226 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1227 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1228 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1229 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1230 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1231 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1232 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1233 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1234 | int status = -EINVAL; |
| 1235 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1236 | if (!phba->cfg_enable_hba_reset) |
| 1237 | return -EACCES; |
| 1238 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1239 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1240 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1241 | |
| 1242 | if (status == 0) |
| 1243 | return strlen(buf); |
| 1244 | else |
| 1245 | return status; |
| 1246 | } |
| 1247 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1248 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1249 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1250 | * @phba: lpfc_hba pointer. |
| 1251 | * |
| 1252 | * Description: |
| 1253 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1254 | * the readyness after performing a firmware reset. |
| 1255 | * |
| 1256 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1257 | * 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] | 1258 | * reset, -EIO when port timeout from recovering from the reset. |
| 1259 | * |
| 1260 | * Note: |
| 1261 | * As the caller will interpret the return code by value, be careful in making |
| 1262 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1263 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1264 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1265 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1266 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1267 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1268 | int i; |
| 1269 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1270 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1271 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1272 | &portstat_reg.word0); |
| 1273 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1274 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1275 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1276 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1277 | return -EPERM; |
| 1278 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1279 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1280 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1281 | msleep(10); |
| 1282 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1283 | &portstat_reg.word0); |
| 1284 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1285 | continue; |
| 1286 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1287 | continue; |
| 1288 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1289 | continue; |
| 1290 | break; |
| 1291 | } |
| 1292 | |
| 1293 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1294 | return 0; |
| 1295 | else |
| 1296 | return -EIO; |
| 1297 | } |
| 1298 | |
| 1299 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1300 | * 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] | 1301 | * @phba: lpfc_hba pointer. |
| 1302 | * |
| 1303 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1304 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1305 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1306 | * |
| 1307 | * Returns: |
| 1308 | * zero for success |
| 1309 | **/ |
| 1310 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1311 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1312 | { |
| 1313 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1314 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1315 | uint32_t before_fc_flag; |
| 1316 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1317 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1318 | int status = 0, rc = 0; |
| 1319 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1320 | |
| 1321 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1322 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1323 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1324 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 1325 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 1326 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1327 | return -EPERM; |
| 1328 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1329 | /* Keep state if we need to restore back */ |
| 1330 | before_fc_flag = phba->pport->fc_flag; |
| 1331 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1332 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1333 | /* Disable SR-IOV virtual functions if enabled */ |
| 1334 | if (phba->cfg_sriov_nr_virtfn) { |
| 1335 | pci_disable_sriov(pdev); |
| 1336 | phba->cfg_sriov_nr_virtfn = 0; |
| 1337 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1338 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1339 | if (opcode == LPFC_FW_DUMP) |
| 1340 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1341 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1342 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1343 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1344 | if (status != 0) { |
| 1345 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1346 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1347 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1348 | |
| 1349 | /* wait for the device to be quiesced before firmware reset */ |
| 1350 | msleep(100); |
| 1351 | |
| 1352 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1353 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1354 | |
| 1355 | if (opcode == LPFC_FW_DUMP) |
| 1356 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1357 | else if (opcode == LPFC_FW_RESET) |
| 1358 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1359 | else if (opcode == LPFC_DV_RESET) |
| 1360 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1361 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1362 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1363 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1364 | /* flush */ |
| 1365 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1366 | |
| 1367 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1368 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1369 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1370 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1371 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1372 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1373 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1374 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1375 | } else if (rc == -EIO) { |
| 1376 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1377 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1378 | "3153 Fail to perform the requested " |
| 1379 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1380 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | /* keep the original port state */ |
| 1384 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1385 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1386 | |
| 1387 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1388 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1389 | LPFC_EVT_ONLINE); |
| 1390 | if (!job_posted) |
| 1391 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1392 | |
| 1393 | wait_for_completion(&online_compl); |
| 1394 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1395 | out: |
| 1396 | /* in any case, restore the virtual functions enabled as before */ |
| 1397 | if (sriov_nr_virtfn) { |
| 1398 | sriov_err = |
| 1399 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1400 | if (!sriov_err) |
| 1401 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1402 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1403 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1404 | /* return proper error code */ |
| 1405 | if (!rc) { |
| 1406 | if (!job_posted) |
| 1407 | rc = -ENOMEM; |
| 1408 | else if (status) |
| 1409 | rc = -EIO; |
| 1410 | } |
| 1411 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1415 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1416 | * @dev: class device that is converted into a Scsi_host. |
| 1417 | * @attr: device attribute, not used. |
| 1418 | * @buf: on return contains the ascii number of nport events. |
| 1419 | * |
| 1420 | * Returns: size of formatted string. |
| 1421 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1422 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1423 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1424 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1425 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1426 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1427 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1428 | struct lpfc_hba *phba = vport->phba; |
| 1429 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1430 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1431 | } |
| 1432 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1433 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1434 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1435 | * @dev: class device that is converted into a Scsi_host. |
| 1436 | * @attr: device attribute, not used. |
| 1437 | * @buf: on return contains the state of the adapter. |
| 1438 | * |
| 1439 | * Returns: size of formatted string. |
| 1440 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1441 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1442 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1443 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1444 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1445 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1446 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1447 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1448 | char * state; |
| 1449 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1450 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1451 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1452 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1453 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1454 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1455 | state = "offline"; |
| 1456 | else |
| 1457 | state = "online"; |
| 1458 | |
| 1459 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1460 | } |
| 1461 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1462 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1463 | * 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] | 1464 | * @dev: class device that is converted into a Scsi_host. |
| 1465 | * @attr: device attribute, not used. |
| 1466 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1467 | * @count: unused variable. |
| 1468 | * |
| 1469 | * Returns: |
| 1470 | * -EACCES if enable hba reset not enabled |
| 1471 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1472 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1473 | * buf length greater than zero indicates success |
| 1474 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1475 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1476 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1477 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1478 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1479 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1480 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1481 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1482 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1483 | char *board_mode_str = NULL; |
| 1484 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1485 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1486 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1487 | if (!phba->cfg_enable_hba_reset) { |
| 1488 | status = -EACCES; |
| 1489 | goto board_mode_out; |
| 1490 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1491 | |
| 1492 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1493 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1494 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1495 | init_completion(&online_compl); |
| 1496 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1497 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1498 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1499 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1500 | if (rc == 0) { |
| 1501 | status = -ENOMEM; |
| 1502 | goto board_mode_out; |
| 1503 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1504 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1505 | if (status) |
| 1506 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1507 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1508 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1509 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1510 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1511 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1512 | else |
| 1513 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1514 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1515 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1516 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1517 | else |
| 1518 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1519 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1520 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1521 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1522 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1523 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1524 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1525 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1526 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1527 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1528 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1529 | if (!status) |
| 1530 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1531 | else { |
| 1532 | board_mode_str = strchr(buf, '\n'); |
| 1533 | if (board_mode_str) |
| 1534 | *board_mode_str = '\0'; |
| 1535 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1536 | "3097 Failed \"%s\", status(%d), " |
| 1537 | "fc_flag(x%x)\n", |
| 1538 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1539 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1540 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1541 | } |
| 1542 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1543 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1544 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1545 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1546 | * @mxri: max xri count. |
| 1547 | * @axri: available xri count. |
| 1548 | * @mrpi: max rpi count. |
| 1549 | * @arpi: available rpi count. |
| 1550 | * @mvpi: max vpi count. |
| 1551 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1552 | * |
| 1553 | * Description: |
| 1554 | * If an integer pointer for an count is not null then the value for the |
| 1555 | * count is returned. |
| 1556 | * |
| 1557 | * Returns: |
| 1558 | * zero on error |
| 1559 | * one for success |
| 1560 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1561 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1562 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1563 | uint32_t *mxri, uint32_t *axri, |
| 1564 | uint32_t *mrpi, uint32_t *arpi, |
| 1565 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1566 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1567 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1568 | LPFC_MBOXQ_t *pmboxq; |
| 1569 | MAILBOX_t *pmb; |
| 1570 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1571 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1572 | |
| 1573 | /* |
| 1574 | * prevent udev from issuing mailbox commands until the port is |
| 1575 | * configured. |
| 1576 | */ |
| 1577 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1578 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1579 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1580 | return 0; |
| 1581 | |
| 1582 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1583 | return 0; |
| 1584 | |
| 1585 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1586 | if (!pmboxq) |
| 1587 | return 0; |
| 1588 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1589 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1590 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1591 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1592 | pmb->mbxOwner = OWN_HOST; |
| 1593 | pmboxq->context1 = NULL; |
| 1594 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1595 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1596 | rc = MBX_NOT_FINISHED; |
| 1597 | else |
| 1598 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1599 | |
| 1600 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1601 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1602 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1603 | return 0; |
| 1604 | } |
| 1605 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1606 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1607 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1608 | if (mrpi) |
| 1609 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1610 | if (arpi) |
| 1611 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1612 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1613 | if (mxri) |
| 1614 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1615 | if (axri) |
| 1616 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1617 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1618 | |
| 1619 | /* Account for differences with SLI-3. Get vpi count from |
| 1620 | * mailbox data and subtract one for max vpi value. |
| 1621 | */ |
| 1622 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1623 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1624 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1625 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1626 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1627 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1628 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1629 | } else { |
| 1630 | if (mrpi) |
| 1631 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1632 | if (arpi) |
| 1633 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1634 | if (mxri) |
| 1635 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1636 | if (axri) |
| 1637 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1638 | if (mvpi) |
| 1639 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1640 | if (avpi) |
| 1641 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1642 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1643 | |
| 1644 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1645 | return 1; |
| 1646 | } |
| 1647 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1648 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1649 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1650 | * @dev: class device that is converted into a Scsi_host. |
| 1651 | * @attr: device attribute, not used. |
| 1652 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1653 | * |
| 1654 | * Description: |
| 1655 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1656 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1657 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1658 | * must check for "Unknown" in the buffer to detect a failure. |
| 1659 | * |
| 1660 | * Returns: size of formatted string. |
| 1661 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1662 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1663 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1664 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1665 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1666 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1667 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1668 | struct lpfc_hba *phba = vport->phba; |
| 1669 | uint32_t cnt; |
| 1670 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1671 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1672 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1673 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1674 | } |
| 1675 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1676 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1677 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1678 | * @dev: class device that is converted into a Scsi_host. |
| 1679 | * @attr: device attribute, not used. |
| 1680 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1681 | * |
| 1682 | * Description: |
| 1683 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1684 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1685 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1686 | * must check for "Unknown" in the buffer to detect a failure. |
| 1687 | * |
| 1688 | * Returns: size of formatted string. |
| 1689 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1690 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1691 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1692 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1693 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1694 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1695 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1696 | struct lpfc_hba *phba = vport->phba; |
| 1697 | uint32_t cnt, acnt; |
| 1698 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1699 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1700 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1701 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1702 | } |
| 1703 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1704 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1705 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1706 | * @dev: class device that is converted into a Scsi_host. |
| 1707 | * @attr: device attribute, not used. |
| 1708 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1709 | * |
| 1710 | * Description: |
| 1711 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1712 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1713 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1714 | * must check for "Unknown" in the buffer to detect a failure. |
| 1715 | * |
| 1716 | * Returns: size of formatted string. |
| 1717 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1718 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1719 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1720 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1721 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1722 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1723 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1724 | struct lpfc_hba *phba = vport->phba; |
| 1725 | uint32_t cnt; |
| 1726 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1727 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1728 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1729 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1730 | } |
| 1731 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1732 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1733 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1734 | * @dev: class device that is converted into a Scsi_host. |
| 1735 | * @attr: device attribute, not used. |
| 1736 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1737 | * |
| 1738 | * Description: |
| 1739 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1740 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1741 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1742 | * must check for "Unknown" in the buffer to detect a failure. |
| 1743 | * |
| 1744 | * Returns: size of formatted string. |
| 1745 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1746 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1747 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1748 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1749 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1750 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1751 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1752 | struct lpfc_hba *phba = vport->phba; |
| 1753 | uint32_t cnt, acnt; |
| 1754 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1755 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1756 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1757 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1758 | } |
| 1759 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1760 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1761 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1762 | * @dev: class device that is converted into a Scsi_host. |
| 1763 | * @attr: device attribute, not used. |
| 1764 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1765 | * |
| 1766 | * Description: |
| 1767 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1768 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1769 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1770 | * must check for "Unknown" in the buffer to detect a failure. |
| 1771 | * |
| 1772 | * Returns: size of formatted string. |
| 1773 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1774 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1775 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1776 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1777 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1778 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1779 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1780 | struct lpfc_hba *phba = vport->phba; |
| 1781 | uint32_t cnt; |
| 1782 | |
| 1783 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1784 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1785 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1786 | } |
| 1787 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1788 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1789 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1790 | * @dev: class device that is converted into a Scsi_host. |
| 1791 | * @attr: device attribute, not used. |
| 1792 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1793 | * |
| 1794 | * Description: |
| 1795 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1796 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1797 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1798 | * must check for "Unknown" in the buffer to detect a failure. |
| 1799 | * |
| 1800 | * Returns: size of formatted string. |
| 1801 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1802 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1803 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1804 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1805 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1806 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1807 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1808 | struct lpfc_hba *phba = vport->phba; |
| 1809 | uint32_t cnt, acnt; |
| 1810 | |
| 1811 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1812 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1813 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1814 | } |
| 1815 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1816 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1817 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1818 | * @dev: class device that is converted into a Scsi_host. |
| 1819 | * @attr: device attribute, not used. |
| 1820 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1821 | * |
| 1822 | * Description: |
| 1823 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1824 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1825 | * the id of the vport. |
| 1826 | * |
| 1827 | * Returns: size of formatted string. |
| 1828 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1829 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1830 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1831 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1832 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1833 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1834 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1835 | struct lpfc_hba *phba = vport->phba; |
| 1836 | |
| 1837 | if (!(phba->max_vpi)) |
| 1838 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1839 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1840 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1841 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1842 | } |
| 1843 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1844 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1845 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1846 | * @dev: class device that is converted into a Scsi_host. |
| 1847 | * @attr: device attribute, not used. |
| 1848 | * @buf: on return contains the cfg_poll in hex. |
| 1849 | * |
| 1850 | * Notes: |
| 1851 | * cfg_poll should be a lpfc_polling_flags type. |
| 1852 | * |
| 1853 | * Returns: size of formatted string. |
| 1854 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1855 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1856 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1857 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1858 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1859 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1860 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1861 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1862 | |
| 1863 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1864 | } |
| 1865 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1866 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1867 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1868 | * @dev: class device that is converted into a Scsi_host. |
| 1869 | * @attr: device attribute, not used. |
| 1870 | * @buf: one or more lpfc_polling_flags values. |
| 1871 | * @count: not used. |
| 1872 | * |
| 1873 | * Notes: |
| 1874 | * buf contents converted to integer and checked for a valid value. |
| 1875 | * |
| 1876 | * Returns: |
| 1877 | * -EINVAL if the buffer connot be converted or is out of range |
| 1878 | * length of the buf on success |
| 1879 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1880 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1881 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1882 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1883 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1884 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1885 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1886 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1887 | uint32_t creg_val; |
| 1888 | uint32_t old_val; |
| 1889 | int val=0; |
| 1890 | |
| 1891 | if (!isdigit(buf[0])) |
| 1892 | return -EINVAL; |
| 1893 | |
| 1894 | if (sscanf(buf, "%i", &val) != 1) |
| 1895 | return -EINVAL; |
| 1896 | |
| 1897 | if ((val & 0x3) != val) |
| 1898 | return -EINVAL; |
| 1899 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1900 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1901 | val = 0; |
| 1902 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1903 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1904 | "3051 lpfc_poll changed from %d to %d\n", |
| 1905 | phba->cfg_poll, val); |
| 1906 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1907 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1908 | |
| 1909 | old_val = phba->cfg_poll; |
| 1910 | |
| 1911 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1912 | if ((val & DISABLE_FCP_RING_INT) && |
| 1913 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1914 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1915 | spin_unlock_irq(&phba->hbalock); |
| 1916 | return -EINVAL; |
| 1917 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1918 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1919 | writel(creg_val, phba->HCregaddr); |
| 1920 | readl(phba->HCregaddr); /* flush */ |
| 1921 | |
| 1922 | lpfc_poll_start_timer(phba); |
| 1923 | } |
| 1924 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1925 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1926 | return -EINVAL; |
| 1927 | } |
| 1928 | |
| 1929 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1930 | (old_val & DISABLE_FCP_RING_INT)) |
| 1931 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1932 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1933 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1934 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1935 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1936 | spin_unlock_irq(&phba->hbalock); |
| 1937 | return -EINVAL; |
| 1938 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1939 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1940 | writel(creg_val, phba->HCregaddr); |
| 1941 | readl(phba->HCregaddr); /* flush */ |
| 1942 | } |
| 1943 | |
| 1944 | phba->cfg_poll = val; |
| 1945 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1946 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1947 | |
| 1948 | return strlen(buf); |
| 1949 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1950 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1951 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1952 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1953 | * @dev: class unused variable. |
| 1954 | * @attr: device attribute, not used. |
| 1955 | * @buf: on return contains the module description text. |
| 1956 | * |
| 1957 | * Returns: size of formatted string. |
| 1958 | **/ |
| 1959 | static ssize_t |
| 1960 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1961 | char *buf) |
| 1962 | { |
| 1963 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1964 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1965 | struct lpfc_hba *phba = vport->phba; |
| 1966 | |
| 1967 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1968 | } |
| 1969 | |
| 1970 | /** |
| 1971 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1972 | * @dev: class unused variable. |
| 1973 | * @attr: device attribute, not used. |
| 1974 | * @buf: on return contains the module description text. |
| 1975 | * |
| 1976 | * Returns: size of formatted string. |
| 1977 | **/ |
| 1978 | static ssize_t |
| 1979 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1980 | char *buf) |
| 1981 | { |
| 1982 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1983 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1984 | struct lpfc_hba *phba = vport->phba; |
| 1985 | |
| 1986 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1987 | } |
| 1988 | |
| 1989 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1990 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1991 | * @dev: class converted to a Scsi_host structure. |
| 1992 | * @attr: device attribute, not used. |
| 1993 | * @buf: on return contains the formatted text. |
| 1994 | * |
| 1995 | * Returns: size of formatted string. |
| 1996 | **/ |
| 1997 | static ssize_t |
| 1998 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1999 | char *buf) |
| 2000 | { |
| 2001 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2002 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2003 | struct lpfc_hba *phba = vport->phba; |
| 2004 | |
| 2005 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 2006 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 2007 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 2008 | "" : "Not "); |
| 2009 | } |
| 2010 | |
| 2011 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2012 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 2013 | * @dev: class converted to a Scsi_host structure. |
| 2014 | * @attr: device attribute, not used. |
| 2015 | * @buf: on return contains the formatted support level. |
| 2016 | * |
| 2017 | * Description: |
| 2018 | * Returns the maximum number of virtual functions a physical function can |
| 2019 | * support, 0 will be returned if called on virtual function. |
| 2020 | * |
| 2021 | * Returns: size of formatted string. |
| 2022 | **/ |
| 2023 | static ssize_t |
| 2024 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 2025 | struct device_attribute *attr, |
| 2026 | char *buf) |
| 2027 | { |
| 2028 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2029 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2030 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2031 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2032 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2033 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 2034 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2035 | } |
| 2036 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2037 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 2038 | { |
| 2039 | return val >= min && val <= max; |
| 2040 | } |
| 2041 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2042 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2043 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 2044 | * @phba: pointer the the adapter structure. |
| 2045 | * @val: integer attribute value. |
| 2046 | * |
| 2047 | * Description: |
| 2048 | * Validates the min and max values then sets the |
| 2049 | * adapter config field if in the valid range. prints error message |
| 2050 | * and does not set the parameter if invalid. |
| 2051 | * |
| 2052 | * Returns: |
| 2053 | * zero on success |
| 2054 | * -EINVAL if val is invalid |
| 2055 | */ |
| 2056 | static ssize_t |
| 2057 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 2058 | { |
| 2059 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 2060 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2061 | "3068 %s_enable_bbcr changed from %d to %d\n", |
| 2062 | LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val); |
| 2063 | phba->cfg_enable_bbcr = val; |
| 2064 | return 0; |
| 2065 | } |
| 2066 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2067 | "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n", |
| 2068 | LPFC_DRIVER_NAME, val); |
| 2069 | return -EINVAL; |
| 2070 | } |
| 2071 | |
| 2072 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2073 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2074 | * |
| 2075 | * Description: |
| 2076 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2077 | * into a function with the name lpfc_hba_queue_depth_show. |
| 2078 | * |
| 2079 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 2080 | * @dev: class device that is converted into a Scsi_host. |
| 2081 | * @attr: device attribute, not used. |
| 2082 | * @buf: on return contains the attribute value in decimal. |
| 2083 | * |
| 2084 | * Returns: size of formatted string. |
| 2085 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | #define lpfc_param_show(attr) \ |
| 2087 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2088 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2089 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2090 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2091 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2092 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2093 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2094 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 2095 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -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_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2100 | * |
| 2101 | * Description: |
| 2102 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2103 | * into a function with the name lpfc_hba_queue_depth_show |
| 2104 | * |
| 2105 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 2106 | * @dev: class device that is converted into a Scsi_host. |
| 2107 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2108 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2109 | * |
| 2110 | * Returns: size of formatted string. |
| 2111 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2112 | #define lpfc_param_hex_show(attr) \ |
| 2113 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2114 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2115 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2116 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2117 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2118 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2119 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2120 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2121 | val = phba->cfg_##attr;\ |
| 2122 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 2123 | phba->cfg_##attr);\ |
| 2124 | } |
| 2125 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2126 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 2127 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2128 | * |
| 2129 | * Description: |
| 2130 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2131 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2132 | * takes a default argument, a minimum and maximum argument. |
| 2133 | * |
| 2134 | * lpfc_##attr##_init: Initializes an attribute. |
| 2135 | * @phba: pointer the the adapter structure. |
| 2136 | * @val: integer attribute value. |
| 2137 | * |
| 2138 | * Validates the min and max values then sets the adapter config field |
| 2139 | * accordingly, or uses the default if out of range and prints an error message. |
| 2140 | * |
| 2141 | * Returns: |
| 2142 | * zero on success |
| 2143 | * -EINVAL if default used |
| 2144 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2145 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 2146 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2147 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2148 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2149 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2150 | phba->cfg_##attr = val;\ |
| 2151 | return 0;\ |
| 2152 | }\ |
| 2153 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2154 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2155 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2156 | phba->cfg_##attr = default;\ |
| 2157 | return -EINVAL;\ |
| 2158 | } |
| 2159 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2160 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2161 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2162 | * |
| 2163 | * Description: |
| 2164 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2165 | * into a function with the name lpfc_hba_queue_depth_set |
| 2166 | * |
| 2167 | * lpfc_##attr##_set: Sets an attribute value. |
| 2168 | * @phba: pointer the the adapter structure. |
| 2169 | * @val: integer attribute value. |
| 2170 | * |
| 2171 | * Description: |
| 2172 | * Validates the min and max values then sets the |
| 2173 | * adapter config field if in the valid range. prints error message |
| 2174 | * and does not set the parameter if invalid. |
| 2175 | * |
| 2176 | * Returns: |
| 2177 | * zero on success |
| 2178 | * -EINVAL if val is invalid |
| 2179 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2180 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2181 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2182 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2183 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2184 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2185 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2186 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2187 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2188 | phba->cfg_##attr = val;\ |
| 2189 | return 0;\ |
| 2190 | }\ |
| 2191 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2192 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2193 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2194 | return -EINVAL;\ |
| 2195 | } |
| 2196 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2197 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2198 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2199 | * |
| 2200 | * Description: |
| 2201 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2202 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2203 | * |
| 2204 | * lpfc_##attr##_store: Set an sttribute value. |
| 2205 | * @dev: class device that is converted into a Scsi_host. |
| 2206 | * @attr: device attribute, not used. |
| 2207 | * @buf: contains the attribute value in ascii. |
| 2208 | * @count: not used. |
| 2209 | * |
| 2210 | * Description: |
| 2211 | * Convert the ascii text number to an integer, then |
| 2212 | * use the lpfc_##attr##_set function to set the value. |
| 2213 | * |
| 2214 | * Returns: |
| 2215 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2216 | * length of buffer upon success. |
| 2217 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2218 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2219 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2220 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2221 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2222 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2223 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2224 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2225 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2226 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2227 | if (!isdigit(buf[0]))\ |
| 2228 | return -EINVAL;\ |
| 2229 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2230 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2231 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2232 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2233 | else \ |
| 2234 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2235 | } |
| 2236 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2237 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2238 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2239 | * |
| 2240 | * Description: |
| 2241 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2242 | * into a function with the name lpfc_hba_queue_depth_show |
| 2243 | * |
| 2244 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2245 | * @dev: class device that is converted into a Scsi_host. |
| 2246 | * @attr: device attribute, not used. |
| 2247 | * @buf: on return contains the attribute value in decimal. |
| 2248 | * |
| 2249 | * Returns: length of formatted string. |
| 2250 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2251 | #define lpfc_vport_param_show(attr) \ |
| 2252 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2253 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2254 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2255 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2256 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2257 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2258 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 2259 | } |
| 2260 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2261 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2262 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2263 | * |
| 2264 | * Description: |
| 2265 | * Macro that given an attr e.g. |
| 2266 | * hba_queue_depth expands into a function with the name |
| 2267 | * lpfc_hba_queue_depth_show |
| 2268 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2269 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2270 | * @dev: class device that is converted into a Scsi_host. |
| 2271 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2272 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2273 | * |
| 2274 | * Returns: length of formatted string. |
| 2275 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2276 | #define lpfc_vport_param_hex_show(attr) \ |
| 2277 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2278 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2279 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2280 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2281 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2282 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2283 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 2284 | } |
| 2285 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2286 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2287 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2288 | * |
| 2289 | * Description: |
| 2290 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2291 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2292 | * takes a default argument, a minimum and maximum argument. |
| 2293 | * |
| 2294 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2295 | * adapter config field accordingly, or uses the default if out of range |
| 2296 | * and prints an error message. |
| 2297 | * @phba: pointer the the adapter structure. |
| 2298 | * @val: integer attribute value. |
| 2299 | * |
| 2300 | * Returns: |
| 2301 | * zero on success |
| 2302 | * -EINVAL if default used |
| 2303 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2304 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2305 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2306 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2307 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2308 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2309 | vport->cfg_##attr = val;\ |
| 2310 | return 0;\ |
| 2311 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2312 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2313 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2314 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2315 | vport->cfg_##attr = default;\ |
| 2316 | return -EINVAL;\ |
| 2317 | } |
| 2318 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2319 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2320 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2321 | * |
| 2322 | * Description: |
| 2323 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2324 | * into a function with the name lpfc_hba_queue_depth_set |
| 2325 | * |
| 2326 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2327 | * adapter config field if in the valid range. prints error message |
| 2328 | * and does not set the parameter if invalid. |
| 2329 | * @phba: pointer the the adapter structure. |
| 2330 | * @val: integer attribute value. |
| 2331 | * |
| 2332 | * Returns: |
| 2333 | * zero on success |
| 2334 | * -EINVAL if val is invalid |
| 2335 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2336 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2337 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2338 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2339 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2340 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2341 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2342 | "3053 lpfc_" #attr \ |
| 2343 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2344 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2345 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2346 | vport->cfg_##attr = val;\ |
| 2347 | return 0;\ |
| 2348 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2349 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2350 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2351 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2352 | return -EINVAL;\ |
| 2353 | } |
| 2354 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2355 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2356 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2357 | * |
| 2358 | * Description: |
| 2359 | * Macro that given an attr e.g. hba_queue_depth |
| 2360 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2361 | * |
| 2362 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2363 | * use the lpfc_##attr##_set function to set the value. |
| 2364 | * @cdev: class device that is converted into a Scsi_host. |
| 2365 | * @buf: contains the attribute value in decimal. |
| 2366 | * @count: not used. |
| 2367 | * |
| 2368 | * Returns: |
| 2369 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2370 | * length of buffer upon success. |
| 2371 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2372 | #define lpfc_vport_param_store(attr) \ |
| 2373 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2374 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2375 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2376 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2377 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2378 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2379 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2380 | if (!isdigit(buf[0]))\ |
| 2381 | return -EINVAL;\ |
| 2382 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2383 | return -EINVAL;\ |
| 2384 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2385 | return strlen(buf);\ |
| 2386 | else \ |
| 2387 | return -EINVAL;\ |
| 2388 | } |
| 2389 | |
| 2390 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2391 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2392 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2393 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2394 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2395 | 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] | 2396 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2397 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2398 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2399 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2400 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2401 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2402 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2403 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2404 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2405 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2406 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2407 | lpfc_option_rom_version_show, NULL); |
| 2408 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2409 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2410 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2411 | 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] | 2412 | static DEVICE_ATTR_RO(lpfc_drvr_version); |
| 2413 | static DEVICE_ATTR_RO(lpfc_enable_fip); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2414 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2415 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2416 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2417 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2418 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2419 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2420 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2421 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2422 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2423 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2424 | static DEVICE_ATTR_RO(lpfc_temp_sensor); |
| 2425 | static DEVICE_ATTR_RO(lpfc_fips_level); |
| 2426 | static DEVICE_ATTR_RO(lpfc_fips_rev); |
| 2427 | static DEVICE_ATTR_RO(lpfc_dss); |
| 2428 | static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2429 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2430 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2431 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2432 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2433 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2434 | #define WWN_SZ 8 |
| 2435 | /** |
| 2436 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2437 | * @buf: WWN string. |
| 2438 | * @cnt: Length of string. |
| 2439 | * @wwn: Array to receive converted wwn value. |
| 2440 | * |
| 2441 | * Returns: |
| 2442 | * -EINVAL if the buffer does not contain a valid wwn |
| 2443 | * 0 success |
| 2444 | **/ |
| 2445 | static size_t |
| 2446 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2447 | { |
| 2448 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2449 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2450 | /* Count may include a LF at end of string */ |
| 2451 | if (buf[cnt-1] == '\n') |
| 2452 | cnt--; |
| 2453 | |
| 2454 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2455 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2456 | return -EINVAL; |
| 2457 | |
| 2458 | memset(wwn, 0, WWN_SZ); |
| 2459 | |
| 2460 | /* Validate and store the new name */ |
| 2461 | for (i = 0, j = 0; i < 16; i++) { |
| 2462 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2463 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2464 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2465 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2466 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2467 | j = ((j << 4) | (*buf++ - '0')); |
| 2468 | else |
| 2469 | return -EINVAL; |
| 2470 | if (i % 2) { |
| 2471 | wwn[i/2] = j & 0xff; |
| 2472 | j = 0; |
| 2473 | } |
| 2474 | } |
| 2475 | return 0; |
| 2476 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2477 | /** |
| 2478 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2479 | * @dev: class device that is converted into a Scsi_host. |
| 2480 | * @attr: device attribute, not used. |
| 2481 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2482 | * @count: must be size of lpfc_soft_wwn_key. |
| 2483 | * |
| 2484 | * Returns: |
| 2485 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2486 | * length of buf indicates success |
| 2487 | **/ |
| 2488 | static ssize_t |
| 2489 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2490 | const char *buf, size_t count) |
| 2491 | { |
| 2492 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2493 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2494 | struct lpfc_hba *phba = vport->phba; |
| 2495 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2496 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2497 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2498 | |
| 2499 | /* |
| 2500 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2501 | * We require that the user write a specific key to enable |
| 2502 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2503 | * is written, the enable key resets. If further updates are |
| 2504 | * desired, the key must be written again to re-enable the |
| 2505 | * attribute. |
| 2506 | * |
| 2507 | * The "key" is not secret - it is a hardcoded string shown |
| 2508 | * here. The intent is to protect against the random user or |
| 2509 | * application that is just writing attributes. |
| 2510 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2511 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2512 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2513 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2514 | " be enabled: fawwpn is enabled\n"); |
| 2515 | return -EINVAL; |
| 2516 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2517 | |
| 2518 | /* count may include a LF at end of string */ |
| 2519 | if (buf[cnt-1] == '\n') |
| 2520 | cnt--; |
| 2521 | |
| 2522 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2523 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2524 | return -EINVAL; |
| 2525 | |
| 2526 | phba->soft_wwn_enable = 1; |
| 2527 | |
| 2528 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2529 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2530 | phba->brd_no); |
| 2531 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2532 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2533 | |
| 2534 | return count; |
| 2535 | } |
Joe Perches | 6cbaefb | 2017-12-19 10:15:09 -0800 | [diff] [blame] | 2536 | static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2537 | |
| 2538 | /** |
| 2539 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2540 | * @dev: class device that is converted into a Scsi_host. |
| 2541 | * @attr: device attribute, not used. |
| 2542 | * @buf: on return contains the wwpn in hexadecimal. |
| 2543 | * |
| 2544 | * Returns: size of formatted string. |
| 2545 | **/ |
| 2546 | static ssize_t |
| 2547 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2548 | char *buf) |
| 2549 | { |
| 2550 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2551 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2552 | struct lpfc_hba *phba = vport->phba; |
| 2553 | |
| 2554 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2555 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2556 | } |
| 2557 | |
| 2558 | /** |
| 2559 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2560 | * @dev class device that is converted into a Scsi_host. |
| 2561 | * @attr: device attribute, not used. |
| 2562 | * @buf: contains the wwpn in hexadecimal. |
| 2563 | * @count: number of wwpn bytes in buf |
| 2564 | * |
| 2565 | * Returns: |
| 2566 | * -EACCES hba reset not enabled, adapter over temp |
| 2567 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2568 | * -EIO error taking adapter offline or online |
| 2569 | * value of count on success |
| 2570 | **/ |
| 2571 | static ssize_t |
| 2572 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2573 | const char *buf, size_t count) |
| 2574 | { |
| 2575 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2576 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2577 | struct lpfc_hba *phba = vport->phba; |
| 2578 | struct completion online_compl; |
| 2579 | int stat1 = 0, stat2 = 0; |
| 2580 | unsigned int cnt = count; |
| 2581 | u8 wwpn[WWN_SZ]; |
| 2582 | int rc; |
| 2583 | |
| 2584 | if (!phba->cfg_enable_hba_reset) |
| 2585 | return -EACCES; |
| 2586 | spin_lock_irq(&phba->hbalock); |
| 2587 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2588 | spin_unlock_irq(&phba->hbalock); |
| 2589 | return -EACCES; |
| 2590 | } |
| 2591 | spin_unlock_irq(&phba->hbalock); |
| 2592 | /* count may include a LF at end of string */ |
| 2593 | if (buf[cnt-1] == '\n') |
| 2594 | cnt--; |
| 2595 | |
| 2596 | if (!phba->soft_wwn_enable) |
| 2597 | return -EINVAL; |
| 2598 | |
| 2599 | /* lock setting wwpn, wwnn down */ |
| 2600 | phba->soft_wwn_enable = 0; |
| 2601 | |
| 2602 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2603 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2604 | /* not able to set wwpn, unlock it */ |
| 2605 | phba->soft_wwn_enable = 1; |
| 2606 | return rc; |
| 2607 | } |
| 2608 | |
| 2609 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2610 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2611 | if (phba->cfg_soft_wwnn) |
| 2612 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2613 | |
| 2614 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2615 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2616 | |
| 2617 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2618 | if (stat1) |
| 2619 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2620 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2621 | "reinit adapter - %d\n", stat1); |
| 2622 | init_completion(&online_compl); |
| 2623 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2624 | LPFC_EVT_ONLINE); |
| 2625 | if (rc == 0) |
| 2626 | return -ENOMEM; |
| 2627 | |
| 2628 | wait_for_completion(&online_compl); |
| 2629 | if (stat2) |
| 2630 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2631 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2632 | "reinit adapter - %d\n", stat2); |
| 2633 | return (stat1 || stat2) ? -EIO : count; |
| 2634 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2635 | static DEVICE_ATTR_RW(lpfc_soft_wwpn); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2636 | |
| 2637 | /** |
| 2638 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2639 | * @dev: class device that is converted into a Scsi_host. |
| 2640 | * @attr: device attribute, not used. |
| 2641 | * @buf: on return contains the wwnn in hexadecimal. |
| 2642 | * |
| 2643 | * Returns: size of formatted string. |
| 2644 | **/ |
| 2645 | static ssize_t |
| 2646 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2647 | char *buf) |
| 2648 | { |
| 2649 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2650 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2651 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2652 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2653 | } |
| 2654 | |
| 2655 | /** |
| 2656 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2657 | * @cdev: class device that is converted into a Scsi_host. |
| 2658 | * @buf: contains the ww node name in hexadecimal. |
| 2659 | * @count: number of wwnn bytes in buf. |
| 2660 | * |
| 2661 | * Returns: |
| 2662 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2663 | * value of count on success |
| 2664 | **/ |
| 2665 | static ssize_t |
| 2666 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2667 | const char *buf, size_t count) |
| 2668 | { |
| 2669 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2670 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2671 | unsigned int cnt = count; |
| 2672 | u8 wwnn[WWN_SZ]; |
| 2673 | int rc; |
| 2674 | |
| 2675 | /* count may include a LF at end of string */ |
| 2676 | if (buf[cnt-1] == '\n') |
| 2677 | cnt--; |
| 2678 | |
| 2679 | if (!phba->soft_wwn_enable) |
| 2680 | return -EINVAL; |
| 2681 | |
| 2682 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2683 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2684 | /* Allow wwnn to be set many times, as long as the enable |
| 2685 | * is set. However, once the wwpn is set, everything locks. |
| 2686 | */ |
| 2687 | return rc; |
| 2688 | } |
| 2689 | |
| 2690 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2691 | |
| 2692 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2693 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2694 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2695 | |
| 2696 | return count; |
| 2697 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2698 | static DEVICE_ATTR_RW(lpfc_soft_wwnn); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2699 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2700 | /** |
| 2701 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2702 | * Optimized Access Storage (OAS) operations. |
| 2703 | * @dev: class device that is converted into a Scsi_host. |
| 2704 | * @attr: device attribute, not used. |
| 2705 | * @buf: buffer for passing information. |
| 2706 | * |
| 2707 | * Returns: |
| 2708 | * value of count |
| 2709 | **/ |
| 2710 | static ssize_t |
| 2711 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2712 | char *buf) |
| 2713 | { |
| 2714 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2715 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2716 | |
| 2717 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2718 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2719 | } |
| 2720 | |
| 2721 | /** |
| 2722 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2723 | * Optimized Access Storage (OAS) operations. |
| 2724 | * @dev: class device that is converted into a Scsi_host. |
| 2725 | * @attr: device attribute, not used. |
| 2726 | * @buf: buffer for passing information. |
| 2727 | * @count: Size of the data buffer. |
| 2728 | * |
| 2729 | * Returns: |
| 2730 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2731 | * -EPERM oas is not supported by hba |
| 2732 | * value of count on success |
| 2733 | **/ |
| 2734 | static ssize_t |
| 2735 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2736 | const char *buf, size_t count) |
| 2737 | { |
| 2738 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2739 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2740 | unsigned int cnt = count; |
| 2741 | uint8_t wwpn[WWN_SZ]; |
| 2742 | int rc; |
| 2743 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2744 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2745 | return -EPERM; |
| 2746 | |
| 2747 | /* count may include a LF at end of string */ |
| 2748 | if (buf[cnt-1] == '\n') |
| 2749 | cnt--; |
| 2750 | |
| 2751 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2752 | if (rc) |
| 2753 | return rc; |
| 2754 | |
| 2755 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2756 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2757 | if (wwn_to_u64(wwpn) == 0) |
| 2758 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2759 | else |
| 2760 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2761 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2762 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2763 | return count; |
| 2764 | } |
| 2765 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2766 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2767 | |
| 2768 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2769 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2770 | * Optimized Access Storage (OAS) operations. |
| 2771 | * @dev: class device that is converted into a Scsi_host. |
| 2772 | * @attr: device attribute, not used. |
| 2773 | * @buf: buffer for passing information. |
| 2774 | * |
| 2775 | * Returns: |
| 2776 | * value of count |
| 2777 | **/ |
| 2778 | static ssize_t |
| 2779 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2780 | char *buf) |
| 2781 | { |
| 2782 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2783 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2784 | |
| 2785 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2786 | } |
| 2787 | |
| 2788 | /** |
| 2789 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2790 | * Optimized Access Storage (OAS) operations. |
| 2791 | * @dev: class device that is converted into a Scsi_host. |
| 2792 | * @attr: device attribute, not used. |
| 2793 | * @buf: buffer for passing information. |
| 2794 | * @count: Size of the data buffer. |
| 2795 | * |
| 2796 | * Returns: |
| 2797 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2798 | * -EPERM oas is not supported by hba |
| 2799 | * value of count on success |
| 2800 | **/ |
| 2801 | static ssize_t |
| 2802 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2803 | const char *buf, size_t count) |
| 2804 | { |
| 2805 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2806 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2807 | unsigned int cnt = count; |
| 2808 | unsigned long val; |
| 2809 | int ret; |
| 2810 | |
| 2811 | if (!phba->cfg_fof) |
| 2812 | return -EPERM; |
| 2813 | |
| 2814 | /* count may include a LF at end of string */ |
| 2815 | if (buf[cnt-1] == '\n') |
| 2816 | cnt--; |
| 2817 | |
| 2818 | ret = kstrtoul(buf, 0, &val); |
| 2819 | if (ret || (val > 0x7f)) |
| 2820 | return -EINVAL; |
| 2821 | |
| 2822 | if (val) |
| 2823 | phba->cfg_oas_priority = (uint8_t)val; |
| 2824 | else |
| 2825 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2826 | return count; |
| 2827 | } |
| 2828 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2829 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2830 | |
| 2831 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2832 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2833 | * for Optimized Access Storage (OAS) operations. |
| 2834 | * @dev: class device that is converted into a Scsi_host. |
| 2835 | * @attr: device attribute, not used. |
| 2836 | * @buf: buffer for passing information. |
| 2837 | * |
| 2838 | * Returns: |
| 2839 | * value of count on success |
| 2840 | **/ |
| 2841 | static ssize_t |
| 2842 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2843 | char *buf) |
| 2844 | { |
| 2845 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2846 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2847 | |
| 2848 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2849 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2850 | } |
| 2851 | |
| 2852 | /** |
| 2853 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2854 | * for Optimized Access Storage (OAS) operations. |
| 2855 | * @dev: class device that is converted into a Scsi_host. |
| 2856 | * @attr: device attribute, not used. |
| 2857 | * @buf: buffer for passing information. |
| 2858 | * @count: Size of the data buffer. |
| 2859 | * |
| 2860 | * Returns: |
| 2861 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2862 | * -EPERM oas is not supported by hba |
| 2863 | * value of count on success |
| 2864 | **/ |
| 2865 | static ssize_t |
| 2866 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2867 | const char *buf, size_t count) |
| 2868 | { |
| 2869 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2870 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2871 | unsigned int cnt = count; |
| 2872 | uint8_t wwpn[WWN_SZ]; |
| 2873 | int rc; |
| 2874 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2875 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2876 | return -EPERM; |
| 2877 | |
| 2878 | /* count may include a LF at end of string */ |
| 2879 | if (buf[cnt-1] == '\n') |
| 2880 | cnt--; |
| 2881 | |
| 2882 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2883 | if (rc) |
| 2884 | return rc; |
| 2885 | |
| 2886 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2887 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2888 | if (wwn_to_u64(wwpn) == 0) |
| 2889 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2890 | else |
| 2891 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2892 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2893 | if (phba->cfg_oas_priority == 0) |
| 2894 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2895 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2896 | return count; |
| 2897 | } |
| 2898 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2899 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2900 | |
| 2901 | /** |
| 2902 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2903 | * of whether luns will be enabled or disabled |
| 2904 | * for Optimized Access Storage (OAS) operations. |
| 2905 | * @dev: class device that is converted into a Scsi_host. |
| 2906 | * @attr: device attribute, not used. |
| 2907 | * @buf: buffer for passing information. |
| 2908 | * |
| 2909 | * Returns: |
| 2910 | * size of formatted string. |
| 2911 | **/ |
| 2912 | static ssize_t |
| 2913 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2914 | char *buf) |
| 2915 | { |
| 2916 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2917 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2918 | |
| 2919 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2920 | } |
| 2921 | |
| 2922 | /** |
| 2923 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2924 | * of whether luns will be enabled or disabled |
| 2925 | * for Optimized Access Storage (OAS) operations. |
| 2926 | * @dev: class device that is converted into a Scsi_host. |
| 2927 | * @attr: device attribute, not used. |
| 2928 | * @buf: buffer for passing information. |
| 2929 | * @count: Size of the data buffer. |
| 2930 | * |
| 2931 | * Returns: |
| 2932 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2933 | * -EPERM oas is not supported by hba |
| 2934 | * value of count on success |
| 2935 | **/ |
| 2936 | static ssize_t |
| 2937 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2938 | const char *buf, size_t count) |
| 2939 | { |
| 2940 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2941 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2942 | int val = 0; |
| 2943 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2944 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2945 | return -EPERM; |
| 2946 | |
| 2947 | if (!isdigit(buf[0])) |
| 2948 | return -EINVAL; |
| 2949 | |
| 2950 | if (sscanf(buf, "%i", &val) != 1) |
| 2951 | return -EINVAL; |
| 2952 | |
| 2953 | if ((val != 0) && (val != 1)) |
| 2954 | return -EINVAL; |
| 2955 | |
| 2956 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2957 | return strlen(buf); |
| 2958 | } |
| 2959 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2960 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2961 | |
| 2962 | /** |
| 2963 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2964 | * Storage (OAS) lun returned by the |
| 2965 | * lpfc_oas_lun_show function. |
| 2966 | * @dev: class device that is converted into a Scsi_host. |
| 2967 | * @attr: device attribute, not used. |
| 2968 | * @buf: buffer for passing information. |
| 2969 | * |
| 2970 | * Returns: |
| 2971 | * size of formatted string. |
| 2972 | **/ |
| 2973 | static ssize_t |
| 2974 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2975 | char *buf) |
| 2976 | { |
| 2977 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2978 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2979 | |
| 2980 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2981 | return -EFAULT; |
| 2982 | |
| 2983 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2984 | } |
| 2985 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2986 | lpfc_oas_lun_status_show, NULL); |
| 2987 | |
| 2988 | |
| 2989 | /** |
| 2990 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2991 | * (OAS) operations. |
| 2992 | * @phba: lpfc_hba pointer. |
| 2993 | * @ndlp: pointer to fcp target node. |
| 2994 | * @lun: the fc lun for setting oas state. |
| 2995 | * @oas_state: the oas state to be set to the lun. |
| 2996 | * |
| 2997 | * Returns: |
| 2998 | * SUCCESS : 0 |
| 2999 | * -EPERM OAS is not enabled or not supported by this port. |
| 3000 | * |
| 3001 | */ |
| 3002 | static size_t |
| 3003 | 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] | 3004 | uint8_t tgt_wwpn[], uint64_t lun, |
| 3005 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3006 | { |
| 3007 | |
| 3008 | int rc = 0; |
| 3009 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3010 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3011 | return -EPERM; |
| 3012 | |
| 3013 | if (oas_state) { |
| 3014 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3015 | (struct lpfc_name *)tgt_wwpn, |
| 3016 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3017 | rc = -ENOMEM; |
| 3018 | } else { |
| 3019 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3020 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3021 | } |
| 3022 | return rc; |
| 3023 | |
| 3024 | } |
| 3025 | |
| 3026 | /** |
| 3027 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 3028 | * Access Storage (OAS) operations. |
| 3029 | * @phba: lpfc_hba pointer. |
| 3030 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 3031 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 3032 | * @lun_status: status of the lun returned lun |
| 3033 | * |
| 3034 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 3035 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 3036 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 3037 | * |
| 3038 | * Return: |
| 3039 | * lun that is OAS enabled for the vport/target |
| 3040 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 3041 | */ |
| 3042 | static uint64_t |
| 3043 | 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] | 3044 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 3045 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3046 | { |
| 3047 | uint64_t found_lun; |
| 3048 | |
| 3049 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 3050 | return NOT_OAS_ENABLED_LUN; |
| 3051 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 3052 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 3053 | (struct lpfc_name *) |
| 3054 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 3055 | &phba->sli4_hba.oas_next_lun, |
| 3056 | (struct lpfc_name *)vpt_wwpn, |
| 3057 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3058 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3059 | return found_lun; |
| 3060 | else |
| 3061 | return NOT_OAS_ENABLED_LUN; |
| 3062 | } |
| 3063 | |
| 3064 | /** |
| 3065 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 3066 | * @phba: lpfc_hba pointer. |
| 3067 | * @vpt_wwpn: vport wwpn by reference. |
| 3068 | * @tgt_wwpn: target wwpn by reference. |
| 3069 | * @lun: the fc lun for setting oas state. |
| 3070 | * @oas_state: the oas state to be set to the oas_lun. |
| 3071 | * |
| 3072 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 3073 | * a lun for OAS operations. |
| 3074 | * |
| 3075 | * Return: |
| 3076 | * SUCCESS: 0 |
| 3077 | * -ENOMEM: failed to enable an lun for OAS operations |
| 3078 | * -EPERM: OAS is not enabled |
| 3079 | */ |
| 3080 | static ssize_t |
| 3081 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 3082 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3083 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3084 | { |
| 3085 | |
| 3086 | int rc; |
| 3087 | |
| 3088 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3089 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3090 | return rc; |
| 3091 | } |
| 3092 | |
| 3093 | /** |
| 3094 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 3095 | * @dev: class device that is converted into a Scsi_host. |
| 3096 | * @attr: device attribute, not used. |
| 3097 | * @buf: buffer for passing information. |
| 3098 | * |
| 3099 | * This routine returns a lun enabled for OAS each time the function |
| 3100 | * is called. |
| 3101 | * |
| 3102 | * Returns: |
| 3103 | * SUCCESS: size of formatted string. |
| 3104 | * -EFAULT: target or vport wwpn was not set properly. |
| 3105 | * -EPERM: oas is not enabled. |
| 3106 | **/ |
| 3107 | static ssize_t |
| 3108 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 3109 | char *buf) |
| 3110 | { |
| 3111 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3112 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3113 | |
| 3114 | uint64_t oas_lun; |
| 3115 | int len = 0; |
| 3116 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3117 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3118 | return -EPERM; |
| 3119 | |
| 3120 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3121 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 3122 | return -EFAULT; |
| 3123 | |
| 3124 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3125 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 3126 | return -EFAULT; |
| 3127 | |
| 3128 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 3129 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3130 | &phba->cfg_oas_lun_status, |
| 3131 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3132 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 3133 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 3134 | |
| 3135 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 3136 | |
| 3137 | return len; |
| 3138 | } |
| 3139 | |
| 3140 | /** |
| 3141 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 3142 | * @dev: class device that is converted into a Scsi_host. |
| 3143 | * @attr: device attribute, not used. |
| 3144 | * @buf: buffer for passing information. |
| 3145 | * |
| 3146 | * This function sets the OAS state for lun. Before this function is called, |
| 3147 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3148 | * |
| 3149 | * Returns: |
| 3150 | * SUCCESS: size of formatted string. |
| 3151 | * -EFAULT: target or vport wwpn was not set properly. |
| 3152 | * -EPERM: oas is not enabled. |
| 3153 | * size of formatted string. |
| 3154 | **/ |
| 3155 | static ssize_t |
| 3156 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3157 | const char *buf, size_t count) |
| 3158 | { |
| 3159 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3160 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3161 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3162 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3163 | ssize_t rc; |
| 3164 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3165 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3166 | return -EPERM; |
| 3167 | |
| 3168 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3169 | return -EFAULT; |
| 3170 | |
| 3171 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3172 | return -EFAULT; |
| 3173 | |
| 3174 | if (!isdigit(buf[0])) |
| 3175 | return -EINVAL; |
| 3176 | |
| 3177 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3178 | return -EINVAL; |
| 3179 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3180 | pri = phba->cfg_oas_priority; |
| 3181 | if (pri == 0) |
| 3182 | pri = phba->cfg_XLanePriority; |
| 3183 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3184 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3185 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3186 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3187 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3188 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3189 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3190 | |
| 3191 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3192 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3193 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3194 | if (rc) |
| 3195 | return rc; |
| 3196 | |
| 3197 | return count; |
| 3198 | } |
| 3199 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3200 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3201 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3202 | int lpfc_enable_nvmet_cnt; |
| 3203 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3204 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3205 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3206 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3207 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3208 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3209 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3210 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3211 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3212 | " 0 - none," |
| 3213 | " 1 - poll with interrupts enabled" |
| 3214 | " 3 - poll and disable FCP ring interrupts"); |
| 3215 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3216 | static DEVICE_ATTR_RW(lpfc_poll); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3217 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3218 | int lpfc_no_hba_reset_cnt; |
| 3219 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3220 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3221 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3222 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3223 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3224 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3225 | "SLI mode selector:" |
| 3226 | " 0 - auto (SLI-3 if supported)," |
| 3227 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3228 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3229 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3230 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3231 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3232 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3233 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3234 | "FCF Fast failover=1 Priority failover=2"); |
| 3235 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3236 | /* |
| 3237 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3238 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3239 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3240 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3241 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3242 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3243 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3244 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3245 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3246 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3247 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3248 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3249 | # 0x2 = never bring up link |
| 3250 | # Default value is 0. |
| 3251 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3252 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3253 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3254 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3255 | /* |
| 3256 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3257 | # 1 - (1024) |
| 3258 | # 2 - (2048) |
| 3259 | # 3 - (3072) |
| 3260 | # 4 - (4096) |
| 3261 | # 5 - (5120) |
| 3262 | */ |
| 3263 | static ssize_t |
| 3264 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3265 | { |
| 3266 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3267 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3268 | |
| 3269 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 3270 | } |
| 3271 | |
| 3272 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3273 | lpfc_iocb_hw_show, NULL); |
| 3274 | static ssize_t |
| 3275 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3276 | { |
| 3277 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3278 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3279 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3280 | |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3281 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 3282 | pring ? pring->txq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3283 | } |
| 3284 | |
| 3285 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3286 | lpfc_txq_hw_show, NULL); |
| 3287 | static ssize_t |
| 3288 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3289 | char *buf) |
| 3290 | { |
| 3291 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3292 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3293 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3294 | |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3295 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 3296 | pring ? pring->txcmplq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3297 | } |
| 3298 | |
| 3299 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3300 | lpfc_txcmplq_hw_show, NULL); |
| 3301 | |
James Smart | 0d8c8ba | 2016-10-13 15:06:07 -0700 | [diff] [blame] | 3302 | LPFC_ATTR_R(iocb_cnt, 2, 1, 5, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3303 | "Number of IOCBs alloc for ELS, CT, and ABTS: 1k to 5k IOCBs"); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3304 | |
| 3305 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3306 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3307 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3308 | */ |
| 3309 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3310 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3311 | module_param(lpfc_nodev_tmo, int, 0); |
| 3312 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3313 | "Seconds driver will hold I/O waiting " |
| 3314 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3315 | |
| 3316 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3317 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3318 | * @dev: class converted to a Scsi_host structure. |
| 3319 | * @attr: device attribute, not used. |
| 3320 | * @buf: on return contains the dev loss timeout in decimal. |
| 3321 | * |
| 3322 | * Returns: size of formatted string. |
| 3323 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3324 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3325 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3326 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3327 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3328 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3329 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3330 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3331 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3332 | } |
| 3333 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3334 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3335 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3336 | * @vport: lpfc vport structure pointer. |
| 3337 | * @val: contains the nodev timeout value. |
| 3338 | * |
| 3339 | * Description: |
| 3340 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3341 | * a kernel error message is printed and zero is returned. |
| 3342 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3343 | * Otherwise nodev tmo is set to the default value. |
| 3344 | * |
| 3345 | * Returns: |
| 3346 | * zero if already set or if val is in range |
| 3347 | * -EINVAL val out of range |
| 3348 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3349 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3350 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3351 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3352 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3353 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3354 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3355 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3356 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3357 | "parameter because lpfc_devloss_tmo " |
| 3358 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3359 | return 0; |
| 3360 | } |
| 3361 | |
| 3362 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3363 | vport->cfg_nodev_tmo = val; |
| 3364 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3365 | return 0; |
| 3366 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3367 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3368 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3369 | " %d, allowed range is [%d, %d]\n", |
| 3370 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3371 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3372 | return -EINVAL; |
| 3373 | } |
| 3374 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3375 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3376 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3377 | * @vport: lpfc vport structure pointer. |
| 3378 | * |
| 3379 | * Description: |
| 3380 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3381 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3382 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3383 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3384 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3385 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3386 | struct lpfc_nodelist *ndlp; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3387 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3388 | struct lpfc_nvme_rport *rport; |
| 3389 | #endif |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3390 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3391 | shost = lpfc_shost_from_vport(vport); |
| 3392 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3393 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3394 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3395 | continue; |
| 3396 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3397 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3398 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3399 | rport = lpfc_ndlp_get_nrport(ndlp); |
| 3400 | if (rport) |
| 3401 | nvme_fc_set_remoteport_devloss(rport->remoteport, |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3402 | vport->cfg_devloss_tmo); |
| 3403 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3404 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3405 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3406 | } |
| 3407 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3408 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3409 | * 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] | 3410 | * @vport: lpfc vport structure pointer. |
| 3411 | * @val: contains the tmo value. |
| 3412 | * |
| 3413 | * Description: |
| 3414 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3415 | * then a kernel error message is printed and zero is returned. |
| 3416 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3417 | * Otherwise nodev tmo is set to the default value. |
| 3418 | * |
| 3419 | * Returns: |
| 3420 | * zero if already set or if val is in range |
| 3421 | * -EINVAL val out of range |
| 3422 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3423 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3424 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3425 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3426 | if (vport->dev_loss_tmo_changed || |
| 3427 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3428 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3429 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3430 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3431 | return 0; |
| 3432 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3433 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3434 | vport->cfg_nodev_tmo = val; |
| 3435 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3436 | /* |
| 3437 | * For compat: set the fc_host dev loss so new rports |
| 3438 | * will get the value. |
| 3439 | */ |
| 3440 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3441 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3442 | return 0; |
| 3443 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3444 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3445 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3446 | "%d, allowed range is [%d, %d]\n", |
| 3447 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3448 | return -EINVAL; |
| 3449 | } |
| 3450 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3451 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3452 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3453 | static DEVICE_ATTR_RW(lpfc_nodev_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3454 | |
| 3455 | /* |
| 3456 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3457 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3458 | # value is 30. |
| 3459 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3460 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3461 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3462 | "Seconds driver will hold I/O waiting " |
| 3463 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3464 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3465 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3466 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3467 | |
| 3468 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3469 | * 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] | 3470 | * @vport: lpfc vport structure pointer. |
| 3471 | * @val: contains the tmo value. |
| 3472 | * |
| 3473 | * Description: |
| 3474 | * If val is in a valid range then set the vport nodev tmo, |
| 3475 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3476 | * Else a kernel error message is printed. |
| 3477 | * |
| 3478 | * Returns: |
| 3479 | * zero if val is in range |
| 3480 | * -EINVAL val out of range |
| 3481 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3482 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3483 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3484 | { |
| 3485 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3486 | vport->cfg_nodev_tmo = val; |
| 3487 | vport->cfg_devloss_tmo = val; |
| 3488 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3489 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3490 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3491 | return 0; |
| 3492 | } |
| 3493 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3494 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3495 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3496 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3497 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3498 | return -EINVAL; |
| 3499 | } |
| 3500 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3501 | lpfc_vport_param_store(devloss_tmo) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3502 | static DEVICE_ATTR_RW(lpfc_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3503 | |
| 3504 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3505 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3506 | * lpfc_suppress_rsp = 0 Disable |
| 3507 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3508 | * |
| 3509 | */ |
| 3510 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3511 | "Enable suppress rsp feature is firmware supports it"); |
| 3512 | |
| 3513 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3514 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3515 | * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3516 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3517 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3518 | * |
| 3519 | */ |
| 3520 | LPFC_ATTR_R(nvmet_mrq, |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3521 | LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3522 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3523 | |
| 3524 | /* |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 3525 | * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post |
| 3526 | * to each NVMET RQ. Range 64 to 2048, default is 512. |
| 3527 | */ |
| 3528 | LPFC_ATTR_R(nvmet_mrq_post, |
| 3529 | LPFC_NVMET_RQE_DEF_POST, LPFC_NVMET_RQE_MIN_POST, |
| 3530 | LPFC_NVMET_RQE_DEF_COUNT, |
| 3531 | "Specify number of RQ buffers to initially post"); |
| 3532 | |
| 3533 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3534 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3535 | * Supported Values: 1 - register just FCP |
| 3536 | * 3 - register both FCP and NVME |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3537 | * Supported values are [1,3]. Default value is 1 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3538 | */ |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3539 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3540 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3541 | "Enable FC4 Protocol support - FCP / NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3542 | |
| 3543 | /* |
| 3544 | * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME |
| 3545 | * This parameter is only used if: |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3546 | * lpfc_enable_fc4_type is 3 - register both FCP and NVME and |
| 3547 | * port is not configured for NVMET. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3548 | * |
| 3549 | * ELS/CT always get 10% of XRIs, up to a maximum of 250 |
| 3550 | * The remaining XRIs get split up based on lpfc_xri_split per port: |
| 3551 | * |
| 3552 | * Supported Values are in percentages |
| 3553 | * the xri_split value is the percentage the SCSI port will get. The remaining |
| 3554 | * percentage will go to NVME. |
| 3555 | */ |
| 3556 | LPFC_ATTR_R(xri_split, 50, 10, 90, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3557 | "Percentage of FCP XRI resources versus NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3558 | |
| 3559 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3560 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3561 | # deluged with LOTS of information. |
| 3562 | # 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] | 3563 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3564 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3565 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3566 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3567 | |
| 3568 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3569 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3570 | # objects that have been registered with the nameserver after login. |
| 3571 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3572 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3573 | "Deregister nameserver objects before LOGO"); |
| 3574 | |
| 3575 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3576 | # 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] | 3577 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3578 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3579 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3580 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3581 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3582 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3583 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3584 | |
| 3585 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3586 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3587 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3588 | */ |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 3589 | static uint lpfc_tgt_queue_depth = LPFC_MAX_TGT_QDEPTH; |
| 3590 | module_param(lpfc_tgt_queue_depth, uint, 0444); |
| 3591 | MODULE_PARM_DESC(lpfc_tgt_queue_depth, "Set max Target queue depth"); |
| 3592 | lpfc_vport_param_show(tgt_queue_depth); |
| 3593 | lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH, |
| 3594 | LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH); |
| 3595 | |
| 3596 | /** |
| 3597 | * lpfc_tgt_queue_depth_store: Sets an attribute value. |
| 3598 | * @phba: pointer the the adapter structure. |
| 3599 | * @val: integer attribute value. |
| 3600 | * |
| 3601 | * Description: Sets the parameter to the new value. |
| 3602 | * |
| 3603 | * Returns: |
| 3604 | * zero on success |
| 3605 | * -EINVAL if val is invalid |
| 3606 | */ |
| 3607 | static int |
| 3608 | lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val) |
| 3609 | { |
| 3610 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3611 | struct lpfc_nodelist *ndlp; |
| 3612 | |
| 3613 | if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH)) |
| 3614 | return -EINVAL; |
| 3615 | |
| 3616 | if (val == vport->cfg_tgt_queue_depth) |
| 3617 | return 0; |
| 3618 | |
| 3619 | spin_lock_irq(shost->host_lock); |
| 3620 | vport->cfg_tgt_queue_depth = val; |
| 3621 | |
| 3622 | /* Next loop thru nodelist and change cmd_qdepth */ |
| 3623 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
| 3624 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
| 3625 | |
| 3626 | spin_unlock_irq(shost->host_lock); |
| 3627 | return 0; |
| 3628 | } |
| 3629 | |
| 3630 | lpfc_vport_param_store(tgt_queue_depth); |
| 3631 | static DEVICE_ATTR_RW(lpfc_tgt_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3632 | |
| 3633 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3634 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3635 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3636 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3637 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3638 | # the hba_queue_depth. |
| 3639 | */ |
| 3640 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3641 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3642 | |
| 3643 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3644 | # peer_port_login: This parameter allows/prevents logins |
| 3645 | # between peer ports hosted on the same physical port. |
| 3646 | # When this parameter is set 0 peer ports of same physical port |
| 3647 | # are not allowed to login to each other. |
| 3648 | # When this parameter is set 1 peer ports of same physical port |
| 3649 | # are allowed to login to each other. |
| 3650 | # Default value of this parameter is 0. |
| 3651 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3652 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3653 | "Allow peer ports on the same physical port to login to each " |
| 3654 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3655 | |
| 3656 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3657 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3658 | # between Virtual Ports and remote initiators. |
| 3659 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3660 | # other initiators and will attempt to PLOGI all remote ports. |
| 3661 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3662 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3663 | # This parameter does not restrict to the physical port. |
| 3664 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3665 | # Default value of this parameter is 1. |
| 3666 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3667 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3668 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3669 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3670 | "Restrict virtual ports login to remote initiators."); |
| 3671 | lpfc_vport_param_show(restrict_login); |
| 3672 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3673 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3674 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3675 | * @vport: lpfc vport structure pointer. |
| 3676 | * @val: contains the restrict login value. |
| 3677 | * |
| 3678 | * Description: |
| 3679 | * If val is not in a valid range then log a kernel error message and set |
| 3680 | * the vport restrict login to one. |
| 3681 | * If the port type is physical clear the restrict login flag and return. |
| 3682 | * Else set the restrict login flag to val. |
| 3683 | * |
| 3684 | * Returns: |
| 3685 | * zero if val is in range |
| 3686 | * -EINVAL val out of range |
| 3687 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3688 | static int |
| 3689 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3690 | { |
| 3691 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3692 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3693 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3694 | "be set to %d, allowed range is [0, 1]\n", |
| 3695 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3696 | vport->cfg_restrict_login = 1; |
| 3697 | return -EINVAL; |
| 3698 | } |
| 3699 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3700 | vport->cfg_restrict_login = 0; |
| 3701 | return 0; |
| 3702 | } |
| 3703 | vport->cfg_restrict_login = val; |
| 3704 | return 0; |
| 3705 | } |
| 3706 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3707 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3708 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3709 | * @vport: lpfc vport structure pointer. |
| 3710 | * @val: contains the restrict login value. |
| 3711 | * |
| 3712 | * Description: |
| 3713 | * If val is not in a valid range then log a kernel error message and set |
| 3714 | * the vport restrict login to one. |
| 3715 | * If the port type is physical and the val is not zero log a kernel |
| 3716 | * error message, clear the restrict login flag and return zero. |
| 3717 | * Else set the restrict login flag to val. |
| 3718 | * |
| 3719 | * Returns: |
| 3720 | * zero if val is in range |
| 3721 | * -EINVAL val out of range |
| 3722 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3723 | static int |
| 3724 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3725 | { |
| 3726 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3727 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3728 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3729 | "be set to %d, allowed range is [0, 1]\n", |
| 3730 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3731 | vport->cfg_restrict_login = 1; |
| 3732 | return -EINVAL; |
| 3733 | } |
| 3734 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3735 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3736 | "0468 lpfc_restrict_login must be 0 for " |
| 3737 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3738 | vport->cfg_restrict_login = 0; |
| 3739 | return 0; |
| 3740 | } |
| 3741 | vport->cfg_restrict_login = val; |
| 3742 | return 0; |
| 3743 | } |
| 3744 | lpfc_vport_param_store(restrict_login); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3745 | static DEVICE_ATTR_RW(lpfc_restrict_login); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3746 | |
| 3747 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3748 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3749 | # From a protocol standpoint "select ID" usually means select the |
| 3750 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3751 | # annex" which contains a table that maps a "select ID" (a number |
| 3752 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3753 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3754 | # ALPA. |
| 3755 | # |
| 3756 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3757 | # cause the lpfc driver to use an inverted table, effectively |
| 3758 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3759 | # |
| 3760 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3761 | # and will not work across a fabric. Also this parameter will take |
| 3762 | # effect only in the case when ALPA map is not available.) |
| 3763 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3764 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3765 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3766 | |
| 3767 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3768 | # lpfc_topology: link topology for init link |
| 3769 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3770 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3771 | # 0x02 = attempt point-to-point mode only |
| 3772 | # 0x04 = attempt loop mode only |
| 3773 | # 0x06 = attempt point-to-point mode then loop |
| 3774 | # Set point-to-point mode if you want to run as an N_Port. |
| 3775 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3776 | # Default value is 0. |
| 3777 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3778 | LPFC_ATTR(topology, 0, 0, 6, |
| 3779 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3780 | |
| 3781 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3782 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3783 | * @phba: lpfc_hba pointer. |
| 3784 | * @val: topology value. |
| 3785 | * |
| 3786 | * Description: |
| 3787 | * If val is in a valid range then set the adapter's topology field and |
| 3788 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3789 | * |
| 3790 | * If the value is not in range log a kernel error message and return an error. |
| 3791 | * |
| 3792 | * Returns: |
| 3793 | * zero if val is in range and lip okay |
| 3794 | * non-zero return value from lpfc_issue_lip() |
| 3795 | * -EINVAL val out of range |
| 3796 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3797 | static ssize_t |
| 3798 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3799 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3800 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3801 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3802 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3803 | struct lpfc_hba *phba = vport->phba; |
| 3804 | int val = 0; |
| 3805 | int nolip = 0; |
| 3806 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3807 | int err; |
| 3808 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3809 | |
| 3810 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3811 | nolip = 1; |
| 3812 | val_buf = &buf[strlen("nolip ")]; |
| 3813 | } |
| 3814 | |
| 3815 | if (!isdigit(val_buf[0])) |
| 3816 | return -EINVAL; |
| 3817 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3818 | return -EINVAL; |
| 3819 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3820 | if (val >= 0 && val <= 6) { |
| 3821 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3822 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3823 | val == 4) { |
| 3824 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3825 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3826 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3827 | return -EINVAL; |
| 3828 | } |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3829 | if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && |
| 3830 | val == 4) { |
| 3831 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3832 | "3114 Loop mode not supported\n"); |
| 3833 | return -EINVAL; |
| 3834 | } |
| 3835 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3836 | if (nolip) |
| 3837 | return strlen(buf); |
| 3838 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3839 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3840 | "3054 lpfc_topology changed from %d to %d\n", |
| 3841 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3842 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3843 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3844 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3845 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3846 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3847 | return -EINVAL; |
| 3848 | } else |
| 3849 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3850 | } |
| 3851 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3852 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3853 | "allowed range is [0, 6]\n", |
| 3854 | phba->brd_no, val); |
| 3855 | return -EINVAL; |
| 3856 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3857 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3858 | lpfc_param_show(topology) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3859 | static DEVICE_ATTR_RW(lpfc_topology); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3860 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3861 | /** |
| 3862 | * lpfc_static_vport_show: Read callback function for |
| 3863 | * lpfc_static_vport sysfs file. |
| 3864 | * @dev: Pointer to class device object. |
| 3865 | * @attr: device attribute structure. |
| 3866 | * @buf: Data buffer. |
| 3867 | * |
| 3868 | * This function is the read call back function for |
| 3869 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3870 | * sysfs file report the mageability of the vport. |
| 3871 | **/ |
| 3872 | static ssize_t |
| 3873 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3874 | char *buf) |
| 3875 | { |
| 3876 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3877 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3878 | if (vport->vport_flag & STATIC_VPORT) |
| 3879 | sprintf(buf, "1\n"); |
| 3880 | else |
| 3881 | sprintf(buf, "0\n"); |
| 3882 | |
| 3883 | return strlen(buf); |
| 3884 | } |
| 3885 | |
| 3886 | /* |
| 3887 | * Sysfs attribute to control the statistical data collection. |
| 3888 | */ |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 3889 | static DEVICE_ATTR_RO(lpfc_static_vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3890 | |
| 3891 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3892 | * 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] | 3893 | * @dev: Pointer to class device. |
| 3894 | * @buf: Data buffer. |
| 3895 | * @count: Size of the data buffer. |
| 3896 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 3897 | * 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] | 3898 | * sysfs file. This function parse the command written to the sysfs file |
| 3899 | * and take appropriate action. These commands are used for controlling |
| 3900 | * driver statistical data collection. |
| 3901 | * Following are the command this function handles. |
| 3902 | * |
| 3903 | * setbucket <bucket_type> <base> <step> |
| 3904 | * = Set the latency buckets. |
| 3905 | * destroybucket = destroy all the buckets. |
| 3906 | * start = start data collection |
| 3907 | * stop = stop data collection |
| 3908 | * reset = reset the collected data |
| 3909 | **/ |
| 3910 | static ssize_t |
| 3911 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3912 | const char *buf, size_t count) |
| 3913 | { |
| 3914 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3915 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3916 | struct lpfc_hba *phba = vport->phba; |
| 3917 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3918 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3919 | unsigned long i; |
| 3920 | char *str_ptr, *token; |
| 3921 | struct lpfc_vport **vports; |
| 3922 | struct Scsi_Host *v_shost; |
| 3923 | char *bucket_type_str, *base_str, *step_str; |
| 3924 | unsigned long base, step, bucket_type; |
| 3925 | |
| 3926 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3927 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3928 | return -EINVAL; |
| 3929 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 3930 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3931 | str_ptr = &bucket_data[0]; |
| 3932 | /* Ignore this token - this is command token */ |
| 3933 | token = strsep(&str_ptr, "\t "); |
| 3934 | if (!token) |
| 3935 | return -EINVAL; |
| 3936 | |
| 3937 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3938 | if (!bucket_type_str) |
| 3939 | return -EINVAL; |
| 3940 | |
| 3941 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3942 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3943 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3944 | bucket_type = LPFC_POWER2_BUCKET; |
| 3945 | else |
| 3946 | return -EINVAL; |
| 3947 | |
| 3948 | base_str = strsep(&str_ptr, "\t "); |
| 3949 | if (!base_str) |
| 3950 | return -EINVAL; |
| 3951 | base = simple_strtoul(base_str, NULL, 0); |
| 3952 | |
| 3953 | step_str = strsep(&str_ptr, "\t "); |
| 3954 | if (!step_str) |
| 3955 | return -EINVAL; |
| 3956 | step = simple_strtoul(step_str, NULL, 0); |
| 3957 | if (!step) |
| 3958 | return -EINVAL; |
| 3959 | |
| 3960 | /* Block the data collection for every vport */ |
| 3961 | vports = lpfc_create_vport_work_array(phba); |
| 3962 | if (vports == NULL) |
| 3963 | return -ENOMEM; |
| 3964 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3965 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3966 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3967 | spin_lock_irq(v_shost->host_lock); |
| 3968 | /* Block and reset data collection */ |
| 3969 | vports[i]->stat_data_blocked = 1; |
| 3970 | if (vports[i]->stat_data_enabled) |
| 3971 | lpfc_vport_reset_stat_data(vports[i]); |
| 3972 | spin_unlock_irq(v_shost->host_lock); |
| 3973 | } |
| 3974 | |
| 3975 | /* Set the bucket attributes */ |
| 3976 | phba->bucket_type = bucket_type; |
| 3977 | phba->bucket_base = base; |
| 3978 | phba->bucket_step = step; |
| 3979 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3980 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3981 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3982 | |
| 3983 | /* Unblock data collection */ |
| 3984 | spin_lock_irq(v_shost->host_lock); |
| 3985 | vports[i]->stat_data_blocked = 0; |
| 3986 | spin_unlock_irq(v_shost->host_lock); |
| 3987 | } |
| 3988 | lpfc_destroy_vport_work_array(phba, vports); |
| 3989 | return strlen(buf); |
| 3990 | } |
| 3991 | |
| 3992 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3993 | vports = lpfc_create_vport_work_array(phba); |
| 3994 | if (vports == NULL) |
| 3995 | return -ENOMEM; |
| 3996 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3997 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3998 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3999 | spin_lock_irq(shost->host_lock); |
| 4000 | vports[i]->stat_data_blocked = 1; |
| 4001 | lpfc_free_bucket(vport); |
| 4002 | vport->stat_data_enabled = 0; |
| 4003 | vports[i]->stat_data_blocked = 0; |
| 4004 | spin_unlock_irq(shost->host_lock); |
| 4005 | } |
| 4006 | lpfc_destroy_vport_work_array(phba, vports); |
| 4007 | phba->bucket_type = LPFC_NO_BUCKET; |
| 4008 | phba->bucket_base = 0; |
| 4009 | phba->bucket_step = 0; |
| 4010 | return strlen(buf); |
| 4011 | } |
| 4012 | |
| 4013 | if (!strncmp(buf, "start", strlen("start"))) { |
| 4014 | /* If no buckets configured return error */ |
| 4015 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 4016 | return -EINVAL; |
| 4017 | spin_lock_irq(shost->host_lock); |
| 4018 | if (vport->stat_data_enabled) { |
| 4019 | spin_unlock_irq(shost->host_lock); |
| 4020 | return strlen(buf); |
| 4021 | } |
| 4022 | lpfc_alloc_bucket(vport); |
| 4023 | vport->stat_data_enabled = 1; |
| 4024 | spin_unlock_irq(shost->host_lock); |
| 4025 | return strlen(buf); |
| 4026 | } |
| 4027 | |
| 4028 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 4029 | spin_lock_irq(shost->host_lock); |
| 4030 | if (vport->stat_data_enabled == 0) { |
| 4031 | spin_unlock_irq(shost->host_lock); |
| 4032 | return strlen(buf); |
| 4033 | } |
| 4034 | lpfc_free_bucket(vport); |
| 4035 | vport->stat_data_enabled = 0; |
| 4036 | spin_unlock_irq(shost->host_lock); |
| 4037 | return strlen(buf); |
| 4038 | } |
| 4039 | |
| 4040 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 4041 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 4042 | || !vport->stat_data_enabled) |
| 4043 | return strlen(buf); |
| 4044 | spin_lock_irq(shost->host_lock); |
| 4045 | vport->stat_data_blocked = 1; |
| 4046 | lpfc_vport_reset_stat_data(vport); |
| 4047 | vport->stat_data_blocked = 0; |
| 4048 | spin_unlock_irq(shost->host_lock); |
| 4049 | return strlen(buf); |
| 4050 | } |
| 4051 | return -EINVAL; |
| 4052 | } |
| 4053 | |
| 4054 | |
| 4055 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4056 | * 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] | 4057 | * @dev: Pointer to class device object. |
| 4058 | * @buf: Data buffer. |
| 4059 | * |
| 4060 | * This function is the read call back function for |
| 4061 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 4062 | * current statistical data collection state. |
| 4063 | **/ |
| 4064 | static ssize_t |
| 4065 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 4066 | char *buf) |
| 4067 | { |
| 4068 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4069 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4070 | struct lpfc_hba *phba = vport->phba; |
| 4071 | int index = 0; |
| 4072 | int i; |
| 4073 | char *bucket_type; |
| 4074 | unsigned long bucket_value; |
| 4075 | |
| 4076 | switch (phba->bucket_type) { |
| 4077 | case LPFC_LINEAR_BUCKET: |
| 4078 | bucket_type = "linear"; |
| 4079 | break; |
| 4080 | case LPFC_POWER2_BUCKET: |
| 4081 | bucket_type = "power2"; |
| 4082 | break; |
| 4083 | default: |
| 4084 | bucket_type = "No Bucket"; |
| 4085 | break; |
| 4086 | } |
| 4087 | |
| 4088 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 4089 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 4090 | " Bucket step :%d\nLatency Ranges :", |
| 4091 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 4092 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 4093 | index = strlen(buf); |
| 4094 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 4095 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4096 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 4097 | bucket_value = phba->bucket_base + |
| 4098 | phba->bucket_step * i; |
| 4099 | else |
| 4100 | bucket_value = phba->bucket_base + |
| 4101 | (1 << i) * phba->bucket_step; |
| 4102 | |
| 4103 | if (index + 10 > PAGE_SIZE) |
| 4104 | break; |
| 4105 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 4106 | index = strlen(buf); |
| 4107 | } |
| 4108 | } |
| 4109 | sprintf(&buf[index], "\n"); |
| 4110 | return strlen(buf); |
| 4111 | } |
| 4112 | |
| 4113 | /* |
| 4114 | * Sysfs attribute to control the statistical data collection. |
| 4115 | */ |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4116 | static DEVICE_ATTR_RW(lpfc_stat_data_ctrl); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4117 | |
| 4118 | /* |
| 4119 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 4120 | */ |
| 4121 | |
| 4122 | /* |
| 4123 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 4124 | * for each target. |
| 4125 | */ |
| 4126 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 4127 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 4128 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 4129 | |
| 4130 | |
| 4131 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4132 | * 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] | 4133 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4134 | * @kobj: Pointer to the kernel object |
| 4135 | * @bin_attr: Attribute object |
| 4136 | * @buff: Buffer pointer |
| 4137 | * @off: File offset |
| 4138 | * @count: Buffer size |
| 4139 | * |
| 4140 | * This function is the read call back function for lpfc_drvr_stat_data |
| 4141 | * sysfs file. This function export the statistical data to user |
| 4142 | * applications. |
| 4143 | **/ |
| 4144 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4145 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 4146 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4147 | char *buf, loff_t off, size_t count) |
| 4148 | { |
| 4149 | struct device *dev = container_of(kobj, struct device, |
| 4150 | kobj); |
| 4151 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4152 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4153 | struct lpfc_hba *phba = vport->phba; |
| 4154 | int i = 0, index = 0; |
| 4155 | unsigned long nport_index; |
| 4156 | struct lpfc_nodelist *ndlp = NULL; |
| 4157 | nport_index = (unsigned long)off / |
| 4158 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 4159 | |
| 4160 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 4161 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 4162 | return 0; |
| 4163 | |
| 4164 | spin_lock_irq(shost->host_lock); |
| 4165 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 4166 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 4167 | continue; |
| 4168 | |
| 4169 | if (nport_index > 0) { |
| 4170 | nport_index--; |
| 4171 | continue; |
| 4172 | } |
| 4173 | |
| 4174 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 4175 | > count) |
| 4176 | break; |
| 4177 | |
| 4178 | if (!ndlp->lat_data) |
| 4179 | continue; |
| 4180 | |
| 4181 | /* Print the WWN */ |
| 4182 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 4183 | ndlp->nlp_portname.u.wwn[0], |
| 4184 | ndlp->nlp_portname.u.wwn[1], |
| 4185 | ndlp->nlp_portname.u.wwn[2], |
| 4186 | ndlp->nlp_portname.u.wwn[3], |
| 4187 | ndlp->nlp_portname.u.wwn[4], |
| 4188 | ndlp->nlp_portname.u.wwn[5], |
| 4189 | ndlp->nlp_portname.u.wwn[6], |
| 4190 | ndlp->nlp_portname.u.wwn[7]); |
| 4191 | |
| 4192 | index = strlen(buf); |
| 4193 | |
| 4194 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4195 | sprintf(&buf[index], "%010u,", |
| 4196 | ndlp->lat_data[i].cmd_count); |
| 4197 | index = strlen(buf); |
| 4198 | } |
| 4199 | sprintf(&buf[index], "\n"); |
| 4200 | index = strlen(buf); |
| 4201 | } |
| 4202 | spin_unlock_irq(shost->host_lock); |
| 4203 | return index; |
| 4204 | } |
| 4205 | |
| 4206 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4207 | .attr = { |
| 4208 | .name = "lpfc_drvr_stat_data", |
| 4209 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4210 | }, |
| 4211 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4212 | .read = sysfs_drvr_stat_data_read, |
| 4213 | .write = NULL, |
| 4214 | }; |
| 4215 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4216 | /* |
| 4217 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4218 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4219 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4220 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4221 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4222 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4223 | * @phba: lpfc_hba pointer. |
| 4224 | * @val: link speed value. |
| 4225 | * |
| 4226 | * Description: |
| 4227 | * If val is in a valid range then set the adapter's link speed field and |
| 4228 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4229 | * |
| 4230 | * Notes: |
| 4231 | * If the value is not in range log a kernel error message and return an error. |
| 4232 | * |
| 4233 | * Returns: |
| 4234 | * zero if val is in range and lip okay. |
| 4235 | * non-zero return value from lpfc_issue_lip() |
| 4236 | * -EINVAL val out of range |
| 4237 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4238 | static ssize_t |
| 4239 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4240 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4241 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4242 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4243 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4244 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4245 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4246 | int nolip = 0; |
| 4247 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4248 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4249 | uint32_t prev_val, if_type; |
| 4250 | |
| 4251 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 4252 | if (if_type == LPFC_SLI_INTF_IF_TYPE_2 && |
| 4253 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4254 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4255 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4256 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4257 | nolip = 1; |
| 4258 | val_buf = &buf[strlen("nolip ")]; |
| 4259 | } |
| 4260 | |
| 4261 | if (!isdigit(val_buf[0])) |
| 4262 | return -EINVAL; |
| 4263 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4264 | return -EINVAL; |
| 4265 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4266 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4267 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4268 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4269 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4270 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4271 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4272 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4273 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4274 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4275 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4276 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) || |
| 4277 | ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4278 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4279 | "2879 lpfc_link_speed attribute cannot be set " |
| 4280 | "to %d. Speed is not supported by this port.\n", |
| 4281 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4282 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4283 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4284 | if (val >= LPFC_USER_LINK_SPEED_16G && |
| 4285 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4286 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4287 | "3112 lpfc_link_speed attribute cannot be set " |
| 4288 | "to %d. Speed is not supported in loop mode.\n", |
| 4289 | val); |
| 4290 | return -EINVAL; |
| 4291 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4292 | |
| 4293 | switch (val) { |
| 4294 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4295 | case LPFC_USER_LINK_SPEED_1G: |
| 4296 | case LPFC_USER_LINK_SPEED_2G: |
| 4297 | case LPFC_USER_LINK_SPEED_4G: |
| 4298 | case LPFC_USER_LINK_SPEED_8G: |
| 4299 | case LPFC_USER_LINK_SPEED_16G: |
| 4300 | case LPFC_USER_LINK_SPEED_32G: |
| 4301 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4302 | prev_val = phba->cfg_link_speed; |
| 4303 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4304 | if (nolip) |
| 4305 | return strlen(buf); |
| 4306 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4307 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4308 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4309 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4310 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4311 | } |
| 4312 | return strlen(buf); |
| 4313 | default: |
| 4314 | break; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4315 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4316 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4317 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4318 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4319 | "allowed values are [%s]\n", |
| 4320 | val, LPFC_LINK_SPEED_STRING); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4321 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4322 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4323 | } |
| 4324 | |
| 4325 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4326 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4327 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4328 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4329 | |
| 4330 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4331 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4332 | * @phba: lpfc_hba pointer. |
| 4333 | * @val: link speed value. |
| 4334 | * |
| 4335 | * Description: |
| 4336 | * If val is in a valid range then set the adapter's link speed field. |
| 4337 | * |
| 4338 | * Notes: |
| 4339 | * If the value is not in range log a kernel error message, clear the link |
| 4340 | * speed and return an error. |
| 4341 | * |
| 4342 | * Returns: |
| 4343 | * zero if val saved. |
| 4344 | * -EINVAL val out of range |
| 4345 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4346 | static int |
| 4347 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4348 | { |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4349 | if (val >= LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4350 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4351 | "3111 lpfc_link_speed of %d cannot " |
| 4352 | "support loop mode, setting topology to default.\n", |
| 4353 | val); |
| 4354 | phba->cfg_topology = 0; |
| 4355 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4356 | |
| 4357 | switch (val) { |
| 4358 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4359 | case LPFC_USER_LINK_SPEED_1G: |
| 4360 | case LPFC_USER_LINK_SPEED_2G: |
| 4361 | case LPFC_USER_LINK_SPEED_4G: |
| 4362 | case LPFC_USER_LINK_SPEED_8G: |
| 4363 | case LPFC_USER_LINK_SPEED_16G: |
| 4364 | case LPFC_USER_LINK_SPEED_32G: |
| 4365 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4366 | phba->cfg_link_speed = val; |
| 4367 | return 0; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4368 | default: |
| 4369 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4370 | "0405 lpfc_link_speed attribute cannot " |
| 4371 | "be set to %d, allowed values are " |
| 4372 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
| 4373 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
| 4374 | return -EINVAL; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4375 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4376 | } |
| 4377 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4378 | static DEVICE_ATTR_RW(lpfc_link_speed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4379 | |
| 4380 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4381 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4382 | # 0 = aer disabled or not supported |
| 4383 | # 1 = aer supported and enabled (default) |
| 4384 | # Value range is [0,1]. Default value is 1. |
| 4385 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4386 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4387 | "Enable PCIe device AER support"); |
| 4388 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4389 | |
| 4390 | /** |
| 4391 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4392 | * |
| 4393 | * @dev: class device that is converted into a Scsi_host. |
| 4394 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4395 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4396 | * @count: unused variable. |
| 4397 | * |
| 4398 | * Description: |
| 4399 | * If the val is 1 and currently the device's AER capability was not |
| 4400 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4401 | * enable the device's AER capability. If the helper routine enabling |
| 4402 | * AER returns success, update the device's cfg_aer_support flag to |
| 4403 | * indicate AER is supported by the device; otherwise, if the device |
| 4404 | * AER capability is already enabled to support AER, then do nothing. |
| 4405 | * |
| 4406 | * If the val is 0 and currently the device's AER support was enabled, |
| 4407 | * invoke the kernel's disable AER helper routine. After that, update |
| 4408 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4409 | * by the device; otherwise, if the device AER capability is already |
| 4410 | * disabled from supporting AER, then do nothing. |
| 4411 | * |
| 4412 | * Returns: |
| 4413 | * length of the buf on success if val is in range the intended mode |
| 4414 | * is supported. |
| 4415 | * -EINVAL if val out of range or intended mode is not supported. |
| 4416 | **/ |
| 4417 | static ssize_t |
| 4418 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4419 | const char *buf, size_t count) |
| 4420 | { |
| 4421 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4422 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4423 | struct lpfc_hba *phba = vport->phba; |
| 4424 | int val = 0, rc = -EINVAL; |
| 4425 | |
| 4426 | if (!isdigit(buf[0])) |
| 4427 | return -EINVAL; |
| 4428 | if (sscanf(buf, "%i", &val) != 1) |
| 4429 | return -EINVAL; |
| 4430 | |
| 4431 | switch (val) { |
| 4432 | case 0: |
| 4433 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4434 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4435 | if (!rc) { |
| 4436 | spin_lock_irq(&phba->hbalock); |
| 4437 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4438 | spin_unlock_irq(&phba->hbalock); |
| 4439 | phba->cfg_aer_support = 0; |
| 4440 | rc = strlen(buf); |
| 4441 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4442 | rc = -EPERM; |
| 4443 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4444 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4445 | rc = strlen(buf); |
| 4446 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4447 | break; |
| 4448 | case 1: |
| 4449 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4450 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4451 | if (!rc) { |
| 4452 | spin_lock_irq(&phba->hbalock); |
| 4453 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4454 | spin_unlock_irq(&phba->hbalock); |
| 4455 | phba->cfg_aer_support = 1; |
| 4456 | rc = strlen(buf); |
| 4457 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4458 | rc = -EPERM; |
| 4459 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4460 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4461 | rc = strlen(buf); |
| 4462 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4463 | break; |
| 4464 | default: |
| 4465 | rc = -EINVAL; |
| 4466 | break; |
| 4467 | } |
| 4468 | return rc; |
| 4469 | } |
| 4470 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4471 | static DEVICE_ATTR_RW(lpfc_aer_support); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4472 | |
| 4473 | /** |
| 4474 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4475 | * @dev: class device that is converted into a Scsi_host. |
| 4476 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4477 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4478 | * @count: unused variable. |
| 4479 | * |
| 4480 | * Description: |
| 4481 | * If the @buf contains 1 and the device currently has the AER support |
| 4482 | * enabled, then invokes the kernel AER helper routine |
| 4483 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4484 | * error status register. |
| 4485 | * |
| 4486 | * Notes: |
| 4487 | * |
| 4488 | * Returns: |
| 4489 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4490 | * enabled with the AER support. |
| 4491 | **/ |
| 4492 | static ssize_t |
| 4493 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4494 | const char *buf, size_t count) |
| 4495 | { |
| 4496 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4497 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4498 | struct lpfc_hba *phba = vport->phba; |
| 4499 | int val, rc = -1; |
| 4500 | |
| 4501 | if (!isdigit(buf[0])) |
| 4502 | return -EINVAL; |
| 4503 | if (sscanf(buf, "%i", &val) != 1) |
| 4504 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4505 | if (val != 1) |
| 4506 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4507 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4508 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4509 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4510 | |
| 4511 | if (rc == 0) |
| 4512 | return strlen(buf); |
| 4513 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4514 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4515 | } |
| 4516 | |
| 4517 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4518 | lpfc_aer_cleanup_state); |
| 4519 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4520 | /** |
| 4521 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4522 | * |
| 4523 | * @dev: class device that is converted into a Scsi_host. |
| 4524 | * @attr: device attribute, not used. |
| 4525 | * @buf: containing the string the number of vfs to be enabled. |
| 4526 | * @count: unused variable. |
| 4527 | * |
| 4528 | * Description: |
| 4529 | * When this api is called either through user sysfs, the driver shall |
| 4530 | * try to enable or disable SR-IOV virtual functions according to the |
| 4531 | * following: |
| 4532 | * |
| 4533 | * If zero virtual function has been enabled to the physical function, |
| 4534 | * the driver shall invoke the pci enable virtual function api trying |
| 4535 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4536 | * than the maximum supported, the maximum virtual function number will |
| 4537 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4538 | * be used for invoking the api. If the api call returned success, the |
| 4539 | * actual number of virtual functions enabled will be set to the driver |
| 4540 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4541 | * cfg_sriov_nr_virtfn remains zero. |
| 4542 | * |
| 4543 | * If none-zero virtual functions have already been enabled to the |
| 4544 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4545 | * -EINVAL will be returned and the driver does nothing; |
| 4546 | * |
| 4547 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4548 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4549 | * disabling virtual function api shall be invoded to disable all the |
| 4550 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4551 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4552 | * nothing. |
| 4553 | * |
| 4554 | * Returns: |
| 4555 | * length of the buf on success if val is in range the intended mode |
| 4556 | * is supported. |
| 4557 | * -EINVAL if val out of range or intended mode is not supported. |
| 4558 | **/ |
| 4559 | static ssize_t |
| 4560 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4561 | const char *buf, size_t count) |
| 4562 | { |
| 4563 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4564 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4565 | struct lpfc_hba *phba = vport->phba; |
| 4566 | struct pci_dev *pdev = phba->pcidev; |
| 4567 | int val = 0, rc = -EINVAL; |
| 4568 | |
| 4569 | /* Sanity check on user data */ |
| 4570 | if (!isdigit(buf[0])) |
| 4571 | return -EINVAL; |
| 4572 | if (sscanf(buf, "%i", &val) != 1) |
| 4573 | return -EINVAL; |
| 4574 | if (val < 0) |
| 4575 | return -EINVAL; |
| 4576 | |
| 4577 | /* Request disabling virtual functions */ |
| 4578 | if (val == 0) { |
| 4579 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4580 | pci_disable_sriov(pdev); |
| 4581 | phba->cfg_sriov_nr_virtfn = 0; |
| 4582 | } |
| 4583 | return strlen(buf); |
| 4584 | } |
| 4585 | |
| 4586 | /* Request enabling virtual functions */ |
| 4587 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4588 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4589 | "3018 There are %d virtual functions " |
| 4590 | "enabled on physical function.\n", |
| 4591 | phba->cfg_sriov_nr_virtfn); |
| 4592 | return -EEXIST; |
| 4593 | } |
| 4594 | |
| 4595 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4596 | phba->cfg_sriov_nr_virtfn = val; |
| 4597 | else { |
| 4598 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4599 | "3019 Enabling %d virtual functions is not " |
| 4600 | "allowed.\n", val); |
| 4601 | return -EINVAL; |
| 4602 | } |
| 4603 | |
| 4604 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4605 | if (rc) { |
| 4606 | phba->cfg_sriov_nr_virtfn = 0; |
| 4607 | rc = -EPERM; |
| 4608 | } else |
| 4609 | rc = strlen(buf); |
| 4610 | |
| 4611 | return rc; |
| 4612 | } |
| 4613 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4614 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4615 | "Enable PCIe device SR-IOV virtual fn"); |
| 4616 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4617 | lpfc_param_show(sriov_nr_virtfn) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4618 | static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4619 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4620 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4621 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4622 | * |
| 4623 | * @dev: class device that is converted into a Scsi_host. |
| 4624 | * @attr: device attribute, not used. |
| 4625 | * @buf: containing the string the number of vfs to be enabled. |
| 4626 | * @count: unused variable. |
| 4627 | * |
| 4628 | * Description: |
| 4629 | * |
| 4630 | * Returns: |
| 4631 | * length of the buf on success if val is in range the intended mode |
| 4632 | * is supported. |
| 4633 | * -EINVAL if val out of range or intended mode is not supported. |
| 4634 | **/ |
| 4635 | static ssize_t |
| 4636 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4637 | struct device_attribute *attr, |
| 4638 | const char *buf, size_t count) |
| 4639 | { |
| 4640 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4641 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4642 | struct lpfc_hba *phba = vport->phba; |
| 4643 | int val = 0, rc = -EINVAL; |
| 4644 | |
| 4645 | /* Sanity check on user data */ |
| 4646 | if (!isdigit(buf[0])) |
| 4647 | return -EINVAL; |
| 4648 | if (sscanf(buf, "%i", &val) != 1) |
| 4649 | return -EINVAL; |
| 4650 | if (val != 1) |
| 4651 | return -EINVAL; |
| 4652 | |
| 4653 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4654 | if (rc) |
| 4655 | rc = -EPERM; |
| 4656 | else |
| 4657 | rc = strlen(buf); |
| 4658 | return rc; |
| 4659 | } |
| 4660 | |
| 4661 | static int lpfc_req_fw_upgrade; |
| 4662 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4663 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4664 | lpfc_param_show(request_firmware_upgrade) |
| 4665 | |
| 4666 | /** |
| 4667 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4668 | * @phba: lpfc_hba pointer. |
| 4669 | * @val: 0 or 1. |
| 4670 | * |
| 4671 | * Description: |
| 4672 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4673 | * |
| 4674 | * Returns: |
| 4675 | * zero if val saved. |
| 4676 | * -EINVAL val out of range |
| 4677 | **/ |
| 4678 | static int |
| 4679 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4680 | { |
| 4681 | if (val >= 0 && val <= 1) { |
| 4682 | phba->cfg_request_firmware_upgrade = val; |
| 4683 | return 0; |
| 4684 | } |
| 4685 | return -EINVAL; |
| 4686 | } |
| 4687 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4688 | lpfc_request_firmware_upgrade_show, |
| 4689 | lpfc_request_firmware_upgrade_store); |
| 4690 | |
| 4691 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4692 | * lpfc_fcp_imax_store |
| 4693 | * |
| 4694 | * @dev: class device that is converted into a Scsi_host. |
| 4695 | * @attr: device attribute, not used. |
| 4696 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4697 | * @count: unused variable. |
| 4698 | * |
| 4699 | * Description: |
| 4700 | * If val is in a valid range [636,651042], then set the adapter's |
| 4701 | * maximum number of fast-path FCP interrupts per second. |
| 4702 | * |
| 4703 | * Returns: |
| 4704 | * length of the buf on success if val is in range the intended mode |
| 4705 | * is supported. |
| 4706 | * -EINVAL if val out of range or intended mode is not supported. |
| 4707 | **/ |
| 4708 | static ssize_t |
| 4709 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4710 | const char *buf, size_t count) |
| 4711 | { |
| 4712 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4713 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4714 | struct lpfc_hba *phba = vport->phba; |
| 4715 | int val = 0, i; |
| 4716 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4717 | /* fcp_imax is only valid for SLI4 */ |
| 4718 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4719 | return -EINVAL; |
| 4720 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4721 | /* Sanity check on user data */ |
| 4722 | if (!isdigit(buf[0])) |
| 4723 | return -EINVAL; |
| 4724 | if (sscanf(buf, "%i", &val) != 1) |
| 4725 | return -EINVAL; |
| 4726 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4727 | /* |
| 4728 | * Value range for the HBA is [5000,5000000] |
| 4729 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4730 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4731 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4732 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4733 | return -EINVAL; |
| 4734 | |
| 4735 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4736 | phba->initial_imax = phba->cfg_fcp_imax; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 4737 | |
| 4738 | for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT) |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4739 | lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT, |
| 4740 | val); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4741 | |
| 4742 | return strlen(buf); |
| 4743 | } |
| 4744 | |
| 4745 | /* |
| 4746 | # 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] | 4747 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4748 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4749 | # 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] | 4750 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4751 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4752 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4753 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4754 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4755 | lpfc_param_show(fcp_imax) |
| 4756 | |
| 4757 | /** |
| 4758 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4759 | * @phba: lpfc_hba pointer. |
| 4760 | * @val: link speed value. |
| 4761 | * |
| 4762 | * Description: |
| 4763 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4764 | * maximum number of fast-path FCP interrupts per second. |
| 4765 | * |
| 4766 | * Returns: |
| 4767 | * zero if val saved. |
| 4768 | * -EINVAL val out of range |
| 4769 | **/ |
| 4770 | static int |
| 4771 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4772 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4773 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4774 | phba->cfg_fcp_imax = 0; |
| 4775 | return 0; |
| 4776 | } |
| 4777 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4778 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 4779 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4780 | phba->cfg_fcp_imax = val; |
| 4781 | return 0; |
| 4782 | } |
| 4783 | |
| 4784 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4785 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 4786 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4787 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4788 | |
| 4789 | return 0; |
| 4790 | } |
| 4791 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4792 | static DEVICE_ATTR_RW(lpfc_fcp_imax); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4793 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4794 | /* |
| 4795 | * lpfc_auto_imax: Controls Auto-interrupt coalescing values support. |
| 4796 | * 0 No auto_imax support |
| 4797 | * 1 auto imax on |
| 4798 | * Auto imax will change the value of fcp_imax on a per EQ basis, using |
| 4799 | * the EQ Delay Multiplier, depending on the activity for that EQ. |
| 4800 | * Value range [0,1]. Default value is 1. |
| 4801 | */ |
| 4802 | LPFC_ATTR_RW(auto_imax, 1, 0, 1, "Enable Auto imax"); |
| 4803 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4804 | /** |
| 4805 | * lpfc_state_show - Display current driver CPU affinity |
| 4806 | * @dev: class converted to a Scsi_host structure. |
| 4807 | * @attr: device attribute, not used. |
| 4808 | * @buf: on return contains text describing the state of the link. |
| 4809 | * |
| 4810 | * Returns: size of formatted string. |
| 4811 | **/ |
| 4812 | static ssize_t |
| 4813 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4814 | char *buf) |
| 4815 | { |
| 4816 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4817 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4818 | struct lpfc_hba *phba = vport->phba; |
| 4819 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4820 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4821 | |
| 4822 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4823 | (phba->intr_type != MSIX)) |
| 4824 | return len; |
| 4825 | |
| 4826 | switch (phba->cfg_fcp_cpu_map) { |
| 4827 | case 0: |
| 4828 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4829 | "fcp_cpu_map: No mapping (%d)\n", |
| 4830 | phba->cfg_fcp_cpu_map); |
| 4831 | return len; |
| 4832 | case 1: |
| 4833 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4834 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4835 | "%d online CPUs\n", |
| 4836 | phba->cfg_fcp_cpu_map, |
| 4837 | phba->sli4_hba.num_online_cpu); |
| 4838 | break; |
| 4839 | case 2: |
| 4840 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4841 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4842 | "%d online CPUs\n", |
| 4843 | phba->cfg_fcp_cpu_map, |
| 4844 | phba->sli4_hba.num_online_cpu); |
| 4845 | break; |
| 4846 | } |
| 4847 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4848 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4849 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4850 | |
| 4851 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4852 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4853 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4854 | "CPU %02d io_chan %02d " |
| 4855 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4856 | phba->sli4_hba.curr_disp_cpu, |
| 4857 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4858 | cpup->core_id); |
| 4859 | else |
| 4860 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4861 | "CPU %02d io_chan %02d " |
| 4862 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4863 | phba->sli4_hba.curr_disp_cpu, |
| 4864 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4865 | cpup->core_id, cpup->irq); |
| 4866 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4867 | phba->sli4_hba.curr_disp_cpu++; |
| 4868 | |
| 4869 | /* display max number of CPUs keeping some margin */ |
| 4870 | if (phba->sli4_hba.curr_disp_cpu < |
| 4871 | phba->sli4_hba.num_present_cpu && |
| 4872 | (len >= (PAGE_SIZE - 64))) { |
| 4873 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4874 | break; |
| 4875 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4876 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4877 | |
| 4878 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4879 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4880 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4881 | return len; |
| 4882 | } |
| 4883 | |
| 4884 | /** |
| 4885 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4886 | * @dev: class device that is converted into a Scsi_host. |
| 4887 | * @attr: device attribute, not used. |
| 4888 | * @buf: one or more lpfc_polling_flags values. |
| 4889 | * @count: not used. |
| 4890 | * |
| 4891 | * Returns: |
| 4892 | * -EINVAL - Not implemented yet. |
| 4893 | **/ |
| 4894 | static ssize_t |
| 4895 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4896 | const char *buf, size_t count) |
| 4897 | { |
| 4898 | int status = -EINVAL; |
| 4899 | return status; |
| 4900 | } |
| 4901 | |
| 4902 | /* |
| 4903 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4904 | # for the HBA. |
| 4905 | # |
| 4906 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4907 | # 0 - Do not affinitze IRQ vectors |
| 4908 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4909 | # (start with CPU0 for each HBA) |
| 4910 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4911 | # (round robin thru all CPUs across all HBAs) |
| 4912 | */ |
| 4913 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4914 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4915 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4916 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4917 | |
| 4918 | /** |
| 4919 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4920 | * @phba: lpfc_hba pointer. |
| 4921 | * @val: link speed value. |
| 4922 | * |
| 4923 | * Description: |
| 4924 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4925 | * MSIX vectors. |
| 4926 | * |
| 4927 | * Returns: |
| 4928 | * zero if val saved. |
| 4929 | * -EINVAL val out of range |
| 4930 | **/ |
| 4931 | static int |
| 4932 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4933 | { |
| 4934 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4935 | phba->cfg_fcp_cpu_map = 0; |
| 4936 | return 0; |
| 4937 | } |
| 4938 | |
| 4939 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4940 | phba->cfg_fcp_cpu_map = val; |
| 4941 | return 0; |
| 4942 | } |
| 4943 | |
| 4944 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4945 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 4946 | "default\n", val); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4947 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4948 | |
| 4949 | return 0; |
| 4950 | } |
| 4951 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4952 | static DEVICE_ATTR_RW(lpfc_fcp_cpu_map); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4953 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4954 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4955 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4956 | # Value range is [2,3]. Default value is 3. |
| 4957 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4958 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4959 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4960 | |
| 4961 | /* |
| 4962 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4963 | # is [0,1]. Default value is 0. |
| 4964 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4965 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4966 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4967 | |
| 4968 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4969 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4970 | # that support first burst. |
| 4971 | # Value range is [0,65536]. Default value is 0. |
| 4972 | */ |
| 4973 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4974 | "First burst size for Targets that support first burst"); |
| 4975 | |
| 4976 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4977 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 4978 | * When the driver is configured as an NVME target, this value is |
| 4979 | * communicated to the NVME initiator in the PRLI response. It is |
| 4980 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 4981 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4982 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4983 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4984 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4985 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 4986 | "NVME Target mode first burst size in 512B increments."); |
| 4987 | |
| 4988 | /* |
| 4989 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 4990 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 4991 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
| 4992 | * processed by the initiator for subsequent NVME FCP IO. For the target |
| 4993 | * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size |
| 4994 | * driver parameter as the target function's first burst size returned to the |
| 4995 | * initiator in the target's NVME PRLI response. Parameter supported on physical |
| 4996 | * port only - no NPIV support. |
| 4997 | * Value range is [0,1]. Default value is 0 (disabled). |
| 4998 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4999 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
| 5000 | "Enable First Burst feature on I and T functions."); |
| 5001 | |
| 5002 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5003 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 5004 | # depth. Default value is 0. When the value of this parameter is zero the |
| 5005 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 5006 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 5007 | # to limit the I/O completion time to the parameter value. |
| 5008 | # The value is set in milliseconds. |
| 5009 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5010 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5011 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5012 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5013 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5014 | static int |
| 5015 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 5016 | { |
| 5017 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5018 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 5019 | |
| 5020 | if (val == vport->cfg_max_scsicmpl_time) |
| 5021 | return 0; |
| 5022 | if ((val < 0) || (val > 60000)) |
| 5023 | return -EINVAL; |
| 5024 | vport->cfg_max_scsicmpl_time = val; |
| 5025 | |
| 5026 | spin_lock_irq(shost->host_lock); |
| 5027 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 5028 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 5029 | continue; |
| 5030 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 5031 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5032 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5033 | } |
| 5034 | spin_unlock_irq(shost->host_lock); |
| 5035 | return 0; |
| 5036 | } |
| 5037 | lpfc_vport_param_store(max_scsicmpl_time); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5038 | static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5039 | |
| 5040 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5041 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 5042 | # range is [0,1]. Default value is 0. |
| 5043 | */ |
| 5044 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 5045 | |
| 5046 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5047 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 5048 | * range is [0,1]. Default value is 0. |
| 5049 | * For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 5050 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 5051 | * current CPU. |
| 5052 | * |
| 5053 | * LPFC_FCP_SCHED_ROUND_ROBIN == 0 |
| 5054 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 5055 | * |
| 5056 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 5057 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 5058 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 5059 | * through WQs will be used. |
| 5060 | */ |
| 5061 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN, |
| 5062 | LPFC_FCP_SCHED_ROUND_ROBIN, |
| 5063 | LPFC_FCP_SCHED_BY_CPU, |
| 5064 | "Determine scheduling algorithm for " |
| 5065 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5066 | |
| 5067 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5068 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 5069 | # range is [0,1]. Default value is 0. |
| 5070 | # For [0], bus reset issues target reset to ALL devices |
| 5071 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 5072 | */ |
| 5073 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 5074 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 5075 | |
| 5076 | |
| 5077 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5078 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 5079 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5080 | # 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] | 5081 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 5082 | # cr_delay is set to 0. |
| 5083 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5084 | 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] | 5085 | "interrupt response is generated"); |
| 5086 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5087 | 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] | 5088 | "interrupt response is generated"); |
| 5089 | |
| 5090 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5091 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 5092 | # cmd/rsp IOCB entries across. |
| 5093 | # Value range is [1,2]. Default value is 1. |
| 5094 | */ |
| 5095 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 5096 | "SLI rings to spread IOCB entries across"); |
| 5097 | |
| 5098 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5099 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 5100 | # identifies what rctl value to configure the additional ring for. |
| 5101 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 5102 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5103 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5104 | 255, "Identifies RCTL for additional ring configuration"); |
| 5105 | |
| 5106 | /* |
| 5107 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 5108 | # identifies what type value to configure the additional ring for. |
| 5109 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 5110 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5111 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5112 | 255, "Identifies TYPE for additional ring configuration"); |
| 5113 | |
| 5114 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5115 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 5116 | # 0 = SmartSAN functionality disabled (default) |
| 5117 | # 1 = SmartSAN functionality enabled |
| 5118 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 5119 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5120 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5121 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 5122 | |
| 5123 | /* |
| 5124 | # lpfc_fdmi_on: Controls FDMI support. |
| 5125 | # 0 No FDMI support (default) |
| 5126 | # 1 Traditional FDMI support |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 5127 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 5128 | # however, if that fails, it will fallback to FDMI-1. |
| 5129 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 5130 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 5131 | # lpfc_fdmi_on. |
| 5132 | # Value range [0,1]. Default value is 0. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5133 | */ |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 5134 | LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5135 | |
| 5136 | /* |
| 5137 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 5138 | # discovery). Value range is [1,64]. Default value = 32. |
| 5139 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5140 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5141 | "during discovery"); |
| 5142 | |
| 5143 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 5144 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 5145 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 5146 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 5147 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 5148 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 5149 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 5150 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 5151 | # on a target can take minutes of wall clock time. Additionally, |
| 5152 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 5153 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 5154 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 5155 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 5156 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 5157 | # devices present, when in fact, there is only 1. |
| 5158 | # A customer that is aware of their target behaviors, and the results as |
| 5159 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 5160 | # As mentioned, this value is not used by the lpfc driver, only the |
| 5161 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 5162 | # Value range is [0,65535]. Default value is 255. |
| 5163 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5164 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 5165 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5166 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5167 | /* |
| 5168 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 5169 | # Value range is [1,255], default value is 10. |
| 5170 | */ |
| 5171 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 5172 | "Milliseconds driver will wait between polling FCP ring"); |
| 5173 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5174 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5175 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 5176 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 5177 | */ |
| 5178 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 5179 | "Maximum time to wait for task management commands to complete"); |
| 5180 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5181 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 5182 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5183 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5184 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5185 | # 2 = MSI-X enabled (default) |
| 5186 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5187 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5188 | 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] | 5189 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5190 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5191 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5192 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5193 | * |
| 5194 | * 0 = NVME OAS disabled |
| 5195 | * 1 = NVME OAS enabled |
| 5196 | * |
| 5197 | * Value range is [0,1]. Default value is 0. |
| 5198 | */ |
| 5199 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 5200 | "Use OAS bit on NVME IOs"); |
| 5201 | |
| 5202 | /* |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5203 | * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs |
| 5204 | * |
| 5205 | * 0 = Put NVME Command in SGL |
| 5206 | * 1 = Embed NVME Command in WQE (unless G7) |
| 5207 | * 2 = Embed NVME Command in WQE (force) |
| 5208 | * |
| 5209 | * Value range is [0,2]. Default value is 1. |
| 5210 | */ |
| 5211 | LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2, |
| 5212 | "Embed NVME Command in WQE"); |
| 5213 | |
| 5214 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5215 | * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver |
| 5216 | * will advertise it supports to the SCSI layer. This also will map to |
| 5217 | * the number of WQs the driver will create. |
| 5218 | * |
| 5219 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5220 | * 1,32 = Manually specify how many io channels to use. |
| 5221 | * |
| 5222 | * Value range is [0,32]. Default value is 4. |
| 5223 | */ |
| 5224 | LPFC_ATTR_R(fcp_io_channel, |
| 5225 | LPFC_FCP_IO_CHAN_DEF, |
| 5226 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5227 | "Set the number of FCP I/O channels"); |
| 5228 | |
| 5229 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5230 | * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver |
| 5231 | * will advertise it supports to the NVME layer. This also will map to |
| 5232 | * the number of WQs the driver will create. |
| 5233 | * |
| 5234 | * This module parameter is valid when lpfc_enable_fc4_type is set |
| 5235 | * to support NVME. |
| 5236 | * |
| 5237 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5238 | * hardware queue. The administrative queue will always map to WQ 0 |
| 5239 | * A hardware IO queue maps (qidx) to a specific driver WQ. |
| 5240 | * |
| 5241 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5242 | * 1,32 = Manually specify how many io channels to use. |
| 5243 | * |
| 5244 | * Value range is [0,32]. Default value is 0. |
| 5245 | */ |
| 5246 | LPFC_ATTR_R(nvme_io_channel, |
| 5247 | LPFC_NVME_IO_CHAN_DEF, |
| 5248 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
| 5249 | "Set the number of NVME I/O channels"); |
| 5250 | |
| 5251 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5252 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 5253 | # 0 = HBA resets disabled |
| 5254 | # 1 = HBA resets enabled (default) |
| 5255 | # Value range is [0,1]. Default value is 1. |
| 5256 | */ |
| 5257 | LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver."); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 5258 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5259 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5260 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5261 | # 0 = HBA Heartbeat disabled |
| 5262 | # 1 = HBA Heartbeat enabled (default) |
| 5263 | # Value range is [0,1]. Default value is 1. |
| 5264 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5265 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5266 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5267 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5268 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 5269 | # 0x0 Express Lane Feature disabled |
| 5270 | # 0x1 Express Lane Feature enabled |
| 5271 | # Value range is [0,1]. Default value is 0. |
| 5272 | */ |
| 5273 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 5274 | |
| 5275 | /* |
| 5276 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 5277 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 5278 | # Value range is [0x0,0x7f]. Default value is 0 |
| 5279 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 5280 | 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] | 5281 | |
| 5282 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5283 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 5284 | # 0 = BlockGuard disabled (default) |
| 5285 | # 1 = BlockGuard enabled |
| 5286 | # Value range is [0,1]. Default value is 0. |
| 5287 | */ |
| 5288 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5289 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5290 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5291 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 5292 | # 0 = disabled (default) |
| 5293 | # 1 = enabled |
| 5294 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 5295 | # |
| 5296 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5297 | */ |
| 5298 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 5299 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5300 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5301 | # lpfc_prot_mask: i |
| 5302 | # - Bit mask of host protection capabilities used to register with the |
| 5303 | # SCSI mid-layer |
| 5304 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5305 | # - Allows you to ultimately specify which profiles to use |
| 5306 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5307 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5308 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5309 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5310 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5311 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5312 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5313 | # |
| 5314 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5315 | LPFC_ATTR(prot_mask, |
| 5316 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5317 | SHOST_DIX_TYPE0_PROTECTION | |
| 5318 | SHOST_DIX_TYPE1_PROTECTION), |
| 5319 | 0, |
| 5320 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5321 | SHOST_DIX_TYPE0_PROTECTION | |
| 5322 | SHOST_DIX_TYPE1_PROTECTION), |
| 5323 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5324 | |
| 5325 | /* |
| 5326 | # lpfc_prot_guard: i |
| 5327 | # - 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] | 5328 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5329 | # - Allows you to ultimately specify which profiles to use |
| 5330 | # - Default will result in registering capabilities for all guard types |
| 5331 | # |
| 5332 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5333 | LPFC_ATTR(prot_guard, |
| 5334 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5335 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5336 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5337 | /* |
| 5338 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5339 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5340 | * This parameter can have value 0 or 1. |
| 5341 | * When this parameter is set to 0, no delay is added to the initial |
| 5342 | * discovery. |
| 5343 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5344 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5345 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5346 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5347 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5348 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5349 | * Default value is 0. |
| 5350 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5351 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5352 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5353 | |
| 5354 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5355 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5356 | * This value can be set to values between 64 and 4096. The default value is |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5357 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 5358 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5359 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5360 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5361 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5362 | */ |
James Smart | b996ce3 | 2017-12-19 10:57:50 -0800 | [diff] [blame] | 5363 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_MIN_SG_SEG_CNT, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5364 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 5365 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5366 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5367 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 5368 | * 0 = MDS Diagnostics disabled (default) |
| 5369 | * 1 = MDS Diagnostics enabled |
| 5370 | * Value range is [0,1]. Default value is 0. |
| 5371 | */ |
| 5372 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 5373 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5374 | /* |
| 5375 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 5376 | * 0 = BB Credit Recovery disabled |
| 5377 | * 1 = BB Credit Recovery enabled (default) |
| 5378 | * Value range is [0,1]. Default value is 1. |
| 5379 | */ |
| 5380 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 5381 | |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 5382 | /* |
| 5383 | * lpfc_enable_dpp: Enable DPP on G7 |
| 5384 | * 0 = DPP on G7 disabled |
| 5385 | * 1 = DPP on G7 enabled (default) |
| 5386 | * Value range is [0,1]. Default value is 1. |
| 5387 | */ |
| 5388 | LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); |
| 5389 | |
James Smart | 414abe0 | 2018-06-26 08:24:26 -0700 | [diff] [blame] | 5390 | /* |
| 5391 | * lpfc_enable_pbde: Enable PBDE on PRISM - G7 |
| 5392 | * 0 = PBDE on G7 disabled |
| 5393 | * 1 = PBDE on G7 enabled (default) |
| 5394 | * Value range is [0,1]. Default value is 1 |
| 5395 | */ |
| 5396 | LPFC_ATTR_R(enable_pbde, 1, 0, 1, "Enable PBDE support on PRISM"); |
| 5397 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5398 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5399 | &dev_attr_nvme_info, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5400 | &dev_attr_bg_info, |
| 5401 | &dev_attr_bg_guard_err, |
| 5402 | &dev_attr_bg_apptag_err, |
| 5403 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5404 | &dev_attr_info, |
| 5405 | &dev_attr_serialnum, |
| 5406 | &dev_attr_modeldesc, |
| 5407 | &dev_attr_modelname, |
| 5408 | &dev_attr_programtype, |
| 5409 | &dev_attr_portnum, |
| 5410 | &dev_attr_fwrev, |
| 5411 | &dev_attr_hdw, |
| 5412 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5413 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5414 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 5415 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5416 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5417 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5418 | &dev_attr_lpfc_temp_sensor, |
| 5419 | &dev_attr_lpfc_log_verbose, |
| 5420 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5421 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5422 | &dev_attr_lpfc_hba_queue_depth, |
| 5423 | &dev_attr_lpfc_peer_port_login, |
| 5424 | &dev_attr_lpfc_nodev_tmo, |
| 5425 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5426 | &dev_attr_lpfc_enable_fc4_type, |
| 5427 | &dev_attr_lpfc_xri_split, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5428 | &dev_attr_lpfc_fcp_class, |
| 5429 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5430 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5431 | &dev_attr_lpfc_ack0, |
| 5432 | &dev_attr_lpfc_topology, |
| 5433 | &dev_attr_lpfc_scan_down, |
| 5434 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5435 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5436 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5437 | &dev_attr_lpfc_cr_delay, |
| 5438 | &dev_attr_lpfc_cr_count, |
| 5439 | &dev_attr_lpfc_multi_ring_support, |
| 5440 | &dev_attr_lpfc_multi_ring_rctl, |
| 5441 | &dev_attr_lpfc_multi_ring_type, |
| 5442 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5443 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5444 | &dev_attr_lpfc_max_luns, |
| 5445 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5446 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5447 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5448 | &dev_attr_nport_evt_cnt, |
| 5449 | &dev_attr_board_mode, |
| 5450 | &dev_attr_max_vpi, |
| 5451 | &dev_attr_used_vpi, |
| 5452 | &dev_attr_max_rpi, |
| 5453 | &dev_attr_used_rpi, |
| 5454 | &dev_attr_max_xri, |
| 5455 | &dev_attr_used_xri, |
| 5456 | &dev_attr_npiv_info, |
| 5457 | &dev_attr_issue_reset, |
| 5458 | &dev_attr_lpfc_poll, |
| 5459 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5460 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5461 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5462 | &dev_attr_lpfc_nvme_oas, |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5463 | &dev_attr_lpfc_nvme_embed_cmd, |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5464 | &dev_attr_lpfc_auto_imax, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5465 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5466 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5467 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5468 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5469 | &dev_attr_lpfc_nvme_io_channel, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5470 | &dev_attr_lpfc_nvmet_mrq, |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 5471 | &dev_attr_lpfc_nvmet_mrq_post, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5472 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5473 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5474 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 5475 | &dev_attr_lpfc_soft_wwnn, |
| 5476 | &dev_attr_lpfc_soft_wwpn, |
| 5477 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5478 | &dev_attr_lpfc_enable_hba_reset, |
| 5479 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5480 | &dev_attr_lpfc_EnableXLane, |
| 5481 | &dev_attr_lpfc_XLanePriority, |
| 5482 | &dev_attr_lpfc_xlane_lun, |
| 5483 | &dev_attr_lpfc_xlane_tgt, |
| 5484 | &dev_attr_lpfc_xlane_vpt, |
| 5485 | &dev_attr_lpfc_xlane_lun_state, |
| 5486 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5487 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5488 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5489 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5490 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5491 | &dev_attr_lpfc_aer_support, |
| 5492 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5493 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5494 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5495 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5496 | &dev_attr_lpfc_iocb_cnt, |
| 5497 | &dev_attr_iocb_hw, |
| 5498 | &dev_attr_txq_hw, |
| 5499 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5500 | &dev_attr_lpfc_fips_level, |
| 5501 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5502 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5503 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5504 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5505 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5506 | &dev_attr_lpfc_enable_mds_diags, |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5507 | &dev_attr_lpfc_enable_bbcr, |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 5508 | &dev_attr_lpfc_enable_dpp, |
James Smart | 414abe0 | 2018-06-26 08:24:26 -0700 | [diff] [blame] | 5509 | &dev_attr_lpfc_enable_pbde, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5510 | NULL, |
| 5511 | }; |
| 5512 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5513 | struct device_attribute *lpfc_vport_attrs[] = { |
| 5514 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5515 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5516 | &dev_attr_num_discovered_ports, |
| 5517 | &dev_attr_lpfc_drvr_version, |
| 5518 | &dev_attr_lpfc_log_verbose, |
| 5519 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5520 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5521 | &dev_attr_lpfc_nodev_tmo, |
| 5522 | &dev_attr_lpfc_devloss_tmo, |
| 5523 | &dev_attr_lpfc_hba_queue_depth, |
| 5524 | &dev_attr_lpfc_peer_port_login, |
| 5525 | &dev_attr_lpfc_restrict_login, |
| 5526 | &dev_attr_lpfc_fcp_class, |
| 5527 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5528 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5529 | &dev_attr_lpfc_max_luns, |
| 5530 | &dev_attr_nport_evt_cnt, |
| 5531 | &dev_attr_npiv_info, |
| 5532 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5533 | &dev_attr_lpfc_max_scsicmpl_time, |
| 5534 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 5535 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5536 | &dev_attr_lpfc_fips_level, |
| 5537 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5538 | NULL, |
| 5539 | }; |
| 5540 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5541 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5542 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5543 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5544 | * @kobj: kernel kobject that contains the kernel class device. |
| 5545 | * @bin_attr: kernel attributes passed to us. |
| 5546 | * @buf: contains the data to be written to the adapter IOREG space. |
| 5547 | * @off: offset into buffer to beginning of data. |
| 5548 | * @count: bytes to transfer. |
| 5549 | * |
| 5550 | * Description: |
| 5551 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5552 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 5553 | * |
| 5554 | * Returns: |
| 5555 | * -ERANGE off and count combo out of range |
| 5556 | * -EINVAL off, count or buff address invalid |
| 5557 | * -EPERM adapter is offline |
| 5558 | * value of count, buf contents written |
| 5559 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5560 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5561 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 5562 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5563 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5564 | { |
| 5565 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5566 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5567 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5568 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5569 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5570 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5571 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5572 | return -EPERM; |
| 5573 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5574 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5575 | return -ERANGE; |
| 5576 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5577 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 5578 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5579 | |
| 5580 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5581 | return -EINVAL; |
| 5582 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5583 | /* This is to protect HBA registers from accidental writes. */ |
| 5584 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 5585 | return -EINVAL; |
| 5586 | |
| 5587 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5588 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5589 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5590 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5591 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 5592 | buf_off += sizeof(uint32_t)) |
| 5593 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5594 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 5595 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5596 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5597 | |
| 5598 | return count; |
| 5599 | } |
| 5600 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5601 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5602 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5603 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5604 | * @kobj: kernel kobject that contains the kernel class device. |
| 5605 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5606 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5607 | * @off: offset into buffer to beginning of data. |
| 5608 | * @count: bytes to transfer. |
| 5609 | * |
| 5610 | * Description: |
| 5611 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5612 | * Uses the adapter io control registers to read data into buf. |
| 5613 | * |
| 5614 | * Returns: |
| 5615 | * -ERANGE off and count combo out of range |
| 5616 | * -EINVAL off, count or buff address invalid |
| 5617 | * value of count, buf contents read |
| 5618 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5619 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5620 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 5621 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5622 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5623 | { |
| 5624 | size_t buf_off; |
| 5625 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5626 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5627 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5628 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5629 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5630 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5631 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5632 | return -EPERM; |
| 5633 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5634 | if (off > FF_REG_AREA_SIZE) |
| 5635 | return -ERANGE; |
| 5636 | |
| 5637 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5638 | count = FF_REG_AREA_SIZE - off; |
| 5639 | |
| 5640 | if (count == 0) return 0; |
| 5641 | |
| 5642 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5643 | return -EINVAL; |
| 5644 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5645 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5646 | |
| 5647 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 5648 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5649 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5650 | } |
| 5651 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5652 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5653 | |
| 5654 | return count; |
| 5655 | } |
| 5656 | |
| 5657 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5658 | .attr = { |
| 5659 | .name = "ctlreg", |
| 5660 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5661 | }, |
| 5662 | .size = 256, |
| 5663 | .read = sysfs_ctlreg_read, |
| 5664 | .write = sysfs_ctlreg_write, |
| 5665 | }; |
| 5666 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5667 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5668 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5669 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5670 | * @kobj: kernel kobject that contains the kernel class device. |
| 5671 | * @bin_attr: kernel attributes passed to us. |
| 5672 | * @buf: contains the data to be written to sysfs mbox. |
| 5673 | * @off: offset into buffer to beginning of data. |
| 5674 | * @count: bytes to transfer. |
| 5675 | * |
| 5676 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5677 | * Deprecated function. All mailbox access from user space is performed via the |
| 5678 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5679 | * |
| 5680 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5681 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5682 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5683 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5684 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5685 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5686 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5687 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5688 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5689 | } |
| 5690 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5691 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5692 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5693 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5694 | * @kobj: kernel kobject that contains the kernel class device. |
| 5695 | * @bin_attr: kernel attributes passed to us. |
| 5696 | * @buf: contains the data to be read from sysfs mbox. |
| 5697 | * @off: offset into buffer to beginning of data. |
| 5698 | * @count: bytes to transfer. |
| 5699 | * |
| 5700 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5701 | * Deprecated function. All mailbox access from user space is performed via the |
| 5702 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5703 | * |
| 5704 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5705 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5706 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5707 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5708 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5709 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5710 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5711 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5712 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5713 | } |
| 5714 | |
| 5715 | static struct bin_attribute sysfs_mbox_attr = { |
| 5716 | .attr = { |
| 5717 | .name = "mbox", |
| 5718 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5719 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5720 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5721 | .read = sysfs_mbox_read, |
| 5722 | .write = sysfs_mbox_write, |
| 5723 | }; |
| 5724 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5725 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5726 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5727 | * @vport: address of lpfc vport structure. |
| 5728 | * |
| 5729 | * Return codes: |
| 5730 | * zero on success |
| 5731 | * error return code from sysfs_create_bin_file() |
| 5732 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5733 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5734 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5735 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5736 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5737 | int error; |
| 5738 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5739 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5740 | &sysfs_drvr_stat_data_attr); |
| 5741 | |
| 5742 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5743 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5744 | goto out; |
| 5745 | |
| 5746 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5747 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5748 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5749 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5750 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5751 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5752 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5753 | if (error) |
| 5754 | goto out_remove_ctlreg_attr; |
| 5755 | |
| 5756 | return 0; |
| 5757 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5758 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5759 | out_remove_stat_attr: |
| 5760 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5761 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5762 | out: |
| 5763 | return error; |
| 5764 | } |
| 5765 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5766 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5767 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5768 | * @vport: address of lpfc vport structure. |
| 5769 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5770 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5771 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5772 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5773 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5774 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5775 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5776 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5777 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5778 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5779 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5780 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5781 | } |
| 5782 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5783 | /* |
| 5784 | * Dynamic FC Host Attributes Support |
| 5785 | */ |
| 5786 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5787 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5788 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 5789 | * @shost: kernel scsi host pointer. |
| 5790 | **/ |
| 5791 | static void |
| 5792 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 5793 | { |
| 5794 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5795 | |
| 5796 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 5797 | sizeof fc_host_symbolic_name(shost)); |
| 5798 | } |
| 5799 | |
| 5800 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5801 | * 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] | 5802 | * @shost: kernel scsi host pointer. |
| 5803 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5804 | static void |
| 5805 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5806 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5807 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5808 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5809 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5810 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5811 | } |
| 5812 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5813 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5814 | * 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] | 5815 | * @shost: kernel scsi host pointer. |
| 5816 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5817 | static void |
| 5818 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5819 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5820 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5821 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5822 | |
| 5823 | spin_lock_irq(shost->host_lock); |
| 5824 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5825 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5826 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5827 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5828 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5829 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5830 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5831 | else |
| 5832 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5833 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5834 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5835 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5836 | else |
| 5837 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5838 | } |
| 5839 | } else |
| 5840 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5841 | |
| 5842 | spin_unlock_irq(shost->host_lock); |
| 5843 | } |
| 5844 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5845 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5846 | * 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] | 5847 | * @shost: kernel scsi host pointer. |
| 5848 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5849 | static void |
| 5850 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5851 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5852 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5853 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5854 | |
| 5855 | spin_lock_irq(shost->host_lock); |
| 5856 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5857 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5858 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5859 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5860 | switch (phba->link_state) { |
| 5861 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5862 | case LPFC_LINK_DOWN: |
| 5863 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5864 | break; |
| 5865 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5866 | case LPFC_CLEAR_LA: |
| 5867 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5868 | /* Links up, reports port state accordingly */ |
| 5869 | if (vport->port_state < LPFC_VPORT_READY) |
| 5870 | fc_host_port_state(shost) = |
| 5871 | FC_PORTSTATE_BYPASSED; |
| 5872 | else |
| 5873 | fc_host_port_state(shost) = |
| 5874 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5875 | break; |
| 5876 | case LPFC_HBA_ERROR: |
| 5877 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5878 | break; |
| 5879 | default: |
| 5880 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5881 | break; |
| 5882 | } |
| 5883 | } |
| 5884 | |
| 5885 | spin_unlock_irq(shost->host_lock); |
| 5886 | } |
| 5887 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5888 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5889 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5890 | * @shost: kernel scsi host pointer. |
| 5891 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5892 | static void |
| 5893 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5894 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5895 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5896 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5897 | |
| 5898 | spin_lock_irq(shost->host_lock); |
| 5899 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 5900 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5901 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5902 | case LPFC_LINK_SPEED_1GHZ: |
| 5903 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5904 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5905 | case LPFC_LINK_SPEED_2GHZ: |
| 5906 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5907 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5908 | case LPFC_LINK_SPEED_4GHZ: |
| 5909 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5910 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5911 | case LPFC_LINK_SPEED_8GHZ: |
| 5912 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5913 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5914 | case LPFC_LINK_SPEED_10GHZ: |
| 5915 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5916 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5917 | case LPFC_LINK_SPEED_16GHZ: |
| 5918 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5919 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 5920 | case LPFC_LINK_SPEED_32GHZ: |
| 5921 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 5922 | break; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 5923 | case LPFC_LINK_SPEED_64GHZ: |
| 5924 | fc_host_speed(shost) = FC_PORTSPEED_64GBIT; |
| 5925 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5926 | default: |
| 5927 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5928 | break; |
| 5929 | } |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame^] | 5930 | } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) { |
| 5931 | switch (phba->fc_linkspeed) { |
| 5932 | case LPFC_ASYNC_LINK_SPEED_10GBPS: |
| 5933 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
| 5934 | break; |
| 5935 | case LPFC_ASYNC_LINK_SPEED_25GBPS: |
| 5936 | fc_host_speed(shost) = FC_PORTSPEED_25GBIT; |
| 5937 | break; |
| 5938 | case LPFC_ASYNC_LINK_SPEED_40GBPS: |
| 5939 | fc_host_speed(shost) = FC_PORTSPEED_40GBIT; |
| 5940 | break; |
| 5941 | case LPFC_ASYNC_LINK_SPEED_100GBPS: |
| 5942 | fc_host_speed(shost) = FC_PORTSPEED_100GBIT; |
| 5943 | break; |
| 5944 | default: |
| 5945 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| 5946 | break; |
| 5947 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5948 | } else |
| 5949 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5950 | |
| 5951 | spin_unlock_irq(shost->host_lock); |
| 5952 | } |
| 5953 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5954 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5955 | * 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] | 5956 | * @shost: kernel scsi host pointer. |
| 5957 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5958 | static void |
| 5959 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5960 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5961 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5962 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5963 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5964 | |
| 5965 | spin_lock_irq(shost->host_lock); |
| 5966 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5967 | if ((vport->port_state > LPFC_FLOGI) && |
| 5968 | ((vport->fc_flag & FC_FABRIC) || |
| 5969 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5970 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5971 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5972 | else |
| 5973 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5974 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5975 | |
| 5976 | spin_unlock_irq(shost->host_lock); |
| 5977 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5978 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5979 | } |
| 5980 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5981 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5982 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5983 | * @shost: kernel scsi host pointer. |
| 5984 | * |
| 5985 | * Notes: |
| 5986 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5987 | * management not allowed, memory allocation error, or mbox error. |
| 5988 | * |
| 5989 | * Returns: |
| 5990 | * NULL for error |
| 5991 | * address of the adapter host statistics |
| 5992 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5993 | static struct fc_host_statistics * |
| 5994 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5995 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5996 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5997 | struct lpfc_hba *phba = vport->phba; |
| 5998 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5999 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6000 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6001 | LPFC_MBOXQ_t *pmboxq; |
| 6002 | MAILBOX_t *pmb; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6003 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6004 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6005 | /* |
| 6006 | * prevent udev from issuing mailbox commands until the port is |
| 6007 | * configured. |
| 6008 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6009 | if (phba->link_state < LPFC_LINK_DOWN || |
| 6010 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6011 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6012 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6013 | |
| 6014 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6015 | return NULL; |
| 6016 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6017 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6018 | if (!pmboxq) |
| 6019 | return NULL; |
| 6020 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 6021 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6022 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6023 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6024 | pmb->mbxOwner = OWN_HOST; |
| 6025 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6026 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6027 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6028 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6029 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6030 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6031 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6032 | |
| 6033 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6034 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6035 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6036 | return NULL; |
| 6037 | } |
| 6038 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6039 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 6040 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6041 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6042 | /* |
| 6043 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 6044 | * converted to words |
| 6045 | */ |
| 6046 | hs->tx_words = (uint64_t) |
| 6047 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 6048 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6049 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6050 | hs->rx_words = (uint64_t) |
| 6051 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 6052 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6053 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6054 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6055 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6056 | pmb->mbxOwner = OWN_HOST; |
| 6057 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6058 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6059 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6060 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6061 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6062 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6063 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6064 | |
| 6065 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6066 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6067 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6068 | return NULL; |
| 6069 | } |
| 6070 | |
| 6071 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6072 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6073 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6074 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6075 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6076 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6077 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 6078 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6079 | hs->link_failure_count -= lso->link_failure_count; |
| 6080 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 6081 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 6082 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 6083 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 6084 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 6085 | hs->error_frames -= lso->error_frames; |
| 6086 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6087 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6088 | hs->lip_count = -1; |
| 6089 | hs->nos_count = (phba->link_events >> 1); |
| 6090 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6091 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6092 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6093 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6094 | hs->nos_count = -1; |
| 6095 | } else { |
| 6096 | hs->lip_count = -1; |
| 6097 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6098 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6099 | } |
| 6100 | |
| 6101 | hs->dumped_frames = -1; |
| 6102 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6103 | hs->seconds_since_last_reset = ktime_get_seconds() - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6104 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6105 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6106 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6107 | return hs; |
| 6108 | } |
| 6109 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6110 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6111 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6112 | * @shost: kernel scsi host pointer. |
| 6113 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6114 | static void |
| 6115 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 6116 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6117 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6118 | struct lpfc_hba *phba = vport->phba; |
| 6119 | struct lpfc_sli *psli = &phba->sli; |
| 6120 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6121 | LPFC_MBOXQ_t *pmboxq; |
| 6122 | MAILBOX_t *pmb; |
| 6123 | int rc = 0; |
| 6124 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6125 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6126 | return; |
| 6127 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6128 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6129 | if (!pmboxq) |
| 6130 | return; |
| 6131 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6132 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6133 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6134 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6135 | pmb->mbxOwner = OWN_HOST; |
| 6136 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 6137 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6138 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6139 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6140 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6141 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6142 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6143 | else |
| 6144 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6145 | |
| 6146 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6147 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6148 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6149 | return; |
| 6150 | } |
| 6151 | |
| 6152 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6153 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6154 | pmb->mbxOwner = OWN_HOST; |
| 6155 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6156 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6157 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6158 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6159 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6160 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6161 | else |
| 6162 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6163 | |
| 6164 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6165 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6166 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 6167 | return; |
| 6168 | } |
| 6169 | |
| 6170 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6171 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6172 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6173 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6174 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6175 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6176 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6177 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6178 | lso->link_events = (phba->link_events >> 1); |
| 6179 | else |
| 6180 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6181 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6182 | psli->stats_start = ktime_get_seconds(); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6183 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6184 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6185 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6186 | return; |
| 6187 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6188 | |
| 6189 | /* |
| 6190 | * The LPFC driver treats linkdown handling as target loss events so there |
| 6191 | * are no sysfs handlers for link_down_tmo. |
| 6192 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6193 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6194 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6195 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6196 | * @starget: kernel scsi target pointer. |
| 6197 | * |
| 6198 | * Returns: |
| 6199 | * address of the node list if found |
| 6200 | * NULL target not found |
| 6201 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6202 | static struct lpfc_nodelist * |
| 6203 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6204 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6205 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 6206 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6207 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6208 | |
| 6209 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6210 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6211 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6212 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 6213 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6214 | starget->id == ndlp->nlp_sid) { |
| 6215 | spin_unlock_irq(shost->host_lock); |
| 6216 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6217 | } |
| 6218 | } |
| 6219 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6220 | return NULL; |
| 6221 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6222 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6223 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6224 | * 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] | 6225 | * @starget: kernel scsi target pointer. |
| 6226 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6227 | static void |
| 6228 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 6229 | { |
| 6230 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 6231 | |
| 6232 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6233 | } |
| 6234 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6235 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6236 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6237 | * @starget: kernel scsi target pointer. |
| 6238 | * |
| 6239 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 6240 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6241 | static void |
| 6242 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 6243 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6244 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6245 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6246 | fc_starget_node_name(starget) = |
| 6247 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6248 | } |
| 6249 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6250 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6251 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6252 | * @starget: kernel scsi target pointer. |
| 6253 | * |
| 6254 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 6255 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6256 | static void |
| 6257 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 6258 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6259 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6260 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6261 | fc_starget_port_name(starget) = |
| 6262 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6263 | } |
| 6264 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6265 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6266 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6267 | * @rport: fc rport address. |
| 6268 | * @timeout: new value for dev loss tmo. |
| 6269 | * |
| 6270 | * Description: |
| 6271 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 6272 | * dev_loss_tmo to one. |
| 6273 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6274 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6275 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 6276 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6277 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6278 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6279 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6280 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6281 | } |
| 6282 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6283 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6284 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6285 | * |
| 6286 | * Description: |
| 6287 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 6288 | * |
| 6289 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 6290 | * @cdev: class converted to an fc_rport. |
| 6291 | * @buf: on return contains the target_field or zero. |
| 6292 | * |
| 6293 | * Returns: size of formatted string. |
| 6294 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6295 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 6296 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6297 | lpfc_show_rport_##field (struct device *dev, \ |
| 6298 | struct device_attribute *attr, \ |
| 6299 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6300 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6301 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6302 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 6303 | return snprintf(buf, sz, format_string, \ |
| 6304 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 6305 | } |
| 6306 | |
| 6307 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 6308 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 6309 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 6310 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6311 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6312 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6313 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 6314 | * |
| 6315 | * Description: |
| 6316 | * This function is called by the transport after the @fc_vport's symbolic name |
| 6317 | * 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] | 6318 | * 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] | 6319 | **/ |
| 6320 | static void |
| 6321 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 6322 | { |
| 6323 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 6324 | |
| 6325 | if (vport->port_state == LPFC_VPORT_READY) |
| 6326 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 6327 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6328 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6329 | /** |
| 6330 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 6331 | * @phba: Pointer to lpfc_hba struct. |
| 6332 | * |
| 6333 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 6334 | * 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] | 6335 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6336 | * before hba port or vport created. |
| 6337 | **/ |
| 6338 | static void |
| 6339 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 6340 | { |
| 6341 | phba->cfg_log_verbose = verbose; |
| 6342 | } |
| 6343 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6344 | struct fc_function_template lpfc_transport_functions = { |
| 6345 | /* fixed attributes the driver supports */ |
| 6346 | .show_host_node_name = 1, |
| 6347 | .show_host_port_name = 1, |
| 6348 | .show_host_supported_classes = 1, |
| 6349 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6350 | .show_host_supported_speeds = 1, |
| 6351 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6352 | |
| 6353 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6354 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6355 | |
| 6356 | /* dynamic attributes the driver supports */ |
| 6357 | .get_host_port_id = lpfc_get_host_port_id, |
| 6358 | .show_host_port_id = 1, |
| 6359 | |
| 6360 | .get_host_port_type = lpfc_get_host_port_type, |
| 6361 | .show_host_port_type = 1, |
| 6362 | |
| 6363 | .get_host_port_state = lpfc_get_host_port_state, |
| 6364 | .show_host_port_state = 1, |
| 6365 | |
| 6366 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6367 | .show_host_active_fc4s = 1, |
| 6368 | |
| 6369 | .get_host_speed = lpfc_get_host_speed, |
| 6370 | .show_host_speed = 1, |
| 6371 | |
| 6372 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6373 | .show_host_fabric_name = 1, |
| 6374 | |
| 6375 | /* |
| 6376 | * The LPFC driver treats linkdown handling as target loss events |
| 6377 | * so there are no sysfs handlers for link_down_tmo. |
| 6378 | */ |
| 6379 | |
| 6380 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6381 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6382 | |
| 6383 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6384 | .show_rport_maxframe_size = 1, |
| 6385 | .show_rport_supported_classes = 1, |
| 6386 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6387 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6388 | .show_rport_dev_loss_tmo = 1, |
| 6389 | |
| 6390 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6391 | .show_starget_port_id = 1, |
| 6392 | |
| 6393 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6394 | .show_starget_node_name = 1, |
| 6395 | |
| 6396 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6397 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 6398 | |
| 6399 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6400 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6401 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6402 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6403 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6404 | |
| 6405 | .vport_disable = lpfc_vport_disable, |
| 6406 | |
| 6407 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 6408 | |
| 6409 | .bsg_request = lpfc_bsg_request, |
| 6410 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6411 | }; |
| 6412 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6413 | struct fc_function_template lpfc_vport_transport_functions = { |
| 6414 | /* fixed attributes the driver supports */ |
| 6415 | .show_host_node_name = 1, |
| 6416 | .show_host_port_name = 1, |
| 6417 | .show_host_supported_classes = 1, |
| 6418 | .show_host_supported_fc4s = 1, |
| 6419 | .show_host_supported_speeds = 1, |
| 6420 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6421 | |
| 6422 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6423 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6424 | |
| 6425 | /* dynamic attributes the driver supports */ |
| 6426 | .get_host_port_id = lpfc_get_host_port_id, |
| 6427 | .show_host_port_id = 1, |
| 6428 | |
| 6429 | .get_host_port_type = lpfc_get_host_port_type, |
| 6430 | .show_host_port_type = 1, |
| 6431 | |
| 6432 | .get_host_port_state = lpfc_get_host_port_state, |
| 6433 | .show_host_port_state = 1, |
| 6434 | |
| 6435 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6436 | .show_host_active_fc4s = 1, |
| 6437 | |
| 6438 | .get_host_speed = lpfc_get_host_speed, |
| 6439 | .show_host_speed = 1, |
| 6440 | |
| 6441 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6442 | .show_host_fabric_name = 1, |
| 6443 | |
| 6444 | /* |
| 6445 | * The LPFC driver treats linkdown handling as target loss events |
| 6446 | * so there are no sysfs handlers for link_down_tmo. |
| 6447 | */ |
| 6448 | |
| 6449 | .get_fc_host_stats = lpfc_get_stats, |
| 6450 | .reset_fc_host_stats = lpfc_reset_stats, |
| 6451 | |
| 6452 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6453 | .show_rport_maxframe_size = 1, |
| 6454 | .show_rport_supported_classes = 1, |
| 6455 | |
| 6456 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6457 | .show_rport_dev_loss_tmo = 1, |
| 6458 | |
| 6459 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6460 | .show_starget_port_id = 1, |
| 6461 | |
| 6462 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6463 | .show_starget_node_name = 1, |
| 6464 | |
| 6465 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6466 | .show_starget_port_name = 1, |
| 6467 | |
| 6468 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6469 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 6470 | |
| 6471 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6472 | |
| 6473 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6474 | }; |
| 6475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6476 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6477 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6478 | * @phba: lpfc_hba pointer. |
| 6479 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6480 | void |
| 6481 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 6482 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6483 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6484 | 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] | 6485 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 6486 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 6487 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 6488 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 6489 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6490 | lpfc_ack0_init(phba, lpfc_ack0); |
| 6491 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6492 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 6493 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6494 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 6495 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6496 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6497 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6498 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 6499 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 6500 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6501 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 6502 | lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6503 | lpfc_auto_imax_init(phba, lpfc_auto_imax); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6504 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6505 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6506 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 6507 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6508 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6509 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 6510 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 6511 | phba->cfg_EnableXLane = 0; |
| 6512 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6513 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6514 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6515 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6516 | phba->cfg_oas_lun_state = 0; |
| 6517 | phba->cfg_oas_lun_status = 0; |
| 6518 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6519 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6520 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6521 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 6522 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 6523 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6524 | phba->cfg_poll = 0; |
| 6525 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6526 | phba->cfg_poll = lpfc_poll; |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 6527 | |
| 6528 | if (phba->cfg_enable_bg) |
| 6529 | phba->sli3_options |= LPFC_SLI3_BG_ENABLED; |
| 6530 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6531 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6532 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6533 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6534 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 6535 | lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6536 | |
| 6537 | /* Initialize first burst. Target vs Initiator are different. */ |
| 6538 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6539 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6540 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
| 6541 | lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6542 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 6543 | lpfc_enable_dpp_init(phba, lpfc_enable_dpp); |
James Smart | 414abe0 | 2018-06-26 08:24:26 -0700 | [diff] [blame] | 6544 | lpfc_enable_pbde_init(phba, lpfc_enable_pbde); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6545 | |
| 6546 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 6547 | /* NVME only supported on SLI4 */ |
| 6548 | phba->nvmet_support = 0; |
| 6549 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6550 | phba->cfg_enable_bbcr = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6551 | } else { |
| 6552 | /* We MUST have FCP support */ |
| 6553 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 6554 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 6555 | } |
| 6556 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6557 | if (phba->cfg_auto_imax && !phba->cfg_fcp_imax) |
| 6558 | phba->cfg_auto_imax = 0; |
| 6559 | phba->initial_imax = phba->cfg_fcp_imax; |
| 6560 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6561 | /* A value of 0 means use the number of CPUs found in the system */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6562 | if (phba->cfg_fcp_io_channel == 0) |
| 6563 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6564 | if (phba->cfg_nvme_io_channel == 0) |
| 6565 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6566 | |
| 6567 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME) |
| 6568 | phba->cfg_fcp_io_channel = 0; |
| 6569 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6570 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) |
| 6571 | phba->cfg_nvme_io_channel = 0; |
| 6572 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6573 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6574 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6575 | else |
| 6576 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6577 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6578 | phba->cfg_soft_wwnn = 0L; |
| 6579 | phba->cfg_soft_wwpn = 0L; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6580 | lpfc_xri_split_init(phba, lpfc_xri_split); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6581 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 6582 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6583 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6584 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6585 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6586 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6587 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6588 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 6589 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 6590 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6591 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6592 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6593 | return; |
| 6594 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 6595 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6596 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6597 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 6598 | * dependencies between protocols and roles. |
| 6599 | * @phba: lpfc_hba pointer. |
| 6600 | **/ |
| 6601 | void |
| 6602 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 6603 | { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6604 | if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu) |
| 6605 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6606 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6607 | if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu) |
| 6608 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
| 6609 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6610 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 6611 | phba->nvmet_support) { |
| 6612 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
| 6613 | phba->cfg_fcp_io_channel = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6614 | |
| 6615 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 6616 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 6617 | "NVME Target PRLI ACC enable_fb ", |
| 6618 | phba->cfg_nvme_enable_fb, |
| 6619 | phba->cfg_nvmet_fb_size, |
| 6620 | LPFC_NVMET_FB_SZ_MAX); |
| 6621 | |
| 6622 | if (phba->cfg_nvme_enable_fb == 0) |
| 6623 | phba->cfg_nvmet_fb_size = 0; |
| 6624 | else { |
| 6625 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 6626 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 6627 | } |
| 6628 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6629 | if (!phba->cfg_nvmet_mrq) |
| 6630 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6631 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6632 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
| 6633 | if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) { |
| 6634 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6635 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 6636 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 6637 | phba->cfg_nvmet_mrq); |
| 6638 | } |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6639 | if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) |
| 6640 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; |
| 6641 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6642 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6643 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 6644 | phba->nvmet_support = 0; |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6645 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_OFF; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6646 | phba->cfg_nvmet_fb_size = 0; |
| 6647 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6648 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6649 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6650 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6651 | else |
| 6652 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
| 6653 | } |
| 6654 | |
| 6655 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6656 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6657 | * @vport: lpfc_vport pointer. |
| 6658 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6659 | void |
| 6660 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 6661 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6662 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6663 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6664 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6665 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 6666 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 6667 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 6668 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 6669 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 6670 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6671 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6672 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6673 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 6674 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 6675 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 6676 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6677 | return; |
| 6678 | } |