| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017 Broadcom. All Rights Reserved. The term * |
| 5 | * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. * |
James Smart | 5061157 | 2016-03-31 14:12:34 -0700 | [diff] [blame] | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * EMULEX and SLI are trademarks of Emulex. * |
James Smart | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 8 | * www.broadcom.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 9 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 12 | * modify it under the terms of version 2 of the GNU General * |
| 13 | * Public License as published by the Free Software Foundation. * |
| 14 | * This program is distributed in the hope that it will be useful. * |
| 15 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 16 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 18 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 19 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 20 | * more details, a copy of which can be found in the file COPYING * |
| 21 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | *******************************************************************/ |
| 23 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 24 | #include <linux/ctype.h> |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 25 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 26 | #include <linux/pci.h> |
| 27 | #include <linux/interrupt.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 28 | #include <linux/module.h> |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 29 | #include <linux/aer.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/gfp.h> |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 31 | #include <linux/kernel.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 32 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 33 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | #include <scsi/scsi_device.h> |
| 35 | #include <scsi/scsi_host.h> |
| 36 | #include <scsi/scsi_tcq.h> |
| 37 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 38 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 39 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 40 | #include <linux/nvme-fc-driver.h> |
| 41 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 42 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 43 | #include "lpfc_hw.h" |
| 44 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 45 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 46 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 47 | #include "lpfc_disc.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 48 | #include "lpfc.h" |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 49 | #include "lpfc_scsi.h" |
| 50 | #include "lpfc_nvme.h" |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 51 | #include "lpfc_nvmet.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 52 | #include "lpfc_logmsg.h" |
| 53 | #include "lpfc_version.h" |
| 54 | #include "lpfc_compat.h" |
| 55 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 56 | #include "lpfc_vport.h" |
James Smart | 93dd191 | 2016-07-06 12:36:10 -0700 | [diff] [blame] | 57 | #include "lpfc_attr.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 58 | |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 59 | #define LPFC_DEF_DEVLOSS_TMO 30 |
| 60 | #define LPFC_MIN_DEVLOSS_TMO 1 |
| 61 | #define LPFC_MAX_DEVLOSS_TMO 255 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 62 | |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 63 | #define LPFC_DEF_MRQ_POST 256 |
| 64 | #define LPFC_MIN_MRQ_POST 32 |
| 65 | #define LPFC_MAX_MRQ_POST 512 |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 66 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 67 | /* |
| 68 | * Write key size should be multiple of 4. If write key is changed |
| 69 | * make sure that library write key is also changed. |
| 70 | */ |
| 71 | #define LPFC_REG_WRITE_KEY_SIZE 4 |
| 72 | #define LPFC_REG_WRITE_KEY "EMLX" |
| 73 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 74 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 75 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 76 | * @incr: integer to convert. |
| 77 | * @hdw: ascii string holding converted integer plus a string terminator. |
| 78 | * |
| 79 | * Description: |
| 80 | * JEDEC Joint Electron Device Engineering Council. |
| 81 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii |
| 82 | * character string. The string is then terminated with a NULL in byte 9. |
| 83 | * Hex 0-9 becomes ascii '0' to '9'. |
| 84 | * Hex a-f becomes ascii '=' to 'B' capital B. |
| 85 | * |
| 86 | * Notes: |
| 87 | * Coded for 32 bit integers only. |
| 88 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 89 | static void |
| 90 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
| 91 | { |
| 92 | int i, j; |
| 93 | for (i = 0; i < 8; i++) { |
| 94 | j = (incr & 0xf); |
| 95 | if (j <= 9) |
| 96 | hdw[7 - i] = 0x30 + j; |
| 97 | else |
| 98 | hdw[7 - i] = 0x61 + j - 10; |
| 99 | incr = (incr >> 4); |
| 100 | } |
| 101 | hdw[8] = 0; |
| 102 | return; |
| 103 | } |
| 104 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 105 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 106 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 107 | * @dev: class unused variable. |
| 108 | * @attr: device attribute, not used. |
| 109 | * @buf: on return contains the module description text. |
| 110 | * |
| 111 | * Returns: size of formatted string. |
| 112 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 113 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 114 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
| 115 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 116 | { |
| 117 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
| 118 | } |
| 119 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 120 | /** |
| 121 | * lpfc_enable_fip_show - Return the fip mode of the HBA |
| 122 | * @dev: class unused variable. |
| 123 | * @attr: device attribute, not used. |
| 124 | * @buf: on return contains the module description text. |
| 125 | * |
| 126 | * Returns: size of formatted string. |
| 127 | **/ |
| 128 | static ssize_t |
| 129 | lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr, |
| 130 | char *buf) |
| 131 | { |
| 132 | struct Scsi_Host *shost = class_to_shost(dev); |
| 133 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 134 | struct lpfc_hba *phba = vport->phba; |
| 135 | |
| 136 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 137 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| 138 | else |
| 139 | return snprintf(buf, PAGE_SIZE, "0\n"); |
| 140 | } |
| 141 | |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 142 | static ssize_t |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 143 | lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, |
| 144 | char *buf) |
| 145 | { |
| 146 | struct Scsi_Host *shost = class_to_shost(dev); |
| 147 | struct lpfc_vport *vport = shost_priv(shost); |
| 148 | struct lpfc_hba *phba = vport->phba; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 149 | struct lpfc_nvmet_tgtport *tgtp; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 150 | struct nvme_fc_local_port *localport; |
| 151 | struct lpfc_nvme_lport *lport; |
| 152 | struct lpfc_nvme_rport *rport; |
| 153 | struct nvme_fc_remote_port *nrport; |
| 154 | char *statep; |
| 155 | int len = 0; |
| 156 | |
| 157 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { |
| 158 | len += snprintf(buf, PAGE_SIZE, "NVME Disabled\n"); |
| 159 | return len; |
| 160 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 161 | if (phba->nvmet_support) { |
| 162 | if (!phba->targetport) { |
| 163 | len = snprintf(buf, PAGE_SIZE, |
| 164 | "NVME Target: x%llx is not allocated\n", |
| 165 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 166 | return len; |
| 167 | } |
| 168 | /* Port state is only one of two values for now. */ |
| 169 | if (phba->targetport->port_id) |
| 170 | statep = "REGISTERED"; |
| 171 | else |
| 172 | statep = "INIT"; |
| 173 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 174 | "NVME Target: Enabled State %s\n", |
| 175 | statep); |
| 176 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 177 | "%s%d WWPN x%llx WWNN x%llx DID x%06x\n", |
| 178 | "NVME Target: lpfc", |
| 179 | phba->brd_no, |
| 180 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 181 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 182 | phba->targetport->port_id); |
| 183 | |
| 184 | len += snprintf(buf + len, PAGE_SIZE, |
| 185 | "\nNVME Target: Statistics\n"); |
| 186 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
| 187 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 188 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 189 | atomic_read(&tgtp->rcv_ls_req_in), |
| 190 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 191 | atomic_read(&tgtp->xmt_ls_abort)); |
| 192 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 193 | atomic_read(&tgtp->rcv_ls_req_out)) { |
| 194 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 195 | "Rcv LS: in %08x != out %08x\n", |
| 196 | atomic_read(&tgtp->rcv_ls_req_in), |
| 197 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 198 | } |
| 199 | |
| 200 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 201 | "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n", |
| 202 | atomic_read(&tgtp->xmt_ls_rsp), |
| 203 | atomic_read(&tgtp->xmt_ls_drop), |
| 204 | atomic_read(&tgtp->xmt_ls_rsp_cmpl), |
| 205 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 206 | |
| 207 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 208 | "FCP: Rcv %08x Drop %08x\n", |
| 209 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 210 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 211 | |
| 212 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 213 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
| 214 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 215 | "Rcv FCP: in %08x != out %08x\n", |
| 216 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 217 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 218 | } |
| 219 | |
| 220 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 221 | "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x\n", |
| 222 | atomic_read(&tgtp->xmt_fcp_read), |
| 223 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 224 | atomic_read(&tgtp->xmt_fcp_write), |
| 225 | atomic_read(&tgtp->xmt_fcp_rsp)); |
| 226 | |
| 227 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 228 | "FCP Rsp: abort %08x drop %08x\n", |
| 229 | atomic_read(&tgtp->xmt_fcp_abort), |
| 230 | atomic_read(&tgtp->xmt_fcp_drop)); |
| 231 | |
| 232 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 233 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 234 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 235 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 236 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 237 | |
| 238 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 239 | "ABORT: Xmt %08x Err %08x Cmpl %08x", |
| 240 | atomic_read(&tgtp->xmt_abort_rsp), |
| 241 | atomic_read(&tgtp->xmt_abort_rsp_error), |
| 242 | atomic_read(&tgtp->xmt_abort_cmpl)); |
| 243 | |
| 244 | len += snprintf(buf+len, PAGE_SIZE-len, "\n"); |
| 245 | return len; |
| 246 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 247 | |
| 248 | localport = vport->localport; |
| 249 | if (!localport) { |
| 250 | len = snprintf(buf, PAGE_SIZE, |
| 251 | "NVME Initiator x%llx is not allocated\n", |
| 252 | wwn_to_u64(vport->fc_portname.u.wwn)); |
| 253 | return len; |
| 254 | } |
| 255 | len = snprintf(buf, PAGE_SIZE, "NVME Initiator Enabled\n"); |
| 256 | |
| 257 | spin_lock_irq(shost->host_lock); |
| 258 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 259 | |
| 260 | /* Port state is only one of two values for now. */ |
| 261 | if (localport->port_id) |
| 262 | statep = "ONLINE"; |
| 263 | else |
| 264 | statep = "UNKNOWN "; |
| 265 | |
| 266 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 267 | "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n", |
| 268 | "NVME LPORT lpfc", |
| 269 | phba->brd_no, |
| 270 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 271 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 272 | localport->port_id, statep); |
| 273 | |
| 274 | list_for_each_entry(rport, &lport->rport_list, list) { |
| 275 | /* local short-hand pointer. */ |
| 276 | nrport = rport->remoteport; |
| 277 | |
| 278 | /* Port state is only one of two values for now. */ |
| 279 | switch (nrport->port_state) { |
| 280 | case FC_OBJSTATE_ONLINE: |
| 281 | statep = "ONLINE"; |
| 282 | break; |
| 283 | case FC_OBJSTATE_UNKNOWN: |
| 284 | statep = "UNKNOWN "; |
| 285 | break; |
| 286 | default: |
| 287 | statep = "UNSUPPORTED"; |
| 288 | break; |
| 289 | } |
| 290 | |
| 291 | /* Tab in to show lport ownership. */ |
| 292 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 293 | "NVME RPORT "); |
| 294 | if (phba->brd_no >= 10) |
| 295 | len += snprintf(buf + len, PAGE_SIZE - len, " "); |
| 296 | |
| 297 | len += snprintf(buf + len, PAGE_SIZE - len, "WWPN x%llx ", |
| 298 | nrport->port_name); |
| 299 | len += snprintf(buf + len, PAGE_SIZE - len, "WWNN x%llx ", |
| 300 | nrport->node_name); |
| 301 | len += snprintf(buf + len, PAGE_SIZE - len, "DID x%06x ", |
| 302 | nrport->port_id); |
| 303 | |
| 304 | switch (nrport->port_role) { |
| 305 | case FC_PORT_ROLE_NVME_INITIATOR: |
| 306 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 307 | "INITIATOR "); |
| 308 | break; |
| 309 | case FC_PORT_ROLE_NVME_TARGET: |
| 310 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 311 | "TARGET "); |
| 312 | break; |
| 313 | case FC_PORT_ROLE_NVME_DISCOVERY: |
| 314 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 315 | "DISCOVERY "); |
| 316 | break; |
| 317 | default: |
| 318 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 319 | "UNKNOWN_ROLE x%x", |
| 320 | nrport->port_role); |
| 321 | break; |
| 322 | } |
| 323 | len += snprintf(buf + len, PAGE_SIZE - len, "%s ", statep); |
| 324 | /* Terminate the string. */ |
| 325 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
| 326 | } |
| 327 | spin_unlock_irq(shost->host_lock); |
| 328 | |
| 329 | len += snprintf(buf + len, PAGE_SIZE, "\nNVME Statistics\n"); |
| 330 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 331 | "LS: Xmt %016llx Cmpl %016llx\n", |
| 332 | phba->fc4NvmeLsRequests, |
| 333 | phba->fc4NvmeLsCmpls); |
| 334 | |
| 335 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 336 | "FCP: Rd %016llx Wr %016llx IO %016llx\n", |
| 337 | phba->fc4NvmeInputRequests, |
| 338 | phba->fc4NvmeOutputRequests, |
| 339 | phba->fc4NvmeControlRequests); |
| 340 | |
| 341 | len += snprintf(buf+len, PAGE_SIZE-len, |
| 342 | " Cmpl %016llx\n", phba->fc4NvmeIoCmpls); |
| 343 | |
| 344 | return len; |
| 345 | } |
| 346 | |
| 347 | static ssize_t |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 348 | lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, |
| 349 | char *buf) |
| 350 | { |
| 351 | struct Scsi_Host *shost = class_to_shost(dev); |
| 352 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 353 | struct lpfc_hba *phba = vport->phba; |
| 354 | |
| 355 | if (phba->cfg_enable_bg) |
| 356 | if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) |
| 357 | return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n"); |
| 358 | else |
| 359 | return snprintf(buf, PAGE_SIZE, |
| 360 | "BlockGuard Not Supported\n"); |
| 361 | else |
| 362 | return snprintf(buf, PAGE_SIZE, |
| 363 | "BlockGuard Disabled\n"); |
| 364 | } |
| 365 | |
| 366 | static ssize_t |
| 367 | lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr, |
| 368 | char *buf) |
| 369 | { |
| 370 | struct Scsi_Host *shost = class_to_shost(dev); |
| 371 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 372 | struct lpfc_hba *phba = vport->phba; |
| 373 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 374 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 375 | (unsigned long long)phba->bg_guard_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | static ssize_t |
| 379 | lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr, |
| 380 | char *buf) |
| 381 | { |
| 382 | struct Scsi_Host *shost = class_to_shost(dev); |
| 383 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 384 | struct lpfc_hba *phba = vport->phba; |
| 385 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 386 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 387 | (unsigned long long)phba->bg_apptag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | static ssize_t |
| 391 | lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, |
| 392 | char *buf) |
| 393 | { |
| 394 | struct Scsi_Host *shost = class_to_shost(dev); |
| 395 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 396 | struct lpfc_hba *phba = vport->phba; |
| 397 | |
James Smart | 87b5c32 | 2008-12-16 10:34:09 -0500 | [diff] [blame] | 398 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 399 | (unsigned long long)phba->bg_reftag_err_cnt); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 400 | } |
| 401 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 402 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 403 | * lpfc_info_show - Return some pci info about the host in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 404 | * @dev: class converted to a Scsi_host structure. |
| 405 | * @attr: device attribute, not used. |
| 406 | * @buf: on return contains the formatted text from lpfc_info(). |
| 407 | * |
| 408 | * Returns: size of formatted string. |
| 409 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 410 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 411 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
| 412 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 413 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 414 | struct Scsi_Host *host = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 415 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 416 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
| 417 | } |
| 418 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 419 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 420 | * lpfc_serialnum_show - Return the hba serial number in ascii |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 421 | * @dev: class converted to a Scsi_host structure. |
| 422 | * @attr: device attribute, not used. |
| 423 | * @buf: on return contains the formatted text serial number. |
| 424 | * |
| 425 | * Returns: size of formatted string. |
| 426 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 427 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 428 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
| 429 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 430 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 431 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 432 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 433 | struct lpfc_hba *phba = vport->phba; |
| 434 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 435 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
| 436 | } |
| 437 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 438 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 439 | * lpfc_temp_sensor_show - Return the temperature sensor level |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 440 | * @dev: class converted to a Scsi_host structure. |
| 441 | * @attr: device attribute, not used. |
| 442 | * @buf: on return contains the formatted support level. |
| 443 | * |
| 444 | * Description: |
| 445 | * Returns a number indicating the temperature sensor level currently |
| 446 | * supported, zero or one in ascii. |
| 447 | * |
| 448 | * Returns: size of formatted string. |
| 449 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 450 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 451 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
| 452 | char *buf) |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 453 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 454 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 455 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 456 | struct lpfc_hba *phba = vport->phba; |
| 457 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
| 458 | } |
| 459 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 460 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 461 | * lpfc_modeldesc_show - Return the model description of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 462 | * @dev: class converted to a Scsi_host structure. |
| 463 | * @attr: device attribute, not used. |
| 464 | * @buf: on return contains the scsi vpd model description. |
| 465 | * |
| 466 | * Returns: size of formatted string. |
| 467 | **/ |
James Smart | 57127f1 | 2007-10-27 13:37:05 -0400 | [diff] [blame] | 468 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 469 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
| 470 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 471 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 472 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 473 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 474 | struct lpfc_hba *phba = vport->phba; |
| 475 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 476 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
| 477 | } |
| 478 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 479 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 480 | * lpfc_modelname_show - Return the model name of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 481 | * @dev: class converted to a Scsi_host structure. |
| 482 | * @attr: device attribute, not used. |
| 483 | * @buf: on return contains the scsi vpd model name. |
| 484 | * |
| 485 | * Returns: size of formatted string. |
| 486 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 487 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 488 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
| 489 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 490 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 491 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 492 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 493 | struct lpfc_hba *phba = vport->phba; |
| 494 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 495 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
| 496 | } |
| 497 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 498 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 499 | * lpfc_programtype_show - Return the program type of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 500 | * @dev: class converted to a Scsi_host structure. |
| 501 | * @attr: device attribute, not used. |
| 502 | * @buf: on return contains the scsi vpd program type. |
| 503 | * |
| 504 | * Returns: size of formatted string. |
| 505 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 506 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 507 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
| 508 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 509 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 510 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 511 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 512 | struct lpfc_hba *phba = vport->phba; |
| 513 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 514 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
| 515 | } |
| 516 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 517 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 518 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 519 | * @dev: class converted to a Scsi_host structure. |
| 520 | * @attr: device attribute, not used. |
| 521 | * @buf: on return contains the Menlo Maintenance sli flag. |
| 522 | * |
| 523 | * Returns: size of formatted string. |
| 524 | **/ |
| 525 | static ssize_t |
| 526 | lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 527 | { |
| 528 | struct Scsi_Host *shost = class_to_shost(dev); |
| 529 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 530 | struct lpfc_hba *phba = vport->phba; |
| 531 | |
| 532 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 533 | (phba->sli.sli_flag & LPFC_MENLO_MAINT)); |
| 534 | } |
| 535 | |
| 536 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 537 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 538 | * @dev: class converted to a Scsi_host structure. |
| 539 | * @attr: device attribute, not used. |
| 540 | * @buf: on return contains scsi vpd program type. |
| 541 | * |
| 542 | * Returns: size of formatted string. |
| 543 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 544 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 545 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
| 546 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 547 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 548 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 549 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 550 | struct lpfc_hba *phba = vport->phba; |
| 551 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 552 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
| 553 | } |
| 554 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 555 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 556 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 557 | * @dev: class converted to a Scsi_host structure. |
| 558 | * @attr: device attribute, not used. |
| 559 | * @buf: on return contains the scsi vpd program type. |
| 560 | * |
| 561 | * Returns: size of formatted string. |
| 562 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 563 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 564 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
| 565 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 566 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 567 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 568 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 569 | struct lpfc_hba *phba = vport->phba; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 570 | uint32_t if_type; |
| 571 | uint8_t sli_family; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 572 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 573 | int len; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 574 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 575 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 576 | if_type = phba->sli4_hba.pc_sli4_params.if_type; |
| 577 | sli_family = phba->sli4_hba.pc_sli4_params.sli_family; |
| 578 | |
| 579 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 580 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", |
| 581 | fwrev, phba->sli_rev); |
| 582 | else |
| 583 | len = snprintf(buf, PAGE_SIZE, "%s, sli-%d:%d:%x\n", |
| 584 | fwrev, phba->sli_rev, if_type, sli_family); |
| 585 | |
| 586 | return len; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 587 | } |
| 588 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 589 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 590 | * lpfc_hdw_show - Return the jedec information about the hba |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 591 | * @dev: class converted to a Scsi_host structure. |
| 592 | * @attr: device attribute, not used. |
| 593 | * @buf: on return contains the scsi vpd program type. |
| 594 | * |
| 595 | * Returns: size of formatted string. |
| 596 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 597 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 598 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 599 | { |
| 600 | char hdw[9]; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 601 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 602 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 603 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 604 | lpfc_vpd_t *vp = &phba->vpd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 605 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 606 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
| 607 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
| 608 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 609 | |
| 610 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 611 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 612 | * @dev: class converted to a Scsi_host structure. |
| 613 | * @attr: device attribute, not used. |
| 614 | * @buf: on return contains the ROM and FCode ascii strings. |
| 615 | * |
| 616 | * Returns: size of formatted string. |
| 617 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 618 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 619 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
| 620 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 621 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 622 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 623 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 624 | struct lpfc_hba *phba = vport->phba; |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 625 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 626 | |
James Smart | a0683bf | 2015-04-07 15:07:16 -0400 | [diff] [blame] | 627 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 628 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
| 629 | |
| 630 | lpfc_decode_firmware_rev(phba, fwrev, 1); |
| 631 | return snprintf(buf, PAGE_SIZE, "%s\n", fwrev); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 632 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 633 | |
| 634 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 635 | * lpfc_state_show - Return the link state of the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 636 | * @dev: class converted to a Scsi_host structure. |
| 637 | * @attr: device attribute, not used. |
| 638 | * @buf: on return contains text describing the state of the link. |
| 639 | * |
| 640 | * Notes: |
| 641 | * The switch statement has no default so zero will be returned. |
| 642 | * |
| 643 | * Returns: size of formatted string. |
| 644 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 645 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 646 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
| 647 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 648 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 649 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 650 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 651 | struct lpfc_hba *phba = vport->phba; |
| 652 | int len = 0; |
| 653 | |
| 654 | switch (phba->link_state) { |
| 655 | case LPFC_LINK_UNKNOWN: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 656 | case LPFC_WARM_START: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 657 | case LPFC_INIT_START: |
| 658 | case LPFC_INIT_MBX_CMDS: |
| 659 | case LPFC_LINK_DOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 660 | case LPFC_HBA_ERROR: |
James Smart | a0c87cb | 2009-07-19 10:01:10 -0400 | [diff] [blame] | 661 | if (phba->hba_flag & LINK_DISABLED) |
| 662 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 663 | "Link Down - User disabled\n"); |
| 664 | else |
| 665 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 666 | "Link Down\n"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 667 | break; |
| 668 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 669 | case LPFC_CLEAR_LA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | case LPFC_HBA_READY: |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 671 | len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - "); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 672 | |
| 673 | switch (vport->port_state) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 674 | case LPFC_LOCAL_CFG_LINK: |
| 675 | len += snprintf(buf + len, PAGE_SIZE-len, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 676 | "Configuring Link\n"); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 677 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 678 | case LPFC_FDISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 679 | case LPFC_FLOGI: |
| 680 | case LPFC_FABRIC_CFG_LINK: |
| 681 | case LPFC_NS_REG: |
| 682 | case LPFC_NS_QRY: |
| 683 | case LPFC_BUILD_DISC_LIST: |
| 684 | case LPFC_DISC_AUTH: |
| 685 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 686 | "Discovery\n"); |
| 687 | break; |
| 688 | case LPFC_VPORT_READY: |
| 689 | len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n"); |
| 690 | break; |
| 691 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 692 | case LPFC_VPORT_FAILED: |
| 693 | len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n"); |
| 694 | break; |
| 695 | |
| 696 | case LPFC_VPORT_UNKNOWN: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 697 | len += snprintf(buf + len, PAGE_SIZE - len, |
| 698 | "Unknown\n"); |
| 699 | break; |
| 700 | } |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 701 | if (phba->sli.sli_flag & LPFC_MENLO_MAINT) |
| 702 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 703 | " Menlo Maint Mode\n"); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 704 | else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 705 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 706 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 707 | " Public Loop\n"); |
| 708 | else |
| 709 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 710 | " Private Loop\n"); |
| 711 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 712 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 713 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 714 | " Fabric\n"); |
| 715 | else |
| 716 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 717 | " Point-2-Point\n"); |
| 718 | } |
| 719 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 720 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 721 | return len; |
| 722 | } |
| 723 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 724 | /** |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 725 | * lpfc_sli4_protocol_show - Return the fip mode of the HBA |
| 726 | * @dev: class unused variable. |
| 727 | * @attr: device attribute, not used. |
| 728 | * @buf: on return contains the module description text. |
| 729 | * |
| 730 | * Returns: size of formatted string. |
| 731 | **/ |
| 732 | static ssize_t |
| 733 | lpfc_sli4_protocol_show(struct device *dev, struct device_attribute *attr, |
| 734 | char *buf) |
| 735 | { |
| 736 | struct Scsi_Host *shost = class_to_shost(dev); |
| 737 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 738 | struct lpfc_hba *phba = vport->phba; |
| 739 | |
| 740 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 741 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 742 | |
| 743 | if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) { |
| 744 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_GE) |
| 745 | return snprintf(buf, PAGE_SIZE, "fcoe\n"); |
| 746 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) |
| 747 | return snprintf(buf, PAGE_SIZE, "fc\n"); |
| 748 | } |
| 749 | return snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 750 | } |
| 751 | |
| 752 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 753 | * lpfc_oas_supported_show - Return whether or not Optimized Access Storage |
| 754 | * (OAS) is supported. |
| 755 | * @dev: class unused variable. |
| 756 | * @attr: device attribute, not used. |
| 757 | * @buf: on return contains the module description text. |
| 758 | * |
| 759 | * Returns: size of formatted string. |
| 760 | **/ |
| 761 | static ssize_t |
| 762 | lpfc_oas_supported_show(struct device *dev, struct device_attribute *attr, |
| 763 | char *buf) |
| 764 | { |
| 765 | struct Scsi_Host *shost = class_to_shost(dev); |
| 766 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 767 | struct lpfc_hba *phba = vport->phba; |
| 768 | |
| 769 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 770 | phba->sli4_hba.pc_sli4_params.oas_supported); |
| 771 | } |
| 772 | |
| 773 | /** |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 774 | * lpfc_link_state_store - Transition the link_state on an HBA port |
| 775 | * @dev: class device that is converted into a Scsi_host. |
| 776 | * @attr: device attribute, not used. |
| 777 | * @buf: one or more lpfc_polling_flags values. |
| 778 | * @count: not used. |
| 779 | * |
| 780 | * Returns: |
| 781 | * -EINVAL if the buffer is not "up" or "down" |
| 782 | * return from link state change function if non-zero |
| 783 | * length of the buf on success |
| 784 | **/ |
| 785 | static ssize_t |
| 786 | lpfc_link_state_store(struct device *dev, struct device_attribute *attr, |
| 787 | const char *buf, size_t count) |
| 788 | { |
| 789 | struct Scsi_Host *shost = class_to_shost(dev); |
| 790 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 791 | struct lpfc_hba *phba = vport->phba; |
| 792 | |
| 793 | int status = -EINVAL; |
| 794 | |
| 795 | if ((strncmp(buf, "up", sizeof("up") - 1) == 0) && |
| 796 | (phba->link_state == LPFC_LINK_DOWN)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 797 | status = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 798 | else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) && |
| 799 | (phba->link_state >= LPFC_LINK_UP)) |
James Smart | 6e7288d | 2010-06-07 15:23:35 -0400 | [diff] [blame] | 800 | status = phba->lpfc_hba_down_link(phba, MBX_NOWAIT); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 801 | |
| 802 | if (status == 0) |
| 803 | return strlen(buf); |
| 804 | else |
| 805 | return status; |
| 806 | } |
| 807 | |
| 808 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 809 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 810 | * @dev: class device that is converted into a Scsi_host. |
| 811 | * @attr: device attribute, not used. |
| 812 | * @buf: on return contains the sum of fc mapped and unmapped. |
| 813 | * |
| 814 | * Description: |
| 815 | * Returns the ascii text number of the sum of the fc mapped and unmapped |
| 816 | * vport counts. |
| 817 | * |
| 818 | * Returns: size of formatted string. |
| 819 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 820 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 821 | lpfc_num_discovered_ports_show(struct device *dev, |
| 822 | struct device_attribute *attr, char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 823 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 824 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 825 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 826 | |
| 827 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 828 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 829 | } |
| 830 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 831 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 832 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 833 | * @shost: Scsi_Host pointer. |
| 834 | * |
| 835 | * Description: |
| 836 | * Bring the link down gracefully then re-init the link. The firmware will |
| 837 | * re-init the fiber channel interface as required. Does not issue a LIP. |
| 838 | * |
| 839 | * Returns: |
| 840 | * -EPERM port offline or management commands are being blocked |
| 841 | * -ENOMEM cannot allocate memory for the mailbox command |
| 842 | * -EIO error sending the mailbox command |
| 843 | * zero for success |
| 844 | **/ |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 845 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 846 | lpfc_issue_lip(struct Scsi_Host *shost) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 847 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 848 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 849 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 850 | LPFC_MBOXQ_t *pmboxq; |
| 851 | int mbxstatus = MBXERR_ERROR; |
| 852 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 853 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 854 | (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 855 | return -EPERM; |
| 856 | |
| 857 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); |
| 858 | |
| 859 | if (!pmboxq) |
| 860 | return -ENOMEM; |
| 861 | |
| 862 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 863 | pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; |
| 864 | pmboxq->u.mb.mbxOwner = OWN_HOST; |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 865 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 866 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 867 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 868 | if ((mbxstatus == MBX_SUCCESS) && |
| 869 | (pmboxq->u.mb.mbxStatus == 0 || |
| 870 | pmboxq->u.mb.mbxStatus == MBXERR_LINK_DOWN)) { |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 871 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 872 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, |
| 873 | phba->cfg_link_speed); |
| 874 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, |
| 875 | phba->fc_ratov * 2); |
James Smart | dcf2a4e | 2010-09-29 11:18:53 -0400 | [diff] [blame] | 876 | if ((mbxstatus == MBX_SUCCESS) && |
| 877 | (pmboxq->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) |
| 878 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
| 879 | "2859 SLI authentication is required " |
| 880 | "for INIT_LINK but has not done yet\n"); |
James Smart | 4db621e | 2006-07-06 15:49:49 -0400 | [diff] [blame] | 881 | } |
| 882 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 883 | lpfc_set_loopback_flag(phba); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 884 | if (mbxstatus != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 885 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 886 | |
| 887 | if (mbxstatus == MBXERR_ERROR) |
| 888 | return -EIO; |
| 889 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 890 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 891 | } |
| 892 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 893 | int |
| 894 | lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock) |
| 895 | { |
| 896 | int cnt = 0; |
| 897 | |
| 898 | spin_lock_irq(lock); |
| 899 | while (!list_empty(q)) { |
| 900 | spin_unlock_irq(lock); |
| 901 | msleep(20); |
| 902 | if (cnt++ > 250) { /* 5 secs */ |
| 903 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, |
| 904 | "0466 %s %s\n", |
| 905 | "Outstanding IO when ", |
| 906 | "bringing Adapter offline\n"); |
| 907 | return 0; |
| 908 | } |
| 909 | spin_lock_irq(lock); |
| 910 | } |
| 911 | spin_unlock_irq(lock); |
| 912 | return 1; |
| 913 | } |
| 914 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 915 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 916 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 917 | * @phba: lpfc_hba pointer. |
| 918 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
| 919 | * |
| 920 | * Notes: |
| 921 | * Assumes any error from lpfc_do_offline() will be negative. |
| 922 | * Can wait up to 5 seconds for the port ring buffers count |
| 923 | * 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] | 924 | * 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] | 925 | * |
| 926 | * Returns: |
| 927 | * -EIO error posting the event |
| 928 | * zero for success |
| 929 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 930 | static int |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 931 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
| 932 | { |
| 933 | struct completion online_compl; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 934 | struct lpfc_queue *qp = NULL; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 935 | struct lpfc_sli_ring *pring; |
| 936 | struct lpfc_sli *psli; |
| 937 | int status = 0; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 938 | int i; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 939 | int rc; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 940 | |
| 941 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 942 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 943 | LPFC_EVT_OFFLINE_PREP); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 944 | if (rc == 0) |
| 945 | return -ENOMEM; |
| 946 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 947 | wait_for_completion(&online_compl); |
| 948 | |
| 949 | if (status != 0) |
| 950 | return -EIO; |
| 951 | |
| 952 | psli = &phba->sli; |
| 953 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 954 | /* Wait a little for things to settle down, but not |
| 955 | * long enough for dev loss timeout to expire. |
| 956 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 957 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 958 | for (i = 0; i < psli->num_rings; i++) { |
| 959 | pring = &psli->sli3_ring[i]; |
| 960 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 961 | &phba->hbalock)) |
| 962 | goto out; |
| 963 | } |
| 964 | } else { |
| 965 | list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { |
| 966 | pring = qp->pring; |
| 967 | if (!pring) |
| 968 | continue; |
| 969 | if (!lpfc_emptyq_wait(phba, &pring->txcmplq, |
| 970 | &pring->ring_lock)) |
| 971 | goto out; |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 972 | } |
| 973 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 974 | out: |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 975 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 976 | rc = lpfc_workq_post_event(phba, &status, &online_compl, type); |
| 977 | if (rc == 0) |
| 978 | return -ENOMEM; |
| 979 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 980 | wait_for_completion(&online_compl); |
| 981 | |
| 982 | if (status != 0) |
| 983 | return -EIO; |
| 984 | |
| 985 | return 0; |
| 986 | } |
| 987 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 988 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 989 | * lpfc_selective_reset - Offline then onlines the port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 990 | * @phba: lpfc_hba pointer. |
| 991 | * |
| 992 | * Description: |
| 993 | * If the port is configured to allow a reset then the hba is brought |
| 994 | * offline then online. |
| 995 | * |
| 996 | * Notes: |
| 997 | * Assumes any error from lpfc_do_offline() will be negative. |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 998 | * Do not make this function static. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 999 | * |
| 1000 | * Returns: |
| 1001 | * lpfc_do_offline() return code if not zero |
| 1002 | * -EIO reset not configured or error posting the event |
| 1003 | * zero for success |
| 1004 | **/ |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1005 | int |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1006 | lpfc_selective_reset(struct lpfc_hba *phba) |
| 1007 | { |
| 1008 | struct completion online_compl; |
| 1009 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1010 | int rc; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1011 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1012 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1013 | return -EACCES; |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 1014 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1015 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { |
| 1016 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1017 | |
James Smart | 71157c9 | 2013-07-15 18:34:36 -0400 | [diff] [blame] | 1018 | if (status != 0) |
| 1019 | return status; |
| 1020 | } |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1021 | |
| 1022 | init_completion(&online_compl); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1023 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1024 | LPFC_EVT_ONLINE); |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1025 | if (rc == 0) |
| 1026 | return -ENOMEM; |
| 1027 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1028 | wait_for_completion(&online_compl); |
| 1029 | |
| 1030 | if (status != 0) |
| 1031 | return -EIO; |
| 1032 | |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1036 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1037 | * lpfc_issue_reset - Selectively resets an adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1038 | * @dev: class device that is converted into a Scsi_host. |
| 1039 | * @attr: device attribute, not used. |
| 1040 | * @buf: containing the string "selective". |
| 1041 | * @count: unused variable. |
| 1042 | * |
| 1043 | * Description: |
| 1044 | * If the buf contains the string "selective" then lpfc_selective_reset() |
| 1045 | * is called to perform the reset. |
| 1046 | * |
| 1047 | * Notes: |
| 1048 | * Assumes any error from lpfc_selective_reset() will be negative. |
| 1049 | * 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] | 1050 | * is returned which indicates success |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1051 | * |
| 1052 | * Returns: |
| 1053 | * -EINVAL if the buffer does not contain the string "selective" |
| 1054 | * length of buf if lpfc-selective_reset() if the call succeeds |
| 1055 | * return value of lpfc_selective_reset() if the call fails |
| 1056 | **/ |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1057 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1058 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
| 1059 | const char *buf, size_t count) |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1060 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1061 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1062 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1063 | struct lpfc_hba *phba = vport->phba; |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1064 | int status = -EINVAL; |
| 1065 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1066 | if (!phba->cfg_enable_hba_reset) |
| 1067 | return -EACCES; |
| 1068 | |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1069 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
James Smart | 7f86059 | 2011-03-11 16:05:52 -0500 | [diff] [blame] | 1070 | status = phba->lpfc_selective_reset(phba); |
James Smart | 40496f0 | 2006-07-06 15:50:22 -0400 | [diff] [blame] | 1071 | |
| 1072 | if (status == 0) |
| 1073 | return strlen(buf); |
| 1074 | else |
| 1075 | return status; |
| 1076 | } |
| 1077 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1078 | /** |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1079 | * lpfc_sli4_pdev_status_reg_wait - Wait for pdev status register for readyness |
| 1080 | * @phba: lpfc_hba pointer. |
| 1081 | * |
| 1082 | * Description: |
| 1083 | * SLI4 interface type-2 device to wait on the sliport status register for |
| 1084 | * the readyness after performing a firmware reset. |
| 1085 | * |
| 1086 | * Returns: |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1087 | * 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] | 1088 | * reset, -EIO when port timeout from recovering from the reset. |
| 1089 | * |
| 1090 | * Note: |
| 1091 | * As the caller will interpret the return code by value, be careful in making |
| 1092 | * change or addition to return codes. |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1093 | **/ |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 1094 | int |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1095 | lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) |
| 1096 | { |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1097 | struct lpfc_register portstat_reg = {0}; |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1098 | int i; |
| 1099 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1100 | msleep(100); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1101 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1102 | &portstat_reg.word0); |
| 1103 | |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1104 | /* verify if privileged for the request operation */ |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1105 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) && |
| 1106 | !bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1107 | return -EPERM; |
| 1108 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1109 | /* wait for the SLI port firmware ready after firmware reset */ |
| 1110 | for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { |
| 1111 | msleep(10); |
| 1112 | lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, |
| 1113 | &portstat_reg.word0); |
| 1114 | if (!bf_get(lpfc_sliport_status_err, &portstat_reg)) |
| 1115 | continue; |
| 1116 | if (!bf_get(lpfc_sliport_status_rn, &portstat_reg)) |
| 1117 | continue; |
| 1118 | if (!bf_get(lpfc_sliport_status_rdy, &portstat_reg)) |
| 1119 | continue; |
| 1120 | break; |
| 1121 | } |
| 1122 | |
| 1123 | if (i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT) |
| 1124 | return 0; |
| 1125 | else |
| 1126 | return -EIO; |
| 1127 | } |
| 1128 | |
| 1129 | /** |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1130 | * 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] | 1131 | * @phba: lpfc_hba pointer. |
| 1132 | * |
| 1133 | * Description: |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1134 | * Request SLI4 interface type-2 device to perform a physical register set |
| 1135 | * access. |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1136 | * |
| 1137 | * Returns: |
| 1138 | * zero for success |
| 1139 | **/ |
| 1140 | static ssize_t |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1141 | lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1142 | { |
| 1143 | struct completion online_compl; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1144 | struct pci_dev *pdev = phba->pcidev; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1145 | uint32_t before_fc_flag; |
| 1146 | uint32_t sriov_nr_virtfn; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1147 | uint32_t reg_val; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1148 | int status = 0, rc = 0; |
| 1149 | int job_posted = 1, sriov_err; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1150 | |
| 1151 | if (!phba->cfg_enable_hba_reset) |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1152 | return -EACCES; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1153 | |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1154 | if ((phba->sli_rev < LPFC_SLI_REV4) || |
| 1155 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 1156 | LPFC_SLI_INTF_IF_TYPE_2)) |
| 1157 | return -EPERM; |
| 1158 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1159 | /* Keep state if we need to restore back */ |
| 1160 | before_fc_flag = phba->pport->fc_flag; |
| 1161 | sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; |
| 1162 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1163 | /* Disable SR-IOV virtual functions if enabled */ |
| 1164 | if (phba->cfg_sriov_nr_virtfn) { |
| 1165 | pci_disable_sriov(pdev); |
| 1166 | phba->cfg_sriov_nr_virtfn = 0; |
| 1167 | } |
James Smart | 229adb0 | 2013-04-17 20:16:51 -0400 | [diff] [blame] | 1168 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1169 | if (opcode == LPFC_FW_DUMP) |
| 1170 | phba->hba_flag |= HBA_FW_DUMP_OP; |
| 1171 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1172 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 1173 | |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1174 | if (status != 0) { |
| 1175 | phba->hba_flag &= ~HBA_FW_DUMP_OP; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1176 | return status; |
James Smart | 0293635 | 2014-04-04 13:52:12 -0400 | [diff] [blame] | 1177 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1178 | |
| 1179 | /* wait for the device to be quiesced before firmware reset */ |
| 1180 | msleep(100); |
| 1181 | |
| 1182 | reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + |
| 1183 | LPFC_CTL_PDEV_CTL_OFFSET); |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1184 | |
| 1185 | if (opcode == LPFC_FW_DUMP) |
| 1186 | reg_val |= LPFC_FW_DUMP_REQUEST; |
| 1187 | else if (opcode == LPFC_FW_RESET) |
| 1188 | reg_val |= LPFC_CTL_PDEV_CTL_FRST; |
| 1189 | else if (opcode == LPFC_DV_RESET) |
| 1190 | reg_val |= LPFC_CTL_PDEV_CTL_DRST; |
| 1191 | |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1192 | writel(reg_val, phba->sli4_hba.conf_regs_memmap_p + |
| 1193 | LPFC_CTL_PDEV_CTL_OFFSET); |
| 1194 | /* flush */ |
| 1195 | readl(phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); |
| 1196 | |
| 1197 | /* delay driver action following IF_TYPE_2 reset */ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1198 | rc = lpfc_sli4_pdev_status_reg_wait(phba); |
| 1199 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1200 | if (rc == -EPERM) { |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1201 | /* no privilege for reset */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1202 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
Masanari Iida | 0b1587b | 2013-07-17 04:37:44 +0900 | [diff] [blame] | 1203 | "3150 No privilege to perform the requested " |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1204 | "access: x%x\n", reg_val); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1205 | } else if (rc == -EIO) { |
| 1206 | /* reset failed, there is nothing more we can do */ |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1207 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
| 1208 | "3153 Fail to perform the requested " |
| 1209 | "access: x%x\n", reg_val); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1210 | return rc; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | /* keep the original port state */ |
| 1214 | if (before_fc_flag & FC_OFFLINE_MODE) |
| 1215 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1216 | |
| 1217 | init_completion(&online_compl); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1218 | job_posted = lpfc_workq_post_event(phba, &status, &online_compl, |
| 1219 | LPFC_EVT_ONLINE); |
| 1220 | if (!job_posted) |
| 1221 | goto out; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1222 | |
| 1223 | wait_for_completion(&online_compl); |
| 1224 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1225 | out: |
| 1226 | /* in any case, restore the virtual functions enabled as before */ |
| 1227 | if (sriov_nr_virtfn) { |
| 1228 | sriov_err = |
| 1229 | lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); |
| 1230 | if (!sriov_err) |
| 1231 | phba->cfg_sriov_nr_virtfn = sriov_nr_virtfn; |
| 1232 | } |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1233 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1234 | /* return proper error code */ |
| 1235 | if (!rc) { |
| 1236 | if (!job_posted) |
| 1237 | rc = -ENOMEM; |
| 1238 | else if (status) |
| 1239 | rc = -EIO; |
| 1240 | } |
| 1241 | return rc; |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1245 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1246 | * @dev: class device that is converted into a Scsi_host. |
| 1247 | * @attr: device attribute, not used. |
| 1248 | * @buf: on return contains the ascii number of nport events. |
| 1249 | * |
| 1250 | * Returns: size of formatted string. |
| 1251 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1252 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1253 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
| 1254 | char *buf) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1255 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1256 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1257 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1258 | struct lpfc_hba *phba = vport->phba; |
| 1259 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1260 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
| 1261 | } |
| 1262 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1263 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1264 | * lpfc_board_mode_show - Return the state of the board |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1265 | * @dev: class device that is converted into a Scsi_host. |
| 1266 | * @attr: device attribute, not used. |
| 1267 | * @buf: on return contains the state of the adapter. |
| 1268 | * |
| 1269 | * Returns: size of formatted string. |
| 1270 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1271 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1272 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
| 1273 | char *buf) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1274 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1275 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1276 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1277 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1278 | char * state; |
| 1279 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1280 | if (phba->link_state == LPFC_HBA_ERROR) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1281 | state = "error"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1282 | else if (phba->link_state == LPFC_WARM_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1283 | state = "warm start"; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1284 | else if (phba->link_state == LPFC_INIT_START) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1285 | state = "offline"; |
| 1286 | else |
| 1287 | state = "online"; |
| 1288 | |
| 1289 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
| 1290 | } |
| 1291 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1292 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1293 | * 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] | 1294 | * @dev: class device that is converted into a Scsi_host. |
| 1295 | * @attr: device attribute, not used. |
| 1296 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
| 1297 | * @count: unused variable. |
| 1298 | * |
| 1299 | * Returns: |
| 1300 | * -EACCES if enable hba reset not enabled |
| 1301 | * -EINVAL if the buffer does not contain a valid string (see above) |
| 1302 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails |
| 1303 | * buf length greater than zero indicates success |
| 1304 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1305 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1306 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
| 1307 | const char *buf, size_t count) |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1308 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1309 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1310 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1311 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1312 | struct completion online_compl; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1313 | char *board_mode_str = NULL; |
| 1314 | int status = 0; |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1315 | int rc; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1316 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1317 | if (!phba->cfg_enable_hba_reset) { |
| 1318 | status = -EACCES; |
| 1319 | goto board_mode_out; |
| 1320 | } |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1321 | |
| 1322 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1323 | "3050 lpfc_board_mode set to %s\n", buf); |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1324 | |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1325 | init_completion(&online_compl); |
| 1326 | |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1327 | if(strncmp(buf, "online", sizeof("online") - 1) == 0) { |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 1328 | rc = lpfc_workq_post_event(phba, &status, &online_compl, |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1329 | LPFC_EVT_ONLINE); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1330 | if (rc == 0) { |
| 1331 | status = -ENOMEM; |
| 1332 | goto board_mode_out; |
| 1333 | } |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1334 | wait_for_completion(&online_compl); |
| 1335 | } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) |
| 1336 | status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1337 | else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1338 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1339 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1340 | else |
| 1341 | status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1342 | else if (strncmp(buf, "error", sizeof("error") - 1) == 0) |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1343 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1344 | status = -EINVAL; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1345 | else |
| 1346 | status = lpfc_do_offline(phba, LPFC_EVT_KILL); |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 1347 | else if (strncmp(buf, "dump", sizeof("dump") - 1) == 0) |
James Smart | 52d5244 | 2011-05-24 11:42:45 -0400 | [diff] [blame] | 1348 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_DUMP); |
| 1349 | else if (strncmp(buf, "fw_reset", sizeof("fw_reset") - 1) == 0) |
| 1350 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_FW_RESET); |
| 1351 | else if (strncmp(buf, "dv_reset", sizeof("dv_reset") - 1) == 0) |
| 1352 | status = lpfc_sli4_pdev_reg_request(phba, LPFC_DV_RESET); |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1353 | else |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1354 | status = -EINVAL; |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1355 | |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1356 | board_mode_out: |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1357 | if (!status) |
| 1358 | return strlen(buf); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1359 | else { |
| 1360 | board_mode_str = strchr(buf, '\n'); |
| 1361 | if (board_mode_str) |
| 1362 | *board_mode_str = '\0'; |
| 1363 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1364 | "3097 Failed \"%s\", status(%d), " |
| 1365 | "fc_flag(x%x)\n", |
| 1366 | buf, status, phba->pport->fc_flag); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 1367 | return status; |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 1368 | } |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1369 | } |
| 1370 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1371 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1372 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1373 | * @phba: pointer to the adapter structure. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1374 | * @mxri: max xri count. |
| 1375 | * @axri: available xri count. |
| 1376 | * @mrpi: max rpi count. |
| 1377 | * @arpi: available rpi count. |
| 1378 | * @mvpi: max vpi count. |
| 1379 | * @avpi: available vpi count. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1380 | * |
| 1381 | * Description: |
| 1382 | * If an integer pointer for an count is not null then the value for the |
| 1383 | * count is returned. |
| 1384 | * |
| 1385 | * Returns: |
| 1386 | * zero on error |
| 1387 | * one for success |
| 1388 | **/ |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1389 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1390 | lpfc_get_hba_info(struct lpfc_hba *phba, |
| 1391 | uint32_t *mxri, uint32_t *axri, |
| 1392 | uint32_t *mrpi, uint32_t *arpi, |
| 1393 | uint32_t *mvpi, uint32_t *avpi) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1394 | { |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1395 | struct lpfc_mbx_read_config *rd_config; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1396 | LPFC_MBOXQ_t *pmboxq; |
| 1397 | MAILBOX_t *pmb; |
| 1398 | int rc = 0; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1399 | uint32_t max_vpi; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1400 | |
| 1401 | /* |
| 1402 | * prevent udev from issuing mailbox commands until the port is |
| 1403 | * configured. |
| 1404 | */ |
| 1405 | if (phba->link_state < LPFC_LINK_DOWN || |
| 1406 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1407 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1408 | return 0; |
| 1409 | |
| 1410 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
| 1411 | return 0; |
| 1412 | |
| 1413 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 1414 | if (!pmboxq) |
| 1415 | return 0; |
| 1416 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 1417 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 1418 | pmb = &pmboxq->u.mb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1419 | pmb->mbxCommand = MBX_READ_CONFIG; |
| 1420 | pmb->mbxOwner = OWN_HOST; |
| 1421 | pmboxq->context1 = NULL; |
| 1422 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 1423 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1424 | rc = MBX_NOT_FINISHED; |
| 1425 | else |
| 1426 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 1427 | |
| 1428 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1429 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1430 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1431 | return 0; |
| 1432 | } |
| 1433 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1434 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1435 | rd_config = &pmboxq->u.mqe.un.rd_config; |
| 1436 | if (mrpi) |
| 1437 | *mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config); |
| 1438 | if (arpi) |
| 1439 | *arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - |
| 1440 | phba->sli4_hba.max_cfg_param.rpi_used; |
| 1441 | if (mxri) |
| 1442 | *mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); |
| 1443 | if (axri) |
| 1444 | *axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - |
| 1445 | phba->sli4_hba.max_cfg_param.xri_used; |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1446 | |
| 1447 | /* Account for differences with SLI-3. Get vpi count from |
| 1448 | * mailbox data and subtract one for max vpi value. |
| 1449 | */ |
| 1450 | max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? |
| 1451 | (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; |
| 1452 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1453 | if (mvpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1454 | *mvpi = max_vpi; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1455 | if (avpi) |
James Smart | 1567231 | 2010-04-06 14:49:03 -0400 | [diff] [blame] | 1456 | *avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 1457 | } else { |
| 1458 | if (mrpi) |
| 1459 | *mrpi = pmb->un.varRdConfig.max_rpi; |
| 1460 | if (arpi) |
| 1461 | *arpi = pmb->un.varRdConfig.avail_rpi; |
| 1462 | if (mxri) |
| 1463 | *mxri = pmb->un.varRdConfig.max_xri; |
| 1464 | if (axri) |
| 1465 | *axri = pmb->un.varRdConfig.avail_xri; |
| 1466 | if (mvpi) |
| 1467 | *mvpi = pmb->un.varRdConfig.max_vpi; |
| 1468 | if (avpi) |
| 1469 | *avpi = pmb->un.varRdConfig.avail_vpi; |
| 1470 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1471 | |
| 1472 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 1473 | return 1; |
| 1474 | } |
| 1475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1476 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1477 | * lpfc_max_rpi_show - Return maximum rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1478 | * @dev: class device that is converted into a Scsi_host. |
| 1479 | * @attr: device attribute, not used. |
| 1480 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
| 1481 | * |
| 1482 | * Description: |
| 1483 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1484 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1485 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1486 | * must check for "Unknown" in the buffer to detect a failure. |
| 1487 | * |
| 1488 | * Returns: size of formatted string. |
| 1489 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1490 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1491 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1492 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1493 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1494 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1495 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1496 | struct lpfc_hba *phba = vport->phba; |
| 1497 | uint32_t cnt; |
| 1498 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1499 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1500 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1501 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1502 | } |
| 1503 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1504 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1505 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1506 | * @dev: class device that is converted into a Scsi_host. |
| 1507 | * @attr: device attribute, not used. |
| 1508 | * @buf: containing the used rpi count in decimal or "Unknown". |
| 1509 | * |
| 1510 | * Description: |
| 1511 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. |
| 1512 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1513 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1514 | * must check for "Unknown" in the buffer to detect a failure. |
| 1515 | * |
| 1516 | * Returns: size of formatted string. |
| 1517 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1518 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1519 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
| 1520 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1521 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1522 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1523 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1524 | struct lpfc_hba *phba = vport->phba; |
| 1525 | uint32_t cnt, acnt; |
| 1526 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1527 | if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1528 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1529 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1530 | } |
| 1531 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1532 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1533 | * lpfc_max_xri_show - Return maximum xri |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1534 | * @dev: class device that is converted into a Scsi_host. |
| 1535 | * @attr: device attribute, not used. |
| 1536 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
| 1537 | * |
| 1538 | * Description: |
| 1539 | * Calls lpfc_get_hba_info() asking for just the mrpi count. |
| 1540 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1541 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1542 | * must check for "Unknown" in the buffer to detect a failure. |
| 1543 | * |
| 1544 | * Returns: size of formatted string. |
| 1545 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1546 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1547 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
| 1548 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1549 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1550 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1551 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1552 | struct lpfc_hba *phba = vport->phba; |
| 1553 | uint32_t cnt; |
| 1554 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1555 | if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1556 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1557 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1558 | } |
| 1559 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1560 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1561 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1562 | * @dev: class device that is converted into a Scsi_host. |
| 1563 | * @attr: device attribute, not used. |
| 1564 | * @buf: on return contains the used xri count in decimal or "Unknown". |
| 1565 | * |
| 1566 | * Description: |
| 1567 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. |
| 1568 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1569 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1570 | * must check for "Unknown" in the buffer to detect a failure. |
| 1571 | * |
| 1572 | * Returns: size of formatted string. |
| 1573 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1574 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1575 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
| 1576 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1577 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1578 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1579 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1580 | struct lpfc_hba *phba = vport->phba; |
| 1581 | uint32_t cnt, acnt; |
| 1582 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1583 | if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) |
| 1584 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1585 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1586 | } |
| 1587 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1588 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1589 | * lpfc_max_vpi_show - Return maximum vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1590 | * @dev: class device that is converted into a Scsi_host. |
| 1591 | * @attr: device attribute, not used. |
| 1592 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
| 1593 | * |
| 1594 | * Description: |
| 1595 | * Calls lpfc_get_hba_info() asking for just the mvpi count. |
| 1596 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1597 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1598 | * must check for "Unknown" in the buffer to detect a failure. |
| 1599 | * |
| 1600 | * Returns: size of formatted string. |
| 1601 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1602 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1603 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1604 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1605 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1606 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1607 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1608 | struct lpfc_hba *phba = vport->phba; |
| 1609 | uint32_t cnt; |
| 1610 | |
| 1611 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) |
| 1612 | return snprintf(buf, PAGE_SIZE, "%d\n", cnt); |
| 1613 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1614 | } |
| 1615 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1616 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1617 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1618 | * @dev: class device that is converted into a Scsi_host. |
| 1619 | * @attr: device attribute, not used. |
| 1620 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
| 1621 | * |
| 1622 | * Description: |
| 1623 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. |
| 1624 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set |
| 1625 | * to "Unknown" and the buffer length is returned, therefore the caller |
| 1626 | * must check for "Unknown" in the buffer to detect a failure. |
| 1627 | * |
| 1628 | * Returns: size of formatted string. |
| 1629 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1630 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1631 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
| 1632 | char *buf) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1633 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1634 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1635 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1636 | struct lpfc_hba *phba = vport->phba; |
| 1637 | uint32_t cnt, acnt; |
| 1638 | |
| 1639 | if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1640 | return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); |
| 1641 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
| 1642 | } |
| 1643 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1644 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1645 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1646 | * @dev: class device that is converted into a Scsi_host. |
| 1647 | * @attr: device attribute, not used. |
| 1648 | * @buf: text that must be interpreted to determine if npiv is supported. |
| 1649 | * |
| 1650 | * Description: |
| 1651 | * Buffer will contain text indicating npiv is not suppoerted on the port, |
| 1652 | * the port is an NPIV physical port, or it is an npiv virtual port with |
| 1653 | * the id of the vport. |
| 1654 | * |
| 1655 | * Returns: size of formatted string. |
| 1656 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1657 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1658 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
| 1659 | char *buf) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1660 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1661 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1662 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1663 | struct lpfc_hba *phba = vport->phba; |
| 1664 | |
| 1665 | if (!(phba->max_vpi)) |
| 1666 | return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n"); |
| 1667 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1668 | return snprintf(buf, PAGE_SIZE, "NPIV Physical\n"); |
| 1669 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
| 1670 | } |
| 1671 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1672 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1673 | * lpfc_poll_show - Return text about poll support for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1674 | * @dev: class device that is converted into a Scsi_host. |
| 1675 | * @attr: device attribute, not used. |
| 1676 | * @buf: on return contains the cfg_poll in hex. |
| 1677 | * |
| 1678 | * Notes: |
| 1679 | * cfg_poll should be a lpfc_polling_flags type. |
| 1680 | * |
| 1681 | * Returns: size of formatted string. |
| 1682 | **/ |
Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 1683 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1684 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
| 1685 | char *buf) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1686 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1687 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1688 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1689 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1690 | |
| 1691 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
| 1692 | } |
| 1693 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1694 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1695 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1696 | * @dev: class device that is converted into a Scsi_host. |
| 1697 | * @attr: device attribute, not used. |
| 1698 | * @buf: one or more lpfc_polling_flags values. |
| 1699 | * @count: not used. |
| 1700 | * |
| 1701 | * Notes: |
| 1702 | * buf contents converted to integer and checked for a valid value. |
| 1703 | * |
| 1704 | * Returns: |
| 1705 | * -EINVAL if the buffer connot be converted or is out of range |
| 1706 | * length of the buf on success |
| 1707 | **/ |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1708 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1709 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
| 1710 | const char *buf, size_t count) |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1711 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1712 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1713 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1714 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1715 | uint32_t creg_val; |
| 1716 | uint32_t old_val; |
| 1717 | int val=0; |
| 1718 | |
| 1719 | if (!isdigit(buf[0])) |
| 1720 | return -EINVAL; |
| 1721 | |
| 1722 | if (sscanf(buf, "%i", &val) != 1) |
| 1723 | return -EINVAL; |
| 1724 | |
| 1725 | if ((val & 0x3) != val) |
| 1726 | return -EINVAL; |
| 1727 | |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 1728 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1729 | val = 0; |
| 1730 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1731 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1732 | "3051 lpfc_poll changed from %d to %d\n", |
| 1733 | phba->cfg_poll, val); |
| 1734 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1735 | spin_lock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1736 | |
| 1737 | old_val = phba->cfg_poll; |
| 1738 | |
| 1739 | if (val & ENABLE_FCP_RING_POLLING) { |
| 1740 | if ((val & DISABLE_FCP_RING_INT) && |
| 1741 | !(old_val & DISABLE_FCP_RING_INT)) { |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1742 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1743 | spin_unlock_irq(&phba->hbalock); |
| 1744 | return -EINVAL; |
| 1745 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1746 | creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); |
| 1747 | writel(creg_val, phba->HCregaddr); |
| 1748 | readl(phba->HCregaddr); /* flush */ |
| 1749 | |
| 1750 | lpfc_poll_start_timer(phba); |
| 1751 | } |
| 1752 | } else if (val != 0x0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1753 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1754 | return -EINVAL; |
| 1755 | } |
| 1756 | |
| 1757 | if (!(val & DISABLE_FCP_RING_INT) && |
| 1758 | (old_val & DISABLE_FCP_RING_INT)) |
| 1759 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1760 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1761 | del_timer(&phba->fcp_poll_timer); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1762 | spin_lock_irq(&phba->hbalock); |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 1763 | if (lpfc_readl(phba->HCregaddr, &creg_val)) { |
| 1764 | spin_unlock_irq(&phba->hbalock); |
| 1765 | return -EINVAL; |
| 1766 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1767 | creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); |
| 1768 | writel(creg_val, phba->HCregaddr); |
| 1769 | readl(phba->HCregaddr); /* flush */ |
| 1770 | } |
| 1771 | |
| 1772 | phba->cfg_poll = val; |
| 1773 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1774 | spin_unlock_irq(&phba->hbalock); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1775 | |
| 1776 | return strlen(buf); |
| 1777 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1778 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1779 | /** |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 1780 | * lpfc_fips_level_show - Return the current FIPS level for the HBA |
| 1781 | * @dev: class unused variable. |
| 1782 | * @attr: device attribute, not used. |
| 1783 | * @buf: on return contains the module description text. |
| 1784 | * |
| 1785 | * Returns: size of formatted string. |
| 1786 | **/ |
| 1787 | static ssize_t |
| 1788 | lpfc_fips_level_show(struct device *dev, struct device_attribute *attr, |
| 1789 | char *buf) |
| 1790 | { |
| 1791 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1792 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1793 | struct lpfc_hba *phba = vport->phba; |
| 1794 | |
| 1795 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level); |
| 1796 | } |
| 1797 | |
| 1798 | /** |
| 1799 | * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA |
| 1800 | * @dev: class unused variable. |
| 1801 | * @attr: device attribute, not used. |
| 1802 | * @buf: on return contains the module description text. |
| 1803 | * |
| 1804 | * Returns: size of formatted string. |
| 1805 | **/ |
| 1806 | static ssize_t |
| 1807 | lpfc_fips_rev_show(struct device *dev, struct device_attribute *attr, |
| 1808 | char *buf) |
| 1809 | { |
| 1810 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1811 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1812 | struct lpfc_hba *phba = vport->phba; |
| 1813 | |
| 1814 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev); |
| 1815 | } |
| 1816 | |
| 1817 | /** |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 1818 | * lpfc_dss_show - Return the current state of dss and the configured state |
| 1819 | * @dev: class converted to a Scsi_host structure. |
| 1820 | * @attr: device attribute, not used. |
| 1821 | * @buf: on return contains the formatted text. |
| 1822 | * |
| 1823 | * Returns: size of formatted string. |
| 1824 | **/ |
| 1825 | static ssize_t |
| 1826 | lpfc_dss_show(struct device *dev, struct device_attribute *attr, |
| 1827 | char *buf) |
| 1828 | { |
| 1829 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1830 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1831 | struct lpfc_hba *phba = vport->phba; |
| 1832 | |
| 1833 | return snprintf(buf, PAGE_SIZE, "%s - %sOperational\n", |
| 1834 | (phba->cfg_enable_dss) ? "Enabled" : "Disabled", |
| 1835 | (phba->sli3_options & LPFC_SLI3_DSS_ENABLED) ? |
| 1836 | "" : "Not "); |
| 1837 | } |
| 1838 | |
| 1839 | /** |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1840 | * lpfc_sriov_hw_max_virtfn_show - Return maximum number of virtual functions |
| 1841 | * @dev: class converted to a Scsi_host structure. |
| 1842 | * @attr: device attribute, not used. |
| 1843 | * @buf: on return contains the formatted support level. |
| 1844 | * |
| 1845 | * Description: |
| 1846 | * Returns the maximum number of virtual functions a physical function can |
| 1847 | * support, 0 will be returned if called on virtual function. |
| 1848 | * |
| 1849 | * Returns: size of formatted string. |
| 1850 | **/ |
| 1851 | static ssize_t |
| 1852 | lpfc_sriov_hw_max_virtfn_show(struct device *dev, |
| 1853 | struct device_attribute *attr, |
| 1854 | char *buf) |
| 1855 | { |
| 1856 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1857 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1858 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1859 | uint16_t max_nr_virtfn; |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1860 | |
James Smart | 0a96e97 | 2011-07-22 18:37:28 -0400 | [diff] [blame] | 1861 | max_nr_virtfn = lpfc_sli_sriov_nr_virtfn_get(phba); |
| 1862 | return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1863 | } |
| 1864 | |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1865 | static inline bool lpfc_rangecheck(uint val, uint min, uint max) |
| 1866 | { |
| 1867 | return val >= min && val <= max; |
| 1868 | } |
| 1869 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 1870 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1871 | * lpfc_param_show - Return a cfg attribute value in decimal |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1872 | * |
| 1873 | * Description: |
| 1874 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1875 | * into a function with the name lpfc_hba_queue_depth_show. |
| 1876 | * |
| 1877 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. |
| 1878 | * @dev: class device that is converted into a Scsi_host. |
| 1879 | * @attr: device attribute, not used. |
| 1880 | * @buf: on return contains the attribute value in decimal. |
| 1881 | * |
| 1882 | * Returns: size of formatted string. |
| 1883 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1884 | #define lpfc_param_show(attr) \ |
| 1885 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1886 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1887 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1888 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1889 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1890 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1891 | struct lpfc_hba *phba = vport->phba;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1892 | return snprintf(buf, PAGE_SIZE, "%d\n",\ |
| 1893 | phba->cfg_##attr);\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1894 | } |
| 1895 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1896 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1897 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1898 | * |
| 1899 | * Description: |
| 1900 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1901 | * into a function with the name lpfc_hba_queue_depth_show |
| 1902 | * |
| 1903 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
| 1904 | * @dev: class device that is converted into a Scsi_host. |
| 1905 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1906 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1907 | * |
| 1908 | * Returns: size of formatted string. |
| 1909 | **/ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1910 | #define lpfc_param_hex_show(attr) \ |
| 1911 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1912 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 1913 | char *buf) \ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1914 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1915 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1916 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 1917 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1918 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 1919 | val = phba->cfg_##attr;\ |
| 1920 | return snprintf(buf, PAGE_SIZE, "%#x\n",\ |
| 1921 | phba->cfg_##attr);\ |
| 1922 | } |
| 1923 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1924 | /** |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1925 | * lpfc_param_init - Initializes a cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1926 | * |
| 1927 | * Description: |
| 1928 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1929 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 1930 | * takes a default argument, a minimum and maximum argument. |
| 1931 | * |
| 1932 | * lpfc_##attr##_init: Initializes an attribute. |
| 1933 | * @phba: pointer the the adapter structure. |
| 1934 | * @val: integer attribute value. |
| 1935 | * |
| 1936 | * Validates the min and max values then sets the adapter config field |
| 1937 | * accordingly, or uses the default if out of range and prints an error message. |
| 1938 | * |
| 1939 | * Returns: |
| 1940 | * zero on success |
| 1941 | * -EINVAL if default used |
| 1942 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1943 | #define lpfc_param_init(attr, default, minval, maxval) \ |
| 1944 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1945 | lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1946 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1947 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1948 | phba->cfg_##attr = val;\ |
| 1949 | return 0;\ |
| 1950 | }\ |
| 1951 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1952 | "0449 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1953 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1954 | phba->cfg_##attr = default;\ |
| 1955 | return -EINVAL;\ |
| 1956 | } |
| 1957 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1958 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1959 | * lpfc_param_set - Set a cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1960 | * |
| 1961 | * Description: |
| 1962 | * Macro that given an attr e.g. hba_queue_depth expands |
| 1963 | * into a function with the name lpfc_hba_queue_depth_set |
| 1964 | * |
| 1965 | * lpfc_##attr##_set: Sets an attribute value. |
| 1966 | * @phba: pointer the the adapter structure. |
| 1967 | * @val: integer attribute value. |
| 1968 | * |
| 1969 | * Description: |
| 1970 | * Validates the min and max values then sets the |
| 1971 | * adapter config field if in the valid range. prints error message |
| 1972 | * and does not set the parameter if invalid. |
| 1973 | * |
| 1974 | * Returns: |
| 1975 | * zero on success |
| 1976 | * -EINVAL if val is invalid |
| 1977 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1978 | #define lpfc_param_set(attr, default, minval, maxval) \ |
| 1979 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 1980 | lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1981 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 1982 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 1983 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
| 1984 | "3052 lpfc_" #attr " changed from %d to %d\n", \ |
| 1985 | phba->cfg_##attr, val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1986 | phba->cfg_##attr = val;\ |
| 1987 | return 0;\ |
| 1988 | }\ |
| 1989 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1990 | "0450 lpfc_"#attr" attribute cannot be set to %d, "\ |
| 1991 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 1992 | return -EINVAL;\ |
| 1993 | } |
| 1994 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1995 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1996 | * lpfc_param_store - Set a vport attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1997 | * |
| 1998 | * Description: |
| 1999 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2000 | * into a function with the name lpfc_hba_queue_depth_store. |
| 2001 | * |
| 2002 | * lpfc_##attr##_store: Set an sttribute value. |
| 2003 | * @dev: class device that is converted into a Scsi_host. |
| 2004 | * @attr: device attribute, not used. |
| 2005 | * @buf: contains the attribute value in ascii. |
| 2006 | * @count: not used. |
| 2007 | * |
| 2008 | * Description: |
| 2009 | * Convert the ascii text number to an integer, then |
| 2010 | * use the lpfc_##attr##_set function to set the value. |
| 2011 | * |
| 2012 | * Returns: |
| 2013 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2014 | * length of buffer upon success. |
| 2015 | **/ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2016 | #define lpfc_param_store(attr) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2017 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2018 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2019 | const char *buf, size_t count) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2020 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2021 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2022 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
| 2023 | struct lpfc_hba *phba = vport->phba;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2024 | uint val = 0;\ |
James.Smart@Emulex.Com | 93a20f7 | 2005-10-28 20:29:32 -0400 | [diff] [blame] | 2025 | if (!isdigit(buf[0]))\ |
| 2026 | return -EINVAL;\ |
| 2027 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2028 | return -EINVAL;\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2029 | if (lpfc_##attr##_set(phba, val) == 0) \ |
James.Smart@Emulex.Com | 755c0d0 | 2005-10-28 20:29:06 -0400 | [diff] [blame] | 2030 | return strlen(buf);\ |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 2031 | else \ |
| 2032 | return -EINVAL;\ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2033 | } |
| 2034 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2035 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2036 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2037 | * |
| 2038 | * Description: |
| 2039 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2040 | * into a function with the name lpfc_hba_queue_depth_show |
| 2041 | * |
| 2042 | * lpfc_##attr##_show: prints the attribute value in decimal. |
| 2043 | * @dev: class device that is converted into a Scsi_host. |
| 2044 | * @attr: device attribute, not used. |
| 2045 | * @buf: on return contains the attribute value in decimal. |
| 2046 | * |
| 2047 | * Returns: length of formatted string. |
| 2048 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2049 | #define lpfc_vport_param_show(attr) \ |
| 2050 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2051 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2052 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2053 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2054 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2055 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2056 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
| 2057 | } |
| 2058 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2059 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2060 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2061 | * |
| 2062 | * Description: |
| 2063 | * Macro that given an attr e.g. |
| 2064 | * hba_queue_depth expands into a function with the name |
| 2065 | * lpfc_hba_queue_depth_show |
| 2066 | * |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2067 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2068 | * @dev: class device that is converted into a Scsi_host. |
| 2069 | * @attr: device attribute, not used. |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2070 | * @buf: on return contains the attribute value in hexadecimal. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2071 | * |
| 2072 | * Returns: length of formatted string. |
| 2073 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2074 | #define lpfc_vport_param_hex_show(attr) \ |
| 2075 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2076 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
| 2077 | char *buf) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2078 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2079 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2080 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2081 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
| 2082 | } |
| 2083 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2084 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2085 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2086 | * |
| 2087 | * Description: |
| 2088 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2089 | * into a function with the name lpfc_hba_queue_depth_init. The macro also |
| 2090 | * takes a default argument, a minimum and maximum argument. |
| 2091 | * |
| 2092 | * lpfc_##attr##_init: validates the min and max values then sets the |
| 2093 | * adapter config field accordingly, or uses the default if out of range |
| 2094 | * and prints an error message. |
| 2095 | * @phba: pointer the the adapter structure. |
| 2096 | * @val: integer attribute value. |
| 2097 | * |
| 2098 | * Returns: |
| 2099 | * zero on success |
| 2100 | * -EINVAL if default used |
| 2101 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2102 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
| 2103 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2104 | lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2105 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2106 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2107 | vport->cfg_##attr = val;\ |
| 2108 | return 0;\ |
| 2109 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2110 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2111 | "0423 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2112 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2113 | vport->cfg_##attr = default;\ |
| 2114 | return -EINVAL;\ |
| 2115 | } |
| 2116 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2117 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2118 | * lpfc_vport_param_set - Set a vport cfg attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2119 | * |
| 2120 | * Description: |
| 2121 | * Macro that given an attr e.g. hba_queue_depth expands |
| 2122 | * into a function with the name lpfc_hba_queue_depth_set |
| 2123 | * |
| 2124 | * lpfc_##attr##_set: validates the min and max values then sets the |
| 2125 | * adapter config field if in the valid range. prints error message |
| 2126 | * and does not set the parameter if invalid. |
| 2127 | * @phba: pointer the the adapter structure. |
| 2128 | * @val: integer attribute value. |
| 2129 | * |
| 2130 | * Returns: |
| 2131 | * zero on success |
| 2132 | * -EINVAL if val is invalid |
| 2133 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2134 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
| 2135 | static int \ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2136 | lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2137 | { \ |
Arnd Bergmann | de8c36b | 2016-06-15 22:42:17 +0200 | [diff] [blame] | 2138 | if (lpfc_rangecheck(val, minval, maxval)) {\ |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 2139 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | 14660f4 | 2013-09-06 12:20:20 -0400 | [diff] [blame] | 2140 | "3053 lpfc_" #attr \ |
| 2141 | " changed from %d (x%x) to %d (x%x)\n", \ |
| 2142 | vport->cfg_##attr, vport->cfg_##attr, \ |
| 2143 | val, val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2144 | vport->cfg_##attr = val;\ |
| 2145 | return 0;\ |
| 2146 | }\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2147 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2148 | "0424 lpfc_"#attr" attribute cannot be set to %d, "\ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2149 | "allowed range is ["#minval", "#maxval"]\n", val); \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2150 | return -EINVAL;\ |
| 2151 | } |
| 2152 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2153 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2154 | * lpfc_vport_param_store - Set a vport attribute |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2155 | * |
| 2156 | * Description: |
| 2157 | * Macro that given an attr e.g. hba_queue_depth |
| 2158 | * expands into a function with the name lpfc_hba_queue_depth_store |
| 2159 | * |
| 2160 | * lpfc_##attr##_store: convert the ascii text number to an integer, then |
| 2161 | * use the lpfc_##attr##_set function to set the value. |
| 2162 | * @cdev: class device that is converted into a Scsi_host. |
| 2163 | * @buf: contains the attribute value in decimal. |
| 2164 | * @count: not used. |
| 2165 | * |
| 2166 | * Returns: |
| 2167 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails |
| 2168 | * length of buffer upon success. |
| 2169 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2170 | #define lpfc_vport_param_store(attr) \ |
| 2171 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2172 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
| 2173 | const char *buf, size_t count) \ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2174 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2175 | struct Scsi_Host *shost = class_to_shost(dev);\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2176 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2177 | uint val = 0;\ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 2178 | if (!isdigit(buf[0]))\ |
| 2179 | return -EINVAL;\ |
| 2180 | if (sscanf(buf, "%i", &val) != 1)\ |
| 2181 | return -EINVAL;\ |
| 2182 | if (lpfc_##attr##_set(vport, val) == 0) \ |
| 2183 | return strlen(buf);\ |
| 2184 | else \ |
| 2185 | return -EINVAL;\ |
| 2186 | } |
| 2187 | |
| 2188 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 2189 | static DEVICE_ATTR(nvme_info, 0444, lpfc_nvme_info_show, NULL); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 2190 | static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL); |
| 2191 | static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL); |
| 2192 | static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL); |
| 2193 | 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] | 2194 | static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); |
| 2195 | static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); |
| 2196 | static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); |
| 2197 | static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); |
| 2198 | static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); |
| 2199 | static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); |
| 2200 | static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); |
| 2201 | static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 2202 | static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show, |
| 2203 | lpfc_link_state_store); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2204 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 2205 | lpfc_option_rom_version_show, NULL); |
| 2206 | static DEVICE_ATTR(num_discovered_ports, S_IRUGO, |
| 2207 | lpfc_num_discovered_ports_show, NULL); |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 2208 | static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2209 | static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); |
| 2210 | static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 2211 | static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 2212 | static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
| 2213 | lpfc_board_mode_show, lpfc_board_mode_store); |
| 2214 | static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); |
| 2215 | static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); |
| 2216 | static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); |
| 2217 | static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); |
| 2218 | static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); |
| 2219 | static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); |
| 2220 | static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); |
| 2221 | static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); |
| 2222 | static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 2223 | static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); |
| 2224 | static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 2225 | static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 2226 | static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, |
| 2227 | lpfc_sriov_hw_max_virtfn_show, NULL); |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 2228 | static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2229 | static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, |
| 2230 | NULL); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2231 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2232 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2233 | #define WWN_SZ 8 |
| 2234 | /** |
| 2235 | * lpfc_wwn_set - Convert string to the 8 byte WWN value. |
| 2236 | * @buf: WWN string. |
| 2237 | * @cnt: Length of string. |
| 2238 | * @wwn: Array to receive converted wwn value. |
| 2239 | * |
| 2240 | * Returns: |
| 2241 | * -EINVAL if the buffer does not contain a valid wwn |
| 2242 | * 0 success |
| 2243 | **/ |
| 2244 | static size_t |
| 2245 | lpfc_wwn_set(const char *buf, size_t cnt, char wwn[]) |
| 2246 | { |
| 2247 | unsigned int i, j; |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 2248 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2249 | /* Count may include a LF at end of string */ |
| 2250 | if (buf[cnt-1] == '\n') |
| 2251 | cnt--; |
| 2252 | |
| 2253 | if ((cnt < 16) || (cnt > 18) || ((cnt == 17) && (*buf++ != 'x')) || |
| 2254 | ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) |
| 2255 | return -EINVAL; |
| 2256 | |
| 2257 | memset(wwn, 0, WWN_SZ); |
| 2258 | |
| 2259 | /* Validate and store the new name */ |
| 2260 | for (i = 0, j = 0; i < 16; i++) { |
| 2261 | if ((*buf >= 'a') && (*buf <= 'f')) |
| 2262 | j = ((j << 4) | ((*buf++ - 'a') + 10)); |
| 2263 | else if ((*buf >= 'A') && (*buf <= 'F')) |
| 2264 | j = ((j << 4) | ((*buf++ - 'A') + 10)); |
| 2265 | else if ((*buf >= '0') && (*buf <= '9')) |
| 2266 | j = ((j << 4) | (*buf++ - '0')); |
| 2267 | else |
| 2268 | return -EINVAL; |
| 2269 | if (i % 2) { |
| 2270 | wwn[i/2] = j & 0xff; |
| 2271 | j = 0; |
| 2272 | } |
| 2273 | } |
| 2274 | return 0; |
| 2275 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2276 | /** |
| 2277 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
| 2278 | * @dev: class device that is converted into a Scsi_host. |
| 2279 | * @attr: device attribute, not used. |
| 2280 | * @buf: containing the string lpfc_soft_wwn_key. |
| 2281 | * @count: must be size of lpfc_soft_wwn_key. |
| 2282 | * |
| 2283 | * Returns: |
| 2284 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key |
| 2285 | * length of buf indicates success |
| 2286 | **/ |
| 2287 | static ssize_t |
| 2288 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
| 2289 | const char *buf, size_t count) |
| 2290 | { |
| 2291 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2292 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2293 | struct lpfc_hba *phba = vport->phba; |
| 2294 | unsigned int cnt = count; |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame^] | 2295 | uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; |
| 2296 | u32 *fawwpn_key = (uint32_t *)&vport->fc_sparam.un.vendorVersion[0]; |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2297 | |
| 2298 | /* |
| 2299 | * We're doing a simple sanity check for soft_wwpn setting. |
| 2300 | * We require that the user write a specific key to enable |
| 2301 | * the soft_wwpn attribute to be settable. Once the attribute |
| 2302 | * is written, the enable key resets. If further updates are |
| 2303 | * desired, the key must be written again to re-enable the |
| 2304 | * attribute. |
| 2305 | * |
| 2306 | * The "key" is not secret - it is a hardcoded string shown |
| 2307 | * here. The intent is to protect against the random user or |
| 2308 | * application that is just writing attributes. |
| 2309 | */ |
James Smart | aeb3c81 | 2017-04-21 16:05:02 -0700 | [diff] [blame^] | 2310 | if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) { |
| 2311 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2312 | "0051 "LPFC_DRIVER_NAME" soft wwpn can not" |
| 2313 | " be enabled: fawwpn is enabled\n"); |
| 2314 | return -EINVAL; |
| 2315 | } |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2316 | |
| 2317 | /* count may include a LF at end of string */ |
| 2318 | if (buf[cnt-1] == '\n') |
| 2319 | cnt--; |
| 2320 | |
| 2321 | if ((cnt != strlen(lpfc_soft_wwn_key)) || |
| 2322 | (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0)) |
| 2323 | return -EINVAL; |
| 2324 | |
| 2325 | phba->soft_wwn_enable = 1; |
| 2326 | |
| 2327 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2328 | "lpfc%d: soft_wwpn assignment has been enabled.\n", |
| 2329 | phba->brd_no); |
| 2330 | dev_printk(KERN_WARNING, &phba->pcidev->dev, |
| 2331 | " The soft_wwpn feature is not supported by Broadcom."); |
| 2332 | |
| 2333 | return count; |
| 2334 | } |
| 2335 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
| 2336 | lpfc_soft_wwn_enable_store); |
| 2337 | |
| 2338 | /** |
| 2339 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
| 2340 | * @dev: class device that is converted into a Scsi_host. |
| 2341 | * @attr: device attribute, not used. |
| 2342 | * @buf: on return contains the wwpn in hexadecimal. |
| 2343 | * |
| 2344 | * Returns: size of formatted string. |
| 2345 | **/ |
| 2346 | static ssize_t |
| 2347 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
| 2348 | char *buf) |
| 2349 | { |
| 2350 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2351 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2352 | struct lpfc_hba *phba = vport->phba; |
| 2353 | |
| 2354 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2355 | (unsigned long long)phba->cfg_soft_wwpn); |
| 2356 | } |
| 2357 | |
| 2358 | /** |
| 2359 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
| 2360 | * @dev class device that is converted into a Scsi_host. |
| 2361 | * @attr: device attribute, not used. |
| 2362 | * @buf: contains the wwpn in hexadecimal. |
| 2363 | * @count: number of wwpn bytes in buf |
| 2364 | * |
| 2365 | * Returns: |
| 2366 | * -EACCES hba reset not enabled, adapter over temp |
| 2367 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid |
| 2368 | * -EIO error taking adapter offline or online |
| 2369 | * value of count on success |
| 2370 | **/ |
| 2371 | static ssize_t |
| 2372 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
| 2373 | const char *buf, size_t count) |
| 2374 | { |
| 2375 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2376 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 2377 | struct lpfc_hba *phba = vport->phba; |
| 2378 | struct completion online_compl; |
| 2379 | int stat1 = 0, stat2 = 0; |
| 2380 | unsigned int cnt = count; |
| 2381 | u8 wwpn[WWN_SZ]; |
| 2382 | int rc; |
| 2383 | |
| 2384 | if (!phba->cfg_enable_hba_reset) |
| 2385 | return -EACCES; |
| 2386 | spin_lock_irq(&phba->hbalock); |
| 2387 | if (phba->over_temp_state == HBA_OVER_TEMP) { |
| 2388 | spin_unlock_irq(&phba->hbalock); |
| 2389 | return -EACCES; |
| 2390 | } |
| 2391 | spin_unlock_irq(&phba->hbalock); |
| 2392 | /* count may include a LF at end of string */ |
| 2393 | if (buf[cnt-1] == '\n') |
| 2394 | cnt--; |
| 2395 | |
| 2396 | if (!phba->soft_wwn_enable) |
| 2397 | return -EINVAL; |
| 2398 | |
| 2399 | /* lock setting wwpn, wwnn down */ |
| 2400 | phba->soft_wwn_enable = 0; |
| 2401 | |
| 2402 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2403 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2404 | /* not able to set wwpn, unlock it */ |
| 2405 | phba->soft_wwn_enable = 1; |
| 2406 | return rc; |
| 2407 | } |
| 2408 | |
| 2409 | phba->cfg_soft_wwpn = wwn_to_u64(wwpn); |
| 2410 | fc_host_port_name(shost) = phba->cfg_soft_wwpn; |
| 2411 | if (phba->cfg_soft_wwnn) |
| 2412 | fc_host_node_name(shost) = phba->cfg_soft_wwnn; |
| 2413 | |
| 2414 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2415 | "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); |
| 2416 | |
| 2417 | stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); |
| 2418 | if (stat1) |
| 2419 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2420 | "0463 lpfc_soft_wwpn attribute set failed to " |
| 2421 | "reinit adapter - %d\n", stat1); |
| 2422 | init_completion(&online_compl); |
| 2423 | rc = lpfc_workq_post_event(phba, &stat2, &online_compl, |
| 2424 | LPFC_EVT_ONLINE); |
| 2425 | if (rc == 0) |
| 2426 | return -ENOMEM; |
| 2427 | |
| 2428 | wait_for_completion(&online_compl); |
| 2429 | if (stat2) |
| 2430 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2431 | "0464 lpfc_soft_wwpn attribute set failed to " |
| 2432 | "reinit adapter - %d\n", stat2); |
| 2433 | return (stat1 || stat2) ? -EIO : count; |
| 2434 | } |
| 2435 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, |
| 2436 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
| 2437 | |
| 2438 | /** |
| 2439 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
| 2440 | * @dev: class device that is converted into a Scsi_host. |
| 2441 | * @attr: device attribute, not used. |
| 2442 | * @buf: on return contains the wwnn in hexadecimal. |
| 2443 | * |
| 2444 | * Returns: size of formatted string. |
| 2445 | **/ |
| 2446 | static ssize_t |
| 2447 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
| 2448 | char *buf) |
| 2449 | { |
| 2450 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2451 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2452 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2453 | (unsigned long long)phba->cfg_soft_wwnn); |
| 2454 | } |
| 2455 | |
| 2456 | /** |
| 2457 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
| 2458 | * @cdev: class device that is converted into a Scsi_host. |
| 2459 | * @buf: contains the ww node name in hexadecimal. |
| 2460 | * @count: number of wwnn bytes in buf. |
| 2461 | * |
| 2462 | * Returns: |
| 2463 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid |
| 2464 | * value of count on success |
| 2465 | **/ |
| 2466 | static ssize_t |
| 2467 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
| 2468 | const char *buf, size_t count) |
| 2469 | { |
| 2470 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2471 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2472 | unsigned int cnt = count; |
| 2473 | u8 wwnn[WWN_SZ]; |
| 2474 | int rc; |
| 2475 | |
| 2476 | /* count may include a LF at end of string */ |
| 2477 | if (buf[cnt-1] == '\n') |
| 2478 | cnt--; |
| 2479 | |
| 2480 | if (!phba->soft_wwn_enable) |
| 2481 | return -EINVAL; |
| 2482 | |
| 2483 | rc = lpfc_wwn_set(buf, cnt, wwnn); |
James Smart | e2934ed | 2017-01-17 12:31:56 -0800 | [diff] [blame] | 2484 | if (rc) { |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 2485 | /* Allow wwnn to be set many times, as long as the enable |
| 2486 | * is set. However, once the wwpn is set, everything locks. |
| 2487 | */ |
| 2488 | return rc; |
| 2489 | } |
| 2490 | |
| 2491 | phba->cfg_soft_wwnn = wwn_to_u64(wwnn); |
| 2492 | |
| 2493 | dev_printk(KERN_NOTICE, &phba->pcidev->dev, |
| 2494 | "lpfc%d: soft_wwnn set. Value will take effect upon " |
| 2495 | "setting of the soft_wwpn\n", phba->brd_no); |
| 2496 | |
| 2497 | return count; |
| 2498 | } |
| 2499 | static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, |
| 2500 | lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); |
James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 2501 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2502 | /** |
| 2503 | * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for |
| 2504 | * Optimized Access Storage (OAS) operations. |
| 2505 | * @dev: class device that is converted into a Scsi_host. |
| 2506 | * @attr: device attribute, not used. |
| 2507 | * @buf: buffer for passing information. |
| 2508 | * |
| 2509 | * Returns: |
| 2510 | * value of count |
| 2511 | **/ |
| 2512 | static ssize_t |
| 2513 | lpfc_oas_tgt_show(struct device *dev, struct device_attribute *attr, |
| 2514 | char *buf) |
| 2515 | { |
| 2516 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2517 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2518 | |
| 2519 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2520 | wwn_to_u64(phba->cfg_oas_tgt_wwpn)); |
| 2521 | } |
| 2522 | |
| 2523 | /** |
| 2524 | * lpfc_oas_tgt_store - Store wwpn of target whose luns maybe enabled for |
| 2525 | * Optimized Access Storage (OAS) operations. |
| 2526 | * @dev: class device that is converted into a Scsi_host. |
| 2527 | * @attr: device attribute, not used. |
| 2528 | * @buf: buffer for passing information. |
| 2529 | * @count: Size of the data buffer. |
| 2530 | * |
| 2531 | * Returns: |
| 2532 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2533 | * -EPERM oas is not supported by hba |
| 2534 | * value of count on success |
| 2535 | **/ |
| 2536 | static ssize_t |
| 2537 | lpfc_oas_tgt_store(struct device *dev, struct device_attribute *attr, |
| 2538 | const char *buf, size_t count) |
| 2539 | { |
| 2540 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2541 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2542 | unsigned int cnt = count; |
| 2543 | uint8_t wwpn[WWN_SZ]; |
| 2544 | int rc; |
| 2545 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2546 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2547 | return -EPERM; |
| 2548 | |
| 2549 | /* count may include a LF at end of string */ |
| 2550 | if (buf[cnt-1] == '\n') |
| 2551 | cnt--; |
| 2552 | |
| 2553 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2554 | if (rc) |
| 2555 | return rc; |
| 2556 | |
| 2557 | memcpy(phba->cfg_oas_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2558 | memcpy(phba->sli4_hba.oas_next_tgt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2559 | if (wwn_to_u64(wwpn) == 0) |
| 2560 | phba->cfg_oas_flags |= OAS_FIND_ANY_TARGET; |
| 2561 | else |
| 2562 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_TARGET; |
| 2563 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
| 2564 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2565 | return count; |
| 2566 | } |
| 2567 | static DEVICE_ATTR(lpfc_xlane_tgt, S_IRUGO | S_IWUSR, |
| 2568 | lpfc_oas_tgt_show, lpfc_oas_tgt_store); |
| 2569 | |
| 2570 | /** |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2571 | * lpfc_oas_priority_show - Return wwpn of target whose luns maybe enabled for |
| 2572 | * Optimized Access Storage (OAS) operations. |
| 2573 | * @dev: class device that is converted into a Scsi_host. |
| 2574 | * @attr: device attribute, not used. |
| 2575 | * @buf: buffer for passing information. |
| 2576 | * |
| 2577 | * Returns: |
| 2578 | * value of count |
| 2579 | **/ |
| 2580 | static ssize_t |
| 2581 | lpfc_oas_priority_show(struct device *dev, struct device_attribute *attr, |
| 2582 | char *buf) |
| 2583 | { |
| 2584 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2585 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2586 | |
| 2587 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_priority); |
| 2588 | } |
| 2589 | |
| 2590 | /** |
| 2591 | * lpfc_oas_priority_store - Store wwpn of target whose luns maybe enabled for |
| 2592 | * Optimized Access Storage (OAS) operations. |
| 2593 | * @dev: class device that is converted into a Scsi_host. |
| 2594 | * @attr: device attribute, not used. |
| 2595 | * @buf: buffer for passing information. |
| 2596 | * @count: Size of the data buffer. |
| 2597 | * |
| 2598 | * Returns: |
| 2599 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2600 | * -EPERM oas is not supported by hba |
| 2601 | * value of count on success |
| 2602 | **/ |
| 2603 | static ssize_t |
| 2604 | lpfc_oas_priority_store(struct device *dev, struct device_attribute *attr, |
| 2605 | const char *buf, size_t count) |
| 2606 | { |
| 2607 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2608 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2609 | unsigned int cnt = count; |
| 2610 | unsigned long val; |
| 2611 | int ret; |
| 2612 | |
| 2613 | if (!phba->cfg_fof) |
| 2614 | return -EPERM; |
| 2615 | |
| 2616 | /* count may include a LF at end of string */ |
| 2617 | if (buf[cnt-1] == '\n') |
| 2618 | cnt--; |
| 2619 | |
| 2620 | ret = kstrtoul(buf, 0, &val); |
| 2621 | if (ret || (val > 0x7f)) |
| 2622 | return -EINVAL; |
| 2623 | |
| 2624 | if (val) |
| 2625 | phba->cfg_oas_priority = (uint8_t)val; |
| 2626 | else |
| 2627 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
| 2628 | return count; |
| 2629 | } |
| 2630 | static DEVICE_ATTR(lpfc_xlane_priority, S_IRUGO | S_IWUSR, |
| 2631 | lpfc_oas_priority_show, lpfc_oas_priority_store); |
| 2632 | |
| 2633 | /** |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2634 | * lpfc_oas_vpt_show - Return wwpn of vport whose targets maybe enabled |
| 2635 | * for Optimized Access Storage (OAS) operations. |
| 2636 | * @dev: class device that is converted into a Scsi_host. |
| 2637 | * @attr: device attribute, not used. |
| 2638 | * @buf: buffer for passing information. |
| 2639 | * |
| 2640 | * Returns: |
| 2641 | * value of count on success |
| 2642 | **/ |
| 2643 | static ssize_t |
| 2644 | lpfc_oas_vpt_show(struct device *dev, struct device_attribute *attr, |
| 2645 | char *buf) |
| 2646 | { |
| 2647 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2648 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2649 | |
| 2650 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
| 2651 | wwn_to_u64(phba->cfg_oas_vpt_wwpn)); |
| 2652 | } |
| 2653 | |
| 2654 | /** |
| 2655 | * lpfc_oas_vpt_store - Store wwpn of vport whose targets maybe enabled |
| 2656 | * for Optimized Access Storage (OAS) operations. |
| 2657 | * @dev: class device that is converted into a Scsi_host. |
| 2658 | * @attr: device attribute, not used. |
| 2659 | * @buf: buffer for passing information. |
| 2660 | * @count: Size of the data buffer. |
| 2661 | * |
| 2662 | * Returns: |
| 2663 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2664 | * -EPERM oas is not supported by hba |
| 2665 | * value of count on success |
| 2666 | **/ |
| 2667 | static ssize_t |
| 2668 | lpfc_oas_vpt_store(struct device *dev, struct device_attribute *attr, |
| 2669 | const char *buf, size_t count) |
| 2670 | { |
| 2671 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2672 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2673 | unsigned int cnt = count; |
| 2674 | uint8_t wwpn[WWN_SZ]; |
| 2675 | int rc; |
| 2676 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2677 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2678 | return -EPERM; |
| 2679 | |
| 2680 | /* count may include a LF at end of string */ |
| 2681 | if (buf[cnt-1] == '\n') |
| 2682 | cnt--; |
| 2683 | |
| 2684 | rc = lpfc_wwn_set(buf, cnt, wwpn); |
| 2685 | if (rc) |
| 2686 | return rc; |
| 2687 | |
| 2688 | memcpy(phba->cfg_oas_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2689 | memcpy(phba->sli4_hba.oas_next_vpt_wwpn, wwpn, (8 * sizeof(uint8_t))); |
| 2690 | if (wwn_to_u64(wwpn) == 0) |
| 2691 | phba->cfg_oas_flags |= OAS_FIND_ANY_VPORT; |
| 2692 | else |
| 2693 | phba->cfg_oas_flags &= ~OAS_FIND_ANY_VPORT; |
| 2694 | phba->cfg_oas_flags &= ~OAS_LUN_VALID; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2695 | if (phba->cfg_oas_priority == 0) |
| 2696 | phba->cfg_oas_priority = phba->cfg_XLanePriority; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2697 | phba->sli4_hba.oas_next_lun = FIND_FIRST_OAS_LUN; |
| 2698 | return count; |
| 2699 | } |
| 2700 | static DEVICE_ATTR(lpfc_xlane_vpt, S_IRUGO | S_IWUSR, |
| 2701 | lpfc_oas_vpt_show, lpfc_oas_vpt_store); |
| 2702 | |
| 2703 | /** |
| 2704 | * lpfc_oas_lun_state_show - Return the current state (enabled or disabled) |
| 2705 | * of whether luns will be enabled or disabled |
| 2706 | * for Optimized Access Storage (OAS) operations. |
| 2707 | * @dev: class device that is converted into a Scsi_host. |
| 2708 | * @attr: device attribute, not used. |
| 2709 | * @buf: buffer for passing information. |
| 2710 | * |
| 2711 | * Returns: |
| 2712 | * size of formatted string. |
| 2713 | **/ |
| 2714 | static ssize_t |
| 2715 | lpfc_oas_lun_state_show(struct device *dev, struct device_attribute *attr, |
| 2716 | char *buf) |
| 2717 | { |
| 2718 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2719 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2720 | |
| 2721 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_state); |
| 2722 | } |
| 2723 | |
| 2724 | /** |
| 2725 | * lpfc_oas_lun_state_store - Store the state (enabled or disabled) |
| 2726 | * of whether luns will be enabled or disabled |
| 2727 | * for Optimized Access Storage (OAS) operations. |
| 2728 | * @dev: class device that is converted into a Scsi_host. |
| 2729 | * @attr: device attribute, not used. |
| 2730 | * @buf: buffer for passing information. |
| 2731 | * @count: Size of the data buffer. |
| 2732 | * |
| 2733 | * Returns: |
| 2734 | * -EINVAL count is invalid, invalid wwpn byte invalid |
| 2735 | * -EPERM oas is not supported by hba |
| 2736 | * value of count on success |
| 2737 | **/ |
| 2738 | static ssize_t |
| 2739 | lpfc_oas_lun_state_store(struct device *dev, struct device_attribute *attr, |
| 2740 | const char *buf, size_t count) |
| 2741 | { |
| 2742 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2743 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2744 | int val = 0; |
| 2745 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2746 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2747 | return -EPERM; |
| 2748 | |
| 2749 | if (!isdigit(buf[0])) |
| 2750 | return -EINVAL; |
| 2751 | |
| 2752 | if (sscanf(buf, "%i", &val) != 1) |
| 2753 | return -EINVAL; |
| 2754 | |
| 2755 | if ((val != 0) && (val != 1)) |
| 2756 | return -EINVAL; |
| 2757 | |
| 2758 | phba->cfg_oas_lun_state = val; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2759 | return strlen(buf); |
| 2760 | } |
| 2761 | static DEVICE_ATTR(lpfc_xlane_lun_state, S_IRUGO | S_IWUSR, |
| 2762 | lpfc_oas_lun_state_show, lpfc_oas_lun_state_store); |
| 2763 | |
| 2764 | /** |
| 2765 | * lpfc_oas_lun_status_show - Return the status of the Optimized Access |
| 2766 | * Storage (OAS) lun returned by the |
| 2767 | * lpfc_oas_lun_show function. |
| 2768 | * @dev: class device that is converted into a Scsi_host. |
| 2769 | * @attr: device attribute, not used. |
| 2770 | * @buf: buffer for passing information. |
| 2771 | * |
| 2772 | * Returns: |
| 2773 | * size of formatted string. |
| 2774 | **/ |
| 2775 | static ssize_t |
| 2776 | lpfc_oas_lun_status_show(struct device *dev, struct device_attribute *attr, |
| 2777 | char *buf) |
| 2778 | { |
| 2779 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2780 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2781 | |
| 2782 | if (!(phba->cfg_oas_flags & OAS_LUN_VALID)) |
| 2783 | return -EFAULT; |
| 2784 | |
| 2785 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->cfg_oas_lun_status); |
| 2786 | } |
| 2787 | static DEVICE_ATTR(lpfc_xlane_lun_status, S_IRUGO, |
| 2788 | lpfc_oas_lun_status_show, NULL); |
| 2789 | |
| 2790 | |
| 2791 | /** |
| 2792 | * lpfc_oas_lun_state_set - enable or disable a lun for Optimized Access Storage |
| 2793 | * (OAS) operations. |
| 2794 | * @phba: lpfc_hba pointer. |
| 2795 | * @ndlp: pointer to fcp target node. |
| 2796 | * @lun: the fc lun for setting oas state. |
| 2797 | * @oas_state: the oas state to be set to the lun. |
| 2798 | * |
| 2799 | * Returns: |
| 2800 | * SUCCESS : 0 |
| 2801 | * -EPERM OAS is not enabled or not supported by this port. |
| 2802 | * |
| 2803 | */ |
| 2804 | static size_t |
| 2805 | 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] | 2806 | uint8_t tgt_wwpn[], uint64_t lun, |
| 2807 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2808 | { |
| 2809 | |
| 2810 | int rc = 0; |
| 2811 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2812 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2813 | return -EPERM; |
| 2814 | |
| 2815 | if (oas_state) { |
| 2816 | if (!lpfc_enable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2817 | (struct lpfc_name *)tgt_wwpn, |
| 2818 | lun, pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2819 | rc = -ENOMEM; |
| 2820 | } else { |
| 2821 | lpfc_disable_oas_lun(phba, (struct lpfc_name *)vpt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2822 | (struct lpfc_name *)tgt_wwpn, lun, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2823 | } |
| 2824 | return rc; |
| 2825 | |
| 2826 | } |
| 2827 | |
| 2828 | /** |
| 2829 | * lpfc_oas_lun_get_next - get the next lun that has been enabled for Optimized |
| 2830 | * Access Storage (OAS) operations. |
| 2831 | * @phba: lpfc_hba pointer. |
| 2832 | * @vpt_wwpn: wwpn of the vport associated with the returned lun |
| 2833 | * @tgt_wwpn: wwpn of the target associated with the returned lun |
| 2834 | * @lun_status: status of the lun returned lun |
| 2835 | * |
| 2836 | * Returns the first or next lun enabled for OAS operations for the vport/target |
| 2837 | * specified. If a lun is found, its vport wwpn, target wwpn and status is |
| 2838 | * returned. If the lun is not found, NOT_OAS_ENABLED_LUN is returned. |
| 2839 | * |
| 2840 | * Return: |
| 2841 | * lun that is OAS enabled for the vport/target |
| 2842 | * NOT_OAS_ENABLED_LUN when no oas enabled lun found. |
| 2843 | */ |
| 2844 | static uint64_t |
| 2845 | 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] | 2846 | uint8_t tgt_wwpn[], uint32_t *lun_status, |
| 2847 | uint32_t *lun_pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2848 | { |
| 2849 | uint64_t found_lun; |
| 2850 | |
| 2851 | if (unlikely(!phba) || !vpt_wwpn || !tgt_wwpn) |
| 2852 | return NOT_OAS_ENABLED_LUN; |
| 2853 | if (lpfc_find_next_oas_lun(phba, (struct lpfc_name *) |
| 2854 | phba->sli4_hba.oas_next_vpt_wwpn, |
| 2855 | (struct lpfc_name *) |
| 2856 | phba->sli4_hba.oas_next_tgt_wwpn, |
| 2857 | &phba->sli4_hba.oas_next_lun, |
| 2858 | (struct lpfc_name *)vpt_wwpn, |
| 2859 | (struct lpfc_name *)tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2860 | &found_lun, lun_status, lun_pri)) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2861 | return found_lun; |
| 2862 | else |
| 2863 | return NOT_OAS_ENABLED_LUN; |
| 2864 | } |
| 2865 | |
| 2866 | /** |
| 2867 | * lpfc_oas_lun_state_change - enable/disable a lun for OAS operations |
| 2868 | * @phba: lpfc_hba pointer. |
| 2869 | * @vpt_wwpn: vport wwpn by reference. |
| 2870 | * @tgt_wwpn: target wwpn by reference. |
| 2871 | * @lun: the fc lun for setting oas state. |
| 2872 | * @oas_state: the oas state to be set to the oas_lun. |
| 2873 | * |
| 2874 | * This routine enables (OAS_LUN_ENABLE) or disables (OAS_LUN_DISABLE) |
| 2875 | * a lun for OAS operations. |
| 2876 | * |
| 2877 | * Return: |
| 2878 | * SUCCESS: 0 |
| 2879 | * -ENOMEM: failed to enable an lun for OAS operations |
| 2880 | * -EPERM: OAS is not enabled |
| 2881 | */ |
| 2882 | static ssize_t |
| 2883 | lpfc_oas_lun_state_change(struct lpfc_hba *phba, uint8_t vpt_wwpn[], |
| 2884 | uint8_t tgt_wwpn[], uint64_t lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2885 | uint32_t oas_state, uint8_t pri) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2886 | { |
| 2887 | |
| 2888 | int rc; |
| 2889 | |
| 2890 | rc = lpfc_oas_lun_state_set(phba, vpt_wwpn, tgt_wwpn, lun, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2891 | oas_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2892 | return rc; |
| 2893 | } |
| 2894 | |
| 2895 | /** |
| 2896 | * lpfc_oas_lun_show - Return oas enabled luns from a chosen target |
| 2897 | * @dev: class device that is converted into a Scsi_host. |
| 2898 | * @attr: device attribute, not used. |
| 2899 | * @buf: buffer for passing information. |
| 2900 | * |
| 2901 | * This routine returns a lun enabled for OAS each time the function |
| 2902 | * is called. |
| 2903 | * |
| 2904 | * Returns: |
| 2905 | * SUCCESS: size of formatted string. |
| 2906 | * -EFAULT: target or vport wwpn was not set properly. |
| 2907 | * -EPERM: oas is not enabled. |
| 2908 | **/ |
| 2909 | static ssize_t |
| 2910 | lpfc_oas_lun_show(struct device *dev, struct device_attribute *attr, |
| 2911 | char *buf) |
| 2912 | { |
| 2913 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2914 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2915 | |
| 2916 | uint64_t oas_lun; |
| 2917 | int len = 0; |
| 2918 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2919 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2920 | return -EPERM; |
| 2921 | |
| 2922 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2923 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)) |
| 2924 | return -EFAULT; |
| 2925 | |
| 2926 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2927 | if (!(phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)) |
| 2928 | return -EFAULT; |
| 2929 | |
| 2930 | oas_lun = lpfc_oas_lun_get_next(phba, phba->cfg_oas_vpt_wwpn, |
| 2931 | phba->cfg_oas_tgt_wwpn, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2932 | &phba->cfg_oas_lun_status, |
| 2933 | &phba->cfg_oas_priority); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2934 | if (oas_lun != NOT_OAS_ENABLED_LUN) |
| 2935 | phba->cfg_oas_flags |= OAS_LUN_VALID; |
| 2936 | |
| 2937 | len += snprintf(buf + len, PAGE_SIZE-len, "0x%llx", oas_lun); |
| 2938 | |
| 2939 | return len; |
| 2940 | } |
| 2941 | |
| 2942 | /** |
| 2943 | * lpfc_oas_lun_store - Sets the OAS state for lun |
| 2944 | * @dev: class device that is converted into a Scsi_host. |
| 2945 | * @attr: device attribute, not used. |
| 2946 | * @buf: buffer for passing information. |
| 2947 | * |
| 2948 | * This function sets the OAS state for lun. Before this function is called, |
| 2949 | * the vport wwpn, target wwpn, and oas state need to be set. |
| 2950 | * |
| 2951 | * Returns: |
| 2952 | * SUCCESS: size of formatted string. |
| 2953 | * -EFAULT: target or vport wwpn was not set properly. |
| 2954 | * -EPERM: oas is not enabled. |
| 2955 | * size of formatted string. |
| 2956 | **/ |
| 2957 | static ssize_t |
| 2958 | lpfc_oas_lun_store(struct device *dev, struct device_attribute *attr, |
| 2959 | const char *buf, size_t count) |
| 2960 | { |
| 2961 | struct Scsi_Host *shost = class_to_shost(dev); |
| 2962 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; |
| 2963 | uint64_t scsi_lun; |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2964 | uint32_t pri; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2965 | ssize_t rc; |
| 2966 | |
James Smart | f38fa0b | 2014-04-04 13:52:21 -0400 | [diff] [blame] | 2967 | if (!phba->cfg_fof) |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2968 | return -EPERM; |
| 2969 | |
| 2970 | if (wwn_to_u64(phba->cfg_oas_vpt_wwpn) == 0) |
| 2971 | return -EFAULT; |
| 2972 | |
| 2973 | if (wwn_to_u64(phba->cfg_oas_tgt_wwpn) == 0) |
| 2974 | return -EFAULT; |
| 2975 | |
| 2976 | if (!isdigit(buf[0])) |
| 2977 | return -EINVAL; |
| 2978 | |
| 2979 | if (sscanf(buf, "0x%llx", &scsi_lun) != 1) |
| 2980 | return -EINVAL; |
| 2981 | |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2982 | pri = phba->cfg_oas_priority; |
| 2983 | if (pri == 0) |
| 2984 | pri = phba->cfg_XLanePriority; |
| 2985 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2986 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2987 | "3372 Try to set vport 0x%llx target 0x%llx lun:0x%llx " |
| 2988 | "priority 0x%x with oas state %d\n", |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2989 | wwn_to_u64(phba->cfg_oas_vpt_wwpn), |
| 2990 | wwn_to_u64(phba->cfg_oas_tgt_wwpn), scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2991 | pri, phba->cfg_oas_lun_state); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2992 | |
| 2993 | rc = lpfc_oas_lun_state_change(phba, phba->cfg_oas_vpt_wwpn, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 2994 | phba->cfg_oas_tgt_wwpn, scsi_lun, |
James Smart | b5749fe | 2016-12-19 15:07:26 -0800 | [diff] [blame] | 2995 | phba->cfg_oas_lun_state, pri); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 2996 | if (rc) |
| 2997 | return rc; |
| 2998 | |
| 2999 | return count; |
| 3000 | } |
| 3001 | static DEVICE_ATTR(lpfc_xlane_lun, S_IRUGO | S_IWUSR, |
| 3002 | lpfc_oas_lun_show, lpfc_oas_lun_store); |
James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 3003 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3004 | int lpfc_enable_nvmet_cnt; |
| 3005 | unsigned long long lpfc_enable_nvmet[LPFC_NVMET_MAX_PORTS] = { |
| 3006 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3007 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3008 | module_param_array(lpfc_enable_nvmet, ullong, &lpfc_enable_nvmet_cnt, 0444); |
| 3009 | MODULE_PARM_DESC(lpfc_enable_nvmet, "Enable HBA port(s) WWPN as a NVME Target"); |
| 3010 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3011 | static int lpfc_poll = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3012 | module_param(lpfc_poll, int, S_IRUGO); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 3013 | MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" |
| 3014 | " 0 - none," |
| 3015 | " 1 - poll with interrupts enabled" |
| 3016 | " 3 - poll and disable FCP ring interrupts"); |
| 3017 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3018 | static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, |
| 3019 | lpfc_poll_show, lpfc_poll_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3020 | |
James Smart | 96418b5 | 2017-03-04 09:30:31 -0800 | [diff] [blame] | 3021 | int lpfc_no_hba_reset_cnt; |
| 3022 | unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { |
| 3023 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 3024 | module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); |
| 3025 | MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); |
| 3026 | |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 3027 | LPFC_ATTR(sli_mode, 0, 0, 3, |
| 3028 | "SLI mode selector:" |
| 3029 | " 0 - auto (SLI-3 if supported)," |
| 3030 | " 2 - select SLI-2 even on SLI-3 capable HBAs," |
| 3031 | " 3 - select SLI-3"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3032 | |
James Smart | 458c083 | 2016-07-06 12:36:07 -0700 | [diff] [blame] | 3033 | LPFC_ATTR_R(enable_npiv, 1, 0, 1, |
| 3034 | "Enable NPIV functionality"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3035 | |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 3036 | LPFC_ATTR_R(fcf_failover_policy, 1, 1, 2, |
| 3037 | "FCF Fast failover=1 Priority failover=2"); |
| 3038 | |
James Smart | e5771b4 | 2013-03-01 16:37:14 -0500 | [diff] [blame] | 3039 | /* |
| 3040 | # lpfc_enable_rrq: Track XRI/OXID reuse after IO failures |
| 3041 | # 0x0 = disabled, XRI/OXID use not tracked. |
| 3042 | # 0x1 = XRI/OXID reuse is timed with ratov, RRQ sent. |
| 3043 | # 0x2 = XRI/OXID reuse is timed with ratov, No RRQ sent. |
| 3044 | */ |
James Smart | 31202b0 | 2016-10-13 15:06:08 -0700 | [diff] [blame] | 3045 | LPFC_ATTR_R(enable_rrq, 2, 0, 2, |
| 3046 | "Enable RRQ functionality"); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 3047 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3048 | /* |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 3049 | # lpfc_suppress_link_up: Bring link up at initialization |
| 3050 | # 0x0 = bring link up (issue MBX_INIT_LINK) |
| 3051 | # 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK) |
| 3052 | # 0x2 = never bring up link |
| 3053 | # Default value is 0. |
| 3054 | */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3055 | LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, |
| 3056 | LPFC_DELAY_INIT_LINK_INDEFINITELY, |
| 3057 | "Suppress Link Up at initialization"); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3058 | /* |
| 3059 | # lpfc_cnt: Number of IOCBs allocated for ELS, CT, and ABTS |
| 3060 | # 1 - (1024) |
| 3061 | # 2 - (2048) |
| 3062 | # 3 - (3072) |
| 3063 | # 4 - (4096) |
| 3064 | # 5 - (5120) |
| 3065 | */ |
| 3066 | static ssize_t |
| 3067 | lpfc_iocb_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3068 | { |
| 3069 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3070 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
| 3071 | |
| 3072 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->iocb_max); |
| 3073 | } |
| 3074 | |
| 3075 | static DEVICE_ATTR(iocb_hw, S_IRUGO, |
| 3076 | lpfc_iocb_hw_show, NULL); |
| 3077 | static ssize_t |
| 3078 | lpfc_txq_hw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 3079 | { |
| 3080 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3081 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3082 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3083 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3084 | return snprintf(buf, PAGE_SIZE, "%d\n", pring->txq_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3085 | } |
| 3086 | |
| 3087 | static DEVICE_ATTR(txq_hw, S_IRUGO, |
| 3088 | lpfc_txq_hw_show, NULL); |
| 3089 | static ssize_t |
| 3090 | lpfc_txcmplq_hw_show(struct device *dev, struct device_attribute *attr, |
| 3091 | char *buf) |
| 3092 | { |
| 3093 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3094 | struct lpfc_hba *phba = ((struct lpfc_vport *) shost->hostdata)->phba; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3095 | struct lpfc_sli_ring *pring = lpfc_phba_elsring(phba); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3096 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3097 | return snprintf(buf, PAGE_SIZE, "%d\n", pring->txcmplq_max); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3098 | } |
| 3099 | |
| 3100 | static DEVICE_ATTR(txcmplq_hw, S_IRUGO, |
| 3101 | lpfc_txcmplq_hw_show, NULL); |
| 3102 | |
James Smart | 0d8c8ba | 2016-10-13 15:06:07 -0700 | [diff] [blame] | 3103 | LPFC_ATTR_R(iocb_cnt, 2, 1, 5, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 3104 | "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] | 3105 | |
| 3106 | /* |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3107 | # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear |
| 3108 | # until the timer expires. Value range is [0,255]. Default value is 30. |
| 3109 | */ |
| 3110 | static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3111 | static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO; |
| 3112 | module_param(lpfc_nodev_tmo, int, 0); |
| 3113 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
| 3114 | "Seconds driver will hold I/O waiting " |
| 3115 | "for a device to come back"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3116 | |
| 3117 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3118 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3119 | * @dev: class converted to a Scsi_host structure. |
| 3120 | * @attr: device attribute, not used. |
| 3121 | * @buf: on return contains the dev loss timeout in decimal. |
| 3122 | * |
| 3123 | * Returns: size of formatted string. |
| 3124 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3125 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3126 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
| 3127 | char *buf) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3128 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3129 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3130 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 3131 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3132 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3133 | } |
| 3134 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3135 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3136 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3137 | * @vport: lpfc vport structure pointer. |
| 3138 | * @val: contains the nodev timeout value. |
| 3139 | * |
| 3140 | * Description: |
| 3141 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, |
| 3142 | * a kernel error message is printed and zero is returned. |
| 3143 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3144 | * Otherwise nodev tmo is set to the default value. |
| 3145 | * |
| 3146 | * Returns: |
| 3147 | * zero if already set or if val is in range |
| 3148 | * -EINVAL val out of range |
| 3149 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3150 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3151 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3152 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3153 | if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { |
| 3154 | vport->cfg_nodev_tmo = vport->cfg_devloss_tmo; |
| 3155 | if (val != LPFC_DEF_DEVLOSS_TMO) |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3156 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3157 | "0407 Ignoring lpfc_nodev_tmo module " |
| 3158 | "parameter because lpfc_devloss_tmo " |
| 3159 | "is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3160 | return 0; |
| 3161 | } |
| 3162 | |
| 3163 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3164 | vport->cfg_nodev_tmo = val; |
| 3165 | vport->cfg_devloss_tmo = val; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3166 | return 0; |
| 3167 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3168 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3169 | "0400 lpfc_nodev_tmo attribute cannot be set to" |
| 3170 | " %d, allowed range is [%d, %d]\n", |
| 3171 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3172 | vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO; |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3173 | return -EINVAL; |
| 3174 | } |
| 3175 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3176 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3177 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3178 | * @vport: lpfc vport structure pointer. |
| 3179 | * |
| 3180 | * Description: |
| 3181 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. |
| 3182 | **/ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3183 | static void |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3184 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3185 | { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3186 | struct Scsi_Host *shost; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3187 | struct lpfc_nodelist *ndlp; |
| 3188 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3189 | shost = lpfc_shost_from_vport(vport); |
| 3190 | spin_lock_irq(shost->host_lock); |
| 3191 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3192 | if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport) |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3193 | ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; |
| 3194 | spin_unlock_irq(shost->host_lock); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 3195 | } |
| 3196 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3197 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3198 | * 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] | 3199 | * @vport: lpfc vport structure pointer. |
| 3200 | * @val: contains the tmo value. |
| 3201 | * |
| 3202 | * Description: |
| 3203 | * If the devloss tmo is already set or the vport dev loss tmo has changed |
| 3204 | * then a kernel error message is printed and zero is returned. |
| 3205 | * Else if val is in range then nodev tmo and devloss tmo are set to val. |
| 3206 | * Otherwise nodev tmo is set to the default value. |
| 3207 | * |
| 3208 | * Returns: |
| 3209 | * zero if already set or if val is in range |
| 3210 | * -EINVAL val out of range |
| 3211 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3212 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3213 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3214 | { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3215 | if (vport->dev_loss_tmo_changed || |
| 3216 | (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3217 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3218 | "0401 Ignoring change to lpfc_nodev_tmo " |
| 3219 | "because lpfc_devloss_tmo is set.\n"); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3220 | return 0; |
| 3221 | } |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3222 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3223 | vport->cfg_nodev_tmo = val; |
| 3224 | vport->cfg_devloss_tmo = val; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3225 | /* |
| 3226 | * For compat: set the fc_host dev loss so new rports |
| 3227 | * will get the value. |
| 3228 | */ |
| 3229 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3230 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3231 | return 0; |
| 3232 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3233 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3234 | "0403 lpfc_nodev_tmo attribute cannot be set to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3235 | "%d, allowed range is [%d, %d]\n", |
| 3236 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3237 | return -EINVAL; |
| 3238 | } |
| 3239 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3240 | lpfc_vport_param_store(nodev_tmo) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3241 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3242 | static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, |
| 3243 | lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3244 | |
| 3245 | /* |
| 3246 | # lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that |
| 3247 | # disappear until the timer expires. Value range is [0,255]. Default |
| 3248 | # value is 30. |
| 3249 | */ |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3250 | module_param(lpfc_devloss_tmo, int, S_IRUGO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3251 | MODULE_PARM_DESC(lpfc_devloss_tmo, |
| 3252 | "Seconds driver will hold I/O waiting " |
| 3253 | "for a device to come back"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3254 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
| 3255 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
| 3256 | lpfc_vport_param_show(devloss_tmo) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3257 | |
| 3258 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3259 | * 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] | 3260 | * @vport: lpfc vport structure pointer. |
| 3261 | * @val: contains the tmo value. |
| 3262 | * |
| 3263 | * Description: |
| 3264 | * If val is in a valid range then set the vport nodev tmo, |
| 3265 | * devloss tmo, also set the vport dev loss tmo changed flag. |
| 3266 | * Else a kernel error message is printed. |
| 3267 | * |
| 3268 | * Returns: |
| 3269 | * zero if val is in range |
| 3270 | * -EINVAL val out of range |
| 3271 | **/ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3272 | static int |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3273 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3274 | { |
| 3275 | if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3276 | vport->cfg_nodev_tmo = val; |
| 3277 | vport->cfg_devloss_tmo = val; |
| 3278 | vport->dev_loss_tmo_changed = 1; |
Mike Christie | 0af5d70 | 2010-09-15 16:52:31 -0500 | [diff] [blame] | 3279 | fc_host_dev_loss_tmo(lpfc_shost_from_vport(vport)) = val; |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3280 | lpfc_update_rport_devloss_tmo(vport); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3281 | return 0; |
| 3282 | } |
| 3283 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3284 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 3285 | "0404 lpfc_devloss_tmo attribute cannot be set to " |
| 3286 | "%d, allowed range is [%d, %d]\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3287 | val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3288 | return -EINVAL; |
| 3289 | } |
| 3290 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3291 | lpfc_vport_param_store(devloss_tmo) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3292 | static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, |
| 3293 | lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 3294 | |
| 3295 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3296 | * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it |
| 3297 | * lpfc_suppress_rsp = 0 Disable |
| 3298 | * lpfc_suppress_rsp = 1 Enable (default) |
| 3299 | * |
| 3300 | */ |
| 3301 | LPFC_ATTR_R(suppress_rsp, 1, 0, 1, |
| 3302 | "Enable suppress rsp feature is firmware supports it"); |
| 3303 | |
| 3304 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3305 | * lpfc_nvmet_mrq: Specify number of RQ pairs for processing NVMET cmds |
| 3306 | * lpfc_nvmet_mrq = 1 use a single RQ pair |
| 3307 | * lpfc_nvmet_mrq >= 2 use specified RQ pairs for MRQ |
| 3308 | * |
| 3309 | */ |
| 3310 | LPFC_ATTR_R(nvmet_mrq, |
| 3311 | 1, 1, 16, |
| 3312 | "Specify number of RQ pairs for processing NVMET cmds"); |
| 3313 | |
| 3314 | /* |
| 3315 | * lpfc_nvmet_mrq_post: Specify number buffers to post on every MRQ |
| 3316 | * |
| 3317 | */ |
| 3318 | LPFC_ATTR_R(nvmet_mrq_post, LPFC_DEF_MRQ_POST, |
| 3319 | LPFC_MIN_MRQ_POST, LPFC_MAX_MRQ_POST, |
| 3320 | "Specify number of buffers to post on every MRQ"); |
| 3321 | |
| 3322 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3323 | * lpfc_enable_fc4_type: Defines what FC4 types are supported. |
| 3324 | * Supported Values: 1 - register just FCP |
| 3325 | * 3 - register both FCP and NVME |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3326 | * Supported values are [1,3]. Default value is 1 |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3327 | */ |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 3328 | LPFC_ATTR_R(enable_fc4_type, LPFC_ENABLE_FCP, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3329 | LPFC_ENABLE_FCP, LPFC_ENABLE_BOTH, |
| 3330 | "Define fc4 type to register with fabric."); |
| 3331 | |
| 3332 | /* |
| 3333 | * lpfc_xri_split: Defines the division of XRI resources between SCSI and NVME |
| 3334 | * This parameter is only used if: |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3335 | * lpfc_enable_fc4_type is 3 - register both FCP and NVME and |
| 3336 | * port is not configured for NVMET. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3337 | * |
| 3338 | * ELS/CT always get 10% of XRIs, up to a maximum of 250 |
| 3339 | * The remaining XRIs get split up based on lpfc_xri_split per port: |
| 3340 | * |
| 3341 | * Supported Values are in percentages |
| 3342 | * the xri_split value is the percentage the SCSI port will get. The remaining |
| 3343 | * percentage will go to NVME. |
| 3344 | */ |
| 3345 | LPFC_ATTR_R(xri_split, 50, 10, 90, |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 3346 | "Division of XRI resources between SCSI and NVME"); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 3347 | |
| 3348 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3349 | # lpfc_log_verbose: Only turn this flag on if you are willing to risk being |
| 3350 | # deluged with LOTS of information. |
| 3351 | # 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] | 3352 | # See lpfc_logmsh.h for definitions. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3353 | */ |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3354 | LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffffffff, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3355 | "Verbose logging bit-mask"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3356 | |
| 3357 | /* |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3358 | # lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters |
| 3359 | # objects that have been registered with the nameserver after login. |
| 3360 | */ |
James Smart | cf97124 | 2012-03-01 22:37:32 -0500 | [diff] [blame] | 3361 | LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 3362 | "Deregister nameserver objects before LOGO"); |
| 3363 | |
| 3364 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3365 | # 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] | 3366 | # commands per FCP LUN. Value range is [1,512]. Default value is 30. |
| 3367 | # If this parameter value is greater than 1/8th the maximum number of exchanges |
| 3368 | # supported by the HBA port, then the lun queue depth will be reduced to |
| 3369 | # 1/8th the maximum number of exchanges. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3370 | */ |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3371 | LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3372 | "Max number of FCP commands we can queue to a specific LUN"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3373 | |
| 3374 | /* |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3375 | # tgt_queue_depth: This parameter is used to limit the number of outstanding |
| 3376 | # commands per target port. Value range is [10,65535]. Default value is 65535. |
| 3377 | */ |
| 3378 | LPFC_VPORT_ATTR_R(tgt_queue_depth, 65535, 10, 65535, |
James Smart | 572709e | 2013-07-15 18:32:43 -0400 | [diff] [blame] | 3379 | "Max number of FCP commands we can queue to a specific target port"); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 3380 | |
| 3381 | /* |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 3382 | # hba_queue_depth: This parameter is used to limit the number of outstanding |
| 3383 | # commands per lpfc HBA. Value range is [32,8192]. If this parameter |
| 3384 | # value is greater than the maximum number of exchanges supported by the HBA, |
| 3385 | # then maximum number of exchanges supported by the HBA is used to determine |
| 3386 | # the hba_queue_depth. |
| 3387 | */ |
| 3388 | LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192, |
| 3389 | "Max number of FCP commands we can queue to a lpfc HBA"); |
| 3390 | |
| 3391 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3392 | # peer_port_login: This parameter allows/prevents logins |
| 3393 | # between peer ports hosted on the same physical port. |
| 3394 | # When this parameter is set 0 peer ports of same physical port |
| 3395 | # are not allowed to login to each other. |
| 3396 | # When this parameter is set 1 peer ports of same physical port |
| 3397 | # are allowed to login to each other. |
| 3398 | # Default value of this parameter is 0. |
| 3399 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3400 | LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1, |
| 3401 | "Allow peer ports on the same physical port to login to each " |
| 3402 | "other."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3403 | |
| 3404 | /* |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3405 | # restrict_login: This parameter allows/prevents logins |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3406 | # between Virtual Ports and remote initiators. |
| 3407 | # When this parameter is not set (0) Virtual Ports will accept PLOGIs from |
| 3408 | # other initiators and will attempt to PLOGI all remote ports. |
| 3409 | # When this parameter is set (1) Virtual Ports will reject PLOGIs from |
| 3410 | # remote ports and will not attempt to PLOGI to other initiators. |
| 3411 | # This parameter does not restrict to the physical port. |
| 3412 | # This parameter does not restrict logins to Fabric resident remote ports. |
| 3413 | # Default value of this parameter is 1. |
| 3414 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3415 | static int lpfc_restrict_login = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 3416 | module_param(lpfc_restrict_login, int, S_IRUGO); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3417 | MODULE_PARM_DESC(lpfc_restrict_login, |
| 3418 | "Restrict virtual ports login to remote initiators."); |
| 3419 | lpfc_vport_param_show(restrict_login); |
| 3420 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3421 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3422 | * lpfc_restrict_login_init - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3423 | * @vport: lpfc vport structure pointer. |
| 3424 | * @val: contains the restrict login value. |
| 3425 | * |
| 3426 | * Description: |
| 3427 | * If val is not in a valid range then log a kernel error message and set |
| 3428 | * the vport restrict login to one. |
| 3429 | * If the port type is physical clear the restrict login flag and return. |
| 3430 | * Else set the restrict login flag to val. |
| 3431 | * |
| 3432 | * Returns: |
| 3433 | * zero if val is in range |
| 3434 | * -EINVAL val out of range |
| 3435 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3436 | static int |
| 3437 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
| 3438 | { |
| 3439 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3440 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3441 | "0422 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3442 | "be set to %d, allowed range is [0, 1]\n", |
| 3443 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3444 | vport->cfg_restrict_login = 1; |
| 3445 | return -EINVAL; |
| 3446 | } |
| 3447 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 3448 | vport->cfg_restrict_login = 0; |
| 3449 | return 0; |
| 3450 | } |
| 3451 | vport->cfg_restrict_login = val; |
| 3452 | return 0; |
| 3453 | } |
| 3454 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3455 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3456 | * lpfc_restrict_login_set - Set the vport restrict login flag |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3457 | * @vport: lpfc vport structure pointer. |
| 3458 | * @val: contains the restrict login value. |
| 3459 | * |
| 3460 | * Description: |
| 3461 | * If val is not in a valid range then log a kernel error message and set |
| 3462 | * the vport restrict login to one. |
| 3463 | * If the port type is physical and the val is not zero log a kernel |
| 3464 | * error message, clear the restrict login flag and return zero. |
| 3465 | * Else set the restrict login flag to val. |
| 3466 | * |
| 3467 | * Returns: |
| 3468 | * zero if val is in range |
| 3469 | * -EINVAL val out of range |
| 3470 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3471 | static int |
| 3472 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
| 3473 | { |
| 3474 | if (val < 0 || val > 1) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3475 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3476 | "0425 lpfc_restrict_login attribute cannot " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3477 | "be set to %d, allowed range is [0, 1]\n", |
| 3478 | val); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3479 | vport->cfg_restrict_login = 1; |
| 3480 | return -EINVAL; |
| 3481 | } |
| 3482 | if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3483 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3484 | "0468 lpfc_restrict_login must be 0 for " |
| 3485 | "Physical ports.\n"); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3486 | vport->cfg_restrict_login = 0; |
| 3487 | return 0; |
| 3488 | } |
| 3489 | vport->cfg_restrict_login = val; |
| 3490 | return 0; |
| 3491 | } |
| 3492 | lpfc_vport_param_store(restrict_login); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3493 | static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, |
| 3494 | lpfc_restrict_login_show, lpfc_restrict_login_store); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3495 | |
| 3496 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3497 | # Some disk devices have a "select ID" or "select Target" capability. |
| 3498 | # From a protocol standpoint "select ID" usually means select the |
| 3499 | # Fibre channel "ALPA". In the FC-AL Profile there is an "informative |
| 3500 | # annex" which contains a table that maps a "select ID" (a number |
| 3501 | # between 0 and 7F) to an ALPA. By default, for compatibility with |
| 3502 | # older drivers, the lpfc driver scans this table from low ALPA to high |
| 3503 | # ALPA. |
| 3504 | # |
| 3505 | # Turning on the scan-down variable (on = 1, off = 0) will |
| 3506 | # cause the lpfc driver to use an inverted table, effectively |
| 3507 | # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1. |
| 3508 | # |
| 3509 | # (Note: This "select ID" functionality is a LOOP ONLY characteristic |
| 3510 | # and will not work across a fabric. Also this parameter will take |
| 3511 | # effect only in the case when ALPA map is not available.) |
| 3512 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3513 | LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, |
| 3514 | "Start scanning for devices from highest ALPA to lowest"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3515 | |
| 3516 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3517 | # lpfc_topology: link topology for init link |
| 3518 | # 0x0 = attempt loop mode then point-to-point |
Jamie Wellnitz | 367c271 | 2006-02-28 19:25:32 -0500 | [diff] [blame] | 3519 | # 0x01 = internal loopback mode |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3520 | # 0x02 = attempt point-to-point mode only |
| 3521 | # 0x04 = attempt loop mode only |
| 3522 | # 0x06 = attempt point-to-point mode then loop |
| 3523 | # Set point-to-point mode if you want to run as an N_Port. |
| 3524 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
| 3525 | # Default value is 0. |
| 3526 | */ |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3527 | LPFC_ATTR(topology, 0, 0, 6, |
| 3528 | "Select Fibre Channel topology"); |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3529 | |
| 3530 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3531 | * lpfc_topology_set - Set the adapters topology field |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3532 | * @phba: lpfc_hba pointer. |
| 3533 | * @val: topology value. |
| 3534 | * |
| 3535 | * Description: |
| 3536 | * If val is in a valid range then set the adapter's topology field and |
| 3537 | * issue a lip; if the lip fails reset the topology to the old value. |
| 3538 | * |
| 3539 | * If the value is not in range log a kernel error message and return an error. |
| 3540 | * |
| 3541 | * Returns: |
| 3542 | * zero if val is in range and lip okay |
| 3543 | * non-zero return value from lpfc_issue_lip() |
| 3544 | * -EINVAL val out of range |
| 3545 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3546 | static ssize_t |
| 3547 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
| 3548 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3549 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3550 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3551 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3552 | struct lpfc_hba *phba = vport->phba; |
| 3553 | int val = 0; |
| 3554 | int nolip = 0; |
| 3555 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3556 | int err; |
| 3557 | uint32_t prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3558 | |
| 3559 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 3560 | nolip = 1; |
| 3561 | val_buf = &buf[strlen("nolip ")]; |
| 3562 | } |
| 3563 | |
| 3564 | if (!isdigit(val_buf[0])) |
| 3565 | return -EINVAL; |
| 3566 | if (sscanf(val_buf, "%i", &val) != 1) |
| 3567 | return -EINVAL; |
| 3568 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3569 | if (val >= 0 && val <= 6) { |
| 3570 | prev_val = phba->cfg_topology; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3571 | if (phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G && |
| 3572 | val == 4) { |
| 3573 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3574 | "3113 Loop mode not supported at speed %d\n", |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3575 | val); |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 3576 | return -EINVAL; |
| 3577 | } |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 3578 | if (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && |
| 3579 | val == 4) { |
| 3580 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3581 | "3114 Loop mode not supported\n"); |
| 3582 | return -EINVAL; |
| 3583 | } |
| 3584 | phba->cfg_topology = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3585 | if (nolip) |
| 3586 | return strlen(buf); |
| 3587 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 3588 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3589 | "3054 lpfc_topology changed from %d to %d\n", |
| 3590 | prev_val, val); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 3591 | if (prev_val != val && phba->sli_rev == LPFC_SLI_REV4) |
| 3592 | phba->fc_topology_changed = 1; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3593 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3594 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3595 | phba->cfg_topology = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3596 | return -EINVAL; |
| 3597 | } else |
| 3598 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3599 | } |
| 3600 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3601 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
| 3602 | "allowed range is [0, 6]\n", |
| 3603 | phba->brd_no, val); |
| 3604 | return -EINVAL; |
| 3605 | } |
James Smart | 0a03543 | 2016-10-13 15:06:10 -0700 | [diff] [blame] | 3606 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3607 | lpfc_param_show(topology) |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 3608 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3609 | lpfc_topology_show, lpfc_topology_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3610 | |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 3611 | /** |
| 3612 | * lpfc_static_vport_show: Read callback function for |
| 3613 | * lpfc_static_vport sysfs file. |
| 3614 | * @dev: Pointer to class device object. |
| 3615 | * @attr: device attribute structure. |
| 3616 | * @buf: Data buffer. |
| 3617 | * |
| 3618 | * This function is the read call back function for |
| 3619 | * lpfc_static_vport sysfs file. The lpfc_static_vport |
| 3620 | * sysfs file report the mageability of the vport. |
| 3621 | **/ |
| 3622 | static ssize_t |
| 3623 | lpfc_static_vport_show(struct device *dev, struct device_attribute *attr, |
| 3624 | char *buf) |
| 3625 | { |
| 3626 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3627 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3628 | if (vport->vport_flag & STATIC_VPORT) |
| 3629 | sprintf(buf, "1\n"); |
| 3630 | else |
| 3631 | sprintf(buf, "0\n"); |
| 3632 | |
| 3633 | return strlen(buf); |
| 3634 | } |
| 3635 | |
| 3636 | /* |
| 3637 | * Sysfs attribute to control the statistical data collection. |
| 3638 | */ |
| 3639 | static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, |
| 3640 | lpfc_static_vport_show, NULL); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3641 | |
| 3642 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3643 | * 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] | 3644 | * @dev: Pointer to class device. |
| 3645 | * @buf: Data buffer. |
| 3646 | * @count: Size of the data buffer. |
| 3647 | * |
Masahiro Yamada | 9332ef9 | 2017-02-27 14:28:47 -0800 | [diff] [blame] | 3648 | * 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] | 3649 | * sysfs file. This function parse the command written to the sysfs file |
| 3650 | * and take appropriate action. These commands are used for controlling |
| 3651 | * driver statistical data collection. |
| 3652 | * Following are the command this function handles. |
| 3653 | * |
| 3654 | * setbucket <bucket_type> <base> <step> |
| 3655 | * = Set the latency buckets. |
| 3656 | * destroybucket = destroy all the buckets. |
| 3657 | * start = start data collection |
| 3658 | * stop = stop data collection |
| 3659 | * reset = reset the collected data |
| 3660 | **/ |
| 3661 | static ssize_t |
| 3662 | lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, |
| 3663 | const char *buf, size_t count) |
| 3664 | { |
| 3665 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3666 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3667 | struct lpfc_hba *phba = vport->phba; |
| 3668 | #define LPFC_MAX_DATA_CTRL_LEN 1024 |
| 3669 | static char bucket_data[LPFC_MAX_DATA_CTRL_LEN]; |
| 3670 | unsigned long i; |
| 3671 | char *str_ptr, *token; |
| 3672 | struct lpfc_vport **vports; |
| 3673 | struct Scsi_Host *v_shost; |
| 3674 | char *bucket_type_str, *base_str, *step_str; |
| 3675 | unsigned long base, step, bucket_type; |
| 3676 | |
| 3677 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3678 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3679 | return -EINVAL; |
| 3680 | |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 3681 | strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3682 | str_ptr = &bucket_data[0]; |
| 3683 | /* Ignore this token - this is command token */ |
| 3684 | token = strsep(&str_ptr, "\t "); |
| 3685 | if (!token) |
| 3686 | return -EINVAL; |
| 3687 | |
| 3688 | bucket_type_str = strsep(&str_ptr, "\t "); |
| 3689 | if (!bucket_type_str) |
| 3690 | return -EINVAL; |
| 3691 | |
| 3692 | if (!strncmp(bucket_type_str, "linear", strlen("linear"))) |
| 3693 | bucket_type = LPFC_LINEAR_BUCKET; |
| 3694 | else if (!strncmp(bucket_type_str, "power2", strlen("power2"))) |
| 3695 | bucket_type = LPFC_POWER2_BUCKET; |
| 3696 | else |
| 3697 | return -EINVAL; |
| 3698 | |
| 3699 | base_str = strsep(&str_ptr, "\t "); |
| 3700 | if (!base_str) |
| 3701 | return -EINVAL; |
| 3702 | base = simple_strtoul(base_str, NULL, 0); |
| 3703 | |
| 3704 | step_str = strsep(&str_ptr, "\t "); |
| 3705 | if (!step_str) |
| 3706 | return -EINVAL; |
| 3707 | step = simple_strtoul(step_str, NULL, 0); |
| 3708 | if (!step) |
| 3709 | return -EINVAL; |
| 3710 | |
| 3711 | /* Block the data collection for every vport */ |
| 3712 | vports = lpfc_create_vport_work_array(phba); |
| 3713 | if (vports == NULL) |
| 3714 | return -ENOMEM; |
| 3715 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3716 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3717 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3718 | spin_lock_irq(v_shost->host_lock); |
| 3719 | /* Block and reset data collection */ |
| 3720 | vports[i]->stat_data_blocked = 1; |
| 3721 | if (vports[i]->stat_data_enabled) |
| 3722 | lpfc_vport_reset_stat_data(vports[i]); |
| 3723 | spin_unlock_irq(v_shost->host_lock); |
| 3724 | } |
| 3725 | |
| 3726 | /* Set the bucket attributes */ |
| 3727 | phba->bucket_type = bucket_type; |
| 3728 | phba->bucket_base = base; |
| 3729 | phba->bucket_step = step; |
| 3730 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3731 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3732 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3733 | |
| 3734 | /* Unblock data collection */ |
| 3735 | spin_lock_irq(v_shost->host_lock); |
| 3736 | vports[i]->stat_data_blocked = 0; |
| 3737 | spin_unlock_irq(v_shost->host_lock); |
| 3738 | } |
| 3739 | lpfc_destroy_vport_work_array(phba, vports); |
| 3740 | return strlen(buf); |
| 3741 | } |
| 3742 | |
| 3743 | if (!strncmp(buf, "destroybucket", strlen("destroybucket"))) { |
| 3744 | vports = lpfc_create_vport_work_array(phba); |
| 3745 | if (vports == NULL) |
| 3746 | return -ENOMEM; |
| 3747 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 3748 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3749 | v_shost = lpfc_shost_from_vport(vports[i]); |
| 3750 | spin_lock_irq(shost->host_lock); |
| 3751 | vports[i]->stat_data_blocked = 1; |
| 3752 | lpfc_free_bucket(vport); |
| 3753 | vport->stat_data_enabled = 0; |
| 3754 | vports[i]->stat_data_blocked = 0; |
| 3755 | spin_unlock_irq(shost->host_lock); |
| 3756 | } |
| 3757 | lpfc_destroy_vport_work_array(phba, vports); |
| 3758 | phba->bucket_type = LPFC_NO_BUCKET; |
| 3759 | phba->bucket_base = 0; |
| 3760 | phba->bucket_step = 0; |
| 3761 | return strlen(buf); |
| 3762 | } |
| 3763 | |
| 3764 | if (!strncmp(buf, "start", strlen("start"))) { |
| 3765 | /* If no buckets configured return error */ |
| 3766 | if (phba->bucket_type == LPFC_NO_BUCKET) |
| 3767 | return -EINVAL; |
| 3768 | spin_lock_irq(shost->host_lock); |
| 3769 | if (vport->stat_data_enabled) { |
| 3770 | spin_unlock_irq(shost->host_lock); |
| 3771 | return strlen(buf); |
| 3772 | } |
| 3773 | lpfc_alloc_bucket(vport); |
| 3774 | vport->stat_data_enabled = 1; |
| 3775 | spin_unlock_irq(shost->host_lock); |
| 3776 | return strlen(buf); |
| 3777 | } |
| 3778 | |
| 3779 | if (!strncmp(buf, "stop", strlen("stop"))) { |
| 3780 | spin_lock_irq(shost->host_lock); |
| 3781 | if (vport->stat_data_enabled == 0) { |
| 3782 | spin_unlock_irq(shost->host_lock); |
| 3783 | return strlen(buf); |
| 3784 | } |
| 3785 | lpfc_free_bucket(vport); |
| 3786 | vport->stat_data_enabled = 0; |
| 3787 | spin_unlock_irq(shost->host_lock); |
| 3788 | return strlen(buf); |
| 3789 | } |
| 3790 | |
| 3791 | if (!strncmp(buf, "reset", strlen("reset"))) { |
| 3792 | if ((phba->bucket_type == LPFC_NO_BUCKET) |
| 3793 | || !vport->stat_data_enabled) |
| 3794 | return strlen(buf); |
| 3795 | spin_lock_irq(shost->host_lock); |
| 3796 | vport->stat_data_blocked = 1; |
| 3797 | lpfc_vport_reset_stat_data(vport); |
| 3798 | vport->stat_data_blocked = 0; |
| 3799 | spin_unlock_irq(shost->host_lock); |
| 3800 | return strlen(buf); |
| 3801 | } |
| 3802 | return -EINVAL; |
| 3803 | } |
| 3804 | |
| 3805 | |
| 3806 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3807 | * 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] | 3808 | * @dev: Pointer to class device object. |
| 3809 | * @buf: Data buffer. |
| 3810 | * |
| 3811 | * This function is the read call back function for |
| 3812 | * lpfc_stat_data_ctrl sysfs file. This function report the |
| 3813 | * current statistical data collection state. |
| 3814 | **/ |
| 3815 | static ssize_t |
| 3816 | lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr, |
| 3817 | char *buf) |
| 3818 | { |
| 3819 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3820 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3821 | struct lpfc_hba *phba = vport->phba; |
| 3822 | int index = 0; |
| 3823 | int i; |
| 3824 | char *bucket_type; |
| 3825 | unsigned long bucket_value; |
| 3826 | |
| 3827 | switch (phba->bucket_type) { |
| 3828 | case LPFC_LINEAR_BUCKET: |
| 3829 | bucket_type = "linear"; |
| 3830 | break; |
| 3831 | case LPFC_POWER2_BUCKET: |
| 3832 | bucket_type = "power2"; |
| 3833 | break; |
| 3834 | default: |
| 3835 | bucket_type = "No Bucket"; |
| 3836 | break; |
| 3837 | } |
| 3838 | |
| 3839 | sprintf(&buf[index], "Statistical Data enabled :%d, " |
| 3840 | "blocked :%d, Bucket type :%s, Bucket base :%d," |
| 3841 | " Bucket step :%d\nLatency Ranges :", |
| 3842 | vport->stat_data_enabled, vport->stat_data_blocked, |
| 3843 | bucket_type, phba->bucket_base, phba->bucket_step); |
| 3844 | index = strlen(buf); |
| 3845 | if (phba->bucket_type != LPFC_NO_BUCKET) { |
| 3846 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3847 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) |
| 3848 | bucket_value = phba->bucket_base + |
| 3849 | phba->bucket_step * i; |
| 3850 | else |
| 3851 | bucket_value = phba->bucket_base + |
| 3852 | (1 << i) * phba->bucket_step; |
| 3853 | |
| 3854 | if (index + 10 > PAGE_SIZE) |
| 3855 | break; |
| 3856 | sprintf(&buf[index], "%08ld ", bucket_value); |
| 3857 | index = strlen(buf); |
| 3858 | } |
| 3859 | } |
| 3860 | sprintf(&buf[index], "\n"); |
| 3861 | return strlen(buf); |
| 3862 | } |
| 3863 | |
| 3864 | /* |
| 3865 | * Sysfs attribute to control the statistical data collection. |
| 3866 | */ |
| 3867 | static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, |
| 3868 | lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store); |
| 3869 | |
| 3870 | /* |
| 3871 | * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. |
| 3872 | */ |
| 3873 | |
| 3874 | /* |
| 3875 | * Each Bucket takes 11 characters and 1 new line + 17 bytes WWN |
| 3876 | * for each target. |
| 3877 | */ |
| 3878 | #define STAT_DATA_SIZE_PER_TARGET(NUM_BUCKETS) ((NUM_BUCKETS) * 11 + 18) |
| 3879 | #define MAX_STAT_DATA_SIZE_PER_TARGET \ |
| 3880 | STAT_DATA_SIZE_PER_TARGET(LPFC_MAX_BUCKET_COUNT) |
| 3881 | |
| 3882 | |
| 3883 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3884 | * 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] | 3885 | * @filp: sysfs file |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3886 | * @kobj: Pointer to the kernel object |
| 3887 | * @bin_attr: Attribute object |
| 3888 | * @buff: Buffer pointer |
| 3889 | * @off: File offset |
| 3890 | * @count: Buffer size |
| 3891 | * |
| 3892 | * This function is the read call back function for lpfc_drvr_stat_data |
| 3893 | * sysfs file. This function export the statistical data to user |
| 3894 | * applications. |
| 3895 | **/ |
| 3896 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 3897 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
| 3898 | struct bin_attribute *bin_attr, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3899 | char *buf, loff_t off, size_t count) |
| 3900 | { |
| 3901 | struct device *dev = container_of(kobj, struct device, |
| 3902 | kobj); |
| 3903 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3904 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3905 | struct lpfc_hba *phba = vport->phba; |
| 3906 | int i = 0, index = 0; |
| 3907 | unsigned long nport_index; |
| 3908 | struct lpfc_nodelist *ndlp = NULL; |
| 3909 | nport_index = (unsigned long)off / |
| 3910 | MAX_STAT_DATA_SIZE_PER_TARGET; |
| 3911 | |
| 3912 | if (!vport->stat_data_enabled || vport->stat_data_blocked |
| 3913 | || (phba->bucket_type == LPFC_NO_BUCKET)) |
| 3914 | return 0; |
| 3915 | |
| 3916 | spin_lock_irq(shost->host_lock); |
| 3917 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 3918 | if (!NLP_CHK_NODE_ACT(ndlp) || !ndlp->lat_data) |
| 3919 | continue; |
| 3920 | |
| 3921 | if (nport_index > 0) { |
| 3922 | nport_index--; |
| 3923 | continue; |
| 3924 | } |
| 3925 | |
| 3926 | if ((index + MAX_STAT_DATA_SIZE_PER_TARGET) |
| 3927 | > count) |
| 3928 | break; |
| 3929 | |
| 3930 | if (!ndlp->lat_data) |
| 3931 | continue; |
| 3932 | |
| 3933 | /* Print the WWN */ |
| 3934 | sprintf(&buf[index], "%02x%02x%02x%02x%02x%02x%02x%02x:", |
| 3935 | ndlp->nlp_portname.u.wwn[0], |
| 3936 | ndlp->nlp_portname.u.wwn[1], |
| 3937 | ndlp->nlp_portname.u.wwn[2], |
| 3938 | ndlp->nlp_portname.u.wwn[3], |
| 3939 | ndlp->nlp_portname.u.wwn[4], |
| 3940 | ndlp->nlp_portname.u.wwn[5], |
| 3941 | ndlp->nlp_portname.u.wwn[6], |
| 3942 | ndlp->nlp_portname.u.wwn[7]); |
| 3943 | |
| 3944 | index = strlen(buf); |
| 3945 | |
| 3946 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT; i++) { |
| 3947 | sprintf(&buf[index], "%010u,", |
| 3948 | ndlp->lat_data[i].cmd_count); |
| 3949 | index = strlen(buf); |
| 3950 | } |
| 3951 | sprintf(&buf[index], "\n"); |
| 3952 | index = strlen(buf); |
| 3953 | } |
| 3954 | spin_unlock_irq(shost->host_lock); |
| 3955 | return index; |
| 3956 | } |
| 3957 | |
| 3958 | static struct bin_attribute sysfs_drvr_stat_data_attr = { |
| 3959 | .attr = { |
| 3960 | .name = "lpfc_drvr_stat_data", |
| 3961 | .mode = S_IRUSR, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 3962 | }, |
| 3963 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
| 3964 | .read = sysfs_drvr_stat_data_read, |
| 3965 | .write = NULL, |
| 3966 | }; |
| 3967 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3968 | /* |
| 3969 | # lpfc_link_speed: Link speed selection for initializing the Fibre Channel |
| 3970 | # connection. |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3971 | # Value range is [0,16]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3972 | */ |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3973 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3974 | * lpfc_link_speed_set - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3975 | * @phba: lpfc_hba pointer. |
| 3976 | * @val: link speed value. |
| 3977 | * |
| 3978 | * Description: |
| 3979 | * If val is in a valid range then set the adapter's link speed field and |
| 3980 | * issue a lip; if the lip fails reset the link speed to the old value. |
| 3981 | * |
| 3982 | * Notes: |
| 3983 | * If the value is not in range log a kernel error message and return an error. |
| 3984 | * |
| 3985 | * Returns: |
| 3986 | * zero if val is in range and lip okay. |
| 3987 | * non-zero return value from lpfc_issue_lip() |
| 3988 | * -EINVAL val out of range |
| 3989 | **/ |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3990 | static ssize_t |
| 3991 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
| 3992 | const char *buf, size_t count) |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 3993 | { |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3994 | struct Scsi_Host *shost = class_to_shost(dev); |
| 3995 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 3996 | struct lpfc_hba *phba = vport->phba; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3997 | int val = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 3998 | int nolip = 0; |
| 3999 | const char *val_buf = buf; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4000 | int err; |
James Smart | c691816 | 2016-10-13 15:06:16 -0700 | [diff] [blame] | 4001 | uint32_t prev_val, if_type; |
| 4002 | |
| 4003 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 4004 | if (if_type == LPFC_SLI_INTF_IF_TYPE_2 && |
| 4005 | phba->hba_flag & HBA_FORCED_LINK_SPEED) |
| 4006 | return -EPERM; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4007 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4008 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { |
| 4009 | nolip = 1; |
| 4010 | val_buf = &buf[strlen("nolip ")]; |
| 4011 | } |
| 4012 | |
| 4013 | if (!isdigit(val_buf[0])) |
| 4014 | return -EINVAL; |
| 4015 | if (sscanf(val_buf, "%i", &val) != 1) |
| 4016 | return -EINVAL; |
| 4017 | |
James Smart | 88a2cfb | 2011-07-22 18:36:33 -0400 | [diff] [blame] | 4018 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4019 | "3055 lpfc_link_speed changed from %d to %d %s\n", |
| 4020 | phba->cfg_link_speed, val, nolip ? "(nolip)" : "(lip)"); |
| 4021 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4022 | if (((val == LPFC_USER_LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
| 4023 | ((val == LPFC_USER_LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
| 4024 | ((val == LPFC_USER_LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
| 4025 | ((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) || |
| 4026 | ((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) || |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4027 | ((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) || |
| 4028 | ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4029 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4030 | "2879 lpfc_link_speed attribute cannot be set " |
| 4031 | "to %d. Speed is not supported by this port.\n", |
| 4032 | val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4033 | return -EINVAL; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4034 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4035 | if (val == LPFC_USER_LINK_SPEED_16G && |
| 4036 | phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| 4037 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4038 | "3112 lpfc_link_speed attribute cannot be set " |
| 4039 | "to %d. Speed is not supported in loop mode.\n", |
| 4040 | val); |
| 4041 | return -EINVAL; |
| 4042 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4043 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 4044 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4045 | prev_val = phba->cfg_link_speed; |
| 4046 | phba->cfg_link_speed = val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4047 | if (nolip) |
| 4048 | return strlen(buf); |
| 4049 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4050 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4051 | if (err) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4052 | phba->cfg_link_speed = prev_val; |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 4053 | return -EINVAL; |
| 4054 | } else |
| 4055 | return strlen(buf); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4056 | } |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4057 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4058 | "0469 lpfc_link_speed attribute cannot be set to %d, " |
| 4059 | "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4060 | return -EINVAL; |
| 4061 | } |
| 4062 | |
| 4063 | static int lpfc_link_speed = 0; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 4064 | module_param(lpfc_link_speed, int, S_IRUGO); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4065 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
| 4066 | lpfc_param_show(link_speed) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4067 | |
| 4068 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4069 | * lpfc_link_speed_init - Set the adapters link speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4070 | * @phba: lpfc_hba pointer. |
| 4071 | * @val: link speed value. |
| 4072 | * |
| 4073 | * Description: |
| 4074 | * If val is in a valid range then set the adapter's link speed field. |
| 4075 | * |
| 4076 | * Notes: |
| 4077 | * If the value is not in range log a kernel error message, clear the link |
| 4078 | * speed and return an error. |
| 4079 | * |
| 4080 | * Returns: |
| 4081 | * zero if val saved. |
| 4082 | * -EINVAL val out of range |
| 4083 | **/ |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4084 | static int |
| 4085 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
| 4086 | { |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 4087 | if (val == LPFC_USER_LINK_SPEED_16G && phba->cfg_topology == 4) { |
| 4088 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4089 | "3111 lpfc_link_speed of %d cannot " |
| 4090 | "support loop mode, setting topology to default.\n", |
| 4091 | val); |
| 4092 | phba->cfg_topology = 0; |
| 4093 | } |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4094 | if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) && |
| 4095 | (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) { |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4096 | phba->cfg_link_speed = val; |
| 4097 | return 0; |
| 4098 | } |
| 4099 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4100 | "0405 lpfc_link_speed attribute cannot " |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4101 | "be set to %d, allowed values are " |
| 4102 | "["LPFC_LINK_SPEED_STRING"]\n", val); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4103 | phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4104 | return -EINVAL; |
| 4105 | } |
| 4106 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 4107 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 4108 | lpfc_link_speed_show, lpfc_link_speed_store); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4109 | |
| 4110 | /* |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4111 | # lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) |
| 4112 | # 0 = aer disabled or not supported |
| 4113 | # 1 = aer supported and enabled (default) |
| 4114 | # Value range is [0,1]. Default value is 1. |
| 4115 | */ |
James Smart | 506139a | 2016-10-13 15:06:09 -0700 | [diff] [blame] | 4116 | LPFC_ATTR(aer_support, 1, 0, 1, |
| 4117 | "Enable PCIe device AER support"); |
| 4118 | lpfc_param_show(aer_support) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4119 | |
| 4120 | /** |
| 4121 | * lpfc_aer_support_store - Set the adapter for aer support |
| 4122 | * |
| 4123 | * @dev: class device that is converted into a Scsi_host. |
| 4124 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4125 | * @buf: containing enable or disable aer flag. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4126 | * @count: unused variable. |
| 4127 | * |
| 4128 | * Description: |
| 4129 | * If the val is 1 and currently the device's AER capability was not |
| 4130 | * enabled, invoke the kernel's enable AER helper routine, trying to |
| 4131 | * enable the device's AER capability. If the helper routine enabling |
| 4132 | * AER returns success, update the device's cfg_aer_support flag to |
| 4133 | * indicate AER is supported by the device; otherwise, if the device |
| 4134 | * AER capability is already enabled to support AER, then do nothing. |
| 4135 | * |
| 4136 | * If the val is 0 and currently the device's AER support was enabled, |
| 4137 | * invoke the kernel's disable AER helper routine. After that, update |
| 4138 | * the device's cfg_aer_support flag to indicate AER is not supported |
| 4139 | * by the device; otherwise, if the device AER capability is already |
| 4140 | * disabled from supporting AER, then do nothing. |
| 4141 | * |
| 4142 | * Returns: |
| 4143 | * length of the buf on success if val is in range the intended mode |
| 4144 | * is supported. |
| 4145 | * -EINVAL if val out of range or intended mode is not supported. |
| 4146 | **/ |
| 4147 | static ssize_t |
| 4148 | lpfc_aer_support_store(struct device *dev, struct device_attribute *attr, |
| 4149 | const char *buf, size_t count) |
| 4150 | { |
| 4151 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4152 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4153 | struct lpfc_hba *phba = vport->phba; |
| 4154 | int val = 0, rc = -EINVAL; |
| 4155 | |
| 4156 | if (!isdigit(buf[0])) |
| 4157 | return -EINVAL; |
| 4158 | if (sscanf(buf, "%i", &val) != 1) |
| 4159 | return -EINVAL; |
| 4160 | |
| 4161 | switch (val) { |
| 4162 | case 0: |
| 4163 | if (phba->hba_flag & HBA_AER_ENABLED) { |
| 4164 | rc = pci_disable_pcie_error_reporting(phba->pcidev); |
| 4165 | if (!rc) { |
| 4166 | spin_lock_irq(&phba->hbalock); |
| 4167 | phba->hba_flag &= ~HBA_AER_ENABLED; |
| 4168 | spin_unlock_irq(&phba->hbalock); |
| 4169 | phba->cfg_aer_support = 0; |
| 4170 | rc = strlen(buf); |
| 4171 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4172 | rc = -EPERM; |
| 4173 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4174 | phba->cfg_aer_support = 0; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4175 | rc = strlen(buf); |
| 4176 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4177 | break; |
| 4178 | case 1: |
| 4179 | if (!(phba->hba_flag & HBA_AER_ENABLED)) { |
| 4180 | rc = pci_enable_pcie_error_reporting(phba->pcidev); |
| 4181 | if (!rc) { |
| 4182 | spin_lock_irq(&phba->hbalock); |
| 4183 | phba->hba_flag |= HBA_AER_ENABLED; |
| 4184 | spin_unlock_irq(&phba->hbalock); |
| 4185 | phba->cfg_aer_support = 1; |
| 4186 | rc = strlen(buf); |
| 4187 | } else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4188 | rc = -EPERM; |
| 4189 | } else { |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4190 | phba->cfg_aer_support = 1; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4191 | rc = strlen(buf); |
| 4192 | } |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4193 | break; |
| 4194 | default: |
| 4195 | rc = -EINVAL; |
| 4196 | break; |
| 4197 | } |
| 4198 | return rc; |
| 4199 | } |
| 4200 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4201 | static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, |
| 4202 | lpfc_aer_support_show, lpfc_aer_support_store); |
| 4203 | |
| 4204 | /** |
| 4205 | * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device |
| 4206 | * @dev: class device that is converted into a Scsi_host. |
| 4207 | * @attr: device attribute, not used. |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4208 | * @buf: containing flag 1 for aer cleanup state. |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4209 | * @count: unused variable. |
| 4210 | * |
| 4211 | * Description: |
| 4212 | * If the @buf contains 1 and the device currently has the AER support |
| 4213 | * enabled, then invokes the kernel AER helper routine |
| 4214 | * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable |
| 4215 | * error status register. |
| 4216 | * |
| 4217 | * Notes: |
| 4218 | * |
| 4219 | * Returns: |
| 4220 | * -EINVAL if the buf does not contain the 1 or the device is not currently |
| 4221 | * enabled with the AER support. |
| 4222 | **/ |
| 4223 | static ssize_t |
| 4224 | lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr, |
| 4225 | const char *buf, size_t count) |
| 4226 | { |
| 4227 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4228 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 4229 | struct lpfc_hba *phba = vport->phba; |
| 4230 | int val, rc = -1; |
| 4231 | |
| 4232 | if (!isdigit(buf[0])) |
| 4233 | return -EINVAL; |
| 4234 | if (sscanf(buf, "%i", &val) != 1) |
| 4235 | return -EINVAL; |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4236 | if (val != 1) |
| 4237 | return -EINVAL; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4238 | |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4239 | if (phba->hba_flag & HBA_AER_ENABLED) |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4240 | rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev); |
| 4241 | |
| 4242 | if (rc == 0) |
| 4243 | return strlen(buf); |
| 4244 | else |
James Smart | 891478a | 2009-11-18 15:40:23 -0500 | [diff] [blame] | 4245 | return -EPERM; |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4246 | } |
| 4247 | |
| 4248 | static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL, |
| 4249 | lpfc_aer_cleanup_state); |
| 4250 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4251 | /** |
| 4252 | * lpfc_sriov_nr_virtfn_store - Enable the adapter for sr-iov virtual functions |
| 4253 | * |
| 4254 | * @dev: class device that is converted into a Scsi_host. |
| 4255 | * @attr: device attribute, not used. |
| 4256 | * @buf: containing the string the number of vfs to be enabled. |
| 4257 | * @count: unused variable. |
| 4258 | * |
| 4259 | * Description: |
| 4260 | * When this api is called either through user sysfs, the driver shall |
| 4261 | * try to enable or disable SR-IOV virtual functions according to the |
| 4262 | * following: |
| 4263 | * |
| 4264 | * If zero virtual function has been enabled to the physical function, |
| 4265 | * the driver shall invoke the pci enable virtual function api trying |
| 4266 | * to enable the virtual functions. If the nr_vfn provided is greater |
| 4267 | * than the maximum supported, the maximum virtual function number will |
| 4268 | * be used for invoking the api; otherwise, the nr_vfn provided shall |
| 4269 | * be used for invoking the api. If the api call returned success, the |
| 4270 | * actual number of virtual functions enabled will be set to the driver |
| 4271 | * cfg_sriov_nr_virtfn; otherwise, -EINVAL shall be returned and driver |
| 4272 | * cfg_sriov_nr_virtfn remains zero. |
| 4273 | * |
| 4274 | * If none-zero virtual functions have already been enabled to the |
| 4275 | * physical function, as reflected by the driver's cfg_sriov_nr_virtfn, |
| 4276 | * -EINVAL will be returned and the driver does nothing; |
| 4277 | * |
| 4278 | * If the nr_vfn provided is zero and none-zero virtual functions have |
| 4279 | * been enabled, as indicated by the driver's cfg_sriov_nr_virtfn, the |
| 4280 | * disabling virtual function api shall be invoded to disable all the |
| 4281 | * virtual functions and driver's cfg_sriov_nr_virtfn shall be set to |
| 4282 | * zero. Otherwise, if zero virtual function has been enabled, do |
| 4283 | * nothing. |
| 4284 | * |
| 4285 | * Returns: |
| 4286 | * length of the buf on success if val is in range the intended mode |
| 4287 | * is supported. |
| 4288 | * -EINVAL if val out of range or intended mode is not supported. |
| 4289 | **/ |
| 4290 | static ssize_t |
| 4291 | lpfc_sriov_nr_virtfn_store(struct device *dev, struct device_attribute *attr, |
| 4292 | const char *buf, size_t count) |
| 4293 | { |
| 4294 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4295 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4296 | struct lpfc_hba *phba = vport->phba; |
| 4297 | struct pci_dev *pdev = phba->pcidev; |
| 4298 | int val = 0, rc = -EINVAL; |
| 4299 | |
| 4300 | /* Sanity check on user data */ |
| 4301 | if (!isdigit(buf[0])) |
| 4302 | return -EINVAL; |
| 4303 | if (sscanf(buf, "%i", &val) != 1) |
| 4304 | return -EINVAL; |
| 4305 | if (val < 0) |
| 4306 | return -EINVAL; |
| 4307 | |
| 4308 | /* Request disabling virtual functions */ |
| 4309 | if (val == 0) { |
| 4310 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4311 | pci_disable_sriov(pdev); |
| 4312 | phba->cfg_sriov_nr_virtfn = 0; |
| 4313 | } |
| 4314 | return strlen(buf); |
| 4315 | } |
| 4316 | |
| 4317 | /* Request enabling virtual functions */ |
| 4318 | if (phba->cfg_sriov_nr_virtfn > 0) { |
| 4319 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4320 | "3018 There are %d virtual functions " |
| 4321 | "enabled on physical function.\n", |
| 4322 | phba->cfg_sriov_nr_virtfn); |
| 4323 | return -EEXIST; |
| 4324 | } |
| 4325 | |
| 4326 | if (val <= LPFC_MAX_VFN_PER_PFN) |
| 4327 | phba->cfg_sriov_nr_virtfn = val; |
| 4328 | else { |
| 4329 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 4330 | "3019 Enabling %d virtual functions is not " |
| 4331 | "allowed.\n", val); |
| 4332 | return -EINVAL; |
| 4333 | } |
| 4334 | |
| 4335 | rc = lpfc_sli_probe_sriov_nr_virtfn(phba, phba->cfg_sriov_nr_virtfn); |
| 4336 | if (rc) { |
| 4337 | phba->cfg_sriov_nr_virtfn = 0; |
| 4338 | rc = -EPERM; |
| 4339 | } else |
| 4340 | rc = strlen(buf); |
| 4341 | |
| 4342 | return rc; |
| 4343 | } |
| 4344 | |
James Smart | 0cfbbf2 | 2016-10-13 15:06:12 -0700 | [diff] [blame] | 4345 | LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN, |
| 4346 | "Enable PCIe device SR-IOV virtual fn"); |
| 4347 | |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4348 | lpfc_param_show(sriov_nr_virtfn) |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 4349 | static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, |
| 4350 | lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); |
| 4351 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4352 | /** |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 4353 | * lpfc_request_firmware_store - Request for Linux generic firmware upgrade |
| 4354 | * |
| 4355 | * @dev: class device that is converted into a Scsi_host. |
| 4356 | * @attr: device attribute, not used. |
| 4357 | * @buf: containing the string the number of vfs to be enabled. |
| 4358 | * @count: unused variable. |
| 4359 | * |
| 4360 | * Description: |
| 4361 | * |
| 4362 | * Returns: |
| 4363 | * length of the buf on success if val is in range the intended mode |
| 4364 | * is supported. |
| 4365 | * -EINVAL if val out of range or intended mode is not supported. |
| 4366 | **/ |
| 4367 | static ssize_t |
| 4368 | lpfc_request_firmware_upgrade_store(struct device *dev, |
| 4369 | struct device_attribute *attr, |
| 4370 | const char *buf, size_t count) |
| 4371 | { |
| 4372 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4373 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4374 | struct lpfc_hba *phba = vport->phba; |
| 4375 | int val = 0, rc = -EINVAL; |
| 4376 | |
| 4377 | /* Sanity check on user data */ |
| 4378 | if (!isdigit(buf[0])) |
| 4379 | return -EINVAL; |
| 4380 | if (sscanf(buf, "%i", &val) != 1) |
| 4381 | return -EINVAL; |
| 4382 | if (val != 1) |
| 4383 | return -EINVAL; |
| 4384 | |
| 4385 | rc = lpfc_sli4_request_firmware_update(phba, RUN_FW_UPGRADE); |
| 4386 | if (rc) |
| 4387 | rc = -EPERM; |
| 4388 | else |
| 4389 | rc = strlen(buf); |
| 4390 | return rc; |
| 4391 | } |
| 4392 | |
| 4393 | static int lpfc_req_fw_upgrade; |
| 4394 | module_param(lpfc_req_fw_upgrade, int, S_IRUGO|S_IWUSR); |
| 4395 | MODULE_PARM_DESC(lpfc_req_fw_upgrade, "Enable Linux generic firmware upgrade"); |
| 4396 | lpfc_param_show(request_firmware_upgrade) |
| 4397 | |
| 4398 | /** |
| 4399 | * lpfc_request_firmware_upgrade_init - Enable initial linux generic fw upgrade |
| 4400 | * @phba: lpfc_hba pointer. |
| 4401 | * @val: 0 or 1. |
| 4402 | * |
| 4403 | * Description: |
| 4404 | * Set the initial Linux generic firmware upgrade enable or disable flag. |
| 4405 | * |
| 4406 | * Returns: |
| 4407 | * zero if val saved. |
| 4408 | * -EINVAL val out of range |
| 4409 | **/ |
| 4410 | static int |
| 4411 | lpfc_request_firmware_upgrade_init(struct lpfc_hba *phba, int val) |
| 4412 | { |
| 4413 | if (val >= 0 && val <= 1) { |
| 4414 | phba->cfg_request_firmware_upgrade = val; |
| 4415 | return 0; |
| 4416 | } |
| 4417 | return -EINVAL; |
| 4418 | } |
| 4419 | static DEVICE_ATTR(lpfc_req_fw_upgrade, S_IRUGO | S_IWUSR, |
| 4420 | lpfc_request_firmware_upgrade_show, |
| 4421 | lpfc_request_firmware_upgrade_store); |
| 4422 | |
| 4423 | /** |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4424 | * lpfc_fcp_imax_store |
| 4425 | * |
| 4426 | * @dev: class device that is converted into a Scsi_host. |
| 4427 | * @attr: device attribute, not used. |
| 4428 | * @buf: string with the number of fast-path FCP interrupts per second. |
| 4429 | * @count: unused variable. |
| 4430 | * |
| 4431 | * Description: |
| 4432 | * If val is in a valid range [636,651042], then set the adapter's |
| 4433 | * maximum number of fast-path FCP interrupts per second. |
| 4434 | * |
| 4435 | * Returns: |
| 4436 | * length of the buf on success if val is in range the intended mode |
| 4437 | * is supported. |
| 4438 | * -EINVAL if val out of range or intended mode is not supported. |
| 4439 | **/ |
| 4440 | static ssize_t |
| 4441 | lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr, |
| 4442 | const char *buf, size_t count) |
| 4443 | { |
| 4444 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4445 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4446 | struct lpfc_hba *phba = vport->phba; |
| 4447 | int val = 0, i; |
| 4448 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4449 | /* fcp_imax is only valid for SLI4 */ |
| 4450 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 4451 | return -EINVAL; |
| 4452 | |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4453 | /* Sanity check on user data */ |
| 4454 | if (!isdigit(buf[0])) |
| 4455 | return -EINVAL; |
| 4456 | if (sscanf(buf, "%i", &val) != 1) |
| 4457 | return -EINVAL; |
| 4458 | |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4459 | /* |
| 4460 | * Value range for the HBA is [5000,5000000] |
| 4461 | * The value for each EQ depends on how many EQs are configured. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4462 | * Allow value == 0 |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4463 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4464 | if (val && (val < LPFC_MIN_IMAX || val > LPFC_MAX_IMAX)) |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4465 | return -EINVAL; |
| 4466 | |
| 4467 | phba->cfg_fcp_imax = (uint32_t)val; |
James Smart | 43140ca | 2017-03-04 09:30:34 -0800 | [diff] [blame] | 4468 | |
| 4469 | for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT) |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4470 | lpfc_modify_hba_eq_delay(phba, i); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4471 | |
| 4472 | return strlen(buf); |
| 4473 | } |
| 4474 | |
| 4475 | /* |
| 4476 | # 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] | 4477 | # for the HBA. |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4478 | # |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4479 | # 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] | 4480 | */ |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4481 | static int lpfc_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4482 | module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR); |
| 4483 | MODULE_PARM_DESC(lpfc_fcp_imax, |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4484 | "Set the maximum number of FCP interrupts per second per HBA"); |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4485 | lpfc_param_show(fcp_imax) |
| 4486 | |
| 4487 | /** |
| 4488 | * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable |
| 4489 | * @phba: lpfc_hba pointer. |
| 4490 | * @val: link speed value. |
| 4491 | * |
| 4492 | * Description: |
| 4493 | * If val is in a valid range [636,651042], then initialize the adapter's |
| 4494 | * maximum number of fast-path FCP interrupts per second. |
| 4495 | * |
| 4496 | * Returns: |
| 4497 | * zero if val saved. |
| 4498 | * -EINVAL val out of range |
| 4499 | **/ |
| 4500 | static int |
| 4501 | lpfc_fcp_imax_init(struct lpfc_hba *phba, int val) |
| 4502 | { |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4503 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4504 | phba->cfg_fcp_imax = 0; |
| 4505 | return 0; |
| 4506 | } |
| 4507 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4508 | if ((val >= LPFC_MIN_IMAX && val <= LPFC_MAX_IMAX) || |
| 4509 | (val == 0)) { |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4510 | phba->cfg_fcp_imax = val; |
| 4511 | return 0; |
| 4512 | } |
| 4513 | |
| 4514 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4515 | "3016 lpfc_fcp_imax: %d out of range, using default\n", |
| 4516 | val); |
James Smart | bf8dae8 | 2012-08-03 12:36:24 -0400 | [diff] [blame] | 4517 | phba->cfg_fcp_imax = LPFC_DEF_IMAX; |
James Smart | 173edbb | 2012-06-12 13:54:50 -0400 | [diff] [blame] | 4518 | |
| 4519 | return 0; |
| 4520 | } |
| 4521 | |
| 4522 | static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, |
| 4523 | lpfc_fcp_imax_show, lpfc_fcp_imax_store); |
| 4524 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4525 | /** |
| 4526 | * lpfc_state_show - Display current driver CPU affinity |
| 4527 | * @dev: class converted to a Scsi_host structure. |
| 4528 | * @attr: device attribute, not used. |
| 4529 | * @buf: on return contains text describing the state of the link. |
| 4530 | * |
| 4531 | * Returns: size of formatted string. |
| 4532 | **/ |
| 4533 | static ssize_t |
| 4534 | lpfc_fcp_cpu_map_show(struct device *dev, struct device_attribute *attr, |
| 4535 | char *buf) |
| 4536 | { |
| 4537 | struct Scsi_Host *shost = class_to_shost(dev); |
| 4538 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 4539 | struct lpfc_hba *phba = vport->phba; |
| 4540 | struct lpfc_vector_map_info *cpup; |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4541 | int len = 0; |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4542 | |
| 4543 | if ((phba->sli_rev != LPFC_SLI_REV4) || |
| 4544 | (phba->intr_type != MSIX)) |
| 4545 | return len; |
| 4546 | |
| 4547 | switch (phba->cfg_fcp_cpu_map) { |
| 4548 | case 0: |
| 4549 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4550 | "fcp_cpu_map: No mapping (%d)\n", |
| 4551 | phba->cfg_fcp_cpu_map); |
| 4552 | return len; |
| 4553 | case 1: |
| 4554 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4555 | "fcp_cpu_map: HBA centric mapping (%d): " |
| 4556 | "%d online CPUs\n", |
| 4557 | phba->cfg_fcp_cpu_map, |
| 4558 | phba->sli4_hba.num_online_cpu); |
| 4559 | break; |
| 4560 | case 2: |
| 4561 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4562 | "fcp_cpu_map: Driver centric mapping (%d): " |
| 4563 | "%d online CPUs\n", |
| 4564 | phba->cfg_fcp_cpu_map, |
| 4565 | phba->sli4_hba.num_online_cpu); |
| 4566 | break; |
| 4567 | } |
| 4568 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4569 | while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) { |
| 4570 | cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu]; |
| 4571 | |
| 4572 | /* margin should fit in this and the truncated message */ |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4573 | if (cpup->irq == LPFC_VECTOR_MAP_EMPTY) |
| 4574 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4575 | "CPU %02d io_chan %02d " |
| 4576 | "physid %d coreid %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4577 | phba->sli4_hba.curr_disp_cpu, |
| 4578 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4579 | cpup->core_id); |
| 4580 | else |
| 4581 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 4582 | "CPU %02d io_chan %02d " |
| 4583 | "physid %d coreid %d IRQ %d\n", |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4584 | phba->sli4_hba.curr_disp_cpu, |
| 4585 | cpup->channel_id, cpup->phys_id, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4586 | cpup->core_id, cpup->irq); |
| 4587 | |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4588 | phba->sli4_hba.curr_disp_cpu++; |
| 4589 | |
| 4590 | /* display max number of CPUs keeping some margin */ |
| 4591 | if (phba->sli4_hba.curr_disp_cpu < |
| 4592 | phba->sli4_hba.num_present_cpu && |
| 4593 | (len >= (PAGE_SIZE - 64))) { |
| 4594 | len += snprintf(buf + len, PAGE_SIZE-len, "more...\n"); |
| 4595 | break; |
| 4596 | } |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4597 | } |
James Smart | 76fd07a | 2014-02-20 09:57:18 -0500 | [diff] [blame] | 4598 | |
| 4599 | if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu) |
| 4600 | phba->sli4_hba.curr_disp_cpu = 0; |
| 4601 | |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4602 | return len; |
| 4603 | } |
| 4604 | |
| 4605 | /** |
| 4606 | * lpfc_fcp_cpu_map_store - Change CPU affinity of driver vectors |
| 4607 | * @dev: class device that is converted into a Scsi_host. |
| 4608 | * @attr: device attribute, not used. |
| 4609 | * @buf: one or more lpfc_polling_flags values. |
| 4610 | * @count: not used. |
| 4611 | * |
| 4612 | * Returns: |
| 4613 | * -EINVAL - Not implemented yet. |
| 4614 | **/ |
| 4615 | static ssize_t |
| 4616 | lpfc_fcp_cpu_map_store(struct device *dev, struct device_attribute *attr, |
| 4617 | const char *buf, size_t count) |
| 4618 | { |
| 4619 | int status = -EINVAL; |
| 4620 | return status; |
| 4621 | } |
| 4622 | |
| 4623 | /* |
| 4624 | # lpfc_fcp_cpu_map: Defines how to map CPUs to IRQ vectors |
| 4625 | # for the HBA. |
| 4626 | # |
| 4627 | # Value range is [0 to 2]. Default value is LPFC_DRIVER_CPU_MAP (2). |
| 4628 | # 0 - Do not affinitze IRQ vectors |
| 4629 | # 1 - Affintize HBA vectors with respect to each HBA |
| 4630 | # (start with CPU0 for each HBA) |
| 4631 | # 2 - Affintize HBA vectors with respect to the entire driver |
| 4632 | # (round robin thru all CPUs across all HBAs) |
| 4633 | */ |
| 4634 | static int lpfc_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4635 | module_param(lpfc_fcp_cpu_map, int, S_IRUGO|S_IWUSR); |
| 4636 | MODULE_PARM_DESC(lpfc_fcp_cpu_map, |
| 4637 | "Defines how to map CPUs to IRQ vectors per HBA"); |
| 4638 | |
| 4639 | /** |
| 4640 | * lpfc_fcp_cpu_map_init - Set the initial sr-iov virtual function enable |
| 4641 | * @phba: lpfc_hba pointer. |
| 4642 | * @val: link speed value. |
| 4643 | * |
| 4644 | * Description: |
| 4645 | * If val is in a valid range [0-2], then affinitze the adapter's |
| 4646 | * MSIX vectors. |
| 4647 | * |
| 4648 | * Returns: |
| 4649 | * zero if val saved. |
| 4650 | * -EINVAL val out of range |
| 4651 | **/ |
| 4652 | static int |
| 4653 | lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val) |
| 4654 | { |
| 4655 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 4656 | phba->cfg_fcp_cpu_map = 0; |
| 4657 | return 0; |
| 4658 | } |
| 4659 | |
| 4660 | if (val >= LPFC_MIN_CPU_MAP && val <= LPFC_MAX_CPU_MAP) { |
| 4661 | phba->cfg_fcp_cpu_map = val; |
| 4662 | return 0; |
| 4663 | } |
| 4664 | |
| 4665 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
James Smart | 6c86068 | 2016-10-13 15:06:13 -0700 | [diff] [blame] | 4666 | "3326 lpfc_fcp_cpu_map: %d out of range, using " |
| 4667 | "default\n", val); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 4668 | phba->cfg_fcp_cpu_map = LPFC_DRIVER_CPU_MAP; |
| 4669 | |
| 4670 | return 0; |
| 4671 | } |
| 4672 | |
| 4673 | static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, |
| 4674 | lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store); |
| 4675 | |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 4676 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4677 | # lpfc_fcp_class: Determines FC class to use for the FCP protocol. |
| 4678 | # Value range is [2,3]. Default value is 3. |
| 4679 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4680 | LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3, |
| 4681 | "Select Fibre Channel class of service for FCP sequences"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4682 | |
| 4683 | /* |
| 4684 | # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range |
| 4685 | # is [0,1]. Default value is 0. |
| 4686 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4687 | LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1, |
| 4688 | "Use ADISC on rediscovery to authenticate FCP devices"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4689 | |
| 4690 | /* |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 4691 | # lpfc_first_burst_size: First burst size to use on the NPorts |
| 4692 | # that support first burst. |
| 4693 | # Value range is [0,65536]. Default value is 0. |
| 4694 | */ |
| 4695 | LPFC_VPORT_ATTR_RW(first_burst_size, 0, 0, 65536, |
| 4696 | "First burst size for Targets that support first burst"); |
| 4697 | |
| 4698 | /* |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4699 | * lpfc_nvmet_fb_size: NVME Target mode supported first burst size. |
| 4700 | * When the driver is configured as an NVME target, this value is |
| 4701 | * communicated to the NVME initiator in the PRLI response. It is |
| 4702 | * used only when the lpfc_nvme_enable_fb and lpfc_nvmet_support |
| 4703 | * parameters are set and the target is sending the PRLI RSP. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4704 | * Parameter supported on physical port only - no NPIV support. |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4705 | * Value range is [0,65536]. Default value is 0. |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4706 | */ |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4707 | LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, |
| 4708 | "NVME Target mode first burst size in 512B increments."); |
| 4709 | |
| 4710 | /* |
| 4711 | * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions. |
| 4712 | * For the Initiator (I), enabling this parameter means that an NVMET |
| 4713 | * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be |
| 4714 | * processed by the initiator for subsequent NVME FCP IO. For the target |
| 4715 | * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size |
| 4716 | * driver parameter as the target function's first burst size returned to the |
| 4717 | * initiator in the target's NVME PRLI response. Parameter supported on physical |
| 4718 | * port only - no NPIV support. |
| 4719 | * Value range is [0,1]. Default value is 0 (disabled). |
| 4720 | */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4721 | LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1, |
| 4722 | "Enable First Burst feature on I and T functions."); |
| 4723 | |
| 4724 | /* |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4725 | # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue |
| 4726 | # depth. Default value is 0. When the value of this parameter is zero the |
| 4727 | # SCSI command completion time is not used for controlling I/O queue depth. When |
| 4728 | # the parameter is set to a non-zero value, the I/O queue depth is controlled |
| 4729 | # to limit the I/O completion time to the parameter value. |
| 4730 | # The value is set in milliseconds. |
| 4731 | */ |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 4732 | LPFC_VPORT_ATTR(max_scsicmpl_time, 0, 0, 60000, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4733 | "Use command completion time to control queue depth"); |
James Smart | ed5b152 | 2016-10-13 15:06:11 -0700 | [diff] [blame] | 4734 | |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4735 | lpfc_vport_param_show(max_scsicmpl_time); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4736 | static int |
| 4737 | lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) |
| 4738 | { |
| 4739 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4740 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 4741 | |
| 4742 | if (val == vport->cfg_max_scsicmpl_time) |
| 4743 | return 0; |
| 4744 | if ((val < 0) || (val > 60000)) |
| 4745 | return -EINVAL; |
| 4746 | vport->cfg_max_scsicmpl_time = val; |
| 4747 | |
| 4748 | spin_lock_irq(shost->host_lock); |
| 4749 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 4750 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4751 | continue; |
| 4752 | if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) |
| 4753 | continue; |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 4754 | ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 4755 | } |
| 4756 | spin_unlock_irq(shost->host_lock); |
| 4757 | return 0; |
| 4758 | } |
| 4759 | lpfc_vport_param_store(max_scsicmpl_time); |
| 4760 | static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, |
| 4761 | lpfc_max_scsicmpl_time_show, |
| 4762 | lpfc_max_scsicmpl_time_store); |
| 4763 | |
| 4764 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4765 | # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value |
| 4766 | # range is [0,1]. Default value is 0. |
| 4767 | */ |
| 4768 | LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); |
| 4769 | |
| 4770 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4771 | * lpfc_io_sched: Determine scheduling algrithmn for issuing FCP cmds |
| 4772 | * range is [0,1]. Default value is 0. |
| 4773 | * For [0], FCP commands are issued to Work Queues ina round robin fashion. |
| 4774 | * For [1], FCP commands are issued to a Work Queue associated with the |
| 4775 | * current CPU. |
| 4776 | * |
| 4777 | * LPFC_FCP_SCHED_ROUND_ROBIN == 0 |
| 4778 | * LPFC_FCP_SCHED_BY_CPU == 1 |
| 4779 | * |
| 4780 | * The driver dynamically sets this to 1 (BY_CPU) if it's able to set up cpu |
| 4781 | * affinity for FCP/NVME I/Os through Work Queues associated with the current |
| 4782 | * CPU. Otherwise, the default 0 (Round Robin) scheduling of FCP/NVME I/Os |
| 4783 | * through WQs will be used. |
| 4784 | */ |
| 4785 | LPFC_ATTR_RW(fcp_io_sched, LPFC_FCP_SCHED_ROUND_ROBIN, |
| 4786 | LPFC_FCP_SCHED_ROUND_ROBIN, |
| 4787 | LPFC_FCP_SCHED_BY_CPU, |
| 4788 | "Determine scheduling algorithm for " |
| 4789 | "issuing commands [0] - Round Robin, [1] - Current CPU"); |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 4790 | |
| 4791 | /* |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 4792 | # lpfc_fcp2_no_tgt_reset: Determine bus reset behavior |
| 4793 | # range is [0,1]. Default value is 0. |
| 4794 | # For [0], bus reset issues target reset to ALL devices |
| 4795 | # For [1], bus reset issues target reset to non-FCP2 devices |
| 4796 | */ |
| 4797 | LPFC_ATTR_RW(fcp2_no_tgt_reset, 0, 0, 1, "Determine bus reset behavior for " |
| 4798 | "FCP2 devices [0] - issue tgt reset, [1] - no tgt reset"); |
| 4799 | |
| 4800 | |
| 4801 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4802 | # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing |
| 4803 | # cr_delay (msec) or cr_count outstanding commands. cr_delay can take |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 4804 | # 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] | 4805 | # is 0. Default value of cr_count is 1. The cr_count feature is disabled if |
| 4806 | # cr_delay is set to 0. |
| 4807 | */ |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4808 | 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] | 4809 | "interrupt response is generated"); |
| 4810 | |
Jamie Wellnitz | 8189fd1 | 2006-02-28 19:25:35 -0500 | [diff] [blame] | 4811 | 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] | 4812 | "interrupt response is generated"); |
| 4813 | |
| 4814 | /* |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 4815 | # lpfc_multi_ring_support: Determines how many rings to spread available |
| 4816 | # cmd/rsp IOCB entries across. |
| 4817 | # Value range is [1,2]. Default value is 1. |
| 4818 | */ |
| 4819 | LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary " |
| 4820 | "SLI rings to spread IOCB entries across"); |
| 4821 | |
| 4822 | /* |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4823 | # lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this |
| 4824 | # identifies what rctl value to configure the additional ring for. |
| 4825 | # Value range is [1,0xff]. Default value is 4 (Unsolicated Data). |
| 4826 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4827 | LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4828 | 255, "Identifies RCTL for additional ring configuration"); |
| 4829 | |
| 4830 | /* |
| 4831 | # lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this |
| 4832 | # identifies what type value to configure the additional ring for. |
| 4833 | # Value range is [1,0xff]. Default value is 5 (LLC/SNAP). |
| 4834 | */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 4835 | LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1, |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 4836 | 255, "Identifies TYPE for additional ring configuration"); |
| 4837 | |
| 4838 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4839 | # lpfc_enable_SmartSAN: Sets up FDMI support for SmartSAN |
| 4840 | # 0 = SmartSAN functionality disabled (default) |
| 4841 | # 1 = SmartSAN functionality enabled |
| 4842 | # This parameter will override the value of lpfc_fdmi_on module parameter. |
| 4843 | # Value range is [0,1]. Default value is 0. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4844 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4845 | LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality"); |
| 4846 | |
| 4847 | /* |
| 4848 | # lpfc_fdmi_on: Controls FDMI support. |
| 4849 | # 0 No FDMI support (default) |
| 4850 | # 1 Traditional FDMI support |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4851 | # Traditional FDMI support means the driver will assume FDMI-2 support; |
| 4852 | # however, if that fails, it will fallback to FDMI-1. |
| 4853 | # If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. |
| 4854 | # If lpfc_enable_SmartSAN is set 0, the driver uses the current value of |
| 4855 | # lpfc_fdmi_on. |
| 4856 | # Value range [0,1]. Default value is 0. |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 4857 | */ |
James Smart | 8663cbb | 2016-03-31 14:12:33 -0700 | [diff] [blame] | 4858 | LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4859 | |
| 4860 | /* |
| 4861 | # Specifies the maximum number of ELS cmds we can have outstanding (for |
| 4862 | # discovery). Value range is [1,64]. Default value = 32. |
| 4863 | */ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4864 | LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4865 | "during discovery"); |
| 4866 | |
| 4867 | /* |
James Smart | c4a7c92 | 2013-05-31 17:04:59 -0400 | [diff] [blame] | 4868 | # lpfc_max_luns: maximum allowed LUN ID. This is the highest LUN ID that |
| 4869 | # will be scanned by the SCSI midlayer when sequential scanning is |
| 4870 | # used; and is also the highest LUN ID allowed when the SCSI midlayer |
| 4871 | # parses REPORT_LUN responses. The lpfc driver has no LUN count or |
| 4872 | # LUN ID limit, but the SCSI midlayer requires this field for the uses |
| 4873 | # above. The lpfc driver limits the default value to 255 for two reasons. |
| 4874 | # As it bounds the sequential scan loop, scanning for thousands of luns |
| 4875 | # on a target can take minutes of wall clock time. Additionally, |
| 4876 | # there are FC targets, such as JBODs, that only recognize 8-bits of |
| 4877 | # LUN ID. When they receive a value greater than 8 bits, they chop off |
| 4878 | # the high order bits. In other words, they see LUN IDs 0, 256, 512, |
| 4879 | # and so on all as LUN ID 0. This causes the linux kernel, which sees |
| 4880 | # valid responses at each of the LUN IDs, to believe there are multiple |
| 4881 | # devices present, when in fact, there is only 1. |
| 4882 | # A customer that is aware of their target behaviors, and the results as |
| 4883 | # indicated above, is welcome to increase the lpfc_max_luns value. |
| 4884 | # As mentioned, this value is not used by the lpfc driver, only the |
| 4885 | # SCSI midlayer. |
James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 4886 | # Value range is [0,65535]. Default value is 255. |
| 4887 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4888 | */ |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 4889 | LPFC_VPORT_ULL_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN ID"); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4890 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 4891 | /* |
| 4892 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
| 4893 | # Value range is [1,255], default value is 10. |
| 4894 | */ |
| 4895 | LPFC_ATTR_RW(poll_tmo, 10, 1, 255, |
| 4896 | "Milliseconds driver will wait between polling FCP ring"); |
| 4897 | |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4898 | /* |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 4899 | # lpfc_task_mgmt_tmo: Maximum time to wait for task management commands |
| 4900 | # to complete in seconds. Value range is [5,180], default value is 60. |
| 4901 | */ |
| 4902 | LPFC_ATTR_RW(task_mgmt_tmo, 60, 5, 180, |
| 4903 | "Maximum time to wait for task management commands to complete"); |
| 4904 | /* |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4905 | # lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that |
| 4906 | # support this feature |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4907 | # 0 = MSI disabled |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4908 | # 1 = MSI enabled |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4909 | # 2 = MSI-X enabled (default) |
| 4910 | # Value range is [0,2]. Default value is 2. |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4911 | */ |
George Kadianakis | 8605c46 | 2010-01-17 21:19:31 +0200 | [diff] [blame] | 4912 | 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] | 4913 | "MSI-X (2), if possible"); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 4914 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4915 | /* |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 4916 | * lpfc_nvme_oas: Use the oas bit when sending NVME/NVMET IOs |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4917 | * |
| 4918 | * 0 = NVME OAS disabled |
| 4919 | * 1 = NVME OAS enabled |
| 4920 | * |
| 4921 | * Value range is [0,1]. Default value is 0. |
| 4922 | */ |
| 4923 | LPFC_ATTR_RW(nvme_oas, 0, 0, 1, |
| 4924 | "Use OAS bit on NVME IOs"); |
| 4925 | |
| 4926 | /* |
| 4927 | * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver |
| 4928 | * will advertise it supports to the SCSI layer. This also will map to |
| 4929 | * the number of WQs the driver will create. |
| 4930 | * |
| 4931 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 4932 | * 1,32 = Manually specify how many io channels to use. |
| 4933 | * |
| 4934 | * Value range is [0,32]. Default value is 4. |
| 4935 | */ |
| 4936 | LPFC_ATTR_R(fcp_io_channel, |
| 4937 | LPFC_FCP_IO_CHAN_DEF, |
| 4938 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4939 | "Set the number of FCP I/O channels"); |
| 4940 | |
| 4941 | /* |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4942 | * lpfc_nvme_io_channel: Set the number of IO hardware queues the driver |
| 4943 | * will advertise it supports to the NVME layer. This also will map to |
| 4944 | * the number of WQs the driver will create. |
| 4945 | * |
| 4946 | * This module parameter is valid when lpfc_enable_fc4_type is set |
| 4947 | * to support NVME. |
| 4948 | * |
| 4949 | * The NVME Layer will try to create this many, plus 1 administrative |
| 4950 | * hardware queue. The administrative queue will always map to WQ 0 |
| 4951 | * A hardware IO queue maps (qidx) to a specific driver WQ. |
| 4952 | * |
| 4953 | * 0 = Configure the number of io channels to the number of active CPUs. |
| 4954 | * 1,32 = Manually specify how many io channels to use. |
| 4955 | * |
| 4956 | * Value range is [0,32]. Default value is 0. |
| 4957 | */ |
| 4958 | LPFC_ATTR_R(nvme_io_channel, |
| 4959 | LPFC_NVME_IO_CHAN_DEF, |
| 4960 | LPFC_HBA_IO_CHAN_MIN, LPFC_HBA_IO_CHAN_MAX, |
| 4961 | "Set the number of NVME I/O channels"); |
| 4962 | |
| 4963 | /* |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4964 | # lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware. |
| 4965 | # 0 = HBA resets disabled |
| 4966 | # 1 = HBA resets enabled (default) |
| 4967 | # Value range is [0,1]. Default value is 1. |
| 4968 | */ |
| 4969 | 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] | 4970 | |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4971 | /* |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4972 | # lpfc_enable_hba_heartbeat: Disable HBA heartbeat timer.. |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 4973 | # 0 = HBA Heartbeat disabled |
| 4974 | # 1 = HBA Heartbeat enabled (default) |
| 4975 | # Value range is [0,1]. Default value is 1. |
| 4976 | */ |
James Smart | eb7a339 | 2010-11-20 23:12:02 -0500 | [diff] [blame] | 4977 | LPFC_ATTR_R(enable_hba_heartbeat, 0, 0, 1, "Enable HBA Heartbeat."); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4978 | |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 4979 | /* |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4980 | # lpfc_EnableXLane: Enable Express Lane Feature |
| 4981 | # 0x0 Express Lane Feature disabled |
| 4982 | # 0x1 Express Lane Feature enabled |
| 4983 | # Value range is [0,1]. Default value is 0. |
| 4984 | */ |
| 4985 | LPFC_ATTR_R(EnableXLane, 0, 0, 1, "Enable Express Lane Feature."); |
| 4986 | |
| 4987 | /* |
| 4988 | # lpfc_XLanePriority: Define CS_CTL priority for Express Lane Feature |
| 4989 | # 0x0 - 0x7f = CS_CTL field in FC header (high 7 bits) |
| 4990 | # Value range is [0x0,0x7f]. Default value is 0 |
| 4991 | */ |
James Smart | 28d7f3d | 2014-05-21 08:05:28 -0400 | [diff] [blame] | 4992 | 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] | 4993 | |
| 4994 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 4995 | # lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF) |
| 4996 | # 0 = BlockGuard disabled (default) |
| 4997 | # 1 = BlockGuard enabled |
| 4998 | # Value range is [0,1]. Default value is 0. |
| 4999 | */ |
| 5000 | LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); |
| 5001 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5002 | /* |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5003 | # lpfc_fcp_look_ahead: Look ahead for completions in FCP start routine |
| 5004 | # 0 = disabled (default) |
| 5005 | # 1 = enabled |
| 5006 | # Value range is [0,1]. Default value is 0. |
James Smart | 5688d67 | 2013-04-17 20:17:13 -0400 | [diff] [blame] | 5007 | # |
| 5008 | # This feature in under investigation and may be supported in the future. |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5009 | */ |
| 5010 | unsigned int lpfc_fcp_look_ahead = LPFC_LOOK_AHEAD_OFF; |
| 5011 | |
James Smart | ba20c85 | 2012-08-03 12:36:52 -0400 | [diff] [blame] | 5012 | /* |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5013 | # lpfc_prot_mask: i |
| 5014 | # - Bit mask of host protection capabilities used to register with the |
| 5015 | # SCSI mid-layer |
| 5016 | # - Only meaningful if BG is turned on (lpfc_enable_bg=1). |
| 5017 | # - Allows you to ultimately specify which profiles to use |
| 5018 | # - Default will result in registering capabilities for all profiles. |
James Smart | 005ffa7 | 2012-09-29 11:29:17 -0400 | [diff] [blame] | 5019 | # - SHOST_DIF_TYPE1_PROTECTION 1 |
| 5020 | # HBA supports T10 DIF Type 1: HBA to Target Type 1 Protection |
| 5021 | # - SHOST_DIX_TYPE0_PROTECTION 8 |
| 5022 | # HBA supports DIX Type 0: Host to HBA protection only |
| 5023 | # - SHOST_DIX_TYPE1_PROTECTION 16 |
| 5024 | # HBA supports DIX Type 1: Host to HBA Type 1 protection |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5025 | # |
| 5026 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5027 | LPFC_ATTR(prot_mask, |
| 5028 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5029 | SHOST_DIX_TYPE0_PROTECTION | |
| 5030 | SHOST_DIX_TYPE1_PROTECTION), |
| 5031 | 0, |
| 5032 | (SHOST_DIF_TYPE1_PROTECTION | |
| 5033 | SHOST_DIX_TYPE0_PROTECTION | |
| 5034 | SHOST_DIX_TYPE1_PROTECTION), |
| 5035 | "T10-DIF host protection capabilities mask"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5036 | |
| 5037 | /* |
| 5038 | # lpfc_prot_guard: i |
| 5039 | # - 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] | 5040 | # - Guard types are currently either 1) T10-DIF CRC 2) IP checksum |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5041 | # - Allows you to ultimately specify which profiles to use |
| 5042 | # - Default will result in registering capabilities for all guard types |
| 5043 | # |
| 5044 | */ |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 5045 | LPFC_ATTR(prot_guard, |
| 5046 | SHOST_DIX_GUARD_IP, SHOST_DIX_GUARD_CRC, SHOST_DIX_GUARD_IP, |
| 5047 | "T10-DIF host protection guard type"); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5048 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 5049 | /* |
| 5050 | * Delay initial NPort discovery when Clean Address bit is cleared in |
| 5051 | * FLOGI/FDISC accept and FCID/Fabric name/Fabric portname is changed. |
| 5052 | * This parameter can have value 0 or 1. |
| 5053 | * When this parameter is set to 0, no delay is added to the initial |
| 5054 | * discovery. |
| 5055 | * When this parameter is set to non-zero value, initial Nport discovery is |
| 5056 | * delayed by ra_tov seconds when Clean Address bit is cleared in FLOGI/FDISC |
| 5057 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5058 | * Driver always delay Nport discovery for subsequent FLOGI/FDISC completion |
| 5059 | * when Clean Address bit is cleared in FLOGI/FDISC |
| 5060 | * accept and FCID/Fabric name/Fabric portname is changed. |
| 5061 | * Default value is 0. |
| 5062 | */ |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 5063 | LPFC_ATTR(delay_discovery, 0, 0, 1, |
| 5064 | "Delay NPort discovery when Clean Address bit is cleared."); |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5065 | |
| 5066 | /* |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5067 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5068 | * This value can be set to values between 64 and 4096. The default value is |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5069 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
| 5070 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5071 | * Because of the additional overhead involved in setting up T10-DIF, |
| 5072 | * this parameter will be limited to 128 if BlockGuard is enabled under SLI4 |
| 5073 | * and will be limited to 512 if BlockGuard is enabled under SLI3. |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 5074 | */ |
| 5075 | LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, |
| 5076 | LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); |
| 5077 | |
James Smart | 96f7077 | 2013-04-17 20:16:15 -0400 | [diff] [blame] | 5078 | /* |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5079 | * lpfc_enable_mds_diags: Enable MDS Diagnostics |
| 5080 | * 0 = MDS Diagnostics disabled (default) |
| 5081 | * 1 = MDS Diagnostics enabled |
| 5082 | * Value range is [0,1]. Default value is 0. |
| 5083 | */ |
| 5084 | LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics"); |
| 5085 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5086 | struct device_attribute *lpfc_hba_attrs[] = { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5087 | &dev_attr_nvme_info, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5088 | &dev_attr_bg_info, |
| 5089 | &dev_attr_bg_guard_err, |
| 5090 | &dev_attr_bg_apptag_err, |
| 5091 | &dev_attr_bg_reftag_err, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5092 | &dev_attr_info, |
| 5093 | &dev_attr_serialnum, |
| 5094 | &dev_attr_modeldesc, |
| 5095 | &dev_attr_modelname, |
| 5096 | &dev_attr_programtype, |
| 5097 | &dev_attr_portnum, |
| 5098 | &dev_attr_fwrev, |
| 5099 | &dev_attr_hdw, |
| 5100 | &dev_attr_option_rom_version, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5101 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5102 | &dev_attr_num_discovered_ports, |
James Smart | 84774a4 | 2008-08-24 21:50:06 -0400 | [diff] [blame] | 5103 | &dev_attr_menlo_mgmt_mode, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5104 | &dev_attr_lpfc_drvr_version, |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 5105 | &dev_attr_lpfc_enable_fip, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5106 | &dev_attr_lpfc_temp_sensor, |
| 5107 | &dev_attr_lpfc_log_verbose, |
| 5108 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5109 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5110 | &dev_attr_lpfc_hba_queue_depth, |
| 5111 | &dev_attr_lpfc_peer_port_login, |
| 5112 | &dev_attr_lpfc_nodev_tmo, |
| 5113 | &dev_attr_lpfc_devloss_tmo, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5114 | &dev_attr_lpfc_enable_fc4_type, |
| 5115 | &dev_attr_lpfc_xri_split, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5116 | &dev_attr_lpfc_fcp_class, |
| 5117 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5118 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5119 | &dev_attr_lpfc_ack0, |
| 5120 | &dev_attr_lpfc_topology, |
| 5121 | &dev_attr_lpfc_scan_down, |
| 5122 | &dev_attr_lpfc_link_speed, |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 5123 | &dev_attr_lpfc_fcp_io_sched, |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 5124 | &dev_attr_lpfc_fcp2_no_tgt_reset, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5125 | &dev_attr_lpfc_cr_delay, |
| 5126 | &dev_attr_lpfc_cr_count, |
| 5127 | &dev_attr_lpfc_multi_ring_support, |
| 5128 | &dev_attr_lpfc_multi_ring_rctl, |
| 5129 | &dev_attr_lpfc_multi_ring_type, |
| 5130 | &dev_attr_lpfc_fdmi_on, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 5131 | &dev_attr_lpfc_enable_SmartSAN, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5132 | &dev_attr_lpfc_max_luns, |
| 5133 | &dev_attr_lpfc_enable_npiv, |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 5134 | &dev_attr_lpfc_fcf_failover_policy, |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5135 | &dev_attr_lpfc_enable_rrq, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5136 | &dev_attr_nport_evt_cnt, |
| 5137 | &dev_attr_board_mode, |
| 5138 | &dev_attr_max_vpi, |
| 5139 | &dev_attr_used_vpi, |
| 5140 | &dev_attr_max_rpi, |
| 5141 | &dev_attr_used_rpi, |
| 5142 | &dev_attr_max_xri, |
| 5143 | &dev_attr_used_xri, |
| 5144 | &dev_attr_npiv_info, |
| 5145 | &dev_attr_issue_reset, |
| 5146 | &dev_attr_lpfc_poll, |
| 5147 | &dev_attr_lpfc_poll_tmo, |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 5148 | &dev_attr_lpfc_task_mgmt_tmo, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5149 | &dev_attr_lpfc_use_msi, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5150 | &dev_attr_lpfc_nvme_oas, |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 5151 | &dev_attr_lpfc_fcp_imax, |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 5152 | &dev_attr_lpfc_fcp_cpu_map, |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 5153 | &dev_attr_lpfc_fcp_io_channel, |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 5154 | &dev_attr_lpfc_suppress_rsp, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5155 | &dev_attr_lpfc_nvme_io_channel, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5156 | &dev_attr_lpfc_nvmet_mrq, |
| 5157 | &dev_attr_lpfc_nvmet_mrq_post, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 5158 | &dev_attr_lpfc_nvme_enable_fb, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 5159 | &dev_attr_lpfc_nvmet_fb_size, |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 5160 | &dev_attr_lpfc_enable_bg, |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 5161 | &dev_attr_lpfc_soft_wwnn, |
| 5162 | &dev_attr_lpfc_soft_wwpn, |
| 5163 | &dev_attr_lpfc_soft_wwn_enable, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5164 | &dev_attr_lpfc_enable_hba_reset, |
| 5165 | &dev_attr_lpfc_enable_hba_heartbeat, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5166 | &dev_attr_lpfc_EnableXLane, |
| 5167 | &dev_attr_lpfc_XLanePriority, |
| 5168 | &dev_attr_lpfc_xlane_lun, |
| 5169 | &dev_attr_lpfc_xlane_tgt, |
| 5170 | &dev_attr_lpfc_xlane_vpt, |
| 5171 | &dev_attr_lpfc_xlane_lun_state, |
| 5172 | &dev_attr_lpfc_xlane_lun_status, |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 5173 | &dev_attr_lpfc_xlane_priority, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5174 | &dev_attr_lpfc_sg_seg_cnt, |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 5175 | &dev_attr_lpfc_max_scsicmpl_time, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5176 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 5177 | &dev_attr_lpfc_aer_support, |
| 5178 | &dev_attr_lpfc_aer_state_cleanup, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5179 | &dev_attr_lpfc_sriov_nr_virtfn, |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 5180 | &dev_attr_lpfc_req_fw_upgrade, |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 5181 | &dev_attr_lpfc_suppress_link_up, |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5182 | &dev_attr_lpfc_iocb_cnt, |
| 5183 | &dev_attr_iocb_hw, |
| 5184 | &dev_attr_txq_hw, |
| 5185 | &dev_attr_txcmplq_hw, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5186 | &dev_attr_lpfc_fips_level, |
| 5187 | &dev_attr_lpfc_fips_rev, |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 5188 | &dev_attr_lpfc_dss, |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 5189 | &dev_attr_lpfc_sriov_hw_max_virtfn, |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5190 | &dev_attr_protocol, |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 5191 | &dev_attr_lpfc_xlane_supported, |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 5192 | &dev_attr_lpfc_enable_mds_diags, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5193 | NULL, |
| 5194 | }; |
| 5195 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5196 | struct device_attribute *lpfc_vport_attrs[] = { |
| 5197 | &dev_attr_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 5198 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5199 | &dev_attr_num_discovered_ports, |
| 5200 | &dev_attr_lpfc_drvr_version, |
| 5201 | &dev_attr_lpfc_log_verbose, |
| 5202 | &dev_attr_lpfc_lun_queue_depth, |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 5203 | &dev_attr_lpfc_tgt_queue_depth, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5204 | &dev_attr_lpfc_nodev_tmo, |
| 5205 | &dev_attr_lpfc_devloss_tmo, |
| 5206 | &dev_attr_lpfc_hba_queue_depth, |
| 5207 | &dev_attr_lpfc_peer_port_login, |
| 5208 | &dev_attr_lpfc_restrict_login, |
| 5209 | &dev_attr_lpfc_fcp_class, |
| 5210 | &dev_attr_lpfc_use_adisc, |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 5211 | &dev_attr_lpfc_first_burst_size, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5212 | &dev_attr_lpfc_max_luns, |
| 5213 | &dev_attr_nport_evt_cnt, |
| 5214 | &dev_attr_npiv_info, |
| 5215 | &dev_attr_lpfc_enable_da_id, |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5216 | &dev_attr_lpfc_max_scsicmpl_time, |
| 5217 | &dev_attr_lpfc_stat_data_ctrl, |
James Smart | 21e9a0a | 2009-05-22 14:53:21 -0400 | [diff] [blame] | 5218 | &dev_attr_lpfc_static_vport, |
James Smart | bc73905 | 2010-08-04 16:11:18 -0400 | [diff] [blame] | 5219 | &dev_attr_lpfc_fips_level, |
| 5220 | &dev_attr_lpfc_fips_rev, |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5221 | NULL, |
| 5222 | }; |
| 5223 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5224 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5225 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5226 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5227 | * @kobj: kernel kobject that contains the kernel class device. |
| 5228 | * @bin_attr: kernel attributes passed to us. |
| 5229 | * @buf: contains the data to be written to the adapter IOREG space. |
| 5230 | * @off: offset into buffer to beginning of data. |
| 5231 | * @count: bytes to transfer. |
| 5232 | * |
| 5233 | * Description: |
| 5234 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5235 | * Uses the adapter io control registers to send buf contents to the adapter. |
| 5236 | * |
| 5237 | * Returns: |
| 5238 | * -ERANGE off and count combo out of range |
| 5239 | * -EINVAL off, count or buff address invalid |
| 5240 | * -EPERM adapter is offline |
| 5241 | * value of count, buf contents written |
| 5242 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5243 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5244 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
| 5245 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5246 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5247 | { |
| 5248 | size_t buf_off; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5249 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5250 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5251 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5252 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5253 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5254 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5255 | return -EPERM; |
| 5256 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5257 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5258 | return -ERANGE; |
| 5259 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5260 | if (count <= LPFC_REG_WRITE_KEY_SIZE) |
| 5261 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5262 | |
| 5263 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5264 | return -EINVAL; |
| 5265 | |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5266 | /* This is to protect HBA registers from accidental writes. */ |
| 5267 | if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) |
| 5268 | return -EINVAL; |
| 5269 | |
| 5270 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5271 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5272 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5273 | spin_lock_irq(&phba->hbalock); |
James Smart | f7a919b | 2011-08-21 21:49:16 -0400 | [diff] [blame] | 5274 | for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE; |
| 5275 | buf_off += sizeof(uint32_t)) |
| 5276 | writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)), |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5277 | phba->ctrl_regs_memmap_p + off + buf_off); |
| 5278 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5279 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5280 | |
| 5281 | return count; |
| 5282 | } |
| 5283 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5284 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5285 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5286 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5287 | * @kobj: kernel kobject that contains the kernel class device. |
| 5288 | * @bin_attr: kernel attributes passed to us. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5289 | * @buf: if successful contains the data from the adapter IOREG space. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5290 | * @off: offset into buffer to beginning of data. |
| 5291 | * @count: bytes to transfer. |
| 5292 | * |
| 5293 | * Description: |
| 5294 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. |
| 5295 | * Uses the adapter io control registers to read data into buf. |
| 5296 | * |
| 5297 | * Returns: |
| 5298 | * -ERANGE off and count combo out of range |
| 5299 | * -EINVAL off, count or buff address invalid |
| 5300 | * value of count, buf contents read |
| 5301 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5302 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5303 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
| 5304 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5305 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5306 | { |
| 5307 | size_t buf_off; |
| 5308 | uint32_t * tmp_ptr; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5309 | struct device *dev = container_of(kobj, struct device, kobj); |
| 5310 | struct Scsi_Host *shost = class_to_shost(dev); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5311 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5312 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5313 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 5314 | if (phba->sli_rev >= LPFC_SLI_REV4) |
| 5315 | return -EPERM; |
| 5316 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5317 | if (off > FF_REG_AREA_SIZE) |
| 5318 | return -ERANGE; |
| 5319 | |
| 5320 | if ((off + count) > FF_REG_AREA_SIZE) |
| 5321 | count = FF_REG_AREA_SIZE - off; |
| 5322 | |
| 5323 | if (count == 0) return 0; |
| 5324 | |
| 5325 | if (off % 4 || count % 4 || (unsigned long)buf % 4) |
| 5326 | return -EINVAL; |
| 5327 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5328 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5329 | |
| 5330 | for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) { |
| 5331 | tmp_ptr = (uint32_t *)(buf + buf_off); |
| 5332 | *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off); |
| 5333 | } |
| 5334 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5335 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5336 | |
| 5337 | return count; |
| 5338 | } |
| 5339 | |
| 5340 | static struct bin_attribute sysfs_ctlreg_attr = { |
| 5341 | .attr = { |
| 5342 | .name = "ctlreg", |
| 5343 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5344 | }, |
| 5345 | .size = 256, |
| 5346 | .read = sysfs_ctlreg_read, |
| 5347 | .write = sysfs_ctlreg_write, |
| 5348 | }; |
| 5349 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5350 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5351 | * sysfs_mbox_write - Write method for writing information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5352 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5353 | * @kobj: kernel kobject that contains the kernel class device. |
| 5354 | * @bin_attr: kernel attributes passed to us. |
| 5355 | * @buf: contains the data to be written to sysfs mbox. |
| 5356 | * @off: offset into buffer to beginning of data. |
| 5357 | * @count: bytes to transfer. |
| 5358 | * |
| 5359 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5360 | * Deprecated function. All mailbox access from user space is performed via the |
| 5361 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5362 | * |
| 5363 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5364 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5365 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5366 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5367 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
| 5368 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5369 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5370 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5371 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5372 | } |
| 5373 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5374 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5375 | * sysfs_mbox_read - Read method for reading information via mbox |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5376 | * @filp: open sysfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5377 | * @kobj: kernel kobject that contains the kernel class device. |
| 5378 | * @bin_attr: kernel attributes passed to us. |
| 5379 | * @buf: contains the data to be read from sysfs mbox. |
| 5380 | * @off: offset into buffer to beginning of data. |
| 5381 | * @count: bytes to transfer. |
| 5382 | * |
| 5383 | * Description: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5384 | * Deprecated function. All mailbox access from user space is performed via the |
| 5385 | * bsg interface. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5386 | * |
| 5387 | * Returns: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5388 | * -EPERM operation not permitted |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5389 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5390 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 5391 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
| 5392 | struct bin_attribute *bin_attr, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 5393 | char *buf, loff_t off, size_t count) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5394 | { |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5395 | return -EPERM; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5396 | } |
| 5397 | |
| 5398 | static struct bin_attribute sysfs_mbox_attr = { |
| 5399 | .attr = { |
| 5400 | .name = "mbox", |
| 5401 | .mode = S_IRUSR | S_IWUSR, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5402 | }, |
James Smart | c0c1151 | 2011-05-24 11:41:34 -0400 | [diff] [blame] | 5403 | .size = MAILBOX_SYSFS_MAX, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5404 | .read = sysfs_mbox_read, |
| 5405 | .write = sysfs_mbox_write, |
| 5406 | }; |
| 5407 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5408 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5409 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5410 | * @vport: address of lpfc vport structure. |
| 5411 | * |
| 5412 | * Return codes: |
| 5413 | * zero on success |
| 5414 | * error return code from sysfs_create_bin_file() |
| 5415 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5416 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5417 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5418 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5419 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5420 | int error; |
| 5421 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5422 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5423 | &sysfs_drvr_stat_data_attr); |
| 5424 | |
| 5425 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5426 | if (error || vport->port_type == LPFC_NPIV_PORT) |
| 5427 | goto out; |
| 5428 | |
| 5429 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5430 | &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5431 | if (error) |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5432 | goto out_remove_stat_attr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5433 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5434 | error = sysfs_create_bin_file(&shost->shost_dev.kobj, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5435 | &sysfs_mbox_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5436 | if (error) |
| 5437 | goto out_remove_ctlreg_attr; |
| 5438 | |
| 5439 | return 0; |
| 5440 | out_remove_ctlreg_attr: |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5441 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5442 | out_remove_stat_attr: |
| 5443 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5444 | &sysfs_drvr_stat_data_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5445 | out: |
| 5446 | return error; |
| 5447 | } |
| 5448 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5449 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5450 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5451 | * @vport: address of lpfc vport structure. |
| 5452 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5453 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5454 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5455 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5456 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5457 | sysfs_remove_bin_file(&shost->shost_dev.kobj, |
| 5458 | &sysfs_drvr_stat_data_attr); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5459 | /* Virtual ports do not need ctrl_reg and mbox */ |
| 5460 | if (vport->port_type == LPFC_NPIV_PORT) |
| 5461 | return; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5462 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr); |
| 5463 | sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5464 | } |
| 5465 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5466 | /* |
| 5467 | * Dynamic FC Host Attributes Support |
| 5468 | */ |
| 5469 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5470 | /** |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 5471 | * lpfc_get_host_symbolic_name - Copy symbolic name into the scsi host |
| 5472 | * @shost: kernel scsi host pointer. |
| 5473 | **/ |
| 5474 | static void |
| 5475 | lpfc_get_host_symbolic_name(struct Scsi_Host *shost) |
| 5476 | { |
| 5477 | struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; |
| 5478 | |
| 5479 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), |
| 5480 | sizeof fc_host_symbolic_name(shost)); |
| 5481 | } |
| 5482 | |
| 5483 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5484 | * 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] | 5485 | * @shost: kernel scsi host pointer. |
| 5486 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5487 | static void |
| 5488 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
| 5489 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5490 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5491 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5492 | /* note: fc_myDID already in cpu endianness */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5493 | fc_host_port_id(shost) = vport->fc_myDID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5494 | } |
| 5495 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5496 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5497 | * 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] | 5498 | * @shost: kernel scsi host pointer. |
| 5499 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5500 | static void |
| 5501 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
| 5502 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5503 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5504 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5505 | |
| 5506 | spin_lock_irq(shost->host_lock); |
| 5507 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5508 | if (vport->port_type == LPFC_NPIV_PORT) { |
| 5509 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 5510 | } else if (lpfc_is_link_up(phba)) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5511 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5512 | if (vport->fc_flag & FC_PUBLIC_LOOP) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5513 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
| 5514 | else |
| 5515 | fc_host_port_type(shost) = FC_PORTTYPE_LPORT; |
| 5516 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5517 | if (vport->fc_flag & FC_FABRIC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5518 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
| 5519 | else |
| 5520 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
| 5521 | } |
| 5522 | } else |
| 5523 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
| 5524 | |
| 5525 | spin_unlock_irq(shost->host_lock); |
| 5526 | } |
| 5527 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5528 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5529 | * 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] | 5530 | * @shost: kernel scsi host pointer. |
| 5531 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5532 | static void |
| 5533 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
| 5534 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5535 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5536 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5537 | |
| 5538 | spin_lock_irq(shost->host_lock); |
| 5539 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5540 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5541 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 5542 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5543 | switch (phba->link_state) { |
| 5544 | case LPFC_LINK_UNKNOWN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5545 | case LPFC_LINK_DOWN: |
| 5546 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 5547 | break; |
| 5548 | case LPFC_LINK_UP: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5549 | case LPFC_CLEAR_LA: |
| 5550 | case LPFC_HBA_READY: |
James Smart | 026abb8 | 2011-12-13 13:20:45 -0500 | [diff] [blame] | 5551 | /* Links up, reports port state accordingly */ |
| 5552 | if (vport->port_state < LPFC_VPORT_READY) |
| 5553 | fc_host_port_state(shost) = |
| 5554 | FC_PORTSTATE_BYPASSED; |
| 5555 | else |
| 5556 | fc_host_port_state(shost) = |
| 5557 | FC_PORTSTATE_ONLINE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5558 | break; |
| 5559 | case LPFC_HBA_ERROR: |
| 5560 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
| 5561 | break; |
| 5562 | default: |
| 5563 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 5564 | break; |
| 5565 | } |
| 5566 | } |
| 5567 | |
| 5568 | spin_unlock_irq(shost->host_lock); |
| 5569 | } |
| 5570 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5571 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5572 | * lpfc_get_host_speed - Set the value of the scsi host speed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5573 | * @shost: kernel scsi host pointer. |
| 5574 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5575 | static void |
| 5576 | lpfc_get_host_speed(struct Scsi_Host *shost) |
| 5577 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5578 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5579 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5580 | |
| 5581 | spin_lock_irq(shost->host_lock); |
| 5582 | |
James Smart | a085e87 | 2015-12-16 18:12:02 -0500 | [diff] [blame] | 5583 | if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5584 | switch(phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5585 | case LPFC_LINK_SPEED_1GHZ: |
| 5586 | fc_host_speed(shost) = FC_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5587 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5588 | case LPFC_LINK_SPEED_2GHZ: |
| 5589 | fc_host_speed(shost) = FC_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5590 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5591 | case LPFC_LINK_SPEED_4GHZ: |
| 5592 | fc_host_speed(shost) = FC_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5593 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5594 | case LPFC_LINK_SPEED_8GHZ: |
| 5595 | fc_host_speed(shost) = FC_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 5596 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5597 | case LPFC_LINK_SPEED_10GHZ: |
| 5598 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5599 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5600 | case LPFC_LINK_SPEED_16GHZ: |
| 5601 | fc_host_speed(shost) = FC_PORTSPEED_16GBIT; |
| 5602 | break; |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 5603 | case LPFC_LINK_SPEED_32GHZ: |
| 5604 | fc_host_speed(shost) = FC_PORTSPEED_32GBIT; |
| 5605 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5606 | default: |
| 5607 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5608 | break; |
| 5609 | } |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5610 | } else |
| 5611 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5612 | |
| 5613 | spin_unlock_irq(shost->host_lock); |
| 5614 | } |
| 5615 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5616 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5617 | * 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] | 5618 | * @shost: kernel scsi host pointer. |
| 5619 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5620 | static void |
| 5621 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
| 5622 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5623 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5624 | struct lpfc_hba *phba = vport->phba; |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5625 | u64 node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5626 | |
| 5627 | spin_lock_irq(shost->host_lock); |
| 5628 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5629 | if ((vport->port_state > LPFC_FLOGI) && |
| 5630 | ((vport->fc_flag & FC_FABRIC) || |
| 5631 | ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && |
| 5632 | (vport->fc_flag & FC_PUBLIC_LOOP)))) |
Andrew Morton | 68ce1eb | 2005-09-21 09:46:54 -0700 | [diff] [blame] | 5633 | node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5634 | else |
| 5635 | /* fabric is local port if there is no F/FL_Port */ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5636 | node_name = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5637 | |
| 5638 | spin_unlock_irq(shost->host_lock); |
| 5639 | |
Andrew Vasquez | f631b4b | 2005-08-31 15:23:12 -0700 | [diff] [blame] | 5640 | fc_host_fabric_name(shost) = node_name; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5641 | } |
| 5642 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5643 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5644 | * lpfc_get_stats - Return statistical information about the adapter |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5645 | * @shost: kernel scsi host pointer. |
| 5646 | * |
| 5647 | * Notes: |
| 5648 | * NULL on error for link down, no mbox pool, sli2 active, |
| 5649 | * management not allowed, memory allocation error, or mbox error. |
| 5650 | * |
| 5651 | * Returns: |
| 5652 | * NULL for error |
| 5653 | * address of the adapter host statistics |
| 5654 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5655 | static struct fc_host_statistics * |
| 5656 | lpfc_get_stats(struct Scsi_Host *shost) |
| 5657 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5658 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5659 | struct lpfc_hba *phba = vport->phba; |
| 5660 | struct lpfc_sli *psli = &phba->sli; |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5661 | struct fc_host_statistics *hs = &phba->link_stats; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5662 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5663 | LPFC_MBOXQ_t *pmboxq; |
| 5664 | MAILBOX_t *pmb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5665 | unsigned long seconds; |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5666 | int rc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5667 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5668 | /* |
| 5669 | * prevent udev from issuing mailbox commands until the port is |
| 5670 | * configured. |
| 5671 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5672 | if (phba->link_state < LPFC_LINK_DOWN || |
| 5673 | !phba->mbox_mem_pool || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5674 | (phba->sli.sli_flag & LPFC_SLI_ACTIVE) == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5675 | return NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5676 | |
| 5677 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5678 | return NULL; |
| 5679 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5680 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5681 | if (!pmboxq) |
| 5682 | return NULL; |
| 5683 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| 5684 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5685 | pmb = &pmboxq->u.mb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5686 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5687 | pmb->mbxOwner = OWN_HOST; |
| 5688 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5689 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5690 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5691 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5692 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5693 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5694 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5695 | |
| 5696 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5697 | if (rc != MBX_TIMEOUT) |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5698 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5699 | return NULL; |
| 5700 | } |
| 5701 | |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 5702 | memset(hs, 0, sizeof (struct fc_host_statistics)); |
| 5703 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5704 | hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5705 | /* |
| 5706 | * The MBX_READ_STATUS returns tx_k_bytes which has to |
| 5707 | * converted to words |
| 5708 | */ |
| 5709 | hs->tx_words = (uint64_t) |
| 5710 | ((uint64_t)pmb->un.varRdStatus.xmitByteCnt |
| 5711 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5712 | hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 5713 | hs->rx_words = (uint64_t) |
| 5714 | ((uint64_t)pmb->un.varRdStatus.rcvByteCnt |
| 5715 | * (uint64_t)256); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5716 | |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5717 | memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5718 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5719 | pmb->mbxOwner = OWN_HOST; |
| 5720 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5721 | pmboxq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5722 | |
James Smart | 75baf69 | 2010-06-08 18:31:21 -0400 | [diff] [blame] | 5723 | if (vport->fc_flag & FC_OFFLINE_MODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5724 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
James.Smart@Emulex.Com | 433c357 | 2005-10-28 20:28:56 -0400 | [diff] [blame] | 5725 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5726 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5727 | |
| 5728 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5729 | if (rc != MBX_TIMEOUT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5730 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5731 | return NULL; |
| 5732 | } |
| 5733 | |
| 5734 | hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5735 | hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5736 | hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5737 | hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5738 | hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5739 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5740 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
| 5741 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5742 | hs->link_failure_count -= lso->link_failure_count; |
| 5743 | hs->loss_of_sync_count -= lso->loss_of_sync_count; |
| 5744 | hs->loss_of_signal_count -= lso->loss_of_signal_count; |
| 5745 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; |
| 5746 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; |
| 5747 | hs->invalid_crc_count -= lso->invalid_crc_count; |
| 5748 | hs->error_frames -= lso->error_frames; |
| 5749 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5750 | if (phba->hba_flag & HBA_FCOE_MODE) { |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5751 | hs->lip_count = -1; |
| 5752 | hs->nos_count = (phba->link_events >> 1); |
| 5753 | hs->nos_count -= lso->link_events; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5754 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5755 | hs->lip_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5756 | hs->lip_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5757 | hs->nos_count = -1; |
| 5758 | } else { |
| 5759 | hs->lip_count = -1; |
| 5760 | hs->nos_count = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5761 | hs->nos_count -= lso->link_events; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5762 | } |
| 5763 | |
| 5764 | hs->dumped_frames = -1; |
| 5765 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5766 | seconds = get_seconds(); |
| 5767 | if (seconds < psli->stats_start) |
| 5768 | hs->seconds_since_last_reset = seconds + |
| 5769 | ((unsigned long)-1 - psli->stats_start); |
| 5770 | else |
| 5771 | hs->seconds_since_last_reset = seconds - psli->stats_start; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5772 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5773 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5774 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5775 | return hs; |
| 5776 | } |
| 5777 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5778 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5779 | * lpfc_reset_stats - Copy the adapter link stats information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5780 | * @shost: kernel scsi host pointer. |
| 5781 | **/ |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5782 | static void |
| 5783 | lpfc_reset_stats(struct Scsi_Host *shost) |
| 5784 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5785 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 5786 | struct lpfc_hba *phba = vport->phba; |
| 5787 | struct lpfc_sli *psli = &phba->sli; |
| 5788 | struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5789 | LPFC_MBOXQ_t *pmboxq; |
| 5790 | MAILBOX_t *pmb; |
| 5791 | int rc = 0; |
| 5792 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5793 | if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) |
James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 5794 | return; |
| 5795 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5796 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5797 | if (!pmboxq) |
| 5798 | return; |
| 5799 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5800 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5801 | pmb = &pmboxq->u.mb; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5802 | pmb->mbxCommand = MBX_READ_STATUS; |
| 5803 | pmb->mbxOwner = OWN_HOST; |
| 5804 | pmb->un.varWords[0] = 0x1; /* reset request */ |
| 5805 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5806 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5807 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5808 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5809 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5810 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5811 | else |
| 5812 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5813 | |
| 5814 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5815 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5816 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5817 | return; |
| 5818 | } |
| 5819 | |
| 5820 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); |
| 5821 | pmb->mbxCommand = MBX_READ_LNK_STAT; |
| 5822 | pmb->mbxOwner = OWN_HOST; |
| 5823 | pmboxq->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5824 | pmboxq->vport = vport; |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5825 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5826 | if ((vport->fc_flag & FC_OFFLINE_MODE) || |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5827 | (!(psli->sli_flag & LPFC_SLI_ACTIVE))) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5828 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); |
| 5829 | else |
| 5830 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); |
| 5831 | |
| 5832 | if (rc != MBX_SUCCESS) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5833 | if (rc != MBX_TIMEOUT) |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5834 | mempool_free( pmboxq, phba->mbox_mem_pool); |
| 5835 | return; |
| 5836 | } |
| 5837 | |
| 5838 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; |
| 5839 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; |
| 5840 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; |
| 5841 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; |
| 5842 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; |
| 5843 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
| 5844 | lso->error_frames = pmb->un.varRdLnk.crcCnt; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5845 | if (phba->hba_flag & HBA_FCOE_MODE) |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 5846 | lso->link_events = (phba->link_events >> 1); |
| 5847 | else |
| 5848 | lso->link_events = (phba->fc_eventTag >> 1); |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5849 | |
| 5850 | psli->stats_start = get_seconds(); |
| 5851 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5852 | mempool_free(pmboxq, phba->mbox_mem_pool); |
| 5853 | |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 5854 | return; |
| 5855 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5856 | |
| 5857 | /* |
| 5858 | * The LPFC driver treats linkdown handling as target loss events so there |
| 5859 | * are no sysfs handlers for link_down_tmo. |
| 5860 | */ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5861 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5862 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5863 | * lpfc_get_node_by_target - Return the nodelist for a target |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5864 | * @starget: kernel scsi target pointer. |
| 5865 | * |
| 5866 | * Returns: |
| 5867 | * address of the node list if found |
| 5868 | * NULL target not found |
| 5869 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5870 | static struct lpfc_nodelist * |
| 5871 | lpfc_get_node_by_target(struct scsi_target *starget) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5872 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5873 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
| 5874 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5875 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5876 | |
| 5877 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5878 | /* Search for this, mapped, target ID */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5879 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5880 | if (NLP_CHK_NODE_ACT(ndlp) && |
| 5881 | ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5882 | starget->id == ndlp->nlp_sid) { |
| 5883 | spin_unlock_irq(shost->host_lock); |
| 5884 | return ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5885 | } |
| 5886 | } |
| 5887 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5888 | return NULL; |
| 5889 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5890 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5891 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5892 | * 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] | 5893 | * @starget: kernel scsi target pointer. |
| 5894 | **/ |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5895 | static void |
| 5896 | lpfc_get_starget_port_id(struct scsi_target *starget) |
| 5897 | { |
| 5898 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| 5899 | |
| 5900 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5901 | } |
| 5902 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5903 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5904 | * lpfc_get_starget_node_name - Set the target node name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5905 | * @starget: kernel scsi target pointer. |
| 5906 | * |
| 5907 | * Description: Set the target node name to the ndlp node name wwn or zero. |
| 5908 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5909 | static void |
| 5910 | lpfc_get_starget_node_name(struct scsi_target *starget) |
| 5911 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5912 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5913 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5914 | fc_starget_node_name(starget) = |
| 5915 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5916 | } |
| 5917 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5918 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5919 | * lpfc_get_starget_port_name - Set the target port name |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5920 | * @starget: kernel scsi target pointer. |
| 5921 | * |
| 5922 | * Description: set the target port name to the ndlp port name wwn or zero. |
| 5923 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5924 | static void |
| 5925 | lpfc_get_starget_port_name(struct scsi_target *starget) |
| 5926 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5927 | struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5928 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5929 | fc_starget_port_name(starget) = |
| 5930 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5931 | } |
| 5932 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5933 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5934 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5935 | * @rport: fc rport address. |
| 5936 | * @timeout: new value for dev loss tmo. |
| 5937 | * |
| 5938 | * Description: |
| 5939 | * If timeout is non zero set the dev_loss_tmo to timeout, else set |
| 5940 | * dev_loss_tmo to one. |
| 5941 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5942 | static void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5943 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 5944 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5945 | if (timeout) |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5946 | rport->dev_loss_tmo = timeout; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5947 | else |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 5948 | rport->dev_loss_tmo = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5949 | } |
| 5950 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5951 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5952 | * lpfc_rport_show_function - Return rport target information |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5953 | * |
| 5954 | * Description: |
| 5955 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
| 5956 | * |
| 5957 | * lpfc_show_rport_##field: returns the bytes formatted in buf |
| 5958 | * @cdev: class converted to an fc_rport. |
| 5959 | * @buf: on return contains the target_field or zero. |
| 5960 | * |
| 5961 | * Returns: size of formatted string. |
| 5962 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5963 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
| 5964 | static ssize_t \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5965 | lpfc_show_rport_##field (struct device *dev, \ |
| 5966 | struct device_attribute *attr, \ |
| 5967 | char *buf) \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5968 | { \ |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 5969 | struct fc_rport *rport = transport_class_to_rport(dev); \ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5970 | struct lpfc_rport_data *rdata = rport->hostdata; \ |
| 5971 | return snprintf(buf, sz, format_string, \ |
| 5972 | (rdata->target) ? cast rdata->target->field : 0); \ |
| 5973 | } |
| 5974 | |
| 5975 | #define lpfc_rport_rd_attr(field, format_string, sz) \ |
| 5976 | lpfc_rport_show_function(field, format_string, sz, ) \ |
| 5977 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
| 5978 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5979 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5980 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 5981 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
| 5982 | * |
| 5983 | * Description: |
| 5984 | * This function is called by the transport after the @fc_vport's symbolic name |
| 5985 | * 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] | 5986 | * 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] | 5987 | **/ |
| 5988 | static void |
| 5989 | lpfc_set_vport_symbolic_name(struct fc_vport *fc_vport) |
| 5990 | { |
| 5991 | struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; |
| 5992 | |
| 5993 | if (vport->port_state == LPFC_VPORT_READY) |
| 5994 | lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0); |
| 5995 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5996 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 5997 | /** |
| 5998 | * lpfc_hba_log_verbose_init - Set hba's log verbose level |
| 5999 | * @phba: Pointer to lpfc_hba struct. |
| 6000 | * |
| 6001 | * This function is called by the lpfc_get_cfgparam() routine to set the |
| 6002 | * 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] | 6003 | * log message according to the module's lpfc_log_verbose parameter setting |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 6004 | * before hba port or vport created. |
| 6005 | **/ |
| 6006 | static void |
| 6007 | lpfc_hba_log_verbose_init(struct lpfc_hba *phba, uint32_t verbose) |
| 6008 | { |
| 6009 | phba->cfg_log_verbose = verbose; |
| 6010 | } |
| 6011 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6012 | struct fc_function_template lpfc_transport_functions = { |
| 6013 | /* fixed attributes the driver supports */ |
| 6014 | .show_host_node_name = 1, |
| 6015 | .show_host_port_name = 1, |
| 6016 | .show_host_supported_classes = 1, |
| 6017 | .show_host_supported_fc4s = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6018 | .show_host_supported_speeds = 1, |
| 6019 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6020 | |
| 6021 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6022 | .show_host_symbolic_name = 1, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6023 | |
| 6024 | /* dynamic attributes the driver supports */ |
| 6025 | .get_host_port_id = lpfc_get_host_port_id, |
| 6026 | .show_host_port_id = 1, |
| 6027 | |
| 6028 | .get_host_port_type = lpfc_get_host_port_type, |
| 6029 | .show_host_port_type = 1, |
| 6030 | |
| 6031 | .get_host_port_state = lpfc_get_host_port_state, |
| 6032 | .show_host_port_state = 1, |
| 6033 | |
| 6034 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6035 | .show_host_active_fc4s = 1, |
| 6036 | |
| 6037 | .get_host_speed = lpfc_get_host_speed, |
| 6038 | .show_host_speed = 1, |
| 6039 | |
| 6040 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6041 | .show_host_fabric_name = 1, |
| 6042 | |
| 6043 | /* |
| 6044 | * The LPFC driver treats linkdown handling as target loss events |
| 6045 | * so there are no sysfs handlers for link_down_tmo. |
| 6046 | */ |
| 6047 | |
| 6048 | .get_fc_host_stats = lpfc_get_stats, |
James Smart | 64ba881 | 2006-08-02 15:24:34 -0400 | [diff] [blame] | 6049 | .reset_fc_host_stats = lpfc_reset_stats, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6050 | |
| 6051 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6052 | .show_rport_maxframe_size = 1, |
| 6053 | .show_rport_supported_classes = 1, |
| 6054 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6055 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6056 | .show_rport_dev_loss_tmo = 1, |
| 6057 | |
| 6058 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6059 | .show_starget_port_id = 1, |
| 6060 | |
| 6061 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6062 | .show_starget_node_name = 1, |
| 6063 | |
| 6064 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6065 | .show_starget_port_name = 1, |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 6066 | |
| 6067 | .issue_fc_host_lip = lpfc_issue_lip, |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 6068 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6069 | .terminate_rport_io = lpfc_terminate_rport_io, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6070 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6071 | .dd_fcvport_size = sizeof(struct lpfc_vport *), |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6072 | |
| 6073 | .vport_disable = lpfc_vport_disable, |
| 6074 | |
| 6075 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 6076 | |
| 6077 | .bsg_request = lpfc_bsg_request, |
| 6078 | .bsg_timeout = lpfc_bsg_timeout, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6079 | }; |
| 6080 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6081 | struct fc_function_template lpfc_vport_transport_functions = { |
| 6082 | /* fixed attributes the driver supports */ |
| 6083 | .show_host_node_name = 1, |
| 6084 | .show_host_port_name = 1, |
| 6085 | .show_host_supported_classes = 1, |
| 6086 | .show_host_supported_fc4s = 1, |
| 6087 | .show_host_supported_speeds = 1, |
| 6088 | .show_host_maxframe_size = 1, |
James Smart | 6c9231f | 2016-12-19 15:07:24 -0800 | [diff] [blame] | 6089 | |
| 6090 | .get_host_symbolic_name = lpfc_get_host_symbolic_name, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6091 | .show_host_symbolic_name = 1, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6092 | |
| 6093 | /* dynamic attributes the driver supports */ |
| 6094 | .get_host_port_id = lpfc_get_host_port_id, |
| 6095 | .show_host_port_id = 1, |
| 6096 | |
| 6097 | .get_host_port_type = lpfc_get_host_port_type, |
| 6098 | .show_host_port_type = 1, |
| 6099 | |
| 6100 | .get_host_port_state = lpfc_get_host_port_state, |
| 6101 | .show_host_port_state = 1, |
| 6102 | |
| 6103 | /* active_fc4s is shown but doesn't change (thus no get function) */ |
| 6104 | .show_host_active_fc4s = 1, |
| 6105 | |
| 6106 | .get_host_speed = lpfc_get_host_speed, |
| 6107 | .show_host_speed = 1, |
| 6108 | |
| 6109 | .get_host_fabric_name = lpfc_get_host_fabric_name, |
| 6110 | .show_host_fabric_name = 1, |
| 6111 | |
| 6112 | /* |
| 6113 | * The LPFC driver treats linkdown handling as target loss events |
| 6114 | * so there are no sysfs handlers for link_down_tmo. |
| 6115 | */ |
| 6116 | |
| 6117 | .get_fc_host_stats = lpfc_get_stats, |
| 6118 | .reset_fc_host_stats = lpfc_reset_stats, |
| 6119 | |
| 6120 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
| 6121 | .show_rport_maxframe_size = 1, |
| 6122 | .show_rport_supported_classes = 1, |
| 6123 | |
| 6124 | .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo, |
| 6125 | .show_rport_dev_loss_tmo = 1, |
| 6126 | |
| 6127 | .get_starget_port_id = lpfc_get_starget_port_id, |
| 6128 | .show_starget_port_id = 1, |
| 6129 | |
| 6130 | .get_starget_node_name = lpfc_get_starget_node_name, |
| 6131 | .show_starget_node_name = 1, |
| 6132 | |
| 6133 | .get_starget_port_name = lpfc_get_starget_port_name, |
| 6134 | .show_starget_port_name = 1, |
| 6135 | |
| 6136 | .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, |
| 6137 | .terminate_rport_io = lpfc_terminate_rport_io, |
| 6138 | |
| 6139 | .vport_disable = lpfc_vport_disable, |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 6140 | |
| 6141 | .set_vport_symbolic_name = lpfc_set_vport_symbolic_name, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6142 | }; |
| 6143 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6144 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6145 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6146 | * @phba: lpfc_hba pointer. |
| 6147 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6148 | void |
| 6149 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
| 6150 | { |
James Smart | 49aa143 | 2012-08-03 12:36:42 -0400 | [diff] [blame] | 6151 | lpfc_fcp_io_sched_init(phba, lpfc_fcp_io_sched); |
James Smart | a6571c6 | 2012-10-31 14:44:42 -0400 | [diff] [blame] | 6152 | 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] | 6153 | lpfc_cr_delay_init(phba, lpfc_cr_delay); |
| 6154 | lpfc_cr_count_init(phba, lpfc_cr_count); |
Jamie Wellnitz | cf5bf97 | 2006-02-28 22:33:08 -0500 | [diff] [blame] | 6155 | lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); |
James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 6156 | lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); |
| 6157 | lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6158 | lpfc_ack0_init(phba, lpfc_ack0); |
| 6159 | lpfc_topology_init(phba, lpfc_topology); |
James.Smart@Emulex.Com | 7bcbb75 | 2005-10-28 20:29:13 -0400 | [diff] [blame] | 6160 | lpfc_link_speed_init(phba, lpfc_link_speed); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 6161 | lpfc_poll_tmo_init(phba, lpfc_poll_tmo); |
James Smart | 0c41122 | 2013-09-06 12:22:46 -0400 | [diff] [blame] | 6162 | lpfc_task_mgmt_tmo_init(phba, lpfc_task_mgmt_tmo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 6163 | lpfc_enable_npiv_init(phba, lpfc_enable_npiv); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 6164 | lpfc_fcf_failover_policy_init(phba, lpfc_fcf_failover_policy); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6165 | lpfc_enable_rrq_init(phba, lpfc_enable_rrq); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6166 | lpfc_fdmi_on_init(phba, lpfc_fdmi_on); |
| 6167 | lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN); |
James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 6168 | lpfc_use_msi_init(phba, lpfc_use_msi); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6169 | lpfc_nvme_oas_init(phba, lpfc_nvme_oas); |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 6170 | lpfc_fcp_imax_init(phba, lpfc_fcp_imax); |
James Smart | 7bb03bb | 2013-04-17 20:19:16 -0400 | [diff] [blame] | 6171 | lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map); |
James Smart | 13815c8 | 2008-01-11 01:52:48 -0500 | [diff] [blame] | 6172 | lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); |
| 6173 | lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6174 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6175 | lpfc_EnableXLane_init(phba, lpfc_EnableXLane); |
| 6176 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 6177 | phba->cfg_EnableXLane = 0; |
| 6178 | lpfc_XLanePriority_init(phba, lpfc_XLanePriority); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6179 | |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6180 | memset(phba->cfg_oas_tgt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6181 | memset(phba->cfg_oas_vpt_wwpn, 0, (8 * sizeof(uint8_t))); |
| 6182 | phba->cfg_oas_lun_state = 0; |
| 6183 | phba->cfg_oas_lun_status = 0; |
| 6184 | phba->cfg_oas_flags = 0; |
James Smart | c92c841 | 2016-07-06 12:36:05 -0700 | [diff] [blame] | 6185 | phba->cfg_oas_priority = 0; |
James Smart | 81301a9 | 2008-12-04 22:39:46 -0500 | [diff] [blame] | 6186 | lpfc_enable_bg_init(phba, lpfc_enable_bg); |
James Smart | b3b98b7 | 2016-10-13 15:06:06 -0700 | [diff] [blame] | 6187 | lpfc_prot_mask_init(phba, lpfc_prot_mask); |
| 6188 | lpfc_prot_guard_init(phba, lpfc_prot_guard); |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 6189 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6190 | phba->cfg_poll = 0; |
| 6191 | else |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 6192 | phba->cfg_poll = lpfc_poll; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6193 | lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6194 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6195 | lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6196 | lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); |
| 6197 | lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6198 | |
| 6199 | /* Initialize first burst. Target vs Initiator are different. */ |
| 6200 | lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6201 | lpfc_nvmet_fb_size_init(phba, lpfc_nvmet_fb_size); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6202 | lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel); |
| 6203 | lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel); |
| 6204 | |
| 6205 | if (phba->sli_rev != LPFC_SLI_REV4) { |
| 6206 | /* NVME only supported on SLI4 */ |
| 6207 | phba->nvmet_support = 0; |
| 6208 | phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
| 6209 | } else { |
| 6210 | /* We MUST have FCP support */ |
| 6211 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
| 6212 | phba->cfg_enable_fc4_type |= LPFC_ENABLE_FCP; |
| 6213 | } |
| 6214 | |
| 6215 | /* 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] | 6216 | if (phba->cfg_fcp_io_channel == 0) |
| 6217 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6218 | if (phba->cfg_nvme_io_channel == 0) |
| 6219 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6220 | |
| 6221 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME) |
| 6222 | phba->cfg_fcp_io_channel = 0; |
| 6223 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6224 | if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) |
| 6225 | phba->cfg_nvme_io_channel = 0; |
| 6226 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6227 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6228 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6229 | else |
| 6230 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame] | 6231 | |
James Smart | 352e5fd | 2016-12-30 06:57:47 -0800 | [diff] [blame] | 6232 | phba->cfg_soft_wwnn = 0L; |
| 6233 | phba->cfg_soft_wwpn = 0L; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6234 | lpfc_xri_split_init(phba, lpfc_xri_split); |
James Smart | 83108bd | 2008-01-11 01:53:09 -0500 | [diff] [blame] | 6235 | lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 6236 | lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6237 | lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); |
James Smart | 0d87841 | 2009-10-02 15:16:56 -0400 | [diff] [blame] | 6238 | lpfc_aer_support_init(phba, lpfc_aer_support); |
James Smart | 912e3ac | 2011-05-24 11:42:11 -0400 | [diff] [blame] | 6239 | lpfc_sriov_nr_virtfn_init(phba, lpfc_sriov_nr_virtfn); |
James Smart | c71ab86 | 2012-10-31 14:44:33 -0400 | [diff] [blame] | 6240 | lpfc_request_firmware_upgrade_init(phba, lpfc_req_fw_upgrade); |
James Smart | 84d1b00 | 2010-02-12 14:42:33 -0500 | [diff] [blame] | 6241 | lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6242 | lpfc_iocb_cnt_init(phba, lpfc_iocb_cnt); |
James Smart | 8eb8b96 | 2016-07-06 12:36:08 -0700 | [diff] [blame] | 6243 | lpfc_delay_discovery_init(phba, lpfc_delay_discovery); |
James Smart | 12247e8 | 2016-07-06 12:36:09 -0700 | [diff] [blame] | 6244 | lpfc_sli_mode_init(phba, lpfc_sli_mode); |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 6245 | phba->cfg_enable_dss = 1; |
James Smart | 7bdedb3 | 2016-07-06 12:36:00 -0700 | [diff] [blame] | 6246 | lpfc_enable_mds_diags_init(phba, lpfc_enable_mds_diags); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6247 | return; |
| 6248 | } |
Jamie Wellnitz | b28485a | 2006-02-28 19:25:21 -0500 | [diff] [blame] | 6249 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6250 | /** |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6251 | * lpfc_nvme_mod_param_dep - Adjust module parameter value based on |
| 6252 | * dependencies between protocols and roles. |
| 6253 | * @phba: lpfc_hba pointer. |
| 6254 | **/ |
| 6255 | void |
| 6256 | lpfc_nvme_mod_param_dep(struct lpfc_hba *phba) |
| 6257 | { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6258 | if (phba->cfg_nvme_io_channel > phba->sli4_hba.num_present_cpu) |
| 6259 | phba->cfg_nvme_io_channel = phba->sli4_hba.num_present_cpu; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6260 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6261 | if (phba->cfg_fcp_io_channel > phba->sli4_hba.num_present_cpu) |
| 6262 | phba->cfg_fcp_io_channel = phba->sli4_hba.num_present_cpu; |
| 6263 | |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6264 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && |
| 6265 | phba->nvmet_support) { |
| 6266 | phba->cfg_enable_fc4_type &= ~LPFC_ENABLE_FCP; |
| 6267 | phba->cfg_fcp_io_channel = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6268 | |
| 6269 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 6270 | "6013 %s x%x fb_size x%x, fb_max x%x\n", |
| 6271 | "NVME Target PRLI ACC enable_fb ", |
| 6272 | phba->cfg_nvme_enable_fb, |
| 6273 | phba->cfg_nvmet_fb_size, |
| 6274 | LPFC_NVMET_FB_SZ_MAX); |
| 6275 | |
| 6276 | if (phba->cfg_nvme_enable_fb == 0) |
| 6277 | phba->cfg_nvmet_fb_size = 0; |
| 6278 | else { |
| 6279 | if (phba->cfg_nvmet_fb_size > LPFC_NVMET_FB_SZ_MAX) |
| 6280 | phba->cfg_nvmet_fb_size = LPFC_NVMET_FB_SZ_MAX; |
| 6281 | } |
| 6282 | |
| 6283 | /* Adjust lpfc_nvmet_mrq to avoid running out of WQE slots */ |
| 6284 | if (phba->cfg_nvmet_mrq > phba->cfg_nvme_io_channel) { |
| 6285 | phba->cfg_nvmet_mrq = phba->cfg_nvme_io_channel; |
| 6286 | lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, |
| 6287 | "6018 Adjust lpfc_nvmet_mrq to %d\n", |
| 6288 | phba->cfg_nvmet_mrq); |
| 6289 | } |
| 6290 | } else { |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6291 | /* Not NVME Target mode. Turn off Target parameters. */ |
| 6292 | phba->nvmet_support = 0; |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 6293 | phba->cfg_nvmet_mrq = 0; |
| 6294 | phba->cfg_nvmet_mrq_post = 0; |
| 6295 | phba->cfg_nvmet_fb_size = 0; |
| 6296 | } |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 6297 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6298 | if (phba->cfg_fcp_io_channel > phba->cfg_nvme_io_channel) |
| 6299 | phba->io_channel_irqs = phba->cfg_fcp_io_channel; |
| 6300 | else |
| 6301 | phba->io_channel_irqs = phba->cfg_nvme_io_channel; |
| 6302 | } |
| 6303 | |
| 6304 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6305 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6306 | * @vport: lpfc_vport pointer. |
| 6307 | **/ |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6308 | void |
| 6309 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
| 6310 | { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6311 | lpfc_log_verbose_init(vport, lpfc_log_verbose); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6312 | lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth); |
James Smart | 7dc517d | 2010-07-14 15:32:10 -0400 | [diff] [blame] | 6313 | lpfc_tgt_queue_depth_init(vport, lpfc_tgt_queue_depth); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6314 | lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo); |
| 6315 | lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo); |
| 6316 | lpfc_peer_port_login_init(vport, lpfc_peer_port_login); |
| 6317 | lpfc_restrict_login_init(vport, lpfc_restrict_login); |
| 6318 | lpfc_fcp_class_init(vport, lpfc_fcp_class); |
| 6319 | lpfc_use_adisc_init(vport, lpfc_use_adisc); |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 6320 | lpfc_first_burst_size_init(vport, lpfc_first_burst_size); |
James Smart | 977b5a0 | 2008-09-07 11:52:04 -0400 | [diff] [blame] | 6321 | lpfc_max_scsicmpl_time_init(vport, lpfc_max_scsicmpl_time); |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6322 | lpfc_discovery_threads_init(vport, lpfc_discovery_threads); |
| 6323 | lpfc_max_luns_init(vport, lpfc_max_luns); |
| 6324 | lpfc_scan_down_init(vport, lpfc_scan_down); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 6325 | lpfc_enable_da_id_init(vport, lpfc_enable_da_id); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6326 | return; |
| 6327 | } |