| 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 | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 363 | nrport = NULL; |
| 364 | spin_lock(&vport->phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 365 | rport = lpfc_ndlp_get_nrport(ndlp); |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 366 | if (rport) |
| 367 | nrport = rport->remoteport; |
| 368 | spin_unlock(&vport->phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 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 | |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 886 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 887 | ((bf_get(lpfc_sli_intf_if_type, |
| 888 | &phba->sli4_hba.sli_intf) == |
| 889 | LPFC_SLI_INTF_IF_TYPE_6))) { |
| 890 | struct lpfc_trunk_link link = phba->trunk_link; |
| 891 | |
| 892 | if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) |
| 893 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 894 | "Trunk port 0: Link %s %s\n", |
| 895 | (link.link0.state == LPFC_LINK_UP) ? |
| 896 | "Up" : "Down. ", |
| 897 | trunk_errmsg[link.link0.fault]); |
| 898 | |
| 899 | if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) |
| 900 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 901 | "Trunk port 1: Link %s %s\n", |
| 902 | (link.link1.state == LPFC_LINK_UP) ? |
| 903 | "Up" : "Down. ", |
| 904 | trunk_errmsg[link.link1.fault]); |
| 905 | |
| 906 | if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) |
| 907 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 908 | "Trunk port 2: Link %s %s\n", |
| 909 | (link.link2.state == LPFC_LINK_UP) ? |
| 910 | "Up" : "Down. ", |
| 911 | trunk_errmsg[link.link2.fault]); |
| 912 | |
| 913 | if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) |
| 914 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 915 | "Trunk port 3: Link %s %s\n", |
| 916 | (link.link3.state == LPFC_LINK_UP) ? |
| 917 | "Up" : "Down. ", |
| 918 | trunk_errmsg[link.link3.fault]); |
| 919 | |
| 920 | } |
| 921 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 922 | return len; |
| 923 | } |
| 924 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 925 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 926 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 927 | * @dev: class unused variable. |
| 928 | * @attr: device attribute, not used. |
| 929 | * @buf: on return contains the module description text. |
| 930 | * |
| 931 | * Returns: size of formatted string. |
| 932 | **/ |
| 933 | static ssize_t |
| 934 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 935 | char *buf) |
| 936 | { |
| 937 | struct Scsi_Host *shost = class_to_shost(dev); |
| 938 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 939 | struct lpfc_hba *phba = vport->phba; |
| 940 | |
| 941 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 942 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 943 | |
| 944 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 945 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 946 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 947 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 948 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 949 | } |
| 950 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 951 | } |
| 952 | |
| 953 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 954 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 955 | * (OAS) is supported. |
| 956 | * @dev: class unused variable. |
| 957 | * @attr: device attribute, not used. |
| 958 | * @buf: on return contains the module description text. |
| 959 | * |
| 960 | * Returns: size of formatted string. |
| 961 | **/ |
| 962 | static ssize_t |
| 963 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 964 | char *buf) |
| 965 | { |
| 966 | struct Scsi_Host *shost = class_to_shost(dev); |
| 967 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 968 | struct lpfc_hba *phba = vport->phba; |
| 969 | |
| 970 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 971 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 972 | } |
| 973 | |
| 974 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 975 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 976 | * @dev: class device that is converted into a Scsi_host. |
| 977 | * @attr: device attribute, not used. |
| 978 | * @buf: one or more lpfc_polling_flags values. |
| 979 | * @count: not used. |
| 980 | * |
| 981 | * Returns: |
| 982 | * -EINVAL if the buffer is not "up" or "down" |
| 983 | * return from link state change function if non-zero |
| 984 | * length of the buf on success |
| 985 | **/ |
| 986 | static ssize_t |
| 987 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 988 | const char *buf, size_t count) |
| 989 | { |
| 990 | struct Scsi_Host *shost = class_to_shost(dev); |
| 991 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 992 | struct lpfc_hba *phba = vport->phba; |
| 993 | |
| 994 | int status = -EINVAL; |
| 995 | |
| 996 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 997 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 998 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 999 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 1000 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 1001 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1002 | |
| 1003 | if (status == 0) |
| 1004 | return strlen(buf); |
| 1005 | else |
| 1006 | return status; |
| 1007 | } |
| 1008 | |
| 1009 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1010 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1011 | * @dev: class device that is converted into a Scsi_host. |
| 1012 | * @attr: device attribute, not used. |
| 1013 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 1014 | * |
| 1015 | * Description: |
| 1016 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 1017 | * vport counts. |
| 1018 | * |
| 1019 | * Returns: size of formatted string. |
| 1020 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1021 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1022 | lpfc_num_discovered_ports_show(struct device *dev, |
| 1023 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1024 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1025 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1026 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1027 | |
| 1028 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 1029 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1030 | } |
| 1031 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1032 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1033 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1034 | * @shost: Scsi_Host pointer. |
| 1035 | * |
| 1036 | * Description: |
| 1037 | * Bring the link down gracefully then re-init the link. The firmware will |
| 1038 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 1039 | * |
| 1040 | * Returns: |
| 1041 | * -EPERM port offline or management commands are being blocked |
| 1042 | * -ENOMEM cannot allocate memory for the mailbox command |
| 1043 | * -EIO error sending the mailbox command |
| 1044 | * zero for success |
| 1045 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1046 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1047 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1048 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1049 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1050 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1051 | LPFC_MBOXQ_t *pmboxq; |
| 1052 | int mbxstatus = MBXERR_ERROR; |
| 1053 | |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1054 | /* |
| 1055 | * If the link is offline, disabled or BLOCK_MGMT_IO |
| 1056 | * it doesn't make any sense to allow issue_lip |
| 1057 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1058 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 2289e95 | 2018-01-30 15:58:55 -0800 | [diff] [blame] | 1059 | (phba->hba_flag & LINK_DISABLED) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 1060 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1061 | return -EPERM; |
| 1062 | |
| 1063 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 1064 | |
| 1065 | if (!pmboxq) |
| 1066 | return -ENOMEM; |
| 1067 | |
| 1068 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1069 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 1070 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1071 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 1072 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1073 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1074 | if ((mbxstatus == MBX_SUCCESS) && |
| 1075 | (pmboxq->u.mb.mbxStatus == 0 || |
| 1076 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1077 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1078 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 1079 | phba->cfg_link_speed); |
| 1080 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 1081 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 1082 | if ((mbxstatus == MBX_SUCCESS) && |
| 1083 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 1084 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 1085 | "2859 SLI authentication is required " |
| 1086 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 1087 | } |
| 1088 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 1089 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1090 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 1091 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1092 | |
| 1093 | if (mbxstatus == MBXERR_ERROR) |
| 1094 | return -EIO; |
| 1095 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1096 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1097 | } |
| 1098 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1099 | int |
| 1100 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 1101 | { |
| 1102 | int cnt = 0; |
| 1103 | |
| 1104 | spin_lock_irq(lock); |
| 1105 | while (!list_empty(q)) { |
| 1106 | spin_unlock_irq(lock); |
| 1107 | msleep(20); |
| 1108 | if (cnt++ > 250) { /* 5 secs */ |
| 1109 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 1110 | "0466 %s %s\n", |
| 1111 | "Outstanding IO when ", |
| 1112 | "bringing Adapter offline\n"); |
| 1113 | return 0; |
| 1114 | } |
| 1115 | spin_lock_irq(lock); |
| 1116 | } |
| 1117 | spin_unlock_irq(lock); |
| 1118 | return 1; |
| 1119 | } |
| 1120 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1121 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1122 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1123 | * @phba: lpfc_hba pointer. |
| 1124 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 1125 | * |
| 1126 | * Notes: |
| 1127 | * Assumes any error from lpfc_do_offline() will be negative. |
| 1128 | * Can wait up to 5 seconds for the port ring buffers count |
| 1129 | * 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] | 1130 | * 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] | 1131 | * |
| 1132 | * Returns: |
| 1133 | * -EIO error posting the event |
| 1134 | * zero for success |
| 1135 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1136 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1137 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 1138 | { |
| 1139 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1140 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1141 | struct lpfc_sli_ring *pring; |
| 1142 | struct lpfc_sli *psli; |
| 1143 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1144 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1145 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1146 | |
| 1147 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1148 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1149 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1150 | if (rc == 0) |
| 1151 | return -ENOMEM; |
| 1152 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1153 | wait_for_completion(&online_compl); |
| 1154 | |
| 1155 | if (status != 0) |
| 1156 | return -EIO; |
| 1157 | |
| 1158 | psli = &phba->sli; |
| 1159 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1160 | /* Wait a little for things to settle down, but not |
| 1161 | * long enough for dev loss timeout to expire. |
| 1162 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1163 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 1164 | for (i = 0; i < psli->num_rings; i++) { |
| 1165 | pring = &psli->sli3_ring[i]; |
| 1166 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1167 | &phba->hbalock)) |
| 1168 | goto out; |
| 1169 | } |
| 1170 | } else { |
| 1171 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 1172 | pring = qp->pring; |
| 1173 | if (!pring) |
| 1174 | continue; |
| 1175 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 1176 | &pring->ring_lock)) |
| 1177 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1178 | } |
| 1179 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 1180 | out: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1181 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1182 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 1183 | if (rc == 0) |
| 1184 | return -ENOMEM; |
| 1185 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1186 | wait_for_completion(&online_compl); |
| 1187 | |
| 1188 | if (status != 0) |
| 1189 | return -EIO; |
| 1190 | |
| 1191 | return 0; |
| 1192 | } |
| 1193 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1194 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1195 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1196 | * @phba: lpfc_hba pointer. |
| 1197 | * |
| 1198 | * Description: |
| 1199 | * If the port is configured to allow a reset then the hba is brought |
| 1200 | * offline then online. |
| 1201 | * |
| 1202 | * Notes: |
| 1203 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1204 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1205 | * |
| 1206 | * Returns: |
| 1207 | * lpfc_do_offline() return code if not zero |
| 1208 | * -EIO reset not configured or error posting the event |
| 1209 | * zero for success |
| 1210 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1211 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1212 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1213 | { |
| 1214 | struct completion online_compl; |
| 1215 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1216 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1217 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1218 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1219 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1220 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1221 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1222 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1223 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1224 | if (status != 0) |
| 1225 | return status; |
| 1226 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1227 | |
| 1228 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1229 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1230 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1231 | if (rc == 0) |
| 1232 | return -ENOMEM; |
| 1233 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1234 | wait_for_completion(&online_compl); |
| 1235 | |
| 1236 | if (status != 0) |
| 1237 | return -EIO; |
| 1238 | |
| 1239 | return 0; |
| 1240 | } |
| 1241 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1242 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1243 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1244 | * @dev: class device that is converted into a Scsi_host. |
| 1245 | * @attr: device attribute, not used. |
| 1246 | * @buf: containing the string "selective". |
| 1247 | * @count: unused variable. |
| 1248 | * |
| 1249 | * Description: |
| 1250 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1251 | * is called to perform the reset. |
| 1252 | * |
| 1253 | * Notes: |
| 1254 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1255 | * 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] | 1256 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1257 | * |
| 1258 | * Returns: |
| 1259 | * -EINVAL if the buffer does not contain the string "selective" |
| 1260 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1261 | * return value of lpfc_selective_reset() if the call fails |
| 1262 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1263 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1264 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1265 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1266 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1267 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1268 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1269 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1270 | int status = -EINVAL; |
| 1271 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1272 | if (!phba->cfg_enable_hba_reset) |
| 1273 | return -EACCES; |
| 1274 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1275 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1276 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1277 | |
| 1278 | if (status == 0) |
| 1279 | return strlen(buf); |
| 1280 | else |
| 1281 | return status; |
| 1282 | } |
| 1283 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1284 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1285 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1286 | * @phba: lpfc_hba pointer. |
| 1287 | * |
| 1288 | * Description: |
| 1289 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1290 | * the readyness after performing a firmware reset. |
| 1291 | * |
| 1292 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1293 | * 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] | 1294 | * reset, -EIO when port timeout from recovering from the reset. |
| 1295 | * |
| 1296 | * Note: |
| 1297 | * As the caller will interpret the return code by value, be careful in making |
| 1298 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1299 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1300 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1301 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1302 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1303 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1304 | int i; |
| 1305 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1306 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1307 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1308 | &portstat_reg.word0); |
| 1309 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1310 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1311 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1312 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1313 | return -EPERM; |
| 1314 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1315 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1316 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1317 | msleep(10); |
| 1318 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1319 | &portstat_reg.word0); |
| 1320 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1321 | continue; |
| 1322 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1323 | continue; |
| 1324 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1325 | continue; |
| 1326 | break; |
| 1327 | } |
| 1328 | |
| 1329 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1330 | return 0; |
| 1331 | else |
| 1332 | return -EIO; |
| 1333 | } |
| 1334 | |
| 1335 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1336 | * 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] | 1337 | * @phba: lpfc_hba pointer. |
| 1338 | * |
| 1339 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1340 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1341 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1342 | * |
| 1343 | * Returns: |
| 1344 | * zero for success |
| 1345 | **/ |
| 1346 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1347 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1348 | { |
| 1349 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1350 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1351 | uint32_t before_fc_flag; |
| 1352 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1353 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1354 | int status = 0, rc = 0; |
| 1355 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1356 | |
| 1357 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1358 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1359 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1360 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame^] | 1361 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1362 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1363 | return -EPERM; |
| 1364 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1365 | /* Keep state if we need to restore back */ |
| 1366 | before_fc_flag = phba->pport->fc_flag; |
| 1367 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1368 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1369 | /* Disable SR-IOV virtual functions if enabled */ |
| 1370 | if (phba->cfg_sriov_nr_virtfn) { |
| 1371 | pci_disable_sriov(pdev); |
| 1372 | phba->cfg_sriov_nr_virtfn = 0; |
| 1373 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1374 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1375 | if (opcode == LPFC_FW_DUMP) |
| 1376 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1377 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1378 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1379 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1380 | if (status != 0) { |
| 1381 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1382 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1383 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1384 | |
| 1385 | /* wait for the device to be quiesced before firmware reset */ |
| 1386 | msleep(100); |
| 1387 | |
| 1388 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1389 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1390 | |
| 1391 | if (opcode == LPFC_FW_DUMP) |
| 1392 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1393 | else if (opcode == LPFC_FW_RESET) |
| 1394 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1395 | else if (opcode == LPFC_DV_RESET) |
| 1396 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1397 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1398 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1399 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1400 | /* flush */ |
| 1401 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1402 | |
| 1403 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1404 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1405 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1406 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1407 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1408 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1409 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1410 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1411 | } else if (rc == -EIO) { |
| 1412 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1413 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1414 | "3153 Fail to perform the requested " |
| 1415 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1416 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | /* keep the original port state */ |
| 1420 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1421 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1422 | |
| 1423 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1424 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1425 | LPFC_EVT_ONLINE); |
| 1426 | if (!job_posted) |
| 1427 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1428 | |
| 1429 | wait_for_completion(&online_compl); |
| 1430 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1431 | out: |
| 1432 | /* in any case, restore the virtual functions enabled as before */ |
| 1433 | if (sriov_nr_virtfn) { |
| 1434 | sriov_err = |
| 1435 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1436 | if (!sriov_err) |
| 1437 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1438 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1439 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1440 | /* return proper error code */ |
| 1441 | if (!rc) { |
| 1442 | if (!job_posted) |
| 1443 | rc = -ENOMEM; |
| 1444 | else if (status) |
| 1445 | rc = -EIO; |
| 1446 | } |
| 1447 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1448 | } |
| 1449 | |
| 1450 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1451 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1452 | * @dev: class device that is converted into a Scsi_host. |
| 1453 | * @attr: device attribute, not used. |
| 1454 | * @buf: on return contains the ascii number of nport events. |
| 1455 | * |
| 1456 | * Returns: size of formatted string. |
| 1457 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1458 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1459 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1460 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1461 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1462 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1463 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1464 | struct lpfc_hba *phba = vport->phba; |
| 1465 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1466 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1467 | } |
| 1468 | |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1469 | int |
| 1470 | lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out) |
| 1471 | { |
| 1472 | LPFC_MBOXQ_t *mbox = NULL; |
| 1473 | unsigned long val = 0; |
| 1474 | char *pval = 0; |
| 1475 | int rc = 0; |
| 1476 | |
| 1477 | if (!strncmp("enable", buff_out, |
| 1478 | strlen("enable"))) { |
| 1479 | pval = buff_out + strlen("enable") + 1; |
| 1480 | rc = kstrtoul(pval, 0, &val); |
| 1481 | if (rc) |
| 1482 | return rc; /* Invalid number */ |
| 1483 | } else if (!strncmp("disable", buff_out, |
| 1484 | strlen("disable"))) { |
| 1485 | val = 0; |
| 1486 | } else { |
| 1487 | return -EINVAL; /* Invalid command */ |
| 1488 | } |
| 1489 | |
| 1490 | switch (val) { |
| 1491 | case 0: |
| 1492 | val = 0x0; /* Disable */ |
| 1493 | break; |
| 1494 | case 2: |
| 1495 | val = 0x1; /* Enable two port trunk */ |
| 1496 | break; |
| 1497 | case 4: |
| 1498 | val = 0x2; /* Enable four port trunk */ |
| 1499 | break; |
| 1500 | default: |
| 1501 | return -EINVAL; |
| 1502 | } |
| 1503 | |
| 1504 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1505 | "0070 Set trunk mode with val %ld ", val); |
| 1506 | |
| 1507 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1508 | if (!mbox) |
| 1509 | return -ENOMEM; |
| 1510 | |
| 1511 | lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE, |
| 1512 | LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE, |
| 1513 | 12, LPFC_SLI4_MBX_EMBED); |
| 1514 | |
| 1515 | bf_set(lpfc_mbx_set_trunk_mode, |
| 1516 | &mbox->u.mqe.un.set_trunk_mode, |
| 1517 | val); |
| 1518 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); |
| 1519 | if (rc) |
| 1520 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
| 1521 | "0071 Set trunk mode failed with status: %d", |
| 1522 | rc); |
| 1523 | if (rc != MBX_TIMEOUT) |
| 1524 | mempool_free(mbox, phba->mbox_mem_pool); |
| 1525 | |
| 1526 | return 0; |
| 1527 | } |
| 1528 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1529 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1530 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1531 | * @dev: class device that is converted into a Scsi_host. |
| 1532 | * @attr: device attribute, not used. |
| 1533 | * @buf: on return contains the state of the adapter. |
| 1534 | * |
| 1535 | * Returns: size of formatted string. |
| 1536 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1537 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1538 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1539 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1540 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1541 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1542 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1543 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1544 | char * state; |
| 1545 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1546 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1547 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1548 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1549 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1550 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1551 | state = "offline"; |
| 1552 | else |
| 1553 | state = "online"; |
| 1554 | |
| 1555 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1556 | } |
| 1557 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1558 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1559 | * 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] | 1560 | * @dev: class device that is converted into a Scsi_host. |
| 1561 | * @attr: device attribute, not used. |
| 1562 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1563 | * @count: unused variable. |
| 1564 | * |
| 1565 | * Returns: |
| 1566 | * -EACCES if enable hba reset not enabled |
| 1567 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1568 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1569 | * buf length greater than zero indicates success |
| 1570 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1571 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1572 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1573 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1574 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1575 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1576 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1577 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1578 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1579 | char *board_mode_str = NULL; |
| 1580 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1581 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1582 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1583 | if (!phba->cfg_enable_hba_reset) { |
| 1584 | status = -EACCES; |
| 1585 | goto board_mode_out; |
| 1586 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1587 | |
| 1588 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1589 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1590 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1591 | init_completion(&online_compl); |
| 1592 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1593 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1594 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1595 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1596 | if (rc == 0) { |
| 1597 | status = -ENOMEM; |
| 1598 | goto board_mode_out; |
| 1599 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1600 | wait_for_completion(&online_compl); |
James Smart | 522dcee | 2017-06-01 21:07:03 -0700 | [diff] [blame] | 1601 | if (status) |
| 1602 | status = -EIO; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1603 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1604 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1605 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1606 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1607 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1608 | else |
| 1609 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1610 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1611 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1612 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1613 | else |
| 1614 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1615 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1616 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1617 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1618 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1619 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1620 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 1621 | else if (strncmp(buf, "trunk", sizeof("trunk") - 1) == 0) |
| 1622 | status = lpfc_set_trunking(phba, (char *)buf + sizeof("trunk")); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1623 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1624 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1625 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1626 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1627 | if (!status) |
| 1628 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1629 | else { |
| 1630 | board_mode_str = strchr(buf, '\n'); |
| 1631 | if (board_mode_str) |
| 1632 | *board_mode_str = '\0'; |
| 1633 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1634 | "3097 Failed \"%s\", status(%d), " |
| 1635 | "fc_flag(x%x)\n", |
| 1636 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1637 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1638 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1639 | } |
| 1640 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1641 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1642 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1643 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1644 | * @mxri: max xri count. |
| 1645 | * @axri: available xri count. |
| 1646 | * @mrpi: max rpi count. |
| 1647 | * @arpi: available rpi count. |
| 1648 | * @mvpi: max vpi count. |
| 1649 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1650 | * |
| 1651 | * Description: |
| 1652 | * If an integer pointer for an count is not null then the value for the |
| 1653 | * count is returned. |
| 1654 | * |
| 1655 | * Returns: |
| 1656 | * zero on error |
| 1657 | * one for success |
| 1658 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1659 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1660 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1661 | uint32_t *mxri, uint32_t *axri, |
| 1662 | uint32_t *mrpi, uint32_t *arpi, |
| 1663 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1664 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1665 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1666 | LPFC_MBOXQ_t *pmboxq; |
| 1667 | MAILBOX_t *pmb; |
| 1668 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1669 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1670 | |
| 1671 | /* |
| 1672 | * prevent udev from issuing mailbox commands until the port is |
| 1673 | * configured. |
| 1674 | */ |
| 1675 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1676 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1677 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1678 | return 0; |
| 1679 | |
| 1680 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1681 | return 0; |
| 1682 | |
| 1683 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1684 | if (!pmboxq) |
| 1685 | return 0; |
| 1686 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1687 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1688 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1689 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1690 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 1691 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1692 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1693 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1694 | rc = MBX_NOT_FINISHED; |
| 1695 | else |
| 1696 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1697 | |
| 1698 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1699 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1700 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1701 | return 0; |
| 1702 | } |
| 1703 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1704 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1705 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1706 | if (mrpi) |
| 1707 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1708 | if (arpi) |
| 1709 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1710 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1711 | if (mxri) |
| 1712 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1713 | if (axri) |
| 1714 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1715 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1716 | |
| 1717 | /* Account for differences with SLI-3. Get vpi count from |
| 1718 | * mailbox data and subtract one for max vpi value. |
| 1719 | */ |
| 1720 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1721 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1722 | |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 1723 | /* Limit the max we support */ |
| 1724 | if (max_vpi > LPFC_MAX_VPI) |
| 1725 | max_vpi = LPFC_MAX_VPI; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1726 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1727 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1728 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1729 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1730 | } else { |
| 1731 | if (mrpi) |
| 1732 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1733 | if (arpi) |
| 1734 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1735 | if (mxri) |
| 1736 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1737 | if (axri) |
| 1738 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1739 | if (mvpi) |
| 1740 | *mvpi = pmb->un.varRdConfig.max_vpi; |
James Smart | 8b47ae6 | 2018-11-29 16:09:33 -0800 | [diff] [blame] | 1741 | if (avpi) { |
| 1742 | /* avail_vpi is only valid if link is up and ready */ |
| 1743 | if (phba->link_state == LPFC_HBA_READY) |
| 1744 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1745 | else |
| 1746 | *avpi = pmb->un.varRdConfig.max_vpi; |
| 1747 | } |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1748 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1749 | |
| 1750 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1751 | return 1; |
| 1752 | } |
| 1753 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1754 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1755 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1756 | * @dev: class device that is converted into a Scsi_host. |
| 1757 | * @attr: device attribute, not used. |
| 1758 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1759 | * |
| 1760 | * Description: |
| 1761 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1762 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1763 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1764 | * must check for "Unknown" in the buffer to detect a failure. |
| 1765 | * |
| 1766 | * Returns: size of formatted string. |
| 1767 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1768 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1769 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1770 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1771 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1772 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1773 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1774 | struct lpfc_hba *phba = vport->phba; |
| 1775 | uint32_t cnt; |
| 1776 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1777 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1778 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1779 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1780 | } |
| 1781 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1782 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1783 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1784 | * @dev: class device that is converted into a Scsi_host. |
| 1785 | * @attr: device attribute, not used. |
| 1786 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1787 | * |
| 1788 | * Description: |
| 1789 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1790 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1791 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1792 | * must check for "Unknown" in the buffer to detect a failure. |
| 1793 | * |
| 1794 | * Returns: size of formatted string. |
| 1795 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1796 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1797 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1798 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1799 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1800 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1801 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1802 | struct lpfc_hba *phba = vport->phba; |
| 1803 | uint32_t cnt, acnt; |
| 1804 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1805 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1806 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1807 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1808 | } |
| 1809 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1810 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1811 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1812 | * @dev: class device that is converted into a Scsi_host. |
| 1813 | * @attr: device attribute, not used. |
| 1814 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1815 | * |
| 1816 | * Description: |
| 1817 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1818 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1819 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1820 | * must check for "Unknown" in the buffer to detect a failure. |
| 1821 | * |
| 1822 | * Returns: size of formatted string. |
| 1823 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1824 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1825 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1826 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1827 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1828 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1829 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1830 | struct lpfc_hba *phba = vport->phba; |
| 1831 | uint32_t cnt; |
| 1832 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1833 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1834 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1835 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1836 | } |
| 1837 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1838 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1839 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1840 | * @dev: class device that is converted into a Scsi_host. |
| 1841 | * @attr: device attribute, not used. |
| 1842 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1843 | * |
| 1844 | * Description: |
| 1845 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1846 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1847 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1848 | * must check for "Unknown" in the buffer to detect a failure. |
| 1849 | * |
| 1850 | * Returns: size of formatted string. |
| 1851 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1852 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1853 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1854 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1855 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1856 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1857 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1858 | struct lpfc_hba *phba = vport->phba; |
| 1859 | uint32_t cnt, acnt; |
| 1860 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1861 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1862 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1863 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 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_max_vpi_show - Return maximum vpi |
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: on return contains the maximum vpi count in decimal or "Unknown". |
| 1871 | * |
| 1872 | * Description: |
| 1873 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1874 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1875 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1876 | * must check for "Unknown" in the buffer to detect a failure. |
| 1877 | * |
| 1878 | * Returns: size of formatted string. |
| 1879 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1880 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1881 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1882 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -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 | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1885 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1886 | struct lpfc_hba *phba = vport->phba; |
| 1887 | uint32_t cnt; |
| 1888 | |
| 1889 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1890 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1891 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1892 | } |
| 1893 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1894 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1895 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1896 | * @dev: class device that is converted into a Scsi_host. |
| 1897 | * @attr: device attribute, not used. |
| 1898 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1899 | * |
| 1900 | * Description: |
| 1901 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1902 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1903 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1904 | * must check for "Unknown" in the buffer to detect a failure. |
| 1905 | * |
| 1906 | * Returns: size of formatted string. |
| 1907 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1908 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1909 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1910 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1911 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1912 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1913 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1914 | struct lpfc_hba *phba = vport->phba; |
| 1915 | uint32_t cnt, acnt; |
| 1916 | |
| 1917 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1918 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1919 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1920 | } |
| 1921 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1922 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1923 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1924 | * @dev: class device that is converted into a Scsi_host. |
| 1925 | * @attr: device attribute, not used. |
| 1926 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1927 | * |
| 1928 | * Description: |
| 1929 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1930 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1931 | * the id of the vport. |
| 1932 | * |
| 1933 | * Returns: size of formatted string. |
| 1934 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1935 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1936 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1937 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1938 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1939 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1940 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1941 | struct lpfc_hba *phba = vport->phba; |
| 1942 | |
| 1943 | if (!(phba->max_vpi)) |
| 1944 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1945 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1946 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1947 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1948 | } |
| 1949 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1950 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1951 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1952 | * @dev: class device that is converted into a Scsi_host. |
| 1953 | * @attr: device attribute, not used. |
| 1954 | * @buf: on return contains the cfg_poll in hex. |
| 1955 | * |
| 1956 | * Notes: |
| 1957 | * cfg_poll should be a lpfc_polling_flags type. |
| 1958 | * |
| 1959 | * Returns: size of formatted string. |
| 1960 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1961 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1962 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1963 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1964 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1965 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1966 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1967 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1968 | |
| 1969 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1970 | } |
| 1971 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1972 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1973 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1974 | * @dev: class device that is converted into a Scsi_host. |
| 1975 | * @attr: device attribute, not used. |
| 1976 | * @buf: one or more lpfc_polling_flags values. |
| 1977 | * @count: not used. |
| 1978 | * |
| 1979 | * Notes: |
| 1980 | * buf contents converted to integer and checked for a valid value. |
| 1981 | * |
| 1982 | * Returns: |
| 1983 | * -EINVAL if the buffer connot be converted or is out of range |
| 1984 | * length of the buf on success |
| 1985 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1986 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1987 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1988 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1989 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1990 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1991 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1992 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1993 | uint32_t creg_val; |
| 1994 | uint32_t old_val; |
| 1995 | int val=0; |
| 1996 | |
| 1997 | if (!isdigit(buf[0])) |
| 1998 | return -EINVAL; |
| 1999 | |
| 2000 | if (sscanf(buf, "%i", &val) != 1) |
| 2001 | return -EINVAL; |
| 2002 | |
| 2003 | if ((val & 0x3) != val) |
| 2004 | return -EINVAL; |
| 2005 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 2006 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 2007 | val = 0; |
| 2008 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2009 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 2010 | "3051 lpfc_poll changed from %d to %d\n", |
| 2011 | phba->cfg_poll, val); |
| 2012 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2013 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2014 | |
| 2015 | old_val = phba->cfg_poll; |
| 2016 | |
| 2017 | if (val & ENABLE_FCP_RING_POLLING) { |
| 2018 | if ((val & DISABLE_FCP_RING_INT) && |
| 2019 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2020 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2021 | spin_unlock_irq(&phba->hbalock); |
| 2022 | return -EINVAL; |
| 2023 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2024 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 2025 | writel(creg_val, phba->HCregaddr); |
| 2026 | readl(phba->HCregaddr); /* flush */ |
| 2027 | |
| 2028 | lpfc_poll_start_timer(phba); |
| 2029 | } |
| 2030 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2031 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2032 | return -EINVAL; |
| 2033 | } |
| 2034 | |
| 2035 | if (!(val & DISABLE_FCP_RING_INT) && |
| 2036 | (old_val & DISABLE_FCP_RING_INT)) |
| 2037 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2038 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2039 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2040 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 2041 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 2042 | spin_unlock_irq(&phba->hbalock); |
| 2043 | return -EINVAL; |
| 2044 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2045 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 2046 | writel(creg_val, phba->HCregaddr); |
| 2047 | readl(phba->HCregaddr); /* flush */ |
| 2048 | } |
| 2049 | |
| 2050 | phba->cfg_poll = val; |
| 2051 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2052 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 2053 | |
| 2054 | return strlen(buf); |
| 2055 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2056 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2057 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2058 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 2059 | * @dev: class unused variable. |
| 2060 | * @attr: device attribute, not used. |
| 2061 | * @buf: on return contains the module description text. |
| 2062 | * |
| 2063 | * Returns: size of formatted string. |
| 2064 | **/ |
| 2065 | static ssize_t |
| 2066 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 2067 | char *buf) |
| 2068 | { |
| 2069 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2070 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2071 | struct lpfc_hba *phba = vport->phba; |
| 2072 | |
| 2073 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 2074 | } |
| 2075 | |
| 2076 | /** |
| 2077 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 2078 | * @dev: class unused variable. |
| 2079 | * @attr: device attribute, not used. |
| 2080 | * @buf: on return contains the module description text. |
| 2081 | * |
| 2082 | * Returns: size of formatted string. |
| 2083 | **/ |
| 2084 | static ssize_t |
| 2085 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 2086 | char *buf) |
| 2087 | { |
| 2088 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2089 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2090 | struct lpfc_hba *phba = vport->phba; |
| 2091 | |
| 2092 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 2093 | } |
| 2094 | |
| 2095 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2096 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 2097 | * @dev: class converted to a Scsi_host structure. |
| 2098 | * @attr: device attribute, not used. |
| 2099 | * @buf: on return contains the formatted text. |
| 2100 | * |
| 2101 | * Returns: size of formatted string. |
| 2102 | **/ |
| 2103 | static ssize_t |
| 2104 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 2105 | char *buf) |
| 2106 | { |
| 2107 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2108 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2109 | struct lpfc_hba *phba = vport->phba; |
| 2110 | |
| 2111 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 2112 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 2113 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 2114 | "" : "Not "); |
| 2115 | } |
| 2116 | |
| 2117 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2118 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 2119 | * @dev: class converted to a Scsi_host structure. |
| 2120 | * @attr: device attribute, not used. |
| 2121 | * @buf: on return contains the formatted support level. |
| 2122 | * |
| 2123 | * Description: |
| 2124 | * Returns the maximum number of virtual functions a physical function can |
| 2125 | * support, 0 will be returned if called on virtual function. |
| 2126 | * |
| 2127 | * Returns: size of formatted string. |
| 2128 | **/ |
| 2129 | static ssize_t |
| 2130 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 2131 | struct device_attribute *attr, |
| 2132 | char *buf) |
| 2133 | { |
| 2134 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2135 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2136 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2137 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2138 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 2139 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 2140 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2141 | } |
| 2142 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2143 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 2144 | { |
| 2145 | return val >= min && val <= max; |
| 2146 | } |
| 2147 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2148 | /** |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 2149 | * lpfc_enable_bbcr_set: Sets an attribute value. |
| 2150 | * @phba: pointer the the adapter structure. |
| 2151 | * @val: integer attribute value. |
| 2152 | * |
| 2153 | * Description: |
| 2154 | * Validates the min and max values then sets the |
| 2155 | * adapter config field if in the valid range. prints error message |
| 2156 | * and does not set the parameter if invalid. |
| 2157 | * |
| 2158 | * Returns: |
| 2159 | * zero on success |
| 2160 | * -EINVAL if val is invalid |
| 2161 | */ |
| 2162 | static ssize_t |
| 2163 | lpfc_enable_bbcr_set(struct lpfc_hba *phba, uint val) |
| 2164 | { |
| 2165 | if (lpfc_rangecheck(val, 0, 1) && phba->sli_rev == LPFC_SLI_REV4) { |
| 2166 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2167 | "3068 %s_enable_bbcr changed from %d to %d\n", |
| 2168 | LPFC_DRIVER_NAME, phba->cfg_enable_bbcr, val); |
| 2169 | phba->cfg_enable_bbcr = val; |
| 2170 | return 0; |
| 2171 | } |
| 2172 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2173 | "0451 %s_enable_bbcr cannot set to %d, range is 0, 1\n", |
| 2174 | LPFC_DRIVER_NAME, val); |
| 2175 | return -EINVAL; |
| 2176 | } |
| 2177 | |
| 2178 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2179 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2180 | * |
| 2181 | * Description: |
| 2182 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2183 | * into a function with the name lpfc_hba_queue_depth_show. |
| 2184 | * |
| 2185 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 2186 | * @dev: class device that is converted into a Scsi_host. |
| 2187 | * @attr: device attribute, not used. |
| 2188 | * @buf: on return contains the attribute value in decimal. |
| 2189 | * |
| 2190 | * Returns: size of formatted string. |
| 2191 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2192 | #define lpfc_param_show(attr) \ |
| 2193 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2194 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2195 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2196 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2197 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2198 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2199 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2200 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 2201 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2202 | } |
| 2203 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2204 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2205 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2206 | * |
| 2207 | * Description: |
| 2208 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2209 | * into a function with the name lpfc_hba_queue_depth_show |
| 2210 | * |
| 2211 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 2212 | * @dev: class device that is converted into a Scsi_host. |
| 2213 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2214 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2215 | * |
| 2216 | * Returns: size of formatted string. |
| 2217 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2218 | #define lpfc_param_hex_show(attr) \ |
| 2219 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2220 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2221 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [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 | val = phba->cfg_##attr;\ |
| 2228 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 2229 | phba->cfg_##attr);\ |
| 2230 | } |
| 2231 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2232 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 2233 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2234 | * |
| 2235 | * Description: |
| 2236 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2237 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2238 | * takes a default argument, a minimum and maximum argument. |
| 2239 | * |
| 2240 | * lpfc_##attr##_init: Initializes an attribute. |
| 2241 | * @phba: pointer the the adapter structure. |
| 2242 | * @val: integer attribute value. |
| 2243 | * |
| 2244 | * Validates the min and max values then sets the adapter config field |
| 2245 | * accordingly, or uses the default if out of range and prints an error message. |
| 2246 | * |
| 2247 | * Returns: |
| 2248 | * zero on success |
| 2249 | * -EINVAL if default used |
| 2250 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2251 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 2252 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2253 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2254 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2255 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2256 | phba->cfg_##attr = val;\ |
| 2257 | return 0;\ |
| 2258 | }\ |
| 2259 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2260 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2261 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2262 | phba->cfg_##attr = default;\ |
| 2263 | return -EINVAL;\ |
| 2264 | } |
| 2265 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2266 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2267 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2268 | * |
| 2269 | * Description: |
| 2270 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2271 | * into a function with the name lpfc_hba_queue_depth_set |
| 2272 | * |
| 2273 | * lpfc_##attr##_set: Sets an attribute value. |
| 2274 | * @phba: pointer the the adapter structure. |
| 2275 | * @val: integer attribute value. |
| 2276 | * |
| 2277 | * Description: |
| 2278 | * Validates the min and max values then sets the |
| 2279 | * adapter config field if in the valid range. prints error message |
| 2280 | * and does not set the parameter if invalid. |
| 2281 | * |
| 2282 | * Returns: |
| 2283 | * zero on success |
| 2284 | * -EINVAL if val is invalid |
| 2285 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2286 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 2287 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2288 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2289 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2290 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2291 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 2292 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 2293 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2294 | phba->cfg_##attr = val;\ |
| 2295 | return 0;\ |
| 2296 | }\ |
| 2297 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2298 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 2299 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2300 | return -EINVAL;\ |
| 2301 | } |
| 2302 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2303 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2304 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2305 | * |
| 2306 | * Description: |
| 2307 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2308 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2309 | * |
| 2310 | * lpfc_##attr##_store: Set an sttribute value. |
| 2311 | * @dev: class device that is converted into a Scsi_host. |
| 2312 | * @attr: device attribute, not used. |
| 2313 | * @buf: contains the attribute value in ascii. |
| 2314 | * @count: not used. |
| 2315 | * |
| 2316 | * Description: |
| 2317 | * Convert the ascii text number to an integer, then |
| 2318 | * use the lpfc_##attr##_set function to set the value. |
| 2319 | * |
| 2320 | * Returns: |
| 2321 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2322 | * length of buffer upon success. |
| 2323 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2324 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2325 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2326 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2327 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2328 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2329 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2330 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2331 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2332 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2333 | if (!isdigit(buf[0]))\ |
| 2334 | return -EINVAL;\ |
| 2335 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2336 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2337 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2338 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2339 | else \ |
| 2340 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2341 | } |
| 2342 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2343 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2344 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2345 | * |
| 2346 | * Description: |
| 2347 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2348 | * into a function with the name lpfc_hba_queue_depth_show |
| 2349 | * |
| 2350 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2351 | * @dev: class device that is converted into a Scsi_host. |
| 2352 | * @attr: device attribute, not used. |
| 2353 | * @buf: on return contains the attribute value in decimal. |
| 2354 | * |
| 2355 | * Returns: length of formatted string. |
| 2356 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2357 | #define lpfc_vport_param_show(attr) \ |
| 2358 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2359 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2360 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2361 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2362 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2363 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2364 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 2365 | } |
| 2366 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2367 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2368 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2369 | * |
| 2370 | * Description: |
| 2371 | * Macro that given an attr e.g. |
| 2372 | * hba_queue_depth expands into a function with the name |
| 2373 | * lpfc_hba_queue_depth_show |
| 2374 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2375 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2376 | * @dev: class device that is converted into a Scsi_host. |
| 2377 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2378 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2379 | * |
| 2380 | * Returns: length of formatted string. |
| 2381 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2382 | #define lpfc_vport_param_hex_show(attr) \ |
| 2383 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2384 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2385 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2386 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2387 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2388 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2389 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 2390 | } |
| 2391 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2392 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2393 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2394 | * |
| 2395 | * Description: |
| 2396 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2397 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2398 | * takes a default argument, a minimum and maximum argument. |
| 2399 | * |
| 2400 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2401 | * adapter config field accordingly, or uses the default if out of range |
| 2402 | * and prints an error message. |
| 2403 | * @phba: pointer the the adapter structure. |
| 2404 | * @val: integer attribute value. |
| 2405 | * |
| 2406 | * Returns: |
| 2407 | * zero on success |
| 2408 | * -EINVAL if default used |
| 2409 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2410 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2411 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2412 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2413 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2414 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2415 | vport->cfg_##attr = val;\ |
| 2416 | return 0;\ |
| 2417 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2418 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2419 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2420 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2421 | vport->cfg_##attr = default;\ |
| 2422 | return -EINVAL;\ |
| 2423 | } |
| 2424 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2425 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2426 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2427 | * |
| 2428 | * Description: |
| 2429 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2430 | * into a function with the name lpfc_hba_queue_depth_set |
| 2431 | * |
| 2432 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2433 | * adapter config field if in the valid range. prints error message |
| 2434 | * and does not set the parameter if invalid. |
| 2435 | * @phba: pointer the the adapter structure. |
| 2436 | * @val: integer attribute value. |
| 2437 | * |
| 2438 | * Returns: |
| 2439 | * zero on success |
| 2440 | * -EINVAL if val is invalid |
| 2441 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2442 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2443 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2444 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2445 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2446 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2447 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2448 | "3053 lpfc_" #attr \ |
| 2449 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2450 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2451 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2452 | vport->cfg_##attr = val;\ |
| 2453 | return 0;\ |
| 2454 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2455 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2456 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2457 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2458 | return -EINVAL;\ |
| 2459 | } |
| 2460 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2461 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2462 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2463 | * |
| 2464 | * Description: |
| 2465 | * Macro that given an attr e.g. hba_queue_depth |
| 2466 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2467 | * |
| 2468 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2469 | * use the lpfc_##attr##_set function to set the value. |
| 2470 | * @cdev: class device that is converted into a Scsi_host. |
| 2471 | * @buf: contains the attribute value in decimal. |
| 2472 | * @count: not used. |
| 2473 | * |
| 2474 | * Returns: |
| 2475 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2476 | * length of buffer upon success. |
| 2477 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2478 | #define lpfc_vport_param_store(attr) \ |
| 2479 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2480 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2481 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2482 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2483 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2484 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2485 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2486 | if (!isdigit(buf[0]))\ |
| 2487 | return -EINVAL;\ |
| 2488 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2489 | return -EINVAL;\ |
| 2490 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2491 | return strlen(buf);\ |
| 2492 | else \ |
| 2493 | return -EINVAL;\ |
| 2494 | } |
| 2495 | |
| 2496 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2497 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2498 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2499 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2500 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2501 | 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] | 2502 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2503 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2504 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2505 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2506 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2507 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2508 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2509 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2510 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2511 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2512 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2513 | lpfc_option_rom_version_show, NULL); |
| 2514 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2515 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2516 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2517 | 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] | 2518 | static DEVICE_ATTR_RO(lpfc_drvr_version); |
| 2519 | static DEVICE_ATTR_RO(lpfc_enable_fip); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2520 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2521 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2522 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2523 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2524 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2525 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2526 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2527 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2528 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2529 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 2530 | static DEVICE_ATTR_RO(lpfc_temp_sensor); |
| 2531 | static DEVICE_ATTR_RO(lpfc_fips_level); |
| 2532 | static DEVICE_ATTR_RO(lpfc_fips_rev); |
| 2533 | static DEVICE_ATTR_RO(lpfc_dss); |
| 2534 | static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2535 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2536 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2537 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2538 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2539 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2540 | #define WWN_SZ 8 |
| 2541 | /** |
| 2542 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2543 | * @buf: WWN string. |
| 2544 | * @cnt: Length of string. |
| 2545 | * @wwn: Array to receive converted wwn value. |
| 2546 | * |
| 2547 | * Returns: |
| 2548 | * -EINVAL if the buffer does not contain a valid wwn |
| 2549 | * 0 success |
| 2550 | **/ |
| 2551 | static size_t |
| 2552 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2553 | { |
| 2554 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2555 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2556 | /* Count may include a LF at end of string */ |
| 2557 | if (buf[cnt-1] == '\n') |
| 2558 | cnt--; |
| 2559 | |
| 2560 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2561 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2562 | return -EINVAL; |
| 2563 | |
| 2564 | memset(wwn, 0, WWN_SZ); |
| 2565 | |
| 2566 | /* Validate and store the new name */ |
| 2567 | for (i = 0, j = 0; i < 16; i++) { |
| 2568 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2569 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2570 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2571 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2572 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2573 | j = ((j << 4) | (*buf++ - '0')); |
| 2574 | else |
| 2575 | return -EINVAL; |
| 2576 | if (i % 2) { |
| 2577 | wwn[i/2] = j & 0xff; |
| 2578 | j = 0; |
| 2579 | } |
| 2580 | } |
| 2581 | return 0; |
| 2582 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2583 | /** |
| 2584 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2585 | * @dev: class device that is converted into a Scsi_host. |
| 2586 | * @attr: device attribute, not used. |
| 2587 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2588 | * @count: must be size of lpfc_soft_wwn_key. |
| 2589 | * |
| 2590 | * Returns: |
| 2591 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2592 | * length of buf indicates success |
| 2593 | **/ |
| 2594 | static ssize_t |
| 2595 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2596 | const char *buf, size_t count) |
| 2597 | { |
| 2598 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2599 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2600 | struct lpfc_hba *phba = vport->phba; |
| 2601 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2602 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2603 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2604 | |
| 2605 | /* |
| 2606 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2607 | * We require that the user write a specific key to enable |
| 2608 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2609 | * is written, the enable key resets. If further updates are |
| 2610 | * desired, the key must be written again to re-enable the |
| 2611 | * attribute. |
| 2612 | * |
| 2613 | * The "key" is not secret - it is a hardcoded string shown |
| 2614 | * here. The intent is to protect against the random user or |
| 2615 | * application that is just writing attributes. |
| 2616 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame] | 2617 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2618 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2619 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2620 | " be enabled: fawwpn is enabled\n"); |
| 2621 | return -EINVAL; |
| 2622 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2623 | |
| 2624 | /* count may include a LF at end of string */ |
| 2625 | if (buf[cnt-1] == '\n') |
| 2626 | cnt--; |
| 2627 | |
| 2628 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2629 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2630 | return -EINVAL; |
| 2631 | |
| 2632 | phba->soft_wwn_enable = 1; |
| 2633 | |
| 2634 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2635 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2636 | phba->brd_no); |
| 2637 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2638 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2639 | |
| 2640 | return count; |
| 2641 | } |
Joe Perches | 6cbaefb | 2017-12-19 10:15:09 -0800 | [diff] [blame] | 2642 | static DEVICE_ATTR_WO(lpfc_soft_wwn_enable); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2643 | |
| 2644 | /** |
| 2645 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2646 | * @dev: class device that is converted into a Scsi_host. |
| 2647 | * @attr: device attribute, not used. |
| 2648 | * @buf: on return contains the wwpn in hexadecimal. |
| 2649 | * |
| 2650 | * Returns: size of formatted string. |
| 2651 | **/ |
| 2652 | static ssize_t |
| 2653 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2654 | char *buf) |
| 2655 | { |
| 2656 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2657 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2658 | struct lpfc_hba *phba = vport->phba; |
| 2659 | |
| 2660 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2661 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2662 | } |
| 2663 | |
| 2664 | /** |
| 2665 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2666 | * @dev class device that is converted into a Scsi_host. |
| 2667 | * @attr: device attribute, not used. |
| 2668 | * @buf: contains the wwpn in hexadecimal. |
| 2669 | * @count: number of wwpn bytes in buf |
| 2670 | * |
| 2671 | * Returns: |
| 2672 | * -EACCES hba reset not enabled, adapter over temp |
| 2673 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2674 | * -EIO error taking adapter offline or online |
| 2675 | * value of count on success |
| 2676 | **/ |
| 2677 | static ssize_t |
| 2678 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2679 | const char *buf, size_t count) |
| 2680 | { |
| 2681 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2682 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2683 | struct lpfc_hba *phba = vport->phba; |
| 2684 | struct completion online_compl; |
| 2685 | int stat1 = 0, stat2 = 0; |
| 2686 | unsigned int cnt = count; |
| 2687 | u8 wwpn[WWN_SZ]; |
| 2688 | int rc; |
| 2689 | |
| 2690 | if (!phba->cfg_enable_hba_reset) |
| 2691 | return -EACCES; |
| 2692 | spin_lock_irq(&phba->hbalock); |
| 2693 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2694 | spin_unlock_irq(&phba->hbalock); |
| 2695 | return -EACCES; |
| 2696 | } |
| 2697 | spin_unlock_irq(&phba->hbalock); |
| 2698 | /* count may include a LF at end of string */ |
| 2699 | if (buf[cnt-1] == '\n') |
| 2700 | cnt--; |
| 2701 | |
| 2702 | if (!phba->soft_wwn_enable) |
| 2703 | return -EINVAL; |
| 2704 | |
| 2705 | /* lock setting wwpn, wwnn down */ |
| 2706 | phba->soft_wwn_enable = 0; |
| 2707 | |
| 2708 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2709 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2710 | /* not able to set wwpn, unlock it */ |
| 2711 | phba->soft_wwn_enable = 1; |
| 2712 | return rc; |
| 2713 | } |
| 2714 | |
| 2715 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2716 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2717 | if (phba->cfg_soft_wwnn) |
| 2718 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2719 | |
| 2720 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2721 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2722 | |
| 2723 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2724 | if (stat1) |
| 2725 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2726 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2727 | "reinit adapter - %d\n", stat1); |
| 2728 | init_completion(&online_compl); |
| 2729 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2730 | LPFC_EVT_ONLINE); |
| 2731 | if (rc == 0) |
| 2732 | return -ENOMEM; |
| 2733 | |
| 2734 | wait_for_completion(&online_compl); |
| 2735 | if (stat2) |
| 2736 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2737 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2738 | "reinit adapter - %d\n", stat2); |
| 2739 | return (stat1 || stat2) ? -EIO : count; |
| 2740 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2741 | static DEVICE_ATTR_RW(lpfc_soft_wwpn); |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2742 | |
| 2743 | /** |
| 2744 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2745 | * @dev: class device that is converted into a Scsi_host. |
| 2746 | * @attr: device attribute, not used. |
| 2747 | * @buf: on return contains the wwnn in hexadecimal. |
| 2748 | * |
| 2749 | * Returns: size of formatted string. |
| 2750 | **/ |
| 2751 | static ssize_t |
| 2752 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2753 | char *buf) |
| 2754 | { |
| 2755 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2756 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2757 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2758 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2759 | } |
| 2760 | |
| 2761 | /** |
| 2762 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2763 | * @cdev: class device that is converted into a Scsi_host. |
| 2764 | * @buf: contains the ww node name in hexadecimal. |
| 2765 | * @count: number of wwnn bytes in buf. |
| 2766 | * |
| 2767 | * Returns: |
| 2768 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2769 | * value of count on success |
| 2770 | **/ |
| 2771 | static ssize_t |
| 2772 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2773 | const char *buf, size_t count) |
| 2774 | { |
| 2775 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2776 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2777 | unsigned int cnt = count; |
| 2778 | u8 wwnn[WWN_SZ]; |
| 2779 | int rc; |
| 2780 | |
| 2781 | /* count may include a LF at end of string */ |
| 2782 | if (buf[cnt-1] == '\n') |
| 2783 | cnt--; |
| 2784 | |
| 2785 | if (!phba->soft_wwn_enable) |
| 2786 | return -EINVAL; |
| 2787 | |
| 2788 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2789 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2790 | /* Allow wwnn to be set many times, as long as the enable |
| 2791 | * is set. However, once the wwpn is set, everything locks. |
| 2792 | */ |
| 2793 | return rc; |
| 2794 | } |
| 2795 | |
| 2796 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2797 | |
| 2798 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2799 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2800 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2801 | |
| 2802 | return count; |
| 2803 | } |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 2804 | static DEVICE_ATTR_RW(lpfc_soft_wwnn); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2805 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2806 | /** |
| 2807 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2808 | * Optimized Access Storage (OAS) operations. |
| 2809 | * @dev: class device that is converted into a Scsi_host. |
| 2810 | * @attr: device attribute, not used. |
| 2811 | * @buf: buffer for passing information. |
| 2812 | * |
| 2813 | * Returns: |
| 2814 | * value of count |
| 2815 | **/ |
| 2816 | static ssize_t |
| 2817 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2818 | char *buf) |
| 2819 | { |
| 2820 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2821 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2822 | |
| 2823 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2824 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2825 | } |
| 2826 | |
| 2827 | /** |
| 2828 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2829 | * Optimized Access Storage (OAS) operations. |
| 2830 | * @dev: class device that is converted into a Scsi_host. |
| 2831 | * @attr: device attribute, not used. |
| 2832 | * @buf: buffer for passing information. |
| 2833 | * @count: Size of the data buffer. |
| 2834 | * |
| 2835 | * Returns: |
| 2836 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2837 | * -EPERM oas is not supported by hba |
| 2838 | * value of count on success |
| 2839 | **/ |
| 2840 | static ssize_t |
| 2841 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2842 | const char *buf, size_t count) |
| 2843 | { |
| 2844 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2845 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2846 | unsigned int cnt = count; |
| 2847 | uint8_t wwpn[WWN_SZ]; |
| 2848 | int rc; |
| 2849 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2850 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2851 | return -EPERM; |
| 2852 | |
| 2853 | /* count may include a LF at end of string */ |
| 2854 | if (buf[cnt-1] == '\n') |
| 2855 | cnt--; |
| 2856 | |
| 2857 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2858 | if (rc) |
| 2859 | return rc; |
| 2860 | |
| 2861 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2862 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2863 | if (wwn_to_u64(wwpn) == 0) |
| 2864 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2865 | else |
| 2866 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2867 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2868 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2869 | return count; |
| 2870 | } |
| 2871 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2872 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2873 | |
| 2874 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2875 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2876 | * Optimized Access Storage (OAS) operations. |
| 2877 | * @dev: class device that is converted into a Scsi_host. |
| 2878 | * @attr: device attribute, not used. |
| 2879 | * @buf: buffer for passing information. |
| 2880 | * |
| 2881 | * Returns: |
| 2882 | * value of count |
| 2883 | **/ |
| 2884 | static ssize_t |
| 2885 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2886 | char *buf) |
| 2887 | { |
| 2888 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2889 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2890 | |
| 2891 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2892 | } |
| 2893 | |
| 2894 | /** |
| 2895 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2896 | * Optimized Access Storage (OAS) operations. |
| 2897 | * @dev: class device that is converted into a Scsi_host. |
| 2898 | * @attr: device attribute, not used. |
| 2899 | * @buf: buffer for passing information. |
| 2900 | * @count: Size of the data buffer. |
| 2901 | * |
| 2902 | * Returns: |
| 2903 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2904 | * -EPERM oas is not supported by hba |
| 2905 | * value of count on success |
| 2906 | **/ |
| 2907 | static ssize_t |
| 2908 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2909 | const char *buf, size_t count) |
| 2910 | { |
| 2911 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2912 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2913 | unsigned int cnt = count; |
| 2914 | unsigned long val; |
| 2915 | int ret; |
| 2916 | |
| 2917 | if (!phba->cfg_fof) |
| 2918 | return -EPERM; |
| 2919 | |
| 2920 | /* count may include a LF at end of string */ |
| 2921 | if (buf[cnt-1] == '\n') |
| 2922 | cnt--; |
| 2923 | |
| 2924 | ret = kstrtoul(buf, 0, &val); |
| 2925 | if (ret || (val > 0x7f)) |
| 2926 | return -EINVAL; |
| 2927 | |
| 2928 | if (val) |
| 2929 | phba->cfg_oas_priority = (uint8_t)val; |
| 2930 | else |
| 2931 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2932 | return count; |
| 2933 | } |
| 2934 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2935 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2936 | |
| 2937 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2938 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2939 | * for Optimized Access Storage (OAS) operations. |
| 2940 | * @dev: class device that is converted into a Scsi_host. |
| 2941 | * @attr: device attribute, not used. |
| 2942 | * @buf: buffer for passing information. |
| 2943 | * |
| 2944 | * Returns: |
| 2945 | * value of count on success |
| 2946 | **/ |
| 2947 | static ssize_t |
| 2948 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2949 | char *buf) |
| 2950 | { |
| 2951 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2952 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2953 | |
| 2954 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2955 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2956 | } |
| 2957 | |
| 2958 | /** |
| 2959 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2960 | * for Optimized Access Storage (OAS) operations. |
| 2961 | * @dev: class device that is converted into a Scsi_host. |
| 2962 | * @attr: device attribute, not used. |
| 2963 | * @buf: buffer for passing information. |
| 2964 | * @count: Size of the data buffer. |
| 2965 | * |
| 2966 | * Returns: |
| 2967 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2968 | * -EPERM oas is not supported by hba |
| 2969 | * value of count on success |
| 2970 | **/ |
| 2971 | static ssize_t |
| 2972 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2973 | const char *buf, size_t count) |
| 2974 | { |
| 2975 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2976 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2977 | unsigned int cnt = count; |
| 2978 | uint8_t wwpn[WWN_SZ]; |
| 2979 | int rc; |
| 2980 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2981 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2982 | return -EPERM; |
| 2983 | |
| 2984 | /* count may include a LF at end of string */ |
| 2985 | if (buf[cnt-1] == '\n') |
| 2986 | cnt--; |
| 2987 | |
| 2988 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2989 | if (rc) |
| 2990 | return rc; |
| 2991 | |
| 2992 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2993 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2994 | if (wwn_to_u64(wwpn) == 0) |
| 2995 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2996 | else |
| 2997 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2998 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2999 | if (phba->cfg_oas_priority == 0) |
| 3000 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3001 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 3002 | return count; |
| 3003 | } |
| 3004 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 3005 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 3006 | |
| 3007 | /** |
| 3008 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 3009 | * of whether luns will be enabled or disabled |
| 3010 | * for Optimized Access Storage (OAS) operations. |
| 3011 | * @dev: class device that is converted into a Scsi_host. |
| 3012 | * @attr: device attribute, not used. |
| 3013 | * @buf: buffer for passing information. |
| 3014 | * |
| 3015 | * Returns: |
| 3016 | * size of formatted string. |
| 3017 | **/ |
| 3018 | static ssize_t |
| 3019 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 3020 | char *buf) |
| 3021 | { |
| 3022 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3023 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3024 | |
| 3025 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 3026 | } |
| 3027 | |
| 3028 | /** |
| 3029 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 3030 | * of whether luns will be enabled or disabled |
| 3031 | * for Optimized Access Storage (OAS) operations. |
| 3032 | * @dev: class device that is converted into a Scsi_host. |
| 3033 | * @attr: device attribute, not used. |
| 3034 | * @buf: buffer for passing information. |
| 3035 | * @count: Size of the data buffer. |
| 3036 | * |
| 3037 | * Returns: |
| 3038 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 3039 | * -EPERM oas is not supported by hba |
| 3040 | * value of count on success |
| 3041 | **/ |
| 3042 | static ssize_t |
| 3043 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 3044 | const char *buf, size_t count) |
| 3045 | { |
| 3046 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3047 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3048 | int val = 0; |
| 3049 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3050 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3051 | return -EPERM; |
| 3052 | |
| 3053 | if (!isdigit(buf[0])) |
| 3054 | return -EINVAL; |
| 3055 | |
| 3056 | if (sscanf(buf, "%i", &val) != 1) |
| 3057 | return -EINVAL; |
| 3058 | |
| 3059 | if ((val != 0) && (val != 1)) |
| 3060 | return -EINVAL; |
| 3061 | |
| 3062 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3063 | return strlen(buf); |
| 3064 | } |
| 3065 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 3066 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 3067 | |
| 3068 | /** |
| 3069 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 3070 | * Storage (OAS) lun returned by the |
| 3071 | * lpfc_oas_lun_show function. |
| 3072 | * @dev: class device that is converted into a Scsi_host. |
| 3073 | * @attr: device attribute, not used. |
| 3074 | * @buf: buffer for passing information. |
| 3075 | * |
| 3076 | * Returns: |
| 3077 | * size of formatted string. |
| 3078 | **/ |
| 3079 | static ssize_t |
| 3080 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 3081 | char *buf) |
| 3082 | { |
| 3083 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3084 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3085 | |
| 3086 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 3087 | return -EFAULT; |
| 3088 | |
| 3089 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 3090 | } |
| 3091 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 3092 | lpfc_oas_lun_status_show, NULL); |
| 3093 | |
| 3094 | |
| 3095 | /** |
| 3096 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 3097 | * (OAS) operations. |
| 3098 | * @phba: lpfc_hba pointer. |
| 3099 | * @ndlp: pointer to fcp target node. |
| 3100 | * @lun: the fc lun for setting oas state. |
| 3101 | * @oas_state: the oas state to be set to the lun. |
| 3102 | * |
| 3103 | * Returns: |
| 3104 | * SUCCESS : 0 |
| 3105 | * -EPERM OAS is not enabled or not supported by this port. |
| 3106 | * |
| 3107 | */ |
| 3108 | static size_t |
| 3109 | 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] | 3110 | uint8_t tgt_wwpn[], uint64_t lun, |
| 3111 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3112 | { |
| 3113 | |
| 3114 | int rc = 0; |
| 3115 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3116 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3117 | return -EPERM; |
| 3118 | |
| 3119 | if (oas_state) { |
| 3120 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3121 | (struct lpfc_name *)tgt_wwpn, |
| 3122 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3123 | rc = -ENOMEM; |
| 3124 | } else { |
| 3125 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3126 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3127 | } |
| 3128 | return rc; |
| 3129 | |
| 3130 | } |
| 3131 | |
| 3132 | /** |
| 3133 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 3134 | * Access Storage (OAS) operations. |
| 3135 | * @phba: lpfc_hba pointer. |
| 3136 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 3137 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 3138 | * @lun_status: status of the lun returned lun |
| 3139 | * |
| 3140 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 3141 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 3142 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 3143 | * |
| 3144 | * Return: |
| 3145 | * lun that is OAS enabled for the vport/target |
| 3146 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 3147 | */ |
| 3148 | static uint64_t |
| 3149 | 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] | 3150 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 3151 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3152 | { |
| 3153 | uint64_t found_lun; |
| 3154 | |
| 3155 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 3156 | return NOT_OAS_ENABLED_LUN; |
| 3157 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 3158 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 3159 | (struct lpfc_name *) |
| 3160 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 3161 | &phba->sli4_hba.oas_next_lun, |
| 3162 | (struct lpfc_name *)vpt_wwpn, |
| 3163 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3164 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3165 | return found_lun; |
| 3166 | else |
| 3167 | return NOT_OAS_ENABLED_LUN; |
| 3168 | } |
| 3169 | |
| 3170 | /** |
| 3171 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 3172 | * @phba: lpfc_hba pointer. |
| 3173 | * @vpt_wwpn: vport wwpn by reference. |
| 3174 | * @tgt_wwpn: target wwpn by reference. |
| 3175 | * @lun: the fc lun for setting oas state. |
| 3176 | * @oas_state: the oas state to be set to the oas_lun. |
| 3177 | * |
| 3178 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 3179 | * a lun for OAS operations. |
| 3180 | * |
| 3181 | * Return: |
| 3182 | * SUCCESS: 0 |
| 3183 | * -ENOMEM: failed to enable an lun for OAS operations |
| 3184 | * -EPERM: OAS is not enabled |
| 3185 | */ |
| 3186 | static ssize_t |
| 3187 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 3188 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3189 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3190 | { |
| 3191 | |
| 3192 | int rc; |
| 3193 | |
| 3194 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3195 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3196 | return rc; |
| 3197 | } |
| 3198 | |
| 3199 | /** |
| 3200 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 3201 | * @dev: class device that is converted into a Scsi_host. |
| 3202 | * @attr: device attribute, not used. |
| 3203 | * @buf: buffer for passing information. |
| 3204 | * |
| 3205 | * This routine returns a lun enabled for OAS each time the function |
| 3206 | * is called. |
| 3207 | * |
| 3208 | * Returns: |
| 3209 | * SUCCESS: size of formatted string. |
| 3210 | * -EFAULT: target or vport wwpn was not set properly. |
| 3211 | * -EPERM: oas is not enabled. |
| 3212 | **/ |
| 3213 | static ssize_t |
| 3214 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 3215 | char *buf) |
| 3216 | { |
| 3217 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3218 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3219 | |
| 3220 | uint64_t oas_lun; |
| 3221 | int len = 0; |
| 3222 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3223 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3224 | return -EPERM; |
| 3225 | |
| 3226 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3227 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 3228 | return -EFAULT; |
| 3229 | |
| 3230 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3231 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 3232 | return -EFAULT; |
| 3233 | |
| 3234 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 3235 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3236 | &phba->cfg_oas_lun_status, |
| 3237 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3238 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 3239 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 3240 | |
| 3241 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 3242 | |
| 3243 | return len; |
| 3244 | } |
| 3245 | |
| 3246 | /** |
| 3247 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 3248 | * @dev: class device that is converted into a Scsi_host. |
| 3249 | * @attr: device attribute, not used. |
| 3250 | * @buf: buffer for passing information. |
| 3251 | * |
| 3252 | * This function sets the OAS state for lun. Before this function is called, |
| 3253 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 3254 | * |
| 3255 | * Returns: |
| 3256 | * SUCCESS: size of formatted string. |
| 3257 | * -EFAULT: target or vport wwpn was not set properly. |
| 3258 | * -EPERM: oas is not enabled. |
| 3259 | * size of formatted string. |
| 3260 | **/ |
| 3261 | static ssize_t |
| 3262 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 3263 | const char *buf, size_t count) |
| 3264 | { |
| 3265 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3266 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 3267 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3268 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3269 | ssize_t rc; |
| 3270 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 3271 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3272 | return -EPERM; |
| 3273 | |
| 3274 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 3275 | return -EFAULT; |
| 3276 | |
| 3277 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 3278 | return -EFAULT; |
| 3279 | |
| 3280 | if (!isdigit(buf[0])) |
| 3281 | return -EINVAL; |
| 3282 | |
| 3283 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 3284 | return -EINVAL; |
| 3285 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3286 | pri = phba->cfg_oas_priority; |
| 3287 | if (pri == 0) |
| 3288 | pri = phba->cfg_XLanePriority; |
| 3289 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3290 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3291 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 3292 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3293 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 3294 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3295 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3296 | |
| 3297 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 3298 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 3299 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 3300 | if (rc) |
| 3301 | return rc; |
| 3302 | |
| 3303 | return count; |
| 3304 | } |
| 3305 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3306 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3307 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3308 | int lpfc_enable_nvmet_cnt; |
| 3309 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3310 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3311 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3312 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3313 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3314 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3315 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3316 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3317 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3318 | " 0 - none," |
| 3319 | " 1 - poll with interrupts enabled" |
| 3320 | " 3 - poll and disable FCP ring interrupts"); |
| 3321 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3322 | static DEVICE_ATTR_RW(lpfc_poll); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3323 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3324 | int lpfc_no_hba_reset_cnt; |
| 3325 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3326 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3327 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3328 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3329 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3330 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3331 | "SLI mode selector:" |
| 3332 | " 0 - auto (SLI-3 if supported)," |
| 3333 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3334 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3335 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3336 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3337 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3338 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3339 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3340 | "FCF Fast failover=1 Priority failover=2"); |
| 3341 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3342 | /* |
| 3343 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3344 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3345 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3346 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3347 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3348 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3349 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3350 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3351 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3352 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3353 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3354 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3355 | # 0x2 = never bring up link |
| 3356 | # Default value is 0. |
| 3357 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3358 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3359 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3360 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3361 | /* |
| 3362 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3363 | # 1 - (1024) |
| 3364 | # 2 - (2048) |
| 3365 | # 3 - (3072) |
| 3366 | # 4 - (4096) |
| 3367 | # 5 - (5120) |
| 3368 | */ |
| 3369 | static ssize_t |
| 3370 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3371 | { |
| 3372 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3373 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3374 | |
| 3375 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 3376 | } |
| 3377 | |
| 3378 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3379 | lpfc_iocb_hw_show, NULL); |
| 3380 | static ssize_t |
| 3381 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3382 | { |
| 3383 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3384 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3385 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3386 | |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3387 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 3388 | pring ? pring->txq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3389 | } |
| 3390 | |
| 3391 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3392 | lpfc_txq_hw_show, NULL); |
| 3393 | static ssize_t |
| 3394 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3395 | char *buf) |
| 3396 | { |
| 3397 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3398 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3399 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3400 | |
Dick Kennedy | 1234a6d | 2017-09-29 17:34:29 -0700 | [diff] [blame] | 3401 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 3402 | pring ? pring->txcmplq_max : 0); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3403 | } |
| 3404 | |
| 3405 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3406 | lpfc_txcmplq_hw_show, NULL); |
| 3407 | |
James Smart | 0d8c8ba | 2016-10-13 15:06:07 -0700 | [diff] [blame] | 3408 | LPFC_ATTR_R(iocb_cnt, 2, 1, 5, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3409 | "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] | 3410 | |
| 3411 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3412 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3413 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3414 | */ |
| 3415 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3416 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3417 | module_param(lpfc_nodev_tmo, int, 0); |
| 3418 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3419 | "Seconds driver will hold I/O waiting " |
| 3420 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3421 | |
| 3422 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3423 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3424 | * @dev: class converted to a Scsi_host structure. |
| 3425 | * @attr: device attribute, not used. |
| 3426 | * @buf: on return contains the dev loss timeout in decimal. |
| 3427 | * |
| 3428 | * Returns: size of formatted string. |
| 3429 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3430 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3431 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3432 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3433 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3434 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3435 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3436 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3437 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3438 | } |
| 3439 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3440 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3441 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3442 | * @vport: lpfc vport structure pointer. |
| 3443 | * @val: contains the nodev timeout value. |
| 3444 | * |
| 3445 | * Description: |
| 3446 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3447 | * a kernel error message is printed and zero is returned. |
| 3448 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3449 | * Otherwise nodev tmo is set to the default value. |
| 3450 | * |
| 3451 | * Returns: |
| 3452 | * zero if already set or if val is in range |
| 3453 | * -EINVAL val out of range |
| 3454 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3455 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3456 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3457 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3458 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3459 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3460 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3461 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3462 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3463 | "parameter because lpfc_devloss_tmo " |
| 3464 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3465 | return 0; |
| 3466 | } |
| 3467 | |
| 3468 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3469 | vport->cfg_nodev_tmo = val; |
| 3470 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3471 | return 0; |
| 3472 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3473 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3474 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3475 | " %d, allowed range is [%d, %d]\n", |
| 3476 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3477 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3478 | return -EINVAL; |
| 3479 | } |
| 3480 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3481 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3482 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3483 | * @vport: lpfc vport structure pointer. |
| 3484 | * |
| 3485 | * Description: |
| 3486 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3487 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3488 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3489 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3490 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3491 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3492 | struct lpfc_nodelist *ndlp; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3493 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 3494 | struct lpfc_nvme_rport *rport; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3495 | struct nvme_fc_remote_port *remoteport = NULL; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3496 | #endif |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3497 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3498 | shost = lpfc_shost_from_vport(vport); |
| 3499 | spin_lock_irq(shost->host_lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3500 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3501 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3502 | continue; |
| 3503 | if (ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3504 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3505 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3506 | spin_lock(&vport->phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3507 | rport = lpfc_ndlp_get_nrport(ndlp); |
| 3508 | if (rport) |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 3509 | remoteport = rport->remoteport; |
| 3510 | spin_unlock(&vport->phba->hbalock); |
| 3511 | if (remoteport) |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 3512 | nvme_fc_set_remoteport_devloss(rport->remoteport, |
James Smart | 6ddcf0a | 2017-11-03 09:33:30 -0700 | [diff] [blame] | 3513 | vport->cfg_devloss_tmo); |
| 3514 | #endif |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 3515 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3516 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3517 | } |
| 3518 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3519 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3520 | * 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] | 3521 | * @vport: lpfc vport structure pointer. |
| 3522 | * @val: contains the tmo value. |
| 3523 | * |
| 3524 | * Description: |
| 3525 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3526 | * then a kernel error message is printed and zero is returned. |
| 3527 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3528 | * Otherwise nodev tmo is set to the default value. |
| 3529 | * |
| 3530 | * Returns: |
| 3531 | * zero if already set or if val is in range |
| 3532 | * -EINVAL val out of range |
| 3533 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3534 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3535 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3536 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3537 | if (vport->dev_loss_tmo_changed || |
| 3538 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3539 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3540 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3541 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3542 | return 0; |
| 3543 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3544 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3545 | vport->cfg_nodev_tmo = val; |
| 3546 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3547 | /* |
| 3548 | * For compat: set the fc_host dev loss so new rports |
| 3549 | * will get the value. |
| 3550 | */ |
| 3551 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3552 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3553 | return 0; |
| 3554 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3555 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3556 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3557 | "%d, allowed range is [%d, %d]\n", |
| 3558 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3559 | return -EINVAL; |
| 3560 | } |
| 3561 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3562 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3563 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3564 | static DEVICE_ATTR_RW(lpfc_nodev_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3565 | |
| 3566 | /* |
| 3567 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3568 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3569 | # value is 30. |
| 3570 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3571 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3572 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3573 | "Seconds driver will hold I/O waiting " |
| 3574 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3575 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3576 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3577 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3578 | |
| 3579 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3580 | * 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] | 3581 | * @vport: lpfc vport structure pointer. |
| 3582 | * @val: contains the tmo value. |
| 3583 | * |
| 3584 | * Description: |
| 3585 | * If val is in a valid range then set the vport nodev tmo, |
| 3586 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3587 | * Else a kernel error message is printed. |
| 3588 | * |
| 3589 | * Returns: |
| 3590 | * zero if val is in range |
| 3591 | * -EINVAL val out of range |
| 3592 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3593 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3594 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3595 | { |
| 3596 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3597 | vport->cfg_nodev_tmo = val; |
| 3598 | vport->cfg_devloss_tmo = val; |
| 3599 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3600 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3601 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3602 | return 0; |
| 3603 | } |
| 3604 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3605 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3606 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3607 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3608 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3609 | return -EINVAL; |
| 3610 | } |
| 3611 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3612 | lpfc_vport_param_store(devloss_tmo) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3613 | static DEVICE_ATTR_RW(lpfc_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3614 | |
| 3615 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3616 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3617 | * lpfc_suppress_rsp = 0 Disable |
| 3618 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3619 | * |
| 3620 | */ |
| 3621 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3622 | "Enable suppress rsp feature is firmware supports it"); |
| 3623 | |
| 3624 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3625 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3626 | * lpfc_nvmet_mrq = 0 driver will calcualte optimal number of RQ pairs |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3627 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3628 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3629 | * |
| 3630 | */ |
| 3631 | LPFC_ATTR_R(nvmet_mrq, |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3632 | LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_AUTO, LPFC_NVMET_MRQ_MAX, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3633 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3634 | |
| 3635 | /* |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 3636 | * lpfc_nvmet_mrq_post: Specify number of RQ buffer to initially post |
| 3637 | * to each NVMET RQ. Range 64 to 2048, default is 512. |
| 3638 | */ |
| 3639 | LPFC_ATTR_R(nvmet_mrq_post, |
| 3640 | LPFC_NVMET_RQE_DEF_POST, LPFC_NVMET_RQE_MIN_POST, |
| 3641 | LPFC_NVMET_RQE_DEF_COUNT, |
| 3642 | "Specify number of RQ buffers to initially post"); |
| 3643 | |
| 3644 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3645 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3646 | * Supported Values: 1 - register just FCP |
| 3647 | * 3 - register both FCP and NVME |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3648 | * Supported values are [1,3]. Default value is 1 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3649 | */ |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3650 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3651 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3652 | "Enable FC4 Protocol support - FCP / NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3653 | |
| 3654 | /* |
| 3655 | * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME |
| 3656 | * This parameter is only used if: |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3657 | * lpfc_enable_fc4_type is 3 - register both FCP and NVME and |
| 3658 | * port is not configured for NVMET. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3659 | * |
| 3660 | * ELS/CT always get 10% of XRIs, up to a maximum of 250 |
| 3661 | * The remaining XRIs get split up based on lpfc_xri_split per port: |
| 3662 | * |
| 3663 | * Supported Values are in percentages |
| 3664 | * the xri_split value is the percentage the SCSI port will get. The remaining |
| 3665 | * percentage will go to NVME. |
| 3666 | */ |
| 3667 | LPFC_ATTR_R(xri_split, 50, 10, 90, |
Dick Kennedy | cf4c8c8 | 2017-09-29 17:34:38 -0700 | [diff] [blame] | 3668 | "Percentage of FCP XRI resources versus NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3669 | |
| 3670 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3671 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3672 | # deluged with LOTS of information. |
| 3673 | # 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] | 3674 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3675 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3676 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3677 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3678 | |
| 3679 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3680 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3681 | # objects that have been registered with the nameserver after login. |
| 3682 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3683 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3684 | "Deregister nameserver objects before LOGO"); |
| 3685 | |
| 3686 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3687 | # 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] | 3688 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3689 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3690 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3691 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3692 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3693 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3694 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3695 | |
| 3696 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3697 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3698 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3699 | */ |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 3700 | static uint lpfc_tgt_queue_depth = LPFC_MAX_TGT_QDEPTH; |
| 3701 | module_param(lpfc_tgt_queue_depth, uint, 0444); |
| 3702 | MODULE_PARM_DESC(lpfc_tgt_queue_depth, "Set max Target queue depth"); |
| 3703 | lpfc_vport_param_show(tgt_queue_depth); |
| 3704 | lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH, |
| 3705 | LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH); |
| 3706 | |
| 3707 | /** |
| 3708 | * lpfc_tgt_queue_depth_store: Sets an attribute value. |
| 3709 | * @phba: pointer the the adapter structure. |
| 3710 | * @val: integer attribute value. |
| 3711 | * |
| 3712 | * Description: Sets the parameter to the new value. |
| 3713 | * |
| 3714 | * Returns: |
| 3715 | * zero on success |
| 3716 | * -EINVAL if val is invalid |
| 3717 | */ |
| 3718 | static int |
| 3719 | lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val) |
| 3720 | { |
| 3721 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3722 | struct lpfc_nodelist *ndlp; |
| 3723 | |
| 3724 | if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH)) |
| 3725 | return -EINVAL; |
| 3726 | |
| 3727 | if (val == vport->cfg_tgt_queue_depth) |
| 3728 | return 0; |
| 3729 | |
| 3730 | spin_lock_irq(shost->host_lock); |
| 3731 | vport->cfg_tgt_queue_depth = val; |
| 3732 | |
| 3733 | /* Next loop thru nodelist and change cmd_qdepth */ |
| 3734 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
| 3735 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
| 3736 | |
| 3737 | spin_unlock_irq(shost->host_lock); |
| 3738 | return 0; |
| 3739 | } |
| 3740 | |
| 3741 | lpfc_vport_param_store(tgt_queue_depth); |
| 3742 | static DEVICE_ATTR_RW(lpfc_tgt_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3743 | |
| 3744 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3745 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3746 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3747 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3748 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3749 | # the hba_queue_depth. |
| 3750 | */ |
| 3751 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3752 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3753 | |
| 3754 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3755 | # peer_port_login: This parameter allows/prevents logins |
| 3756 | # between peer ports hosted on the same physical port. |
| 3757 | # When this parameter is set 0 peer ports of same physical port |
| 3758 | # are not allowed to login to each other. |
| 3759 | # When this parameter is set 1 peer ports of same physical port |
| 3760 | # are allowed to login to each other. |
| 3761 | # Default value of this parameter is 0. |
| 3762 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3763 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3764 | "Allow peer ports on the same physical port to login to each " |
| 3765 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3766 | |
| 3767 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3768 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3769 | # between Virtual Ports and remote initiators. |
| 3770 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3771 | # other initiators and will attempt to PLOGI all remote ports. |
| 3772 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3773 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3774 | # This parameter does not restrict to the physical port. |
| 3775 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3776 | # Default value of this parameter is 1. |
| 3777 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3778 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3779 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3780 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3781 | "Restrict virtual ports login to remote initiators."); |
| 3782 | lpfc_vport_param_show(restrict_login); |
| 3783 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3784 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3785 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3786 | * @vport: lpfc vport structure pointer. |
| 3787 | * @val: contains the restrict login value. |
| 3788 | * |
| 3789 | * Description: |
| 3790 | * If val is not in a valid range then log a kernel error message and set |
| 3791 | * the vport restrict login to one. |
| 3792 | * If the port type is physical clear the restrict login flag and return. |
| 3793 | * Else set the restrict login flag to val. |
| 3794 | * |
| 3795 | * Returns: |
| 3796 | * zero if val is in range |
| 3797 | * -EINVAL val out of range |
| 3798 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3799 | static int |
| 3800 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3801 | { |
| 3802 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3803 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3804 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3805 | "be set to %d, allowed range is [0, 1]\n", |
| 3806 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3807 | vport->cfg_restrict_login = 1; |
| 3808 | return -EINVAL; |
| 3809 | } |
| 3810 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3811 | vport->cfg_restrict_login = 0; |
| 3812 | return 0; |
| 3813 | } |
| 3814 | vport->cfg_restrict_login = val; |
| 3815 | return 0; |
| 3816 | } |
| 3817 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3818 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3819 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3820 | * @vport: lpfc vport structure pointer. |
| 3821 | * @val: contains the restrict login value. |
| 3822 | * |
| 3823 | * Description: |
| 3824 | * If val is not in a valid range then log a kernel error message and set |
| 3825 | * the vport restrict login to one. |
| 3826 | * If the port type is physical and the val is not zero log a kernel |
| 3827 | * error message, clear the restrict login flag and return zero. |
| 3828 | * Else set the restrict login flag to val. |
| 3829 | * |
| 3830 | * Returns: |
| 3831 | * zero if val is in range |
| 3832 | * -EINVAL val out of range |
| 3833 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3834 | static int |
| 3835 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3836 | { |
| 3837 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3838 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3839 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3840 | "be set to %d, allowed range is [0, 1]\n", |
| 3841 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3842 | vport->cfg_restrict_login = 1; |
| 3843 | return -EINVAL; |
| 3844 | } |
| 3845 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3846 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3847 | "0468 lpfc_restrict_login must be 0 for " |
| 3848 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3849 | vport->cfg_restrict_login = 0; |
| 3850 | return 0; |
| 3851 | } |
| 3852 | vport->cfg_restrict_login = val; |
| 3853 | return 0; |
| 3854 | } |
| 3855 | lpfc_vport_param_store(restrict_login); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3856 | static DEVICE_ATTR_RW(lpfc_restrict_login); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3857 | |
| 3858 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3859 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3860 | # From a protocol standpoint "select ID" usually means select the |
| 3861 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3862 | # annex" which contains a table that maps a "select ID" (a number |
| 3863 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3864 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3865 | # ALPA. |
| 3866 | # |
| 3867 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3868 | # cause the lpfc driver to use an inverted table, effectively |
| 3869 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3870 | # |
| 3871 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3872 | # and will not work across a fabric. Also this parameter will take |
| 3873 | # effect only in the case when ALPA map is not available.) |
| 3874 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3875 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3876 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3877 | |
| 3878 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3879 | # lpfc_topology: link topology for init link |
| 3880 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3881 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3882 | # 0x02 = attempt point-to-point mode only |
| 3883 | # 0x04 = attempt loop mode only |
| 3884 | # 0x06 = attempt point-to-point mode then loop |
| 3885 | # Set point-to-point mode if you want to run as an N_Port. |
| 3886 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3887 | # Default value is 0. |
| 3888 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3889 | LPFC_ATTR(topology, 0, 0, 6, |
| 3890 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3891 | |
| 3892 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3893 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3894 | * @phba: lpfc_hba pointer. |
| 3895 | * @val: topology value. |
| 3896 | * |
| 3897 | * Description: |
| 3898 | * If val is in a valid range then set the adapter's topology field and |
| 3899 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3900 | * |
| 3901 | * If the value is not in range log a kernel error message and return an error. |
| 3902 | * |
| 3903 | * Returns: |
| 3904 | * zero if val is in range and lip okay |
| 3905 | * non-zero return value from lpfc_issue_lip() |
| 3906 | * -EINVAL val out of range |
| 3907 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3908 | static ssize_t |
| 3909 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3910 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3911 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3912 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3913 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3914 | struct lpfc_hba *phba = vport->phba; |
| 3915 | int val = 0; |
| 3916 | int nolip = 0; |
| 3917 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3918 | int err; |
| 3919 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3920 | |
| 3921 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3922 | nolip = 1; |
| 3923 | val_buf = &buf[strlen("nolip ")]; |
| 3924 | } |
| 3925 | |
| 3926 | if (!isdigit(val_buf[0])) |
| 3927 | return -EINVAL; |
| 3928 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3929 | return -EINVAL; |
| 3930 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3931 | if (val >= 0 && val <= 6) { |
| 3932 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3933 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3934 | val == 4) { |
| 3935 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3936 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3937 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3938 | return -EINVAL; |
| 3939 | } |
James Smart | 76558b2 | 2018-11-29 16:09:38 -0800 | [diff] [blame] | 3940 | if ((phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC || |
| 3941 | phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC) && |
| 3942 | val == 4) { |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3943 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3944 | "3114 Loop mode not supported\n"); |
| 3945 | return -EINVAL; |
| 3946 | } |
| 3947 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3948 | if (nolip) |
| 3949 | return strlen(buf); |
| 3950 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3951 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3952 | "3054 lpfc_topology changed from %d to %d\n", |
| 3953 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3954 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3955 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3956 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3957 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3958 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3959 | return -EINVAL; |
| 3960 | } else |
| 3961 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3962 | } |
| 3963 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3964 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3965 | "allowed range is [0, 6]\n", |
| 3966 | phba->brd_no, val); |
| 3967 | return -EINVAL; |
| 3968 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3969 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3970 | lpfc_param_show(topology) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 3971 | static DEVICE_ATTR_RW(lpfc_topology); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3972 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3973 | /** |
| 3974 | * lpfc_static_vport_show: Read callback function for |
| 3975 | * lpfc_static_vport sysfs file. |
| 3976 | * @dev: Pointer to class device object. |
| 3977 | * @attr: device attribute structure. |
| 3978 | * @buf: Data buffer. |
| 3979 | * |
| 3980 | * This function is the read call back function for |
| 3981 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3982 | * sysfs file report the mageability of the vport. |
| 3983 | **/ |
| 3984 | static ssize_t |
| 3985 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3986 | char *buf) |
| 3987 | { |
| 3988 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3989 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3990 | if (vport->vport_flag & STATIC_VPORT) |
| 3991 | sprintf(buf, "1\n"); |
| 3992 | else |
| 3993 | sprintf(buf, "0\n"); |
| 3994 | |
| 3995 | return strlen(buf); |
| 3996 | } |
| 3997 | |
| 3998 | /* |
| 3999 | * Sysfs attribute to control the statistical data collection. |
| 4000 | */ |
Joe Perches | c828a89 | 2017-12-19 10:15:08 -0800 | [diff] [blame] | 4001 | static DEVICE_ATTR_RO(lpfc_static_vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4002 | |
| 4003 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4004 | * 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] | 4005 | * @dev: Pointer to class device. |
| 4006 | * @buf: Data buffer. |
| 4007 | * @count: Size of the data buffer. |
| 4008 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 4009 | * 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] | 4010 | * sysfs file. This function parse the command written to the sysfs file |
| 4011 | * and take appropriate action. These commands are used for controlling |
| 4012 | * driver statistical data collection. |
| 4013 | * Following are the command this function handles. |
| 4014 | * |
| 4015 | * setbucket <bucket_type> <base> <step> |
| 4016 | * = Set the latency buckets. |
| 4017 | * destroybucket = destroy all the buckets. |
| 4018 | * start = start data collection |
| 4019 | * stop = stop data collection |
| 4020 | * reset = reset the collected data |
| 4021 | **/ |
| 4022 | static ssize_t |
| 4023 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 4024 | const char *buf, size_t count) |
| 4025 | { |
| 4026 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4027 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4028 | struct lpfc_hba *phba = vport->phba; |
| 4029 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 4030 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 4031 | unsigned long i; |
| 4032 | char *str_ptr, *token; |
| 4033 | struct lpfc_vport **vports; |
| 4034 | struct Scsi_Host *v_shost; |
| 4035 | char *bucket_type_str, *base_str, *step_str; |
| 4036 | unsigned long base, step, bucket_type; |
| 4037 | |
| 4038 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4039 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4040 | return -EINVAL; |
| 4041 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 4042 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4043 | str_ptr = &bucket_data[0]; |
| 4044 | /* Ignore this token - this is command token */ |
| 4045 | token = strsep(&str_ptr, "\t "); |
| 4046 | if (!token) |
| 4047 | return -EINVAL; |
| 4048 | |
| 4049 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 4050 | if (!bucket_type_str) |
| 4051 | return -EINVAL; |
| 4052 | |
| 4053 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 4054 | bucket_type = LPFC_LINEAR_BUCKET; |
| 4055 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 4056 | bucket_type = LPFC_POWER2_BUCKET; |
| 4057 | else |
| 4058 | return -EINVAL; |
| 4059 | |
| 4060 | base_str = strsep(&str_ptr, "\t "); |
| 4061 | if (!base_str) |
| 4062 | return -EINVAL; |
| 4063 | base = simple_strtoul(base_str, NULL, 0); |
| 4064 | |
| 4065 | step_str = strsep(&str_ptr, "\t "); |
| 4066 | if (!step_str) |
| 4067 | return -EINVAL; |
| 4068 | step = simple_strtoul(step_str, NULL, 0); |
| 4069 | if (!step) |
| 4070 | return -EINVAL; |
| 4071 | |
| 4072 | /* Block the data collection for every vport */ |
| 4073 | vports = lpfc_create_vport_work_array(phba); |
| 4074 | if (vports == NULL) |
| 4075 | return -ENOMEM; |
| 4076 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4077 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4078 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4079 | spin_lock_irq(v_shost->host_lock); |
| 4080 | /* Block and reset data collection */ |
| 4081 | vports[i]->stat_data_blocked = 1; |
| 4082 | if (vports[i]->stat_data_enabled) |
| 4083 | lpfc_vport_reset_stat_data(vports[i]); |
| 4084 | spin_unlock_irq(v_shost->host_lock); |
| 4085 | } |
| 4086 | |
| 4087 | /* Set the bucket attributes */ |
| 4088 | phba->bucket_type = bucket_type; |
| 4089 | phba->bucket_base = base; |
| 4090 | phba->bucket_step = step; |
| 4091 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4092 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4093 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4094 | |
| 4095 | /* Unblock data collection */ |
| 4096 | spin_lock_irq(v_shost->host_lock); |
| 4097 | vports[i]->stat_data_blocked = 0; |
| 4098 | spin_unlock_irq(v_shost->host_lock); |
| 4099 | } |
| 4100 | lpfc_destroy_vport_work_array(phba, vports); |
| 4101 | return strlen(buf); |
| 4102 | } |
| 4103 | |
| 4104 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 4105 | vports = lpfc_create_vport_work_array(phba); |
| 4106 | if (vports == NULL) |
| 4107 | return -ENOMEM; |
| 4108 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 4109 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4110 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 4111 | spin_lock_irq(shost->host_lock); |
| 4112 | vports[i]->stat_data_blocked = 1; |
| 4113 | lpfc_free_bucket(vport); |
| 4114 | vport->stat_data_enabled = 0; |
| 4115 | vports[i]->stat_data_blocked = 0; |
| 4116 | spin_unlock_irq(shost->host_lock); |
| 4117 | } |
| 4118 | lpfc_destroy_vport_work_array(phba, vports); |
| 4119 | phba->bucket_type = LPFC_NO_BUCKET; |
| 4120 | phba->bucket_base = 0; |
| 4121 | phba->bucket_step = 0; |
| 4122 | return strlen(buf); |
| 4123 | } |
| 4124 | |
| 4125 | if (!strncmp(buf, "start", strlen("start"))) { |
| 4126 | /* If no buckets configured return error */ |
| 4127 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 4128 | return -EINVAL; |
| 4129 | spin_lock_irq(shost->host_lock); |
| 4130 | if (vport->stat_data_enabled) { |
| 4131 | spin_unlock_irq(shost->host_lock); |
| 4132 | return strlen(buf); |
| 4133 | } |
| 4134 | lpfc_alloc_bucket(vport); |
| 4135 | vport->stat_data_enabled = 1; |
| 4136 | spin_unlock_irq(shost->host_lock); |
| 4137 | return strlen(buf); |
| 4138 | } |
| 4139 | |
| 4140 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 4141 | spin_lock_irq(shost->host_lock); |
| 4142 | if (vport->stat_data_enabled == 0) { |
| 4143 | spin_unlock_irq(shost->host_lock); |
| 4144 | return strlen(buf); |
| 4145 | } |
| 4146 | lpfc_free_bucket(vport); |
| 4147 | vport->stat_data_enabled = 0; |
| 4148 | spin_unlock_irq(shost->host_lock); |
| 4149 | return strlen(buf); |
| 4150 | } |
| 4151 | |
| 4152 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 4153 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 4154 | || !vport->stat_data_enabled) |
| 4155 | return strlen(buf); |
| 4156 | spin_lock_irq(shost->host_lock); |
| 4157 | vport->stat_data_blocked = 1; |
| 4158 | lpfc_vport_reset_stat_data(vport); |
| 4159 | vport->stat_data_blocked = 0; |
| 4160 | spin_unlock_irq(shost->host_lock); |
| 4161 | return strlen(buf); |
| 4162 | } |
| 4163 | return -EINVAL; |
| 4164 | } |
| 4165 | |
| 4166 | |
| 4167 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4168 | * 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] | 4169 | * @dev: Pointer to class device object. |
| 4170 | * @buf: Data buffer. |
| 4171 | * |
| 4172 | * This function is the read call back function for |
| 4173 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 4174 | * current statistical data collection state. |
| 4175 | **/ |
| 4176 | static ssize_t |
| 4177 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 4178 | char *buf) |
| 4179 | { |
| 4180 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4181 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4182 | struct lpfc_hba *phba = vport->phba; |
| 4183 | int index = 0; |
| 4184 | int i; |
| 4185 | char *bucket_type; |
| 4186 | unsigned long bucket_value; |
| 4187 | |
| 4188 | switch (phba->bucket_type) { |
| 4189 | case LPFC_LINEAR_BUCKET: |
| 4190 | bucket_type = "linear"; |
| 4191 | break; |
| 4192 | case LPFC_POWER2_BUCKET: |
| 4193 | bucket_type = "power2"; |
| 4194 | break; |
| 4195 | default: |
| 4196 | bucket_type = "No Bucket"; |
| 4197 | break; |
| 4198 | } |
| 4199 | |
| 4200 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 4201 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 4202 | " Bucket step :%d\nLatency Ranges :", |
| 4203 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 4204 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 4205 | index = strlen(buf); |
| 4206 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 4207 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4208 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 4209 | bucket_value = phba->bucket_base + |
| 4210 | phba->bucket_step * i; |
| 4211 | else |
| 4212 | bucket_value = phba->bucket_base + |
| 4213 | (1 << i) * phba->bucket_step; |
| 4214 | |
| 4215 | if (index + 10 > PAGE_SIZE) |
| 4216 | break; |
| 4217 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 4218 | index = strlen(buf); |
| 4219 | } |
| 4220 | } |
| 4221 | sprintf(&buf[index], "\n"); |
| 4222 | return strlen(buf); |
| 4223 | } |
| 4224 | |
| 4225 | /* |
| 4226 | * Sysfs attribute to control the statistical data collection. |
| 4227 | */ |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4228 | static DEVICE_ATTR_RW(lpfc_stat_data_ctrl); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4229 | |
| 4230 | /* |
| 4231 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 4232 | */ |
| 4233 | |
| 4234 | /* |
| 4235 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 4236 | * for each target. |
| 4237 | */ |
| 4238 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 4239 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 4240 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 4241 | |
| 4242 | |
| 4243 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4244 | * 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] | 4245 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4246 | * @kobj: Pointer to the kernel object |
| 4247 | * @bin_attr: Attribute object |
| 4248 | * @buff: Buffer pointer |
| 4249 | * @off: File offset |
| 4250 | * @count: Buffer size |
| 4251 | * |
| 4252 | * This function is the read call back function for lpfc_drvr_stat_data |
| 4253 | * sysfs file. This function export the statistical data to user |
| 4254 | * applications. |
| 4255 | **/ |
| 4256 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 4257 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 4258 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4259 | char *buf, loff_t off, size_t count) |
| 4260 | { |
| 4261 | struct device *dev = container_of(kobj, struct device, |
| 4262 | kobj); |
| 4263 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4264 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4265 | struct lpfc_hba *phba = vport->phba; |
| 4266 | int i = 0, index = 0; |
| 4267 | unsigned long nport_index; |
| 4268 | struct lpfc_nodelist *ndlp = NULL; |
| 4269 | nport_index = (unsigned long)off / |
| 4270 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 4271 | |
| 4272 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 4273 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 4274 | return 0; |
| 4275 | |
| 4276 | spin_lock_irq(shost->host_lock); |
| 4277 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 4278 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 4279 | continue; |
| 4280 | |
| 4281 | if (nport_index > 0) { |
| 4282 | nport_index--; |
| 4283 | continue; |
| 4284 | } |
| 4285 | |
| 4286 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 4287 | > count) |
| 4288 | break; |
| 4289 | |
| 4290 | if (!ndlp->lat_data) |
| 4291 | continue; |
| 4292 | |
| 4293 | /* Print the WWN */ |
| 4294 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 4295 | ndlp->nlp_portname.u.wwn[0], |
| 4296 | ndlp->nlp_portname.u.wwn[1], |
| 4297 | ndlp->nlp_portname.u.wwn[2], |
| 4298 | ndlp->nlp_portname.u.wwn[3], |
| 4299 | ndlp->nlp_portname.u.wwn[4], |
| 4300 | ndlp->nlp_portname.u.wwn[5], |
| 4301 | ndlp->nlp_portname.u.wwn[6], |
| 4302 | ndlp->nlp_portname.u.wwn[7]); |
| 4303 | |
| 4304 | index = strlen(buf); |
| 4305 | |
| 4306 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 4307 | sprintf(&buf[index], "%010u,", |
| 4308 | ndlp->lat_data[i].cmd_count); |
| 4309 | index = strlen(buf); |
| 4310 | } |
| 4311 | sprintf(&buf[index], "\n"); |
| 4312 | index = strlen(buf); |
| 4313 | } |
| 4314 | spin_unlock_irq(shost->host_lock); |
| 4315 | return index; |
| 4316 | } |
| 4317 | |
| 4318 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 4319 | .attr = { |
| 4320 | .name = "lpfc_drvr_stat_data", |
| 4321 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 4322 | }, |
| 4323 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 4324 | .read = sysfs_drvr_stat_data_read, |
| 4325 | .write = NULL, |
| 4326 | }; |
| 4327 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4328 | /* |
| 4329 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 4330 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4331 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4332 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4333 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4334 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4335 | * @phba: lpfc_hba pointer. |
| 4336 | * @val: link speed value. |
| 4337 | * |
| 4338 | * Description: |
| 4339 | * If val is in a valid range then set the adapter's link speed field and |
| 4340 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 4341 | * |
| 4342 | * Notes: |
| 4343 | * If the value is not in range log a kernel error message and return an error. |
| 4344 | * |
| 4345 | * Returns: |
| 4346 | * zero if val is in range and lip okay. |
| 4347 | * non-zero return value from lpfc_issue_lip() |
| 4348 | * -EINVAL val out of range |
| 4349 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4350 | static ssize_t |
| 4351 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 4352 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4353 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4354 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4355 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4356 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4357 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4358 | int nolip = 0; |
| 4359 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4360 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4361 | uint32_t prev_val, if_type; |
| 4362 | |
| 4363 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
James Smart | 719162b | 2018-12-10 19:37:01 -0800 | [diff] [blame^] | 4364 | if (if_type >= LPFC_SLI_INTF_IF_TYPE_2 && |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4365 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4366 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4367 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4368 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4369 | nolip = 1; |
| 4370 | val_buf = &buf[strlen("nolip ")]; |
| 4371 | } |
| 4372 | |
| 4373 | if (!isdigit(val_buf[0])) |
| 4374 | return -EINVAL; |
| 4375 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4376 | return -EINVAL; |
| 4377 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4378 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4379 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4380 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4381 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4382 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4383 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4384 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4385 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4386 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4387 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4388 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) || |
| 4389 | ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4390 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4391 | "2879 lpfc_link_speed attribute cannot be set " |
| 4392 | "to %d. Speed is not supported by this port.\n", |
| 4393 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4394 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4395 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4396 | if (val >= LPFC_USER_LINK_SPEED_16G && |
| 4397 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4398 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4399 | "3112 lpfc_link_speed attribute cannot be set " |
| 4400 | "to %d. Speed is not supported in loop mode.\n", |
| 4401 | val); |
| 4402 | return -EINVAL; |
| 4403 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4404 | |
| 4405 | switch (val) { |
| 4406 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4407 | case LPFC_USER_LINK_SPEED_1G: |
| 4408 | case LPFC_USER_LINK_SPEED_2G: |
| 4409 | case LPFC_USER_LINK_SPEED_4G: |
| 4410 | case LPFC_USER_LINK_SPEED_8G: |
| 4411 | case LPFC_USER_LINK_SPEED_16G: |
| 4412 | case LPFC_USER_LINK_SPEED_32G: |
| 4413 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4414 | prev_val = phba->cfg_link_speed; |
| 4415 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4416 | if (nolip) |
| 4417 | return strlen(buf); |
| 4418 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4419 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4420 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4421 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4422 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4423 | } |
| 4424 | return strlen(buf); |
| 4425 | default: |
| 4426 | break; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4427 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4428 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4429 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4430 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4431 | "allowed values are [%s]\n", |
| 4432 | val, LPFC_LINK_SPEED_STRING); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4433 | return -EINVAL; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4434 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4435 | } |
| 4436 | |
| 4437 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4438 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4439 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4440 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4441 | |
| 4442 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4443 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4444 | * @phba: lpfc_hba pointer. |
| 4445 | * @val: link speed value. |
| 4446 | * |
| 4447 | * Description: |
| 4448 | * If val is in a valid range then set the adapter's link speed field. |
| 4449 | * |
| 4450 | * Notes: |
| 4451 | * If the value is not in range log a kernel error message, clear the link |
| 4452 | * speed and return an error. |
| 4453 | * |
| 4454 | * Returns: |
| 4455 | * zero if val saved. |
| 4456 | * -EINVAL val out of range |
| 4457 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4458 | static int |
| 4459 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4460 | { |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4461 | if (val >= LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4462 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4463 | "3111 lpfc_link_speed of %d cannot " |
| 4464 | "support loop mode, setting topology to default.\n", |
| 4465 | val); |
| 4466 | phba->cfg_topology = 0; |
| 4467 | } |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4468 | |
| 4469 | switch (val) { |
| 4470 | case LPFC_USER_LINK_SPEED_AUTO: |
| 4471 | case LPFC_USER_LINK_SPEED_1G: |
| 4472 | case LPFC_USER_LINK_SPEED_2G: |
| 4473 | case LPFC_USER_LINK_SPEED_4G: |
| 4474 | case LPFC_USER_LINK_SPEED_8G: |
| 4475 | case LPFC_USER_LINK_SPEED_16G: |
| 4476 | case LPFC_USER_LINK_SPEED_32G: |
| 4477 | case LPFC_USER_LINK_SPEED_64G: |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4478 | phba->cfg_link_speed = val; |
| 4479 | return 0; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 4480 | default: |
| 4481 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4482 | "0405 lpfc_link_speed attribute cannot " |
| 4483 | "be set to %d, allowed values are " |
| 4484 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
| 4485 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
| 4486 | return -EINVAL; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4487 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4488 | } |
| 4489 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4490 | static DEVICE_ATTR_RW(lpfc_link_speed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4491 | |
| 4492 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4493 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4494 | # 0 = aer disabled or not supported |
| 4495 | # 1 = aer supported and enabled (default) |
| 4496 | # Value range is [0,1]. Default value is 1. |
| 4497 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4498 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4499 | "Enable PCIe device AER support"); |
| 4500 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4501 | |
| 4502 | /** |
| 4503 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4504 | * |
| 4505 | * @dev: class device that is converted into a Scsi_host. |
| 4506 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4507 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4508 | * @count: unused variable. |
| 4509 | * |
| 4510 | * Description: |
| 4511 | * If the val is 1 and currently the device's AER capability was not |
| 4512 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4513 | * enable the device's AER capability. If the helper routine enabling |
| 4514 | * AER returns success, update the device's cfg_aer_support flag to |
| 4515 | * indicate AER is supported by the device; otherwise, if the device |
| 4516 | * AER capability is already enabled to support AER, then do nothing. |
| 4517 | * |
| 4518 | * If the val is 0 and currently the device's AER support was enabled, |
| 4519 | * invoke the kernel's disable AER helper routine. After that, update |
| 4520 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4521 | * by the device; otherwise, if the device AER capability is already |
| 4522 | * disabled from supporting AER, then do nothing. |
| 4523 | * |
| 4524 | * Returns: |
| 4525 | * length of the buf on success if val is in range the intended mode |
| 4526 | * is supported. |
| 4527 | * -EINVAL if val out of range or intended mode is not supported. |
| 4528 | **/ |
| 4529 | static ssize_t |
| 4530 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4531 | const char *buf, size_t count) |
| 4532 | { |
| 4533 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4534 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4535 | struct lpfc_hba *phba = vport->phba; |
| 4536 | int val = 0, rc = -EINVAL; |
| 4537 | |
| 4538 | if (!isdigit(buf[0])) |
| 4539 | return -EINVAL; |
| 4540 | if (sscanf(buf, "%i", &val) != 1) |
| 4541 | return -EINVAL; |
| 4542 | |
| 4543 | switch (val) { |
| 4544 | case 0: |
| 4545 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4546 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4547 | if (!rc) { |
| 4548 | spin_lock_irq(&phba->hbalock); |
| 4549 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4550 | spin_unlock_irq(&phba->hbalock); |
| 4551 | phba->cfg_aer_support = 0; |
| 4552 | rc = strlen(buf); |
| 4553 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4554 | rc = -EPERM; |
| 4555 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4556 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4557 | rc = strlen(buf); |
| 4558 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4559 | break; |
| 4560 | case 1: |
| 4561 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4562 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4563 | if (!rc) { |
| 4564 | spin_lock_irq(&phba->hbalock); |
| 4565 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4566 | spin_unlock_irq(&phba->hbalock); |
| 4567 | phba->cfg_aer_support = 1; |
| 4568 | rc = strlen(buf); |
| 4569 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4570 | rc = -EPERM; |
| 4571 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4572 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4573 | rc = strlen(buf); |
| 4574 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4575 | break; |
| 4576 | default: |
| 4577 | rc = -EINVAL; |
| 4578 | break; |
| 4579 | } |
| 4580 | return rc; |
| 4581 | } |
| 4582 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4583 | static DEVICE_ATTR_RW(lpfc_aer_support); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4584 | |
| 4585 | /** |
| 4586 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4587 | * @dev: class device that is converted into a Scsi_host. |
| 4588 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4589 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4590 | * @count: unused variable. |
| 4591 | * |
| 4592 | * Description: |
| 4593 | * If the @buf contains 1 and the device currently has the AER support |
| 4594 | * enabled, then invokes the kernel AER helper routine |
| 4595 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4596 | * error status register. |
| 4597 | * |
| 4598 | * Notes: |
| 4599 | * |
| 4600 | * Returns: |
| 4601 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4602 | * enabled with the AER support. |
| 4603 | **/ |
| 4604 | static ssize_t |
| 4605 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4606 | const char *buf, size_t count) |
| 4607 | { |
| 4608 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4609 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4610 | struct lpfc_hba *phba = vport->phba; |
| 4611 | int val, rc = -1; |
| 4612 | |
| 4613 | if (!isdigit(buf[0])) |
| 4614 | return -EINVAL; |
| 4615 | if (sscanf(buf, "%i", &val) != 1) |
| 4616 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4617 | if (val != 1) |
| 4618 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4619 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4620 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4621 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4622 | |
| 4623 | if (rc == 0) |
| 4624 | return strlen(buf); |
| 4625 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4626 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4627 | } |
| 4628 | |
| 4629 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4630 | lpfc_aer_cleanup_state); |
| 4631 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4632 | /** |
| 4633 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4634 | * |
| 4635 | * @dev: class device that is converted into a Scsi_host. |
| 4636 | * @attr: device attribute, not used. |
| 4637 | * @buf: containing the string the number of vfs to be enabled. |
| 4638 | * @count: unused variable. |
| 4639 | * |
| 4640 | * Description: |
| 4641 | * When this api is called either through user sysfs, the driver shall |
| 4642 | * try to enable or disable SR-IOV virtual functions according to the |
| 4643 | * following: |
| 4644 | * |
| 4645 | * If zero virtual function has been enabled to the physical function, |
| 4646 | * the driver shall invoke the pci enable virtual function api trying |
| 4647 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4648 | * than the maximum supported, the maximum virtual function number will |
| 4649 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4650 | * be used for invoking the api. If the api call returned success, the |
| 4651 | * actual number of virtual functions enabled will be set to the driver |
| 4652 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4653 | * cfg_sriov_nr_virtfn remains zero. |
| 4654 | * |
| 4655 | * If none-zero virtual functions have already been enabled to the |
| 4656 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4657 | * -EINVAL will be returned and the driver does nothing; |
| 4658 | * |
| 4659 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4660 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4661 | * disabling virtual function api shall be invoded to disable all the |
| 4662 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4663 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4664 | * nothing. |
| 4665 | * |
| 4666 | * Returns: |
| 4667 | * length of the buf on success if val is in range the intended mode |
| 4668 | * is supported. |
| 4669 | * -EINVAL if val out of range or intended mode is not supported. |
| 4670 | **/ |
| 4671 | static ssize_t |
| 4672 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4673 | const char *buf, size_t count) |
| 4674 | { |
| 4675 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4676 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4677 | struct lpfc_hba *phba = vport->phba; |
| 4678 | struct pci_dev *pdev = phba->pcidev; |
| 4679 | int val = 0, rc = -EINVAL; |
| 4680 | |
| 4681 | /* Sanity check on user data */ |
| 4682 | if (!isdigit(buf[0])) |
| 4683 | return -EINVAL; |
| 4684 | if (sscanf(buf, "%i", &val) != 1) |
| 4685 | return -EINVAL; |
| 4686 | if (val < 0) |
| 4687 | return -EINVAL; |
| 4688 | |
| 4689 | /* Request disabling virtual functions */ |
| 4690 | if (val == 0) { |
| 4691 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4692 | pci_disable_sriov(pdev); |
| 4693 | phba->cfg_sriov_nr_virtfn = 0; |
| 4694 | } |
| 4695 | return strlen(buf); |
| 4696 | } |
| 4697 | |
| 4698 | /* Request enabling virtual functions */ |
| 4699 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4700 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4701 | "3018 There are %d virtual functions " |
| 4702 | "enabled on physical function.\n", |
| 4703 | phba->cfg_sriov_nr_virtfn); |
| 4704 | return -EEXIST; |
| 4705 | } |
| 4706 | |
| 4707 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4708 | phba->cfg_sriov_nr_virtfn = val; |
| 4709 | else { |
| 4710 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4711 | "3019 Enabling %d virtual functions is not " |
| 4712 | "allowed.\n", val); |
| 4713 | return -EINVAL; |
| 4714 | } |
| 4715 | |
| 4716 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4717 | if (rc) { |
| 4718 | phba->cfg_sriov_nr_virtfn = 0; |
| 4719 | rc = -EPERM; |
| 4720 | } else |
| 4721 | rc = strlen(buf); |
| 4722 | |
| 4723 | return rc; |
| 4724 | } |
| 4725 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4726 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4727 | "Enable PCIe device SR-IOV virtual fn"); |
| 4728 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4729 | lpfc_param_show(sriov_nr_virtfn) |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4730 | static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4731 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4732 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4733 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4734 | * |
| 4735 | * @dev: class device that is converted into a Scsi_host. |
| 4736 | * @attr: device attribute, not used. |
| 4737 | * @buf: containing the string the number of vfs to be enabled. |
| 4738 | * @count: unused variable. |
| 4739 | * |
| 4740 | * Description: |
| 4741 | * |
| 4742 | * Returns: |
| 4743 | * length of the buf on success if val is in range the intended mode |
| 4744 | * is supported. |
| 4745 | * -EINVAL if val out of range or intended mode is not supported. |
| 4746 | **/ |
| 4747 | static ssize_t |
| 4748 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4749 | struct device_attribute *attr, |
| 4750 | const char *buf, size_t count) |
| 4751 | { |
| 4752 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4753 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4754 | struct lpfc_hba *phba = vport->phba; |
| 4755 | int val = 0, rc = -EINVAL; |
| 4756 | |
| 4757 | /* Sanity check on user data */ |
| 4758 | if (!isdigit(buf[0])) |
| 4759 | return -EINVAL; |
| 4760 | if (sscanf(buf, "%i", &val) != 1) |
| 4761 | return -EINVAL; |
| 4762 | if (val != 1) |
| 4763 | return -EINVAL; |
| 4764 | |
| 4765 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4766 | if (rc) |
| 4767 | rc = -EPERM; |
| 4768 | else |
| 4769 | rc = strlen(buf); |
| 4770 | return rc; |
| 4771 | } |
| 4772 | |
| 4773 | static int lpfc_req_fw_upgrade; |
| 4774 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4775 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4776 | lpfc_param_show(request_firmware_upgrade) |
| 4777 | |
| 4778 | /** |
| 4779 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4780 | * @phba: lpfc_hba pointer. |
| 4781 | * @val: 0 or 1. |
| 4782 | * |
| 4783 | * Description: |
| 4784 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4785 | * |
| 4786 | * Returns: |
| 4787 | * zero if val saved. |
| 4788 | * -EINVAL val out of range |
| 4789 | **/ |
| 4790 | static int |
| 4791 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4792 | { |
| 4793 | if (val >= 0 && val <= 1) { |
| 4794 | phba->cfg_request_firmware_upgrade = val; |
| 4795 | return 0; |
| 4796 | } |
| 4797 | return -EINVAL; |
| 4798 | } |
| 4799 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4800 | lpfc_request_firmware_upgrade_show, |
| 4801 | lpfc_request_firmware_upgrade_store); |
| 4802 | |
| 4803 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4804 | * lpfc_fcp_imax_store |
| 4805 | * |
| 4806 | * @dev: class device that is converted into a Scsi_host. |
| 4807 | * @attr: device attribute, not used. |
| 4808 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4809 | * @count: unused variable. |
| 4810 | * |
| 4811 | * Description: |
| 4812 | * If val is in a valid range [636,651042], then set the adapter's |
| 4813 | * maximum number of fast-path FCP interrupts per second. |
| 4814 | * |
| 4815 | * Returns: |
| 4816 | * length of the buf on success if val is in range the intended mode |
| 4817 | * is supported. |
| 4818 | * -EINVAL if val out of range or intended mode is not supported. |
| 4819 | **/ |
| 4820 | static ssize_t |
| 4821 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4822 | const char *buf, size_t count) |
| 4823 | { |
| 4824 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4825 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4826 | struct lpfc_hba *phba = vport->phba; |
| 4827 | int val = 0, i; |
| 4828 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4829 | /* fcp_imax is only valid for SLI4 */ |
| 4830 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4831 | return -EINVAL; |
| 4832 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4833 | /* Sanity check on user data */ |
| 4834 | if (!isdigit(buf[0])) |
| 4835 | return -EINVAL; |
| 4836 | if (sscanf(buf, "%i", &val) != 1) |
| 4837 | return -EINVAL; |
| 4838 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4839 | /* |
| 4840 | * Value range for the HBA is [5000,5000000] |
| 4841 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4842 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4843 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4844 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4845 | return -EINVAL; |
| 4846 | |
| 4847 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4848 | phba->initial_imax = phba->cfg_fcp_imax; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 4849 | |
| 4850 | 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] | 4851 | lpfc_modify_hba_eq_delay(phba, i, LPFC_MAX_EQ_DELAY_EQID_CNT, |
| 4852 | val); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4853 | |
| 4854 | return strlen(buf); |
| 4855 | } |
| 4856 | |
| 4857 | /* |
| 4858 | # 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] | 4859 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4860 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4861 | # 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] | 4862 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4863 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4864 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4865 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4866 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4867 | lpfc_param_show(fcp_imax) |
| 4868 | |
| 4869 | /** |
| 4870 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4871 | * @phba: lpfc_hba pointer. |
| 4872 | * @val: link speed value. |
| 4873 | * |
| 4874 | * Description: |
| 4875 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4876 | * maximum number of fast-path FCP interrupts per second. |
| 4877 | * |
| 4878 | * Returns: |
| 4879 | * zero if val saved. |
| 4880 | * -EINVAL val out of range |
| 4881 | **/ |
| 4882 | static int |
| 4883 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4884 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4885 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4886 | phba->cfg_fcp_imax = 0; |
| 4887 | return 0; |
| 4888 | } |
| 4889 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4890 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 4891 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4892 | phba->cfg_fcp_imax = val; |
| 4893 | return 0; |
| 4894 | } |
| 4895 | |
| 4896 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4897 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 4898 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4899 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4900 | |
| 4901 | return 0; |
| 4902 | } |
| 4903 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 4904 | static DEVICE_ATTR_RW(lpfc_fcp_imax); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4905 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4906 | /* |
| 4907 | * lpfc_auto_imax: Controls Auto-interrupt coalescing values support. |
| 4908 | * 0 No auto_imax support |
| 4909 | * 1 auto imax on |
| 4910 | * Auto imax will change the value of fcp_imax on a per EQ basis, using |
| 4911 | * the EQ Delay Multiplier, depending on the activity for that EQ. |
| 4912 | * Value range [0,1]. Default value is 1. |
| 4913 | */ |
| 4914 | LPFC_ATTR_RW(auto_imax, 1, 0, 1, "Enable Auto imax"); |
| 4915 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4916 | /** |
| 4917 | * lpfc_state_show - Display current driver CPU affinity |
| 4918 | * @dev: class converted to a Scsi_host structure. |
| 4919 | * @attr: device attribute, not used. |
| 4920 | * @buf: on return contains text describing the state of the link. |
| 4921 | * |
| 4922 | * Returns: size of formatted string. |
| 4923 | **/ |
| 4924 | static ssize_t |
| 4925 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4926 | char *buf) |
| 4927 | { |
| 4928 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4929 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4930 | struct lpfc_hba *phba = vport->phba; |
| 4931 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4932 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4933 | |
| 4934 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4935 | (phba->intr_type != MSIX)) |
| 4936 | return len; |
| 4937 | |
| 4938 | switch (phba->cfg_fcp_cpu_map) { |
| 4939 | case 0: |
| 4940 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4941 | "fcp_cpu_map: No mapping (%d)\n", |
| 4942 | phba->cfg_fcp_cpu_map); |
| 4943 | return len; |
| 4944 | case 1: |
| 4945 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4946 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4947 | "%d online CPUs\n", |
| 4948 | phba->cfg_fcp_cpu_map, |
| 4949 | phba->sli4_hba.num_online_cpu); |
| 4950 | break; |
| 4951 | case 2: |
| 4952 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4953 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4954 | "%d online CPUs\n", |
| 4955 | phba->cfg_fcp_cpu_map, |
| 4956 | phba->sli4_hba.num_online_cpu); |
| 4957 | break; |
| 4958 | } |
| 4959 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4960 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4961 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4962 | |
| 4963 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4964 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4965 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4966 | "CPU %02d io_chan %02d " |
| 4967 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4968 | phba->sli4_hba.curr_disp_cpu, |
| 4969 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4970 | cpup->core_id); |
| 4971 | else |
| 4972 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4973 | "CPU %02d io_chan %02d " |
| 4974 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4975 | phba->sli4_hba.curr_disp_cpu, |
| 4976 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4977 | cpup->core_id, cpup->irq); |
| 4978 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4979 | phba->sli4_hba.curr_disp_cpu++; |
| 4980 | |
| 4981 | /* display max number of CPUs keeping some margin */ |
| 4982 | if (phba->sli4_hba.curr_disp_cpu < |
| 4983 | phba->sli4_hba.num_present_cpu && |
| 4984 | (len >= (PAGE_SIZE - 64))) { |
| 4985 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4986 | break; |
| 4987 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4988 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4989 | |
| 4990 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4991 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4992 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4993 | return len; |
| 4994 | } |
| 4995 | |
| 4996 | /** |
| 4997 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4998 | * @dev: class device that is converted into a Scsi_host. |
| 4999 | * @attr: device attribute, not used. |
| 5000 | * @buf: one or more lpfc_polling_flags values. |
| 5001 | * @count: not used. |
| 5002 | * |
| 5003 | * Returns: |
| 5004 | * -EINVAL - Not implemented yet. |
| 5005 | **/ |
| 5006 | static ssize_t |
| 5007 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 5008 | const char *buf, size_t count) |
| 5009 | { |
| 5010 | int status = -EINVAL; |
| 5011 | return status; |
| 5012 | } |
| 5013 | |
| 5014 | /* |
| 5015 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 5016 | # for the HBA. |
| 5017 | # |
| 5018 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 5019 | # 0 - Do not affinitze IRQ vectors |
| 5020 | # 1 - Affintize HBA vectors with respect to each HBA |
| 5021 | # (start with CPU0 for each HBA) |
| 5022 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 5023 | # (round robin thru all CPUs across all HBAs) |
| 5024 | */ |
| 5025 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 5026 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 5027 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 5028 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 5029 | |
| 5030 | /** |
| 5031 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 5032 | * @phba: lpfc_hba pointer. |
| 5033 | * @val: link speed value. |
| 5034 | * |
| 5035 | * Description: |
| 5036 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 5037 | * MSIX vectors. |
| 5038 | * |
| 5039 | * Returns: |
| 5040 | * zero if val saved. |
| 5041 | * -EINVAL val out of range |
| 5042 | **/ |
| 5043 | static int |
| 5044 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 5045 | { |
| 5046 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 5047 | phba->cfg_fcp_cpu_map = 0; |
| 5048 | return 0; |
| 5049 | } |
| 5050 | |
| 5051 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 5052 | phba->cfg_fcp_cpu_map = val; |
| 5053 | return 0; |
| 5054 | } |
| 5055 | |
| 5056 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 5057 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 5058 | "default\n", val); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5059 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 5060 | |
| 5061 | return 0; |
| 5062 | } |
| 5063 | |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5064 | static DEVICE_ATTR_RW(lpfc_fcp_cpu_map); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5065 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5066 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5067 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 5068 | # Value range is [2,3]. Default value is 3. |
| 5069 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5070 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 5071 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5072 | |
| 5073 | /* |
| 5074 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 5075 | # is [0,1]. Default value is 0. |
| 5076 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5077 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 5078 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5079 | |
| 5080 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5081 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 5082 | # that support first burst. |
| 5083 | # Value range is [0,65536]. Default value is 0. |
| 5084 | */ |
| 5085 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 5086 | "First burst size for Targets that support first burst"); |
| 5087 | |
| 5088 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5089 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 5090 | * When the driver is configured as an NVME target, this value is |
| 5091 | * communicated to the NVME initiator in the PRLI response. It is |
| 5092 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 5093 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5094 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5095 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5096 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5097 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 5098 | "NVME Target mode first burst size in 512B increments."); |
| 5099 | |
| 5100 | /* |
| 5101 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 5102 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 5103 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
| 5104 | * processed by the initiator for subsequent NVME FCP IO. For the target |
| 5105 | * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size |
| 5106 | * driver parameter as the target function's first burst size returned to the |
| 5107 | * initiator in the target's NVME PRLI response. Parameter supported on physical |
| 5108 | * port only - no NPIV support. |
| 5109 | * Value range is [0,1]. Default value is 0 (disabled). |
| 5110 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5111 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
| 5112 | "Enable First Burst feature on I and T functions."); |
| 5113 | |
| 5114 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5115 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 5116 | # depth. Default value is 0. When the value of this parameter is zero the |
| 5117 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 5118 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 5119 | # to limit the I/O completion time to the parameter value. |
| 5120 | # The value is set in milliseconds. |
| 5121 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5122 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5123 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 5124 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5125 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5126 | static int |
| 5127 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 5128 | { |
| 5129 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5130 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 5131 | |
| 5132 | if (val == vport->cfg_max_scsicmpl_time) |
| 5133 | return 0; |
| 5134 | if ((val < 0) || (val > 60000)) |
| 5135 | return -EINVAL; |
| 5136 | vport->cfg_max_scsicmpl_time = val; |
| 5137 | |
| 5138 | spin_lock_irq(shost->host_lock); |
| 5139 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 5140 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 5141 | continue; |
| 5142 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 5143 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5144 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5145 | } |
| 5146 | spin_unlock_irq(shost->host_lock); |
| 5147 | return 0; |
| 5148 | } |
| 5149 | lpfc_vport_param_store(max_scsicmpl_time); |
Joe Perches | b6b996b | 2017-12-19 10:15:07 -0800 | [diff] [blame] | 5150 | static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5151 | |
| 5152 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5153 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 5154 | # range is [0,1]. Default value is 0. |
| 5155 | */ |
| 5156 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 5157 | |
| 5158 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5159 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 5160 | * range is [0,1]. Default value is 0. |
| 5161 | * For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 5162 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 5163 | * current CPU. |
| 5164 | * |
| 5165 | * LPFC_FCP_SCHED_ROUND_ROBIN == 0 |
| 5166 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 5167 | * |
| 5168 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 5169 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 5170 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 5171 | * through WQs will be used. |
| 5172 | */ |
| 5173 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN, |
| 5174 | LPFC_FCP_SCHED_ROUND_ROBIN, |
| 5175 | LPFC_FCP_SCHED_BY_CPU, |
| 5176 | "Determine scheduling algorithm for " |
| 5177 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5178 | |
| 5179 | /* |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 5180 | * lpfc_ns_query: Determine algrithmn for NameServer queries after RSCN |
| 5181 | * range is [0,1]. Default value is 0. |
| 5182 | * For [0], GID_FT is used for NameServer queries after RSCN (default) |
| 5183 | * For [1], GID_PT is used for NameServer queries after RSCN |
| 5184 | * |
| 5185 | */ |
| 5186 | LPFC_ATTR_RW(ns_query, LPFC_NS_QUERY_GID_FT, |
| 5187 | LPFC_NS_QUERY_GID_FT, LPFC_NS_QUERY_GID_PT, |
| 5188 | "Determine algorithm NameServer queries after RSCN " |
| 5189 | "[0] - GID_FT, [1] - GID_PT"); |
| 5190 | |
| 5191 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5192 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 5193 | # range is [0,1]. Default value is 0. |
| 5194 | # For [0], bus reset issues target reset to ALL devices |
| 5195 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 5196 | */ |
| 5197 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 5198 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 5199 | |
| 5200 | |
| 5201 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5202 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 5203 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 5204 | # 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] | 5205 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 5206 | # cr_delay is set to 0. |
| 5207 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5208 | 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] | 5209 | "interrupt response is generated"); |
| 5210 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 5211 | 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] | 5212 | "interrupt response is generated"); |
| 5213 | |
| 5214 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 5215 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 5216 | # cmd/rsp IOCB entries across. |
| 5217 | # Value range is [1,2]. Default value is 1. |
| 5218 | */ |
| 5219 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 5220 | "SLI rings to spread IOCB entries across"); |
| 5221 | |
| 5222 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5223 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 5224 | # identifies what rctl value to configure the additional ring for. |
| 5225 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 5226 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5227 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5228 | 255, "Identifies RCTL for additional ring configuration"); |
| 5229 | |
| 5230 | /* |
| 5231 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 5232 | # identifies what type value to configure the additional ring for. |
| 5233 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 5234 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 5235 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 5236 | 255, "Identifies TYPE for additional ring configuration"); |
| 5237 | |
| 5238 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5239 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 5240 | # 0 = SmartSAN functionality disabled (default) |
| 5241 | # 1 = SmartSAN functionality enabled |
| 5242 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 5243 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5244 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5245 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 5246 | |
| 5247 | /* |
| 5248 | # lpfc_fdmi_on: Controls FDMI support. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5249 | # 0 No FDMI support |
| 5250 | # 1 Traditional FDMI support (default) |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 5251 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 5252 | # however, if that fails, it will fallback to FDMI-1. |
| 5253 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 5254 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 5255 | # lpfc_fdmi_on. |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5256 | # Value range [0,1]. Default value is 1. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5257 | */ |
James Smart | 9abd999 | 2018-08-14 12:55:05 -0700 | [diff] [blame] | 5258 | LPFC_ATTR_R(fdmi_on, 1, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5259 | |
| 5260 | /* |
| 5261 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 5262 | # discovery). Value range is [1,64]. Default value = 32. |
| 5263 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5264 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5265 | "during discovery"); |
| 5266 | |
| 5267 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 5268 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 5269 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 5270 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 5271 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 5272 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 5273 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 5274 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 5275 | # on a target can take minutes of wall clock time. Additionally, |
| 5276 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 5277 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 5278 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 5279 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 5280 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 5281 | # devices present, when in fact, there is only 1. |
| 5282 | # A customer that is aware of their target behaviors, and the results as |
| 5283 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 5284 | # As mentioned, this value is not used by the lpfc driver, only the |
| 5285 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 5286 | # Value range is [0,65535]. Default value is 255. |
| 5287 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5288 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 5289 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5290 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 5291 | /* |
| 5292 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 5293 | # Value range is [1,255], default value is 10. |
| 5294 | */ |
| 5295 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 5296 | "Milliseconds driver will wait between polling FCP ring"); |
| 5297 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5298 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5299 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 5300 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 5301 | */ |
| 5302 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 5303 | "Maximum time to wait for task management commands to complete"); |
| 5304 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5305 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 5306 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5307 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5308 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5309 | # 2 = MSI-X enabled (default) |
| 5310 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5311 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 5312 | 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] | 5313 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 5314 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5315 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5316 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5317 | * |
| 5318 | * 0 = NVME OAS disabled |
| 5319 | * 1 = NVME OAS enabled |
| 5320 | * |
| 5321 | * Value range is [0,1]. Default value is 0. |
| 5322 | */ |
| 5323 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 5324 | "Use OAS bit on NVME IOs"); |
| 5325 | |
| 5326 | /* |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5327 | * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs |
| 5328 | * |
| 5329 | * 0 = Put NVME Command in SGL |
| 5330 | * 1 = Embed NVME Command in WQE (unless G7) |
| 5331 | * 2 = Embed NVME Command in WQE (force) |
| 5332 | * |
| 5333 | * Value range is [0,2]. Default value is 1. |
| 5334 | */ |
| 5335 | LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2, |
| 5336 | "Embed NVME Command in WQE"); |
| 5337 | |
| 5338 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5339 | * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver |
| 5340 | * will advertise it supports to the SCSI layer. This also will map to |
| 5341 | * the number of WQs the driver will create. |
| 5342 | * |
| 5343 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5344 | * 1,32 = Manually specify how many io channels to use. |
| 5345 | * |
| 5346 | * Value range is [0,32]. Default value is 4. |
| 5347 | */ |
| 5348 | LPFC_ATTR_R(fcp_io_channel, |
| 5349 | LPFC_FCP_IO_CHAN_DEF, |
| 5350 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5351 | "Set the number of FCP I/O channels"); |
| 5352 | |
| 5353 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5354 | * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver |
| 5355 | * will advertise it supports to the NVME layer. This also will map to |
| 5356 | * the number of WQs the driver will create. |
| 5357 | * |
| 5358 | * This module parameter is valid when lpfc_enable_fc4_type is set |
| 5359 | * to support NVME. |
| 5360 | * |
| 5361 | * The NVME Layer will try to create this many, plus 1 administrative |
| 5362 | * hardware queue. The administrative queue will always map to WQ 0 |
| 5363 | * A hardware IO queue maps (qidx) to a specific driver WQ. |
| 5364 | * |
| 5365 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 5366 | * 1,32 = Manually specify how many io channels to use. |
| 5367 | * |
| 5368 | * Value range is [0,32]. Default value is 0. |
| 5369 | */ |
| 5370 | LPFC_ATTR_R(nvme_io_channel, |
| 5371 | LPFC_NVME_IO_CHAN_DEF, |
| 5372 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
| 5373 | "Set the number of NVME I/O channels"); |
| 5374 | |
| 5375 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5376 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 5377 | # 0 = HBA resets disabled |
| 5378 | # 1 = HBA resets enabled (default) |
| 5379 | # Value range is [0,1]. Default value is 1. |
| 5380 | */ |
| 5381 | 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] | 5382 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5383 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5384 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 5385 | # 0 = HBA Heartbeat disabled |
| 5386 | # 1 = HBA Heartbeat enabled (default) |
| 5387 | # Value range is [0,1]. Default value is 1. |
| 5388 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 5389 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5390 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5391 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5392 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 5393 | # 0x0 Express Lane Feature disabled |
| 5394 | # 0x1 Express Lane Feature enabled |
| 5395 | # Value range is [0,1]. Default value is 0. |
| 5396 | */ |
| 5397 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 5398 | |
| 5399 | /* |
| 5400 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 5401 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 5402 | # Value range is [0x0,0x7f]. Default value is 0 |
| 5403 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 5404 | 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] | 5405 | |
| 5406 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5407 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 5408 | # 0 = BlockGuard disabled (default) |
| 5409 | # 1 = BlockGuard enabled |
| 5410 | # Value range is [0,1]. Default value is 0. |
| 5411 | */ |
| 5412 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5413 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5414 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5415 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 5416 | # 0 = disabled (default) |
| 5417 | # 1 = enabled |
| 5418 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 5419 | # |
| 5420 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5421 | */ |
| 5422 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 5423 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5424 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5425 | # lpfc_prot_mask: i |
| 5426 | # - Bit mask of host protection capabilities used to register with the |
| 5427 | # SCSI mid-layer |
| 5428 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5429 | # - Allows you to ultimately specify which profiles to use |
| 5430 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5431 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5432 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5433 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5434 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5435 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5436 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5437 | # |
| 5438 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5439 | LPFC_ATTR(prot_mask, |
| 5440 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5441 | SHOST_DIX_TYPE0_PROTECTION | |
| 5442 | SHOST_DIX_TYPE1_PROTECTION), |
| 5443 | 0, |
| 5444 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5445 | SHOST_DIX_TYPE0_PROTECTION | |
| 5446 | SHOST_DIX_TYPE1_PROTECTION), |
| 5447 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5448 | |
| 5449 | /* |
| 5450 | # lpfc_prot_guard: i |
| 5451 | # - 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] | 5452 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5453 | # - Allows you to ultimately specify which profiles to use |
| 5454 | # - Default will result in registering capabilities for all guard types |
| 5455 | # |
| 5456 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5457 | LPFC_ATTR(prot_guard, |
| 5458 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5459 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5460 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5461 | /* |
| 5462 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5463 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5464 | * This parameter can have value 0 or 1. |
| 5465 | * When this parameter is set to 0, no delay is added to the initial |
| 5466 | * discovery. |
| 5467 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5468 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5469 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5470 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5471 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5472 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5473 | * Default value is 0. |
| 5474 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5475 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5476 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5477 | |
| 5478 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5479 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5480 | * This value can be set to values between 64 and 4096. The default value |
| 5481 | * is 64, but may be increased to allow for larger Max I/O sizes. The scsi |
| 5482 | * and nvme layers will allow I/O sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5483 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5484 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5485 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5486 | */ |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 5487 | static uint lpfc_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 5488 | module_param(lpfc_sg_seg_cnt, uint, 0444); |
| 5489 | MODULE_PARM_DESC(lpfc_sg_seg_cnt, "Max Scatter Gather Segment Count"); |
| 5490 | |
| 5491 | /** |
| 5492 | * lpfc_sg_seg_cnt_show - Display the scatter/gather list sizes |
| 5493 | * configured for the adapter |
| 5494 | * @dev: class converted to a Scsi_host structure. |
| 5495 | * @attr: device attribute, not used. |
| 5496 | * @buf: on return contains a string with the list sizes |
| 5497 | * |
| 5498 | * Returns: size of formatted string. |
| 5499 | **/ |
| 5500 | static ssize_t |
| 5501 | lpfc_sg_seg_cnt_show(struct device *dev, struct device_attribute *attr, |
| 5502 | char *buf) |
| 5503 | { |
| 5504 | struct Scsi_Host *shost = class_to_shost(dev); |
| 5505 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5506 | struct lpfc_hba *phba = vport->phba; |
| 5507 | int len; |
| 5508 | |
| 5509 | len = snprintf(buf, PAGE_SIZE, "SGL sz: %d total SGEs: %d\n", |
| 5510 | phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt); |
| 5511 | |
| 5512 | len += snprintf(buf + len, PAGE_SIZE, "Cfg: %d SCSI: %d NVME: %d\n", |
| 5513 | phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt, |
| 5514 | phba->cfg_nvme_seg_cnt); |
| 5515 | return len; |
| 5516 | } |
| 5517 | |
| 5518 | static DEVICE_ATTR_RO(lpfc_sg_seg_cnt); |
| 5519 | |
| 5520 | /** |
| 5521 | * lpfc_sg_seg_cnt_init - Set the hba sg_seg_cnt initial value |
| 5522 | * @phba: lpfc_hba pointer. |
| 5523 | * @val: contains the initial value |
| 5524 | * |
| 5525 | * Description: |
| 5526 | * Validates the initial value is within range and assigns it to the |
| 5527 | * adapter. If not in range, an error message is posted and the |
| 5528 | * default value is assigned. |
| 5529 | * |
| 5530 | * Returns: |
| 5531 | * zero if value is in range and is set |
| 5532 | * -EINVAL if value was out of range |
| 5533 | **/ |
| 5534 | static int |
| 5535 | lpfc_sg_seg_cnt_init(struct lpfc_hba *phba, int val) |
| 5536 | { |
| 5537 | if (val >= LPFC_MIN_SG_SEG_CNT && val <= LPFC_MAX_SG_SEG_CNT) { |
| 5538 | phba->cfg_sg_seg_cnt = val; |
| 5539 | return 0; |
| 5540 | } |
| 5541 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 5542 | "0409 "LPFC_DRIVER_NAME"_sg_seg_cnt attribute cannot " |
| 5543 | "be set to %d, allowed range is [%d, %d]\n", |
| 5544 | val, LPFC_MIN_SG_SEG_CNT, LPFC_MAX_SG_SEG_CNT); |
| 5545 | phba->cfg_sg_seg_cnt = LPFC_DEFAULT_SG_SEG_CNT; |
| 5546 | return -EINVAL; |
| 5547 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5548 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5549 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5550 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 5551 | * 0 = MDS Diagnostics disabled (default) |
| 5552 | * 1 = MDS Diagnostics enabled |
| 5553 | * Value range is [0,1]. Default value is 0. |
| 5554 | */ |
| 5555 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 5556 | |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5557 | /* |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 5558 | * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size |
| 5559 | * 0 = Disable firmware logging (default) |
| 5560 | * [1-4] = Multiple of 1/4th Mb of host memory for FW logging |
| 5561 | * Value range [0..4]. Default value is 0 |
| 5562 | */ |
| 5563 | LPFC_ATTR_RW(ras_fwlog_buffsize, 0, 0, 4, "Host memory for FW logging"); |
| 5564 | |
| 5565 | /* |
| 5566 | * lpfc_ras_fwlog_level: Firmware logging verbosity level |
| 5567 | * Valid only if firmware logging is enabled |
| 5568 | * 0(Least Verbosity) 4 (most verbosity) |
| 5569 | * Value range is [0..4]. Default value is 0 |
| 5570 | */ |
| 5571 | LPFC_ATTR_RW(ras_fwlog_level, 0, 0, 4, "Firmware Logging Level"); |
| 5572 | |
| 5573 | /* |
| 5574 | * lpfc_ras_fwlog_func: Firmware logging enabled on function number |
| 5575 | * Default function which has RAS support : 0 |
| 5576 | * Value Range is [0..7]. |
| 5577 | * FW logging is a global action and enablement is via a specific |
| 5578 | * port. |
| 5579 | */ |
| 5580 | LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function"); |
| 5581 | |
| 5582 | /* |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5583 | * lpfc_enable_bbcr: Enable BB Credit Recovery |
| 5584 | * 0 = BB Credit Recovery disabled |
| 5585 | * 1 = BB Credit Recovery enabled (default) |
| 5586 | * Value range is [0,1]. Default value is 1. |
| 5587 | */ |
| 5588 | LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery"); |
| 5589 | |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 5590 | /* |
| 5591 | * lpfc_enable_dpp: Enable DPP on G7 |
| 5592 | * 0 = DPP on G7 disabled |
| 5593 | * 1 = DPP on G7 enabled (default) |
| 5594 | * Value range is [0,1]. Default value is 1. |
| 5595 | */ |
| 5596 | LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push"); |
| 5597 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5598 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5599 | &dev_attr_nvme_info, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5600 | &dev_attr_bg_info, |
| 5601 | &dev_attr_bg_guard_err, |
| 5602 | &dev_attr_bg_apptag_err, |
| 5603 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5604 | &dev_attr_info, |
| 5605 | &dev_attr_serialnum, |
| 5606 | &dev_attr_modeldesc, |
| 5607 | &dev_attr_modelname, |
| 5608 | &dev_attr_programtype, |
| 5609 | &dev_attr_portnum, |
| 5610 | &dev_attr_fwrev, |
| 5611 | &dev_attr_hdw, |
| 5612 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5613 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5614 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 5615 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5616 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5617 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5618 | &dev_attr_lpfc_temp_sensor, |
| 5619 | &dev_attr_lpfc_log_verbose, |
| 5620 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5621 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5622 | &dev_attr_lpfc_hba_queue_depth, |
| 5623 | &dev_attr_lpfc_peer_port_login, |
| 5624 | &dev_attr_lpfc_nodev_tmo, |
| 5625 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5626 | &dev_attr_lpfc_enable_fc4_type, |
| 5627 | &dev_attr_lpfc_xri_split, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5628 | &dev_attr_lpfc_fcp_class, |
| 5629 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5630 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5631 | &dev_attr_lpfc_ack0, |
| 5632 | &dev_attr_lpfc_topology, |
| 5633 | &dev_attr_lpfc_scan_down, |
| 5634 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5635 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 5636 | &dev_attr_lpfc_ns_query, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5637 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5638 | &dev_attr_lpfc_cr_delay, |
| 5639 | &dev_attr_lpfc_cr_count, |
| 5640 | &dev_attr_lpfc_multi_ring_support, |
| 5641 | &dev_attr_lpfc_multi_ring_rctl, |
| 5642 | &dev_attr_lpfc_multi_ring_type, |
| 5643 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5644 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5645 | &dev_attr_lpfc_max_luns, |
| 5646 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5647 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5648 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5649 | &dev_attr_nport_evt_cnt, |
| 5650 | &dev_attr_board_mode, |
| 5651 | &dev_attr_max_vpi, |
| 5652 | &dev_attr_used_vpi, |
| 5653 | &dev_attr_max_rpi, |
| 5654 | &dev_attr_used_rpi, |
| 5655 | &dev_attr_max_xri, |
| 5656 | &dev_attr_used_xri, |
| 5657 | &dev_attr_npiv_info, |
| 5658 | &dev_attr_issue_reset, |
| 5659 | &dev_attr_lpfc_poll, |
| 5660 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5661 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5662 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5663 | &dev_attr_lpfc_nvme_oas, |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 5664 | &dev_attr_lpfc_nvme_embed_cmd, |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 5665 | &dev_attr_lpfc_auto_imax, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5666 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5667 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5668 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5669 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5670 | &dev_attr_lpfc_nvme_io_channel, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5671 | &dev_attr_lpfc_nvmet_mrq, |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 5672 | &dev_attr_lpfc_nvmet_mrq_post, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5673 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5674 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5675 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 5676 | &dev_attr_lpfc_soft_wwnn, |
| 5677 | &dev_attr_lpfc_soft_wwpn, |
| 5678 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5679 | &dev_attr_lpfc_enable_hba_reset, |
| 5680 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5681 | &dev_attr_lpfc_EnableXLane, |
| 5682 | &dev_attr_lpfc_XLanePriority, |
| 5683 | &dev_attr_lpfc_xlane_lun, |
| 5684 | &dev_attr_lpfc_xlane_tgt, |
| 5685 | &dev_attr_lpfc_xlane_vpt, |
| 5686 | &dev_attr_lpfc_xlane_lun_state, |
| 5687 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5688 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5689 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5690 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5691 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5692 | &dev_attr_lpfc_aer_support, |
| 5693 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5694 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5695 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5696 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5697 | &dev_attr_lpfc_iocb_cnt, |
| 5698 | &dev_attr_iocb_hw, |
| 5699 | &dev_attr_txq_hw, |
| 5700 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5701 | &dev_attr_lpfc_fips_level, |
| 5702 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5703 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5704 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5705 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5706 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5707 | &dev_attr_lpfc_enable_mds_diags, |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 5708 | &dev_attr_lpfc_ras_fwlog_buffsize, |
| 5709 | &dev_attr_lpfc_ras_fwlog_level, |
| 5710 | &dev_attr_lpfc_ras_fwlog_func, |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 5711 | &dev_attr_lpfc_enable_bbcr, |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 5712 | &dev_attr_lpfc_enable_dpp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5713 | NULL, |
| 5714 | }; |
| 5715 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5716 | struct device_attribute *lpfc_vport_attrs[] = { |
| 5717 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5718 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5719 | &dev_attr_num_discovered_ports, |
| 5720 | &dev_attr_lpfc_drvr_version, |
| 5721 | &dev_attr_lpfc_log_verbose, |
| 5722 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5723 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5724 | &dev_attr_lpfc_nodev_tmo, |
| 5725 | &dev_attr_lpfc_devloss_tmo, |
| 5726 | &dev_attr_lpfc_hba_queue_depth, |
| 5727 | &dev_attr_lpfc_peer_port_login, |
| 5728 | &dev_attr_lpfc_restrict_login, |
| 5729 | &dev_attr_lpfc_fcp_class, |
| 5730 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5731 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5732 | &dev_attr_lpfc_max_luns, |
| 5733 | &dev_attr_nport_evt_cnt, |
| 5734 | &dev_attr_npiv_info, |
| 5735 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5736 | &dev_attr_lpfc_max_scsicmpl_time, |
| 5737 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 5738 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5739 | &dev_attr_lpfc_fips_level, |
| 5740 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5741 | NULL, |
| 5742 | }; |
| 5743 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5744 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5745 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5746 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5747 | * @kobj: kernel kobject that contains the kernel class device. |
| 5748 | * @bin_attr: kernel attributes passed to us. |
| 5749 | * @buf: contains the data to be written to the adapter IOREG space. |
| 5750 | * @off: offset into buffer to beginning of data. |
| 5751 | * @count: bytes to transfer. |
| 5752 | * |
| 5753 | * Description: |
| 5754 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5755 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 5756 | * |
| 5757 | * Returns: |
| 5758 | * -ERANGE off and count combo out of range |
| 5759 | * -EINVAL off, count or buff address invalid |
| 5760 | * -EPERM adapter is offline |
| 5761 | * value of count, buf contents written |
| 5762 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5763 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5764 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 5765 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5766 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5767 | { |
| 5768 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5769 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5770 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5771 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5772 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5773 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5774 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5775 | return -EPERM; |
| 5776 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5777 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5778 | return -ERANGE; |
| 5779 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5780 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 5781 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5782 | |
| 5783 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5784 | return -EINVAL; |
| 5785 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5786 | /* This is to protect HBA registers from accidental writes. */ |
| 5787 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 5788 | return -EINVAL; |
| 5789 | |
| 5790 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5791 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5792 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5793 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5794 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 5795 | buf_off += sizeof(uint32_t)) |
| 5796 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5797 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 5798 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5799 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5800 | |
| 5801 | return count; |
| 5802 | } |
| 5803 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5804 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5805 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5806 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5807 | * @kobj: kernel kobject that contains the kernel class device. |
| 5808 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5809 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5810 | * @off: offset into buffer to beginning of data. |
| 5811 | * @count: bytes to transfer. |
| 5812 | * |
| 5813 | * Description: |
| 5814 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5815 | * Uses the adapter io control registers to read data into buf. |
| 5816 | * |
| 5817 | * Returns: |
| 5818 | * -ERANGE off and count combo out of range |
| 5819 | * -EINVAL off, count or buff address invalid |
| 5820 | * value of count, buf contents read |
| 5821 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5822 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5823 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 5824 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5825 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5826 | { |
| 5827 | size_t buf_off; |
| 5828 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5829 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5830 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5831 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5832 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5833 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5834 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5835 | return -EPERM; |
| 5836 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5837 | if (off > FF_REG_AREA_SIZE) |
| 5838 | return -ERANGE; |
| 5839 | |
| 5840 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5841 | count = FF_REG_AREA_SIZE - off; |
| 5842 | |
| 5843 | if (count == 0) return 0; |
| 5844 | |
| 5845 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5846 | return -EINVAL; |
| 5847 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5848 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5849 | |
| 5850 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 5851 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5852 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5853 | } |
| 5854 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5855 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5856 | |
| 5857 | return count; |
| 5858 | } |
| 5859 | |
| 5860 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5861 | .attr = { |
| 5862 | .name = "ctlreg", |
| 5863 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5864 | }, |
| 5865 | .size = 256, |
| 5866 | .read = sysfs_ctlreg_read, |
| 5867 | .write = sysfs_ctlreg_write, |
| 5868 | }; |
| 5869 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5870 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5871 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5872 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5873 | * @kobj: kernel kobject that contains the kernel class device. |
| 5874 | * @bin_attr: kernel attributes passed to us. |
| 5875 | * @buf: contains the data to be written to sysfs mbox. |
| 5876 | * @off: offset into buffer to beginning of data. |
| 5877 | * @count: bytes to transfer. |
| 5878 | * |
| 5879 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5880 | * Deprecated function. All mailbox access from user space is performed via the |
| 5881 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5882 | * |
| 5883 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5884 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5885 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5886 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5887 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5888 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5889 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5890 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5891 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5892 | } |
| 5893 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5894 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5895 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5896 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5897 | * @kobj: kernel kobject that contains the kernel class device. |
| 5898 | * @bin_attr: kernel attributes passed to us. |
| 5899 | * @buf: contains the data to be read from sysfs mbox. |
| 5900 | * @off: offset into buffer to beginning of data. |
| 5901 | * @count: bytes to transfer. |
| 5902 | * |
| 5903 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5904 | * Deprecated function. All mailbox access from user space is performed via the |
| 5905 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5906 | * |
| 5907 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5908 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5909 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5910 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5911 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5912 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5913 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5914 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5915 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5916 | } |
| 5917 | |
| 5918 | static struct bin_attribute sysfs_mbox_attr = { |
| 5919 | .attr = { |
| 5920 | .name = "mbox", |
| 5921 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5922 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5923 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5924 | .read = sysfs_mbox_read, |
| 5925 | .write = sysfs_mbox_write, |
| 5926 | }; |
| 5927 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5928 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5929 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5930 | * @vport: address of lpfc vport structure. |
| 5931 | * |
| 5932 | * Return codes: |
| 5933 | * zero on success |
| 5934 | * error return code from sysfs_create_bin_file() |
| 5935 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5936 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5937 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5938 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5939 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5940 | int error; |
| 5941 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5942 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5943 | &sysfs_drvr_stat_data_attr); |
| 5944 | |
| 5945 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5946 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5947 | goto out; |
| 5948 | |
| 5949 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5950 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5951 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5952 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5953 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5954 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5955 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5956 | if (error) |
| 5957 | goto out_remove_ctlreg_attr; |
| 5958 | |
| 5959 | return 0; |
| 5960 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5961 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5962 | out_remove_stat_attr: |
| 5963 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5964 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5965 | out: |
| 5966 | return error; |
| 5967 | } |
| 5968 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5969 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5970 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5971 | * @vport: address of lpfc vport structure. |
| 5972 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5973 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5974 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5975 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5976 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5977 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5978 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5979 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5980 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5981 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5982 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5983 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5984 | } |
| 5985 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5986 | /* |
| 5987 | * Dynamic FC Host Attributes Support |
| 5988 | */ |
| 5989 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5990 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5991 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 5992 | * @shost: kernel scsi host pointer. |
| 5993 | **/ |
| 5994 | static void |
| 5995 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 5996 | { |
| 5997 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5998 | |
| 5999 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 6000 | sizeof fc_host_symbolic_name(shost)); |
| 6001 | } |
| 6002 | |
| 6003 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6004 | * 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] | 6005 | * @shost: kernel scsi host pointer. |
| 6006 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6007 | static void |
| 6008 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 6009 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6010 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6011 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6012 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6013 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6014 | } |
| 6015 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6016 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6017 | * 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] | 6018 | * @shost: kernel scsi host pointer. |
| 6019 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6020 | static void |
| 6021 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 6022 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6023 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6024 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6025 | |
| 6026 | spin_lock_irq(shost->host_lock); |
| 6027 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6028 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 6029 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 6030 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6031 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6032 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6033 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 6034 | else |
| 6035 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 6036 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6037 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6038 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 6039 | else |
| 6040 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 6041 | } |
| 6042 | } else |
| 6043 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 6044 | |
| 6045 | spin_unlock_irq(shost->host_lock); |
| 6046 | } |
| 6047 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6048 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6049 | * 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] | 6050 | * @shost: kernel scsi host pointer. |
| 6051 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6052 | static void |
| 6053 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 6054 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6055 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6056 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6057 | |
| 6058 | spin_lock_irq(shost->host_lock); |
| 6059 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6060 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6061 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 6062 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6063 | switch (phba->link_state) { |
| 6064 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6065 | case LPFC_LINK_DOWN: |
| 6066 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 6067 | break; |
| 6068 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6069 | case LPFC_CLEAR_LA: |
| 6070 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 6071 | /* Links up, reports port state accordingly */ |
| 6072 | if (vport->port_state < LPFC_VPORT_READY) |
| 6073 | fc_host_port_state(shost) = |
| 6074 | FC_PORTSTATE_BYPASSED; |
| 6075 | else |
| 6076 | fc_host_port_state(shost) = |
| 6077 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6078 | break; |
| 6079 | case LPFC_HBA_ERROR: |
| 6080 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 6081 | break; |
| 6082 | default: |
| 6083 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 6084 | break; |
| 6085 | } |
| 6086 | } |
| 6087 | |
| 6088 | spin_unlock_irq(shost->host_lock); |
| 6089 | } |
| 6090 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6091 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6092 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6093 | * @shost: kernel scsi host pointer. |
| 6094 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6095 | static void |
| 6096 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 6097 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6098 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6099 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6100 | |
| 6101 | spin_lock_irq(shost->host_lock); |
| 6102 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 6103 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6104 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6105 | case LPFC_LINK_SPEED_1GHZ: |
| 6106 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6107 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6108 | case LPFC_LINK_SPEED_2GHZ: |
| 6109 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6110 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6111 | case LPFC_LINK_SPEED_4GHZ: |
| 6112 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6113 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6114 | case LPFC_LINK_SPEED_8GHZ: |
| 6115 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 6116 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6117 | case LPFC_LINK_SPEED_10GHZ: |
| 6118 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6119 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6120 | case LPFC_LINK_SPEED_16GHZ: |
| 6121 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 6122 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 6123 | case LPFC_LINK_SPEED_32GHZ: |
| 6124 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 6125 | break; |
James Smart | fbd8a6b | 2018-02-22 08:18:45 -0800 | [diff] [blame] | 6126 | case LPFC_LINK_SPEED_64GHZ: |
| 6127 | fc_host_speed(shost) = FC_PORTSPEED_64GBIT; |
| 6128 | break; |
James Smart | 1dc5ec2 | 2018-10-23 13:41:11 -0700 | [diff] [blame] | 6129 | case LPFC_LINK_SPEED_128GHZ: |
| 6130 | fc_host_speed(shost) = FC_PORTSPEED_128GBIT; |
| 6131 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6132 | default: |
| 6133 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6134 | break; |
| 6135 | } |
James Smart | b615a20 | 2018-07-31 17:23:19 -0700 | [diff] [blame] | 6136 | } else if (lpfc_is_link_up(phba) && (phba->hba_flag & HBA_FCOE_MODE)) { |
| 6137 | switch (phba->fc_linkspeed) { |
| 6138 | case LPFC_ASYNC_LINK_SPEED_10GBPS: |
| 6139 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
| 6140 | break; |
| 6141 | case LPFC_ASYNC_LINK_SPEED_25GBPS: |
| 6142 | fc_host_speed(shost) = FC_PORTSPEED_25GBIT; |
| 6143 | break; |
| 6144 | case LPFC_ASYNC_LINK_SPEED_40GBPS: |
| 6145 | fc_host_speed(shost) = FC_PORTSPEED_40GBIT; |
| 6146 | break; |
| 6147 | case LPFC_ASYNC_LINK_SPEED_100GBPS: |
| 6148 | fc_host_speed(shost) = FC_PORTSPEED_100GBIT; |
| 6149 | break; |
| 6150 | default: |
| 6151 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| 6152 | break; |
| 6153 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6154 | } else |
| 6155 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6156 | |
| 6157 | spin_unlock_irq(shost->host_lock); |
| 6158 | } |
| 6159 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6160 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6161 | * 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] | 6162 | * @shost: kernel scsi host pointer. |
| 6163 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6164 | static void |
| 6165 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 6166 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6167 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6168 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 6169 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6170 | |
| 6171 | spin_lock_irq(shost->host_lock); |
| 6172 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6173 | if ((vport->port_state > LPFC_FLOGI) && |
| 6174 | ((vport->fc_flag & FC_FABRIC) || |
| 6175 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 6176 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 6177 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6178 | else |
| 6179 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6180 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6181 | |
| 6182 | spin_unlock_irq(shost->host_lock); |
| 6183 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 6184 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6185 | } |
| 6186 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6187 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6188 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6189 | * @shost: kernel scsi host pointer. |
| 6190 | * |
| 6191 | * Notes: |
| 6192 | * NULL on error for link down, no mbox pool, sli2 active, |
| 6193 | * management not allowed, memory allocation error, or mbox error. |
| 6194 | * |
| 6195 | * Returns: |
| 6196 | * NULL for error |
| 6197 | * address of the adapter host statistics |
| 6198 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6199 | static struct fc_host_statistics * |
| 6200 | lpfc_get_stats(struct Scsi_Host *shost) |
| 6201 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6202 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6203 | struct lpfc_hba *phba = vport->phba; |
| 6204 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6205 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6206 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6207 | LPFC_MBOXQ_t *pmboxq; |
| 6208 | MAILBOX_t *pmb; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6209 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6210 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6211 | /* |
| 6212 | * prevent udev from issuing mailbox commands until the port is |
| 6213 | * configured. |
| 6214 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6215 | if (phba->link_state < LPFC_LINK_DOWN || |
| 6216 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6217 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6218 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6219 | |
| 6220 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6221 | return NULL; |
| 6222 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6223 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6224 | if (!pmboxq) |
| 6225 | return NULL; |
| 6226 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 6227 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6228 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6229 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6230 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6231 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6232 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6233 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6234 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6235 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6236 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6237 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6238 | |
| 6239 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6240 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6241 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6242 | return NULL; |
| 6243 | } |
| 6244 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 6245 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 6246 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6247 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6248 | /* |
| 6249 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 6250 | * converted to words |
| 6251 | */ |
| 6252 | hs->tx_words = (uint64_t) |
| 6253 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 6254 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6255 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 6256 | hs->rx_words = (uint64_t) |
| 6257 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 6258 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6259 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6260 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6261 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6262 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6263 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6264 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6265 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 6266 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6267 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 6268 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6269 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6270 | |
| 6271 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6272 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6273 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6274 | return NULL; |
| 6275 | } |
| 6276 | |
| 6277 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6278 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6279 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6280 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6281 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6282 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6283 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 6284 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6285 | hs->link_failure_count -= lso->link_failure_count; |
| 6286 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 6287 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 6288 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 6289 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 6290 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 6291 | hs->error_frames -= lso->error_frames; |
| 6292 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6293 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6294 | hs->lip_count = -1; |
| 6295 | hs->nos_count = (phba->link_events >> 1); |
| 6296 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6297 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6298 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6299 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6300 | hs->nos_count = -1; |
| 6301 | } else { |
| 6302 | hs->lip_count = -1; |
| 6303 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6304 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6305 | } |
| 6306 | |
| 6307 | hs->dumped_frames = -1; |
| 6308 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6309 | hs->seconds_since_last_reset = ktime_get_seconds() - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6310 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6311 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6312 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6313 | return hs; |
| 6314 | } |
| 6315 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6316 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6317 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6318 | * @shost: kernel scsi host pointer. |
| 6319 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6320 | static void |
| 6321 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 6322 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6323 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 6324 | struct lpfc_hba *phba = vport->phba; |
| 6325 | struct lpfc_sli *psli = &phba->sli; |
| 6326 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6327 | LPFC_MBOXQ_t *pmboxq; |
| 6328 | MAILBOX_t *pmb; |
| 6329 | int rc = 0; |
| 6330 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6331 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 6332 | return; |
| 6333 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6334 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6335 | if (!pmboxq) |
| 6336 | return; |
| 6337 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6338 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6339 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6340 | pmb->mbxCommand = MBX_READ_STATUS; |
| 6341 | pmb->mbxOwner = OWN_HOST; |
| 6342 | pmb->un.varWords[0] = 0x1; /* reset request */ |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6343 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6344 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6345 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6346 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6347 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6348 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6349 | else |
| 6350 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6351 | |
| 6352 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6353 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6354 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6355 | return; |
| 6356 | } |
| 6357 | |
| 6358 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 6359 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 6360 | pmb->mbxOwner = OWN_HOST; |
James Smart | 3e1f071 | 2018-11-29 16:09:29 -0800 | [diff] [blame] | 6361 | pmboxq->ctx_buf = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6362 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6363 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6364 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6365 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6366 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 6367 | else |
| 6368 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 6369 | |
| 6370 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6371 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6372 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 6373 | return; |
| 6374 | } |
| 6375 | |
| 6376 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 6377 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 6378 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 6379 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 6380 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 6381 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 6382 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6383 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 6384 | lso->link_events = (phba->link_events >> 1); |
| 6385 | else |
| 6386 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6387 | |
Arnd Bergmann | c4d6204d | 2018-06-18 17:28:23 +0200 | [diff] [blame] | 6388 | psli->stats_start = ktime_get_seconds(); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6389 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 6390 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 6391 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6392 | return; |
| 6393 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6394 | |
| 6395 | /* |
| 6396 | * The LPFC driver treats linkdown handling as target loss events so there |
| 6397 | * are no sysfs handlers for link_down_tmo. |
| 6398 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6399 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6400 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6401 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6402 | * @starget: kernel scsi target pointer. |
| 6403 | * |
| 6404 | * Returns: |
| 6405 | * address of the node list if found |
| 6406 | * NULL target not found |
| 6407 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6408 | static struct lpfc_nodelist * |
| 6409 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6410 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6411 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 6412 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6413 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6414 | |
| 6415 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6416 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6417 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6418 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 6419 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6420 | starget->id == ndlp->nlp_sid) { |
| 6421 | spin_unlock_irq(shost->host_lock); |
| 6422 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6423 | } |
| 6424 | } |
| 6425 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6426 | return NULL; |
| 6427 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6428 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6429 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6430 | * 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] | 6431 | * @starget: kernel scsi target pointer. |
| 6432 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6433 | static void |
| 6434 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 6435 | { |
| 6436 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 6437 | |
| 6438 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6439 | } |
| 6440 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6441 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6442 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6443 | * @starget: kernel scsi target pointer. |
| 6444 | * |
| 6445 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 6446 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6447 | static void |
| 6448 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 6449 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6450 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6451 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6452 | fc_starget_node_name(starget) = |
| 6453 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6454 | } |
| 6455 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6456 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6457 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6458 | * @starget: kernel scsi target pointer. |
| 6459 | * |
| 6460 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 6461 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6462 | static void |
| 6463 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 6464 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6465 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6466 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 6467 | fc_starget_port_name(starget) = |
| 6468 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6469 | } |
| 6470 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6471 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6472 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6473 | * @rport: fc rport address. |
| 6474 | * @timeout: new value for dev loss tmo. |
| 6475 | * |
| 6476 | * Description: |
| 6477 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 6478 | * dev_loss_tmo to one. |
| 6479 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6480 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6481 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 6482 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6483 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6484 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6485 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6486 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6487 | } |
| 6488 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6489 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6490 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6491 | * |
| 6492 | * Description: |
| 6493 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 6494 | * |
| 6495 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 6496 | * @cdev: class converted to an fc_rport. |
| 6497 | * @buf: on return contains the target_field or zero. |
| 6498 | * |
| 6499 | * Returns: size of formatted string. |
| 6500 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6501 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 6502 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6503 | lpfc_show_rport_##field (struct device *dev, \ |
| 6504 | struct device_attribute *attr, \ |
| 6505 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6506 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 6507 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6508 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 6509 | return snprintf(buf, sz, format_string, \ |
| 6510 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 6511 | } |
| 6512 | |
| 6513 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 6514 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 6515 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 6516 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6517 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6518 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6519 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 6520 | * |
| 6521 | * Description: |
| 6522 | * This function is called by the transport after the @fc_vport's symbolic name |
| 6523 | * 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] | 6524 | * 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] | 6525 | **/ |
| 6526 | static void |
| 6527 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 6528 | { |
| 6529 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 6530 | |
| 6531 | if (vport->port_state == LPFC_VPORT_READY) |
| 6532 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 6533 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6534 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6535 | /** |
| 6536 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 6537 | * @phba: Pointer to lpfc_hba struct. |
| 6538 | * |
| 6539 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 6540 | * 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] | 6541 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6542 | * before hba port or vport created. |
| 6543 | **/ |
| 6544 | static void |
| 6545 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 6546 | { |
| 6547 | phba->cfg_log_verbose = verbose; |
| 6548 | } |
| 6549 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6550 | struct fc_function_template lpfc_transport_functions = { |
| 6551 | /* fixed attributes the driver supports */ |
| 6552 | .show_host_node_name = 1, |
| 6553 | .show_host_port_name = 1, |
| 6554 | .show_host_supported_classes = 1, |
| 6555 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6556 | .show_host_supported_speeds = 1, |
| 6557 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6558 | |
| 6559 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6560 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6561 | |
| 6562 | /* dynamic attributes the driver supports */ |
| 6563 | .get_host_port_id = lpfc_get_host_port_id, |
| 6564 | .show_host_port_id = 1, |
| 6565 | |
| 6566 | .get_host_port_type = lpfc_get_host_port_type, |
| 6567 | .show_host_port_type = 1, |
| 6568 | |
| 6569 | .get_host_port_state = lpfc_get_host_port_state, |
| 6570 | .show_host_port_state = 1, |
| 6571 | |
| 6572 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6573 | .show_host_active_fc4s = 1, |
| 6574 | |
| 6575 | .get_host_speed = lpfc_get_host_speed, |
| 6576 | .show_host_speed = 1, |
| 6577 | |
| 6578 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6579 | .show_host_fabric_name = 1, |
| 6580 | |
| 6581 | /* |
| 6582 | * The LPFC driver treats linkdown handling as target loss events |
| 6583 | * so there are no sysfs handlers for link_down_tmo. |
| 6584 | */ |
| 6585 | |
| 6586 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6587 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6588 | |
| 6589 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6590 | .show_rport_maxframe_size = 1, |
| 6591 | .show_rport_supported_classes = 1, |
| 6592 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6593 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6594 | .show_rport_dev_loss_tmo = 1, |
| 6595 | |
| 6596 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6597 | .show_starget_port_id = 1, |
| 6598 | |
| 6599 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6600 | .show_starget_node_name = 1, |
| 6601 | |
| 6602 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6603 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 6604 | |
| 6605 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6606 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6607 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6608 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6609 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6610 | |
| 6611 | .vport_disable = lpfc_vport_disable, |
| 6612 | |
| 6613 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 6614 | |
| 6615 | .bsg_request = lpfc_bsg_request, |
| 6616 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6617 | }; |
| 6618 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6619 | struct fc_function_template lpfc_vport_transport_functions = { |
| 6620 | /* fixed attributes the driver supports */ |
| 6621 | .show_host_node_name = 1, |
| 6622 | .show_host_port_name = 1, |
| 6623 | .show_host_supported_classes = 1, |
| 6624 | .show_host_supported_fc4s = 1, |
| 6625 | .show_host_supported_speeds = 1, |
| 6626 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6627 | |
| 6628 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6629 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6630 | |
| 6631 | /* dynamic attributes the driver supports */ |
| 6632 | .get_host_port_id = lpfc_get_host_port_id, |
| 6633 | .show_host_port_id = 1, |
| 6634 | |
| 6635 | .get_host_port_type = lpfc_get_host_port_type, |
| 6636 | .show_host_port_type = 1, |
| 6637 | |
| 6638 | .get_host_port_state = lpfc_get_host_port_state, |
| 6639 | .show_host_port_state = 1, |
| 6640 | |
| 6641 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6642 | .show_host_active_fc4s = 1, |
| 6643 | |
| 6644 | .get_host_speed = lpfc_get_host_speed, |
| 6645 | .show_host_speed = 1, |
| 6646 | |
| 6647 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6648 | .show_host_fabric_name = 1, |
| 6649 | |
| 6650 | /* |
| 6651 | * The LPFC driver treats linkdown handling as target loss events |
| 6652 | * so there are no sysfs handlers for link_down_tmo. |
| 6653 | */ |
| 6654 | |
| 6655 | .get_fc_host_stats = lpfc_get_stats, |
| 6656 | .reset_fc_host_stats = lpfc_reset_stats, |
| 6657 | |
| 6658 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6659 | .show_rport_maxframe_size = 1, |
| 6660 | .show_rport_supported_classes = 1, |
| 6661 | |
| 6662 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6663 | .show_rport_dev_loss_tmo = 1, |
| 6664 | |
| 6665 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6666 | .show_starget_port_id = 1, |
| 6667 | |
| 6668 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6669 | .show_starget_node_name = 1, |
| 6670 | |
| 6671 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6672 | .show_starget_port_name = 1, |
| 6673 | |
| 6674 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6675 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 6676 | |
| 6677 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6678 | |
| 6679 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6680 | }; |
| 6681 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6682 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6683 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6684 | * @phba: lpfc_hba pointer. |
| 6685 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6686 | void |
| 6687 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 6688 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6689 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | 7ea92eb | 2018-10-23 13:41:10 -0700 | [diff] [blame] | 6690 | lpfc_ns_query_init(phba, lpfc_ns_query); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6691 | 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] | 6692 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 6693 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 6694 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 6695 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 6696 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6697 | lpfc_ack0_init(phba, lpfc_ack0); |
| 6698 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6699 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 6700 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6701 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 6702 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6703 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6704 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6705 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 6706 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 6707 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6708 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 6709 | lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd); |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6710 | lpfc_auto_imax_init(phba, lpfc_auto_imax); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6711 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6712 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6713 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 6714 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6715 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6716 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 6717 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 6718 | phba->cfg_EnableXLane = 0; |
| 6719 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6720 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6721 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6722 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6723 | phba->cfg_oas_lun_state = 0; |
| 6724 | phba->cfg_oas_lun_status = 0; |
| 6725 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6726 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6727 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6728 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 6729 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 6730 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6731 | phba->cfg_poll = 0; |
| 6732 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6733 | phba->cfg_poll = lpfc_poll; |
James Smart | f44ac12 | 2018-03-05 12:04:08 -0800 | [diff] [blame] | 6734 | |
| 6735 | if (phba->cfg_enable_bg) |
| 6736 | phba->sli3_options |= LPFC_SLI3_BG_ENABLED; |
| 6737 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6738 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6739 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6740 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6741 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
James Smart | 2448e48 | 2018-04-09 14:24:24 -0700 | [diff] [blame] | 6742 | lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6743 | |
| 6744 | /* Initialize first burst. Target vs Initiator are different. */ |
| 6745 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6746 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6747 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
| 6748 | lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel); |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6749 | lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr); |
James Smart | 1351e69 | 2018-02-22 08:18:43 -0800 | [diff] [blame] | 6750 | lpfc_enable_dpp_init(phba, lpfc_enable_dpp); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6751 | |
| 6752 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 6753 | /* NVME only supported on SLI4 */ |
| 6754 | phba->nvmet_support = 0; |
| 6755 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
James Smart | 44fd7fe | 2017-08-23 16:55:47 -0700 | [diff] [blame] | 6756 | phba->cfg_enable_bbcr = 0; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6757 | } else { |
| 6758 | /* We MUST have FCP support */ |
| 6759 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 6760 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 6761 | } |
| 6762 | |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 6763 | if (phba->cfg_auto_imax && !phba->cfg_fcp_imax) |
| 6764 | phba->cfg_auto_imax = 0; |
| 6765 | phba->initial_imax = phba->cfg_fcp_imax; |
| 6766 | |
James Smart | 06b6fa38 | 2018-07-31 17:23:24 -0700 | [diff] [blame] | 6767 | phba->cfg_enable_pbde = 0; |
| 6768 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6769 | /* 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] | 6770 | if (phba->cfg_fcp_io_channel == 0) |
| 6771 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6772 | if (phba->cfg_nvme_io_channel == 0) |
| 6773 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6774 | |
| 6775 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME) |
| 6776 | phba->cfg_fcp_io_channel = 0; |
| 6777 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6778 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) |
| 6779 | phba->cfg_nvme_io_channel = 0; |
| 6780 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6781 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6782 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6783 | else |
| 6784 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6785 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6786 | phba->cfg_soft_wwnn = 0L; |
| 6787 | phba->cfg_soft_wwpn = 0L; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6788 | lpfc_xri_split_init(phba, lpfc_xri_split); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6789 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 6790 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6791 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6792 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6793 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6794 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6795 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6796 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 6797 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 6798 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6799 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6800 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | d2cc9bc | 2018-09-10 10:30:50 -0700 | [diff] [blame] | 6801 | lpfc_ras_fwlog_buffsize_init(phba, lpfc_ras_fwlog_buffsize); |
| 6802 | lpfc_ras_fwlog_level_init(phba, lpfc_ras_fwlog_level); |
| 6803 | lpfc_ras_fwlog_func_init(phba, lpfc_ras_fwlog_func); |
| 6804 | |
James Smart | faf0a5f | 2018-09-10 10:30:43 -0700 | [diff] [blame] | 6805 | |
| 6806 | /* If the NVME FC4 type is enabled, scale the sg_seg_cnt to |
| 6807 | * accommodate 512K and 1M IOs in a single nvme buf and supply |
| 6808 | * enough NVME LS iocb buffers for larger connectivity counts. |
| 6809 | */ |
| 6810 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { |
| 6811 | phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; |
| 6812 | phba->cfg_iocb_cnt = 5; |
| 6813 | } |
| 6814 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6815 | return; |
| 6816 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 6817 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6818 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6819 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 6820 | * dependencies between protocols and roles. |
| 6821 | * @phba: lpfc_hba pointer. |
| 6822 | **/ |
| 6823 | void |
| 6824 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 6825 | { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6826 | if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu) |
| 6827 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6828 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6829 | if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu) |
| 6830 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
| 6831 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6832 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 6833 | phba->nvmet_support) { |
| 6834 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
| 6835 | phba->cfg_fcp_io_channel = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6836 | |
| 6837 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 6838 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 6839 | "NVME Target PRLI ACC enable_fb ", |
| 6840 | phba->cfg_nvme_enable_fb, |
| 6841 | phba->cfg_nvmet_fb_size, |
| 6842 | LPFC_NVMET_FB_SZ_MAX); |
| 6843 | |
| 6844 | if (phba->cfg_nvme_enable_fb == 0) |
| 6845 | phba->cfg_nvmet_fb_size = 0; |
| 6846 | else { |
| 6847 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 6848 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 6849 | } |
| 6850 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6851 | if (!phba->cfg_nvmet_mrq) |
| 6852 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6853 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6854 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
| 6855 | if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) { |
| 6856 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6857 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 6858 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 6859 | phba->cfg_nvmet_mrq); |
| 6860 | } |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6861 | if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) |
| 6862 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; |
| 6863 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6864 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6865 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 6866 | phba->nvmet_support = 0; |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 6867 | phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_OFF; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6868 | phba->cfg_nvmet_fb_size = 0; |
| 6869 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6870 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6871 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6872 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6873 | else |
| 6874 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
| 6875 | } |
| 6876 | |
| 6877 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6878 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6879 | * @vport: lpfc_vport pointer. |
| 6880 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6881 | void |
| 6882 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 6883 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6884 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6885 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6886 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6887 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 6888 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 6889 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 6890 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 6891 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 6892 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6893 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6894 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6895 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 6896 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 6897 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 6898 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6899 | return; |
| 6900 | } |