blob: eb5a5ad4ffbf892cbb2a423a29a0c6996ff3f591 [file] [log] [blame]
dea31012005-04-17 16:05:31 -05001/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04003 * Fibre Channel Host Bus Adapters. *
James Smart09372822008-01-11 01:52:54 -05004 * Copyright (C) 2004-2008 Emulex. All rights reserved. *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04005 * EMULEX and SLI are trademarks of Emulex. *
dea31012005-04-17 16:05:31 -05006 * www.emulex.com *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04007 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
dea31012005-04-17 16:05:31 -05008 * *
9 * This program is free software; you can redistribute it and/or *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -040010 * modify it under the terms of version 2 of the GNU General *
11 * Public License as published by the Free Software Foundation. *
12 * This program is distributed in the hope that it will be useful. *
13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
dea31012005-04-17 16:05:31 -050020 *******************************************************************/
21
dea31012005-04-17 16:05:31 -050022#include <linux/ctype.h>
James Smart46fa3112007-04-25 09:51:45 -040023#include <linux/delay.h>
dea31012005-04-17 16:05:31 -050024#include <linux/pci.h>
25#include <linux/interrupt.h>
26
James.Smart@Emulex.Com91886522005-08-10 15:03:09 -040027#include <scsi/scsi.h>
dea31012005-04-17 16:05:31 -050028#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h>
30#include <scsi/scsi_tcq.h>
31#include <scsi/scsi_transport_fc.h>
32
33#include "lpfc_hw.h"
34#include "lpfc_sli.h"
35#include "lpfc_disc.h"
36#include "lpfc_scsi.h"
37#include "lpfc.h"
38#include "lpfc_logmsg.h"
39#include "lpfc_version.h"
40#include "lpfc_compat.h"
41#include "lpfc_crtn.h"
James Smart92d7f7b2007-06-17 19:56:38 -050042#include "lpfc_vport.h"
dea31012005-04-17 16:05:31 -050043
James Smartc01f3202006-08-18 17:47:08 -040044#define LPFC_DEF_DEVLOSS_TMO 30
45#define LPFC_MIN_DEVLOSS_TMO 1
46#define LPFC_MAX_DEVLOSS_TMO 255
dea31012005-04-17 16:05:31 -050047
48static void
49lpfc_jedec_to_ascii(int incr, char hdw[])
50{
51 int i, j;
52 for (i = 0; i < 8; i++) {
53 j = (incr & 0xf);
54 if (j <= 9)
55 hdw[7 - i] = 0x30 + j;
56 else
57 hdw[7 - i] = 0x61 + j - 10;
58 incr = (incr >> 4);
59 }
60 hdw[8] = 0;
61 return;
62}
63
64static ssize_t
65lpfc_drvr_version_show(struct class_device *cdev, char *buf)
66{
67 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
68}
69
70static ssize_t
dea31012005-04-17 16:05:31 -050071lpfc_info_show(struct class_device *cdev, char *buf)
72{
73 struct Scsi_Host *host = class_to_shost(cdev);
James Smart2e0fef82007-06-17 19:56:36 -050074
dea31012005-04-17 16:05:31 -050075 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
76}
77
78static ssize_t
79lpfc_serialnum_show(struct class_device *cdev, char *buf)
80{
James Smart2e0fef82007-06-17 19:56:36 -050081 struct Scsi_Host *shost = class_to_shost(cdev);
82 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
83 struct lpfc_hba *phba = vport->phba;
84
dea31012005-04-17 16:05:31 -050085 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
86}
87
88static ssize_t
James Smart57127f12007-10-27 13:37:05 -040089lpfc_temp_sensor_show(struct class_device *cdev, char *buf)
90{
91 struct Scsi_Host *shost = class_to_shost(cdev);
92 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
93 struct lpfc_hba *phba = vport->phba;
94 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
95}
96
97static ssize_t
dea31012005-04-17 16:05:31 -050098lpfc_modeldesc_show(struct class_device *cdev, char *buf)
99{
James Smart2e0fef82007-06-17 19:56:36 -0500100 struct Scsi_Host *shost = class_to_shost(cdev);
101 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
102 struct lpfc_hba *phba = vport->phba;
103
dea31012005-04-17 16:05:31 -0500104 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
105}
106
107static ssize_t
108lpfc_modelname_show(struct class_device *cdev, char *buf)
109{
James Smart2e0fef82007-06-17 19:56:36 -0500110 struct Scsi_Host *shost = class_to_shost(cdev);
111 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
112 struct lpfc_hba *phba = vport->phba;
113
dea31012005-04-17 16:05:31 -0500114 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
115}
116
117static ssize_t
118lpfc_programtype_show(struct class_device *cdev, char *buf)
119{
James Smart2e0fef82007-06-17 19:56:36 -0500120 struct Scsi_Host *shost = class_to_shost(cdev);
121 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
122 struct lpfc_hba *phba = vport->phba;
123
dea31012005-04-17 16:05:31 -0500124 return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
125}
126
127static ssize_t
James Smart2e0fef82007-06-17 19:56:36 -0500128lpfc_vportnum_show(struct class_device *cdev, char *buf)
dea31012005-04-17 16:05:31 -0500129{
James Smart2e0fef82007-06-17 19:56:36 -0500130 struct Scsi_Host *shost = class_to_shost(cdev);
131 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
132 struct lpfc_hba *phba = vport->phba;
133
dea31012005-04-17 16:05:31 -0500134 return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
135}
136
137static ssize_t
138lpfc_fwrev_show(struct class_device *cdev, char *buf)
139{
James Smart2e0fef82007-06-17 19:56:36 -0500140 struct Scsi_Host *shost = class_to_shost(cdev);
141 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
142 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -0500143 char fwrev[32];
James Smart2e0fef82007-06-17 19:56:36 -0500144
dea31012005-04-17 16:05:31 -0500145 lpfc_decode_firmware_rev(phba, fwrev, 1);
James Smart92d7f7b2007-06-17 19:56:38 -0500146 return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev);
dea31012005-04-17 16:05:31 -0500147}
148
149static ssize_t
150lpfc_hdw_show(struct class_device *cdev, char *buf)
151{
152 char hdw[9];
James Smart2e0fef82007-06-17 19:56:36 -0500153 struct Scsi_Host *shost = class_to_shost(cdev);
154 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
155 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -0500156 lpfc_vpd_t *vp = &phba->vpd;
James Smart2e0fef82007-06-17 19:56:36 -0500157
dea31012005-04-17 16:05:31 -0500158 lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
159 return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
160}
161static ssize_t
162lpfc_option_rom_version_show(struct class_device *cdev, char *buf)
163{
James Smart2e0fef82007-06-17 19:56:36 -0500164 struct Scsi_Host *shost = class_to_shost(cdev);
165 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
166 struct lpfc_hba *phba = vport->phba;
167
dea31012005-04-17 16:05:31 -0500168 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
169}
170static ssize_t
171lpfc_state_show(struct class_device *cdev, char *buf)
172{
James Smart2e0fef82007-06-17 19:56:36 -0500173 struct Scsi_Host *shost = class_to_shost(cdev);
174 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
175 struct lpfc_hba *phba = vport->phba;
176 int len = 0;
177
178 switch (phba->link_state) {
179 case LPFC_LINK_UNKNOWN:
Jamie Wellnitz41415862006-02-28 19:25:27 -0500180 case LPFC_WARM_START:
dea31012005-04-17 16:05:31 -0500181 case LPFC_INIT_START:
182 case LPFC_INIT_MBX_CMDS:
183 case LPFC_LINK_DOWN:
James Smart2e0fef82007-06-17 19:56:36 -0500184 case LPFC_HBA_ERROR:
dea31012005-04-17 16:05:31 -0500185 len += snprintf(buf + len, PAGE_SIZE-len, "Link Down\n");
186 break;
187 case LPFC_LINK_UP:
dea31012005-04-17 16:05:31 -0500188 case LPFC_CLEAR_LA:
dea31012005-04-17 16:05:31 -0500189 case LPFC_HBA_READY:
James Smarta8adb832007-10-27 13:37:53 -0400190 len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
James Smart2e0fef82007-06-17 19:56:36 -0500191
192 switch (vport->port_state) {
James Smart2e0fef82007-06-17 19:56:36 -0500193 case LPFC_LOCAL_CFG_LINK:
194 len += snprintf(buf + len, PAGE_SIZE-len,
James Smart92d7f7b2007-06-17 19:56:38 -0500195 "Configuring Link\n");
James Smart2e0fef82007-06-17 19:56:36 -0500196 break;
James Smart92d7f7b2007-06-17 19:56:38 -0500197 case LPFC_FDISC:
James Smart2e0fef82007-06-17 19:56:36 -0500198 case LPFC_FLOGI:
199 case LPFC_FABRIC_CFG_LINK:
200 case LPFC_NS_REG:
201 case LPFC_NS_QRY:
202 case LPFC_BUILD_DISC_LIST:
203 case LPFC_DISC_AUTH:
204 len += snprintf(buf + len, PAGE_SIZE - len,
205 "Discovery\n");
206 break;
207 case LPFC_VPORT_READY:
208 len += snprintf(buf + len, PAGE_SIZE - len, "Ready\n");
209 break;
210
James Smart92d7f7b2007-06-17 19:56:38 -0500211 case LPFC_VPORT_FAILED:
212 len += snprintf(buf + len, PAGE_SIZE - len, "Failed\n");
213 break;
214
215 case LPFC_VPORT_UNKNOWN:
James Smart2e0fef82007-06-17 19:56:36 -0500216 len += snprintf(buf + len, PAGE_SIZE - len,
217 "Unknown\n");
218 break;
219 }
220
dea31012005-04-17 16:05:31 -0500221 if (phba->fc_topology == TOPOLOGY_LOOP) {
James Smart2e0fef82007-06-17 19:56:36 -0500222 if (vport->fc_flag & FC_PUBLIC_LOOP)
dea31012005-04-17 16:05:31 -0500223 len += snprintf(buf + len, PAGE_SIZE-len,
224 " Public Loop\n");
225 else
226 len += snprintf(buf + len, PAGE_SIZE-len,
227 " Private Loop\n");
228 } else {
James Smart2e0fef82007-06-17 19:56:36 -0500229 if (vport->fc_flag & FC_FABRIC)
dea31012005-04-17 16:05:31 -0500230 len += snprintf(buf + len, PAGE_SIZE-len,
231 " Fabric\n");
232 else
233 len += snprintf(buf + len, PAGE_SIZE-len,
234 " Point-2-Point\n");
235 }
236 }
James Smart2e0fef82007-06-17 19:56:36 -0500237
dea31012005-04-17 16:05:31 -0500238 return len;
239}
240
241static ssize_t
242lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf)
243{
James Smart2e0fef82007-06-17 19:56:36 -0500244 struct Scsi_Host *shost = class_to_shost(cdev);
245 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
246
247 return snprintf(buf, PAGE_SIZE, "%d\n",
248 vport->fc_map_cnt + vport->fc_unmap_cnt);
dea31012005-04-17 16:05:31 -0500249}
250
251
Andrew Vasquez91ca7b02005-10-27 16:03:37 -0700252static int
James Smart2e0fef82007-06-17 19:56:36 -0500253lpfc_issue_lip(struct Scsi_Host *shost)
dea31012005-04-17 16:05:31 -0500254{
James Smart2e0fef82007-06-17 19:56:36 -0500255 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
256 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -0500257 LPFC_MBOXQ_t *pmboxq;
258 int mbxstatus = MBXERR_ERROR;
259
James Smart2e0fef82007-06-17 19:56:36 -0500260 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
261 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) ||
262 (vport->port_state != LPFC_VPORT_READY))
dea31012005-04-17 16:05:31 -0500263 return -EPERM;
264
265 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
266
267 if (!pmboxq)
268 return -ENOMEM;
269
270 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
James Smart4db621e2006-07-06 15:49:49 -0400271 pmboxq->mb.mbxCommand = MBX_DOWN_LINK;
272 pmboxq->mb.mbxOwner = OWN_HOST;
273
James Smart33ccf8d2006-08-17 11:57:58 -0400274 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2);
dea31012005-04-17 16:05:31 -0500275
James Smart4db621e2006-07-06 15:49:49 -0400276 if ((mbxstatus == MBX_SUCCESS) && (pmboxq->mb.mbxStatus == 0)) {
277 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
278 lpfc_init_link(phba, pmboxq, phba->cfg_topology,
279 phba->cfg_link_speed);
280 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq,
281 phba->fc_ratov * 2);
282 }
283
James Smart5b8bd0c2007-04-25 09:52:49 -0400284 lpfc_set_loopback_flag(phba);
James Smart858c9f62007-06-17 19:56:39 -0500285 if (mbxstatus != MBX_TIMEOUT)
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -0400286 mempool_free(pmboxq, phba->mbox_mem_pool);
dea31012005-04-17 16:05:31 -0500287
288 if (mbxstatus == MBXERR_ERROR)
289 return -EIO;
290
Andrew Vasquez91ca7b02005-10-27 16:03:37 -0700291 return 0;
dea31012005-04-17 16:05:31 -0500292}
293
James Smart40496f02006-07-06 15:50:22 -0400294static int
James Smart46fa3112007-04-25 09:51:45 -0400295lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
296{
297 struct completion online_compl;
298 struct lpfc_sli_ring *pring;
299 struct lpfc_sli *psli;
300 int status = 0;
301 int cnt = 0;
302 int i;
303
304 init_completion(&online_compl);
305 lpfc_workq_post_event(phba, &status, &online_compl,
306 LPFC_EVT_OFFLINE_PREP);
307 wait_for_completion(&online_compl);
308
309 if (status != 0)
310 return -EIO;
311
312 psli = &phba->sli;
313
James Smart09372822008-01-11 01:52:54 -0500314 /* Wait a little for things to settle down, but not
315 * long enough for dev loss timeout to expire.
316 */
James Smart46fa3112007-04-25 09:51:45 -0400317 for (i = 0; i < psli->num_rings; i++) {
318 pring = &psli->ring[i];
James Smart46fa3112007-04-25 09:51:45 -0400319 while (pring->txcmplq_cnt) {
320 msleep(10);
James Smart09372822008-01-11 01:52:54 -0500321 if (cnt++ > 500) { /* 5 secs */
James Smart46fa3112007-04-25 09:51:45 -0400322 lpfc_printf_log(phba,
323 KERN_WARNING, LOG_INIT,
James Smarte8b62012007-08-02 11:10:09 -0400324 "0466 Outstanding IO when "
325 "bringing Adapter offline\n");
James Smart46fa3112007-04-25 09:51:45 -0400326 break;
327 }
328 }
329 }
330
331 init_completion(&online_compl);
332 lpfc_workq_post_event(phba, &status, &online_compl, type);
333 wait_for_completion(&online_compl);
334
335 if (status != 0)
336 return -EIO;
337
338 return 0;
339}
340
341static int
James Smart40496f02006-07-06 15:50:22 -0400342lpfc_selective_reset(struct lpfc_hba *phba)
343{
344 struct completion online_compl;
345 int status = 0;
346
James Smart13815c82008-01-11 01:52:48 -0500347 if (!phba->cfg_enable_hba_reset)
348 return -EIO;
349
James Smart46fa3112007-04-25 09:51:45 -0400350 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
James Smart40496f02006-07-06 15:50:22 -0400351
352 if (status != 0)
James Smart46fa3112007-04-25 09:51:45 -0400353 return status;
James Smart40496f02006-07-06 15:50:22 -0400354
355 init_completion(&online_compl);
356 lpfc_workq_post_event(phba, &status, &online_compl,
357 LPFC_EVT_ONLINE);
358 wait_for_completion(&online_compl);
359
360 if (status != 0)
361 return -EIO;
362
363 return 0;
364}
365
366static ssize_t
367lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count)
368{
James Smart2e0fef82007-06-17 19:56:36 -0500369 struct Scsi_Host *shost = class_to_shost(cdev);
370 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
371 struct lpfc_hba *phba = vport->phba;
372
James Smart40496f02006-07-06 15:50:22 -0400373 int status = -EINVAL;
374
375 if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
376 status = lpfc_selective_reset(phba);
377
378 if (status == 0)
379 return strlen(buf);
380 else
381 return status;
382}
383
dea31012005-04-17 16:05:31 -0500384static ssize_t
385lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf)
386{
James Smart2e0fef82007-06-17 19:56:36 -0500387 struct Scsi_Host *shost = class_to_shost(cdev);
388 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
389 struct lpfc_hba *phba = vport->phba;
390
dea31012005-04-17 16:05:31 -0500391 return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
392}
393
394static ssize_t
Jamie Wellnitz41415862006-02-28 19:25:27 -0500395lpfc_board_mode_show(struct class_device *cdev, char *buf)
396{
James Smart2e0fef82007-06-17 19:56:36 -0500397 struct Scsi_Host *shost = class_to_shost(cdev);
398 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
399 struct lpfc_hba *phba = vport->phba;
Jamie Wellnitz41415862006-02-28 19:25:27 -0500400 char * state;
401
James Smart2e0fef82007-06-17 19:56:36 -0500402 if (phba->link_state == LPFC_HBA_ERROR)
Jamie Wellnitz41415862006-02-28 19:25:27 -0500403 state = "error";
James Smart2e0fef82007-06-17 19:56:36 -0500404 else if (phba->link_state == LPFC_WARM_START)
Jamie Wellnitz41415862006-02-28 19:25:27 -0500405 state = "warm start";
James Smart2e0fef82007-06-17 19:56:36 -0500406 else if (phba->link_state == LPFC_INIT_START)
Jamie Wellnitz41415862006-02-28 19:25:27 -0500407 state = "offline";
408 else
409 state = "online";
410
411 return snprintf(buf, PAGE_SIZE, "%s\n", state);
412}
413
414static ssize_t
415lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
416{
James Smart2e0fef82007-06-17 19:56:36 -0500417 struct Scsi_Host *shost = class_to_shost(cdev);
418 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
419 struct lpfc_hba *phba = vport->phba;
Jamie Wellnitz41415862006-02-28 19:25:27 -0500420 struct completion online_compl;
421 int status=0;
422
James Smart13815c82008-01-11 01:52:48 -0500423 if (!phba->cfg_enable_hba_reset)
424 return -EACCES;
Jamie Wellnitz41415862006-02-28 19:25:27 -0500425 init_completion(&online_compl);
426
James Smart46fa3112007-04-25 09:51:45 -0400427 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
Jamie Wellnitz41415862006-02-28 19:25:27 -0500428 lpfc_workq_post_event(phba, &status, &online_compl,
429 LPFC_EVT_ONLINE);
James Smart46fa3112007-04-25 09:51:45 -0400430 wait_for_completion(&online_compl);
431 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
432 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
Jamie Wellnitz41415862006-02-28 19:25:27 -0500433 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
James Smart46fa3112007-04-25 09:51:45 -0400434 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
435 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
436 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
Jamie Wellnitz41415862006-02-28 19:25:27 -0500437 else
438 return -EINVAL;
439
Jamie Wellnitz41415862006-02-28 19:25:27 -0500440 if (!status)
441 return strlen(buf);
442 else
443 return -EIO;
444}
445
James Smart311464e2007-08-02 11:10:37 -0400446static int
James Smart858c9f62007-06-17 19:56:39 -0500447lpfc_get_hba_info(struct lpfc_hba *phba,
448 uint32_t *mxri, uint32_t *axri,
449 uint32_t *mrpi, uint32_t *arpi,
450 uint32_t *mvpi, uint32_t *avpi)
James Smart92d7f7b2007-06-17 19:56:38 -0500451{
452 struct lpfc_sli *psli = &phba->sli;
453 LPFC_MBOXQ_t *pmboxq;
454 MAILBOX_t *pmb;
455 int rc = 0;
456
457 /*
458 * prevent udev from issuing mailbox commands until the port is
459 * configured.
460 */
461 if (phba->link_state < LPFC_LINK_DOWN ||
462 !phba->mbox_mem_pool ||
463 (phba->sli.sli_flag & LPFC_SLI2_ACTIVE) == 0)
464 return 0;
465
466 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
467 return 0;
468
469 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
470 if (!pmboxq)
471 return 0;
472 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
473
474 pmb = &pmboxq->mb;
475 pmb->mbxCommand = MBX_READ_CONFIG;
476 pmb->mbxOwner = OWN_HOST;
477 pmboxq->context1 = NULL;
478
479 if ((phba->pport->fc_flag & FC_OFFLINE_MODE) ||
480 (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
481 rc = MBX_NOT_FINISHED;
482 else
483 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
484
485 if (rc != MBX_SUCCESS) {
James Smart858c9f62007-06-17 19:56:39 -0500486 if (rc != MBX_TIMEOUT)
James Smart92d7f7b2007-06-17 19:56:38 -0500487 mempool_free(pmboxq, phba->mbox_mem_pool);
488 return 0;
489 }
490
491 if (mrpi)
492 *mrpi = pmb->un.varRdConfig.max_rpi;
493 if (arpi)
494 *arpi = pmb->un.varRdConfig.avail_rpi;
495 if (mxri)
496 *mxri = pmb->un.varRdConfig.max_xri;
497 if (axri)
498 *axri = pmb->un.varRdConfig.avail_xri;
James Smart858c9f62007-06-17 19:56:39 -0500499 if (mvpi)
500 *mvpi = pmb->un.varRdConfig.max_vpi;
501 if (avpi)
502 *avpi = pmb->un.varRdConfig.avail_vpi;
James Smart92d7f7b2007-06-17 19:56:38 -0500503
504 mempool_free(pmboxq, phba->mbox_mem_pool);
505 return 1;
506}
507
508static ssize_t
509lpfc_max_rpi_show(struct class_device *cdev, char *buf)
510{
511 struct Scsi_Host *shost = class_to_shost(cdev);
512 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
513 struct lpfc_hba *phba = vport->phba;
514 uint32_t cnt;
515
James Smart858c9f62007-06-17 19:56:39 -0500516 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL))
James Smart92d7f7b2007-06-17 19:56:38 -0500517 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
518 return snprintf(buf, PAGE_SIZE, "Unknown\n");
519}
520
521static ssize_t
522lpfc_used_rpi_show(struct class_device *cdev, char *buf)
523{
524 struct Scsi_Host *shost = class_to_shost(cdev);
525 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
526 struct lpfc_hba *phba = vport->phba;
527 uint32_t cnt, acnt;
528
James Smart858c9f62007-06-17 19:56:39 -0500529 if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
James Smart92d7f7b2007-06-17 19:56:38 -0500530 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
531 return snprintf(buf, PAGE_SIZE, "Unknown\n");
532}
533
534static ssize_t
535lpfc_max_xri_show(struct class_device *cdev, char *buf)
536{
537 struct Scsi_Host *shost = class_to_shost(cdev);
538 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
539 struct lpfc_hba *phba = vport->phba;
540 uint32_t cnt;
541
James Smart858c9f62007-06-17 19:56:39 -0500542 if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL))
James Smart92d7f7b2007-06-17 19:56:38 -0500543 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
544 return snprintf(buf, PAGE_SIZE, "Unknown\n");
545}
546
547static ssize_t
548lpfc_used_xri_show(struct class_device *cdev, char *buf)
549{
550 struct Scsi_Host *shost = class_to_shost(cdev);
551 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
552 struct lpfc_hba *phba = vport->phba;
553 uint32_t cnt, acnt;
554
James Smart858c9f62007-06-17 19:56:39 -0500555 if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
556 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
557 return snprintf(buf, PAGE_SIZE, "Unknown\n");
558}
559
560static ssize_t
561lpfc_max_vpi_show(struct class_device *cdev, char *buf)
562{
563 struct Scsi_Host *shost = class_to_shost(cdev);
564 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
565 struct lpfc_hba *phba = vport->phba;
566 uint32_t cnt;
567
568 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL))
569 return snprintf(buf, PAGE_SIZE, "%d\n", cnt);
570 return snprintf(buf, PAGE_SIZE, "Unknown\n");
571}
572
573static ssize_t
574lpfc_used_vpi_show(struct class_device *cdev, char *buf)
575{
576 struct Scsi_Host *shost = class_to_shost(cdev);
577 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
578 struct lpfc_hba *phba = vport->phba;
579 uint32_t cnt, acnt;
580
581 if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
James Smart92d7f7b2007-06-17 19:56:38 -0500582 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
583 return snprintf(buf, PAGE_SIZE, "Unknown\n");
584}
585
586static ssize_t
587lpfc_npiv_info_show(struct class_device *cdev, char *buf)
588{
589 struct Scsi_Host *shost = class_to_shost(cdev);
590 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
591 struct lpfc_hba *phba = vport->phba;
592
593 if (!(phba->max_vpi))
594 return snprintf(buf, PAGE_SIZE, "NPIV Not Supported\n");
595 if (vport->port_type == LPFC_PHYSICAL_PORT)
596 return snprintf(buf, PAGE_SIZE, "NPIV Physical\n");
597 return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi);
598}
599
Jamie Wellnitz41415862006-02-28 19:25:27 -0500600static ssize_t
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500601lpfc_poll_show(struct class_device *cdev, char *buf)
602{
James Smart2e0fef82007-06-17 19:56:36 -0500603 struct Scsi_Host *shost = class_to_shost(cdev);
604 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
605 struct lpfc_hba *phba = vport->phba;
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500606
607 return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
608}
609
610static ssize_t
611lpfc_poll_store(struct class_device *cdev, const char *buf,
612 size_t count)
613{
James Smart2e0fef82007-06-17 19:56:36 -0500614 struct Scsi_Host *shost = class_to_shost(cdev);
615 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
616 struct lpfc_hba *phba = vport->phba;
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500617 uint32_t creg_val;
618 uint32_t old_val;
619 int val=0;
620
621 if (!isdigit(buf[0]))
622 return -EINVAL;
623
624 if (sscanf(buf, "%i", &val) != 1)
625 return -EINVAL;
626
627 if ((val & 0x3) != val)
628 return -EINVAL;
629
James Smart2e0fef82007-06-17 19:56:36 -0500630 spin_lock_irq(&phba->hbalock);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500631
632 old_val = phba->cfg_poll;
633
634 if (val & ENABLE_FCP_RING_POLLING) {
635 if ((val & DISABLE_FCP_RING_INT) &&
636 !(old_val & DISABLE_FCP_RING_INT)) {
637 creg_val = readl(phba->HCregaddr);
638 creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
639 writel(creg_val, phba->HCregaddr);
640 readl(phba->HCregaddr); /* flush */
641
642 lpfc_poll_start_timer(phba);
643 }
644 } else if (val != 0x0) {
James Smart2e0fef82007-06-17 19:56:36 -0500645 spin_unlock_irq(&phba->hbalock);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500646 return -EINVAL;
647 }
648
649 if (!(val & DISABLE_FCP_RING_INT) &&
650 (old_val & DISABLE_FCP_RING_INT))
651 {
James Smart2e0fef82007-06-17 19:56:36 -0500652 spin_unlock_irq(&phba->hbalock);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500653 del_timer(&phba->fcp_poll_timer);
James Smart2e0fef82007-06-17 19:56:36 -0500654 spin_lock_irq(&phba->hbalock);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500655 creg_val = readl(phba->HCregaddr);
656 creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
657 writel(creg_val, phba->HCregaddr);
658 readl(phba->HCregaddr); /* flush */
659 }
660
661 phba->cfg_poll = val;
662
James Smart2e0fef82007-06-17 19:56:36 -0500663 spin_unlock_irq(&phba->hbalock);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500664
665 return strlen(buf);
666}
dea31012005-04-17 16:05:31 -0500667
668#define lpfc_param_show(attr) \
669static ssize_t \
670lpfc_##attr##_show(struct class_device *cdev, char *buf) \
671{ \
James Smart2e0fef82007-06-17 19:56:36 -0500672 struct Scsi_Host *shost = class_to_shost(cdev);\
673 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
674 struct lpfc_hba *phba = vport->phba;\
dea31012005-04-17 16:05:31 -0500675 int val = 0;\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400676 val = phba->cfg_##attr;\
677 return snprintf(buf, PAGE_SIZE, "%d\n",\
678 phba->cfg_##attr);\
dea31012005-04-17 16:05:31 -0500679}
680
James.Smart@Emulex.Com93a20f72005-10-28 20:29:32 -0400681#define lpfc_param_hex_show(attr) \
682static ssize_t \
683lpfc_##attr##_show(struct class_device *cdev, char *buf) \
684{ \
James Smart2e0fef82007-06-17 19:56:36 -0500685 struct Scsi_Host *shost = class_to_shost(cdev);\
686 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
687 struct lpfc_hba *phba = vport->phba;\
James.Smart@Emulex.Com93a20f72005-10-28 20:29:32 -0400688 int val = 0;\
689 val = phba->cfg_##attr;\
690 return snprintf(buf, PAGE_SIZE, "%#x\n",\
691 phba->cfg_##attr);\
692}
693
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400694#define lpfc_param_init(attr, default, minval, maxval) \
695static int \
696lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
697{ \
698 if (val >= minval && val <= maxval) {\
699 phba->cfg_##attr = val;\
700 return 0;\
701 }\
702 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
James Smarte8b62012007-08-02 11:10:09 -0400703 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
704 "allowed range is ["#minval", "#maxval"]\n", val); \
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400705 phba->cfg_##attr = default;\
706 return -EINVAL;\
707}
708
709#define lpfc_param_set(attr, default, minval, maxval) \
710static int \
711lpfc_##attr##_set(struct lpfc_hba *phba, int val) \
712{ \
713 if (val >= minval && val <= maxval) {\
714 phba->cfg_##attr = val;\
715 return 0;\
716 }\
717 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
James Smarte8b62012007-08-02 11:10:09 -0400718 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
719 "allowed range is ["#minval", "#maxval"]\n", val); \
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400720 return -EINVAL;\
721}
722
723#define lpfc_param_store(attr) \
dea31012005-04-17 16:05:31 -0500724static ssize_t \
725lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
726{ \
James Smart2e0fef82007-06-17 19:56:36 -0500727 struct Scsi_Host *shost = class_to_shost(cdev);\
728 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
729 struct lpfc_hba *phba = vport->phba;\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400730 int val=0;\
James.Smart@Emulex.Com93a20f72005-10-28 20:29:32 -0400731 if (!isdigit(buf[0]))\
732 return -EINVAL;\
733 if (sscanf(buf, "%i", &val) != 1)\
734 return -EINVAL;\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400735 if (lpfc_##attr##_set(phba, val) == 0) \
James.Smart@Emulex.Com755c0d02005-10-28 20:29:06 -0400736 return strlen(buf);\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400737 else \
738 return -EINVAL;\
dea31012005-04-17 16:05:31 -0500739}
740
James Smart3de2a652007-08-02 11:09:59 -0400741#define lpfc_vport_param_show(attr) \
742static ssize_t \
743lpfc_##attr##_show(struct class_device *cdev, char *buf) \
744{ \
745 struct Scsi_Host *shost = class_to_shost(cdev);\
746 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
747 int val = 0;\
748 val = vport->cfg_##attr;\
749 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
750}
751
752#define lpfc_vport_param_hex_show(attr) \
753static ssize_t \
754lpfc_##attr##_show(struct class_device *cdev, char *buf) \
755{ \
756 struct Scsi_Host *shost = class_to_shost(cdev);\
757 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
758 int val = 0;\
759 val = vport->cfg_##attr;\
760 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
761}
762
763#define lpfc_vport_param_init(attr, default, minval, maxval) \
764static int \
765lpfc_##attr##_init(struct lpfc_vport *vport, int val) \
766{ \
767 if (val >= minval && val <= maxval) {\
768 vport->cfg_##attr = val;\
769 return 0;\
770 }\
James Smarte8b62012007-08-02 11:10:09 -0400771 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
772 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
773 "allowed range is ["#minval", "#maxval"]\n", val); \
James Smart3de2a652007-08-02 11:09:59 -0400774 vport->cfg_##attr = default;\
775 return -EINVAL;\
776}
777
778#define lpfc_vport_param_set(attr, default, minval, maxval) \
779static int \
780lpfc_##attr##_set(struct lpfc_vport *vport, int val) \
781{ \
782 if (val >= minval && val <= maxval) {\
783 vport->cfg_##attr = val;\
784 return 0;\
785 }\
James Smarte8b62012007-08-02 11:10:09 -0400786 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
787 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
788 "allowed range is ["#minval", "#maxval"]\n", val); \
James Smart3de2a652007-08-02 11:09:59 -0400789 return -EINVAL;\
790}
791
792#define lpfc_vport_param_store(attr) \
793static ssize_t \
794lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
795{ \
796 struct Scsi_Host *shost = class_to_shost(cdev);\
797 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
798 int val=0;\
799 if (!isdigit(buf[0]))\
800 return -EINVAL;\
801 if (sscanf(buf, "%i", &val) != 1)\
802 return -EINVAL;\
803 if (lpfc_##attr##_set(vport, val) == 0) \
804 return strlen(buf);\
805 else \
806 return -EINVAL;\
807}
808
809
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400810#define LPFC_ATTR(name, defval, minval, maxval, desc) \
811static int lpfc_##name = defval;\
dea31012005-04-17 16:05:31 -0500812module_param(lpfc_##name, int, 0);\
813MODULE_PARM_DESC(lpfc_##name, desc);\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400814lpfc_param_init(name, defval, minval, maxval)
dea31012005-04-17 16:05:31 -0500815
816#define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
817static int lpfc_##name = defval;\
818module_param(lpfc_##name, int, 0);\
819MODULE_PARM_DESC(lpfc_##name, desc);\
820lpfc_param_show(name)\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400821lpfc_param_init(name, defval, minval, maxval)\
dea31012005-04-17 16:05:31 -0500822static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
823
824#define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
825static int lpfc_##name = defval;\
826module_param(lpfc_##name, int, 0);\
827MODULE_PARM_DESC(lpfc_##name, desc);\
828lpfc_param_show(name)\
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -0400829lpfc_param_init(name, defval, minval, maxval)\
830lpfc_param_set(name, defval, minval, maxval)\
831lpfc_param_store(name)\
dea31012005-04-17 16:05:31 -0500832static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
833 lpfc_##name##_show, lpfc_##name##_store)
834
James.Smart@Emulex.Com93a20f72005-10-28 20:29:32 -0400835#define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
836static int lpfc_##name = defval;\
837module_param(lpfc_##name, int, 0);\
838MODULE_PARM_DESC(lpfc_##name, desc);\
839lpfc_param_hex_show(name)\
840lpfc_param_init(name, defval, minval, maxval)\
841static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
842
843#define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
844static int lpfc_##name = defval;\
845module_param(lpfc_##name, int, 0);\
846MODULE_PARM_DESC(lpfc_##name, desc);\
847lpfc_param_hex_show(name)\
848lpfc_param_init(name, defval, minval, maxval)\
849lpfc_param_set(name, defval, minval, maxval)\
850lpfc_param_store(name)\
851static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
852 lpfc_##name##_show, lpfc_##name##_store)
853
James Smart3de2a652007-08-02 11:09:59 -0400854#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
855static int lpfc_##name = defval;\
856module_param(lpfc_##name, int, 0);\
857MODULE_PARM_DESC(lpfc_##name, desc);\
858lpfc_vport_param_init(name, defval, minval, maxval)
859
860#define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
861static int lpfc_##name = defval;\
862module_param(lpfc_##name, int, 0);\
863MODULE_PARM_DESC(lpfc_##name, desc);\
864lpfc_vport_param_show(name)\
865lpfc_vport_param_init(name, defval, minval, maxval)\
866static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
867
868#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
869static int lpfc_##name = defval;\
870module_param(lpfc_##name, int, 0);\
871MODULE_PARM_DESC(lpfc_##name, desc);\
872lpfc_vport_param_show(name)\
873lpfc_vport_param_init(name, defval, minval, maxval)\
874lpfc_vport_param_set(name, defval, minval, maxval)\
875lpfc_vport_param_store(name)\
876static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
877 lpfc_##name##_show, lpfc_##name##_store)
878
879#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
880static int lpfc_##name = defval;\
881module_param(lpfc_##name, int, 0);\
882MODULE_PARM_DESC(lpfc_##name, desc);\
883lpfc_vport_param_hex_show(name)\
884lpfc_vport_param_init(name, defval, minval, maxval)\
885static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
886
887#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
888static int lpfc_##name = defval;\
889module_param(lpfc_##name, int, 0);\
890MODULE_PARM_DESC(lpfc_##name, desc);\
891lpfc_vport_param_hex_show(name)\
892lpfc_vport_param_init(name, defval, minval, maxval)\
893lpfc_vport_param_set(name, defval, minval, maxval)\
894lpfc_vport_param_store(name)\
895static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
896 lpfc_##name##_show, lpfc_##name##_store)
897
dea31012005-04-17 16:05:31 -0500898static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
899static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
900static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
901static CLASS_DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL);
902static CLASS_DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
James Smart2e0fef82007-06-17 19:56:36 -0500903static CLASS_DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL);
dea31012005-04-17 16:05:31 -0500904static CLASS_DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
905static CLASS_DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
906static CLASS_DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL);
907static CLASS_DEVICE_ATTR(option_rom_version, S_IRUGO,
908 lpfc_option_rom_version_show, NULL);
909static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO,
910 lpfc_num_discovered_ports_show, NULL);
911static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
912static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show,
913 NULL);
Jamie Wellnitz41415862006-02-28 19:25:27 -0500914static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
915 lpfc_board_mode_show, lpfc_board_mode_store);
James Smart40496f02006-07-06 15:50:22 -0400916static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
James Smart92d7f7b2007-06-17 19:56:38 -0500917static CLASS_DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL);
918static CLASS_DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL);
919static CLASS_DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL);
920static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
921static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
922static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
923static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
James Smart57127f12007-10-27 13:37:05 -0400924static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show,
925 NULL);
dea31012005-04-17 16:05:31 -0500926
James Smartc3f28af2006-08-18 17:47:18 -0400927
James Smarta12e07b2006-12-02 13:35:30 -0500928static char *lpfc_soft_wwn_key = "C99G71SL8032A";
James Smartc3f28af2006-08-18 17:47:18 -0400929
930static ssize_t
James Smarta12e07b2006-12-02 13:35:30 -0500931lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf,
James Smartc3f28af2006-08-18 17:47:18 -0400932 size_t count)
933{
James Smart2e0fef82007-06-17 19:56:36 -0500934 struct Scsi_Host *shost = class_to_shost(cdev);
935 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
936 struct lpfc_hba *phba = vport->phba;
James Smartc3f28af2006-08-18 17:47:18 -0400937 unsigned int cnt = count;
938
939 /*
940 * We're doing a simple sanity check for soft_wwpn setting.
941 * We require that the user write a specific key to enable
942 * the soft_wwpn attribute to be settable. Once the attribute
943 * is written, the enable key resets. If further updates are
944 * desired, the key must be written again to re-enable the
945 * attribute.
946 *
947 * The "key" is not secret - it is a hardcoded string shown
948 * here. The intent is to protect against the random user or
949 * application that is just writing attributes.
950 */
951
952 /* count may include a LF at end of string */
953 if (buf[cnt-1] == '\n')
954 cnt--;
955
James Smarta12e07b2006-12-02 13:35:30 -0500956 if ((cnt != strlen(lpfc_soft_wwn_key)) ||
957 (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0))
James Smartc3f28af2006-08-18 17:47:18 -0400958 return -EINVAL;
959
James Smarta12e07b2006-12-02 13:35:30 -0500960 phba->soft_wwn_enable = 1;
James Smartc3f28af2006-08-18 17:47:18 -0400961 return count;
962}
James Smarta12e07b2006-12-02 13:35:30 -0500963static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
964 lpfc_soft_wwn_enable_store);
James Smartc3f28af2006-08-18 17:47:18 -0400965
966static ssize_t
967lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
968{
James Smart2e0fef82007-06-17 19:56:36 -0500969 struct Scsi_Host *shost = class_to_shost(cdev);
970 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
971 struct lpfc_hba *phba = vport->phba;
972
Randy Dunlapafc071e2006-10-23 21:47:13 -0700973 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
974 (unsigned long long)phba->cfg_soft_wwpn);
James Smartc3f28af2006-08-18 17:47:18 -0400975}
976
977
978static ssize_t
979lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
980{
James Smart2e0fef82007-06-17 19:56:36 -0500981 struct Scsi_Host *shost = class_to_shost(cdev);
982 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
983 struct lpfc_hba *phba = vport->phba;
James Smartc3f28af2006-08-18 17:47:18 -0400984 struct completion online_compl;
985 int stat1=0, stat2=0;
986 unsigned int i, j, cnt=count;
987 u8 wwpn[8];
988
James Smart13815c82008-01-11 01:52:48 -0500989 if (!phba->cfg_enable_hba_reset)
990 return -EACCES;
James Smart7af67052007-10-27 13:38:11 -0400991 spin_lock_irq(&phba->hbalock);
992 if (phba->over_temp_state == HBA_OVER_TEMP) {
993 spin_unlock_irq(&phba->hbalock);
James Smart09372822008-01-11 01:52:54 -0500994 return -EACCES;
James Smart7af67052007-10-27 13:38:11 -0400995 }
996 spin_unlock_irq(&phba->hbalock);
James Smartc3f28af2006-08-18 17:47:18 -0400997 /* count may include a LF at end of string */
998 if (buf[cnt-1] == '\n')
999 cnt--;
1000
James Smarta12e07b2006-12-02 13:35:30 -05001001 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
James Smartc3f28af2006-08-18 17:47:18 -04001002 ((cnt == 17) && (*buf++ != 'x')) ||
1003 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
1004 return -EINVAL;
1005
James Smarta12e07b2006-12-02 13:35:30 -05001006 phba->soft_wwn_enable = 0;
James Smartc3f28af2006-08-18 17:47:18 -04001007
1008 memset(wwpn, 0, sizeof(wwpn));
1009
1010 /* Validate and store the new name */
1011 for (i=0, j=0; i < 16; i++) {
1012 if ((*buf >= 'a') && (*buf <= 'f'))
1013 j = ((j << 4) | ((*buf++ -'a') + 10));
1014 else if ((*buf >= 'A') && (*buf <= 'F'))
1015 j = ((j << 4) | ((*buf++ -'A') + 10));
1016 else if ((*buf >= '0') && (*buf <= '9'))
1017 j = ((j << 4) | (*buf++ -'0'));
1018 else
1019 return -EINVAL;
1020 if (i % 2) {
1021 wwpn[i/2] = j & 0xff;
1022 j = 0;
1023 }
1024 }
1025 phba->cfg_soft_wwpn = wwn_to_u64(wwpn);
James Smart2e0fef82007-06-17 19:56:36 -05001026 fc_host_port_name(shost) = phba->cfg_soft_wwpn;
James Smarta12e07b2006-12-02 13:35:30 -05001027 if (phba->cfg_soft_wwnn)
James Smart2e0fef82007-06-17 19:56:36 -05001028 fc_host_node_name(shost) = phba->cfg_soft_wwnn;
James Smartc3f28af2006-08-18 17:47:18 -04001029
1030 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
1031 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
1032
James Smart46fa3112007-04-25 09:51:45 -04001033 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
James Smartc3f28af2006-08-18 17:47:18 -04001034 if (stat1)
1035 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
James Smarte8b62012007-08-02 11:10:09 -04001036 "0463 lpfc_soft_wwpn attribute set failed to "
1037 "reinit adapter - %d\n", stat1);
James Smartc3f28af2006-08-18 17:47:18 -04001038 init_completion(&online_compl);
1039 lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE);
1040 wait_for_completion(&online_compl);
1041 if (stat2)
1042 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
James Smarte8b62012007-08-02 11:10:09 -04001043 "0464 lpfc_soft_wwpn attribute set failed to "
1044 "reinit adapter - %d\n", stat2);
James Smartc3f28af2006-08-18 17:47:18 -04001045 return (stat1 || stat2) ? -EIO : count;
1046}
1047static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
1048 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
1049
James Smarta12e07b2006-12-02 13:35:30 -05001050static ssize_t
1051lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
1052{
James Smart51ef4c22007-08-02 11:10:31 -04001053 struct Scsi_Host *shost = class_to_shost(cdev);
1054 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
James Smarta12e07b2006-12-02 13:35:30 -05001055 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
1056 (unsigned long long)phba->cfg_soft_wwnn);
1057}
1058
1059
1060static ssize_t
1061lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count)
1062{
James Smart51ef4c22007-08-02 11:10:31 -04001063 struct Scsi_Host *shost = class_to_shost(cdev);
1064 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
James Smarta12e07b2006-12-02 13:35:30 -05001065 unsigned int i, j, cnt=count;
1066 u8 wwnn[8];
1067
1068 /* count may include a LF at end of string */
1069 if (buf[cnt-1] == '\n')
1070 cnt--;
1071
1072 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
1073 ((cnt == 17) && (*buf++ != 'x')) ||
1074 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
1075 return -EINVAL;
1076
1077 /*
1078 * Allow wwnn to be set many times, as long as the enable is set.
1079 * However, once the wwpn is set, everything locks.
1080 */
1081
1082 memset(wwnn, 0, sizeof(wwnn));
1083
1084 /* Validate and store the new name */
1085 for (i=0, j=0; i < 16; i++) {
1086 if ((*buf >= 'a') && (*buf <= 'f'))
1087 j = ((j << 4) | ((*buf++ -'a') + 10));
1088 else if ((*buf >= 'A') && (*buf <= 'F'))
1089 j = ((j << 4) | ((*buf++ -'A') + 10));
1090 else if ((*buf >= '0') && (*buf <= '9'))
1091 j = ((j << 4) | (*buf++ -'0'));
1092 else
1093 return -EINVAL;
1094 if (i % 2) {
1095 wwnn[i/2] = j & 0xff;
1096 j = 0;
1097 }
1098 }
1099 phba->cfg_soft_wwnn = wwn_to_u64(wwnn);
1100
1101 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
1102 "lpfc%d: soft_wwnn set. Value will take effect upon "
1103 "setting of the soft_wwpn\n", phba->brd_no);
1104
1105 return count;
1106}
1107static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\
1108 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
1109
James Smartc3f28af2006-08-18 17:47:18 -04001110
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001111static int lpfc_poll = 0;
1112module_param(lpfc_poll, int, 0);
1113MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
1114 " 0 - none,"
1115 " 1 - poll with interrupts enabled"
1116 " 3 - poll and disable FCP ring interrupts");
1117
1118static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
1119 lpfc_poll_show, lpfc_poll_store);
dea31012005-04-17 16:05:31 -05001120
James Smart92d7f7b2007-06-17 19:56:38 -05001121int lpfc_sli_mode = 0;
1122module_param(lpfc_sli_mode, int, 0);
1123MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:"
1124 " 0 - auto (SLI-3 if supported),"
1125 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
1126 " 3 - select SLI-3");
1127
James Smart7ee5d432007-10-27 13:37:17 -04001128int lpfc_enable_npiv = 0;
1129module_param(lpfc_enable_npiv, int, 0);
1130MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality");
1131lpfc_param_show(enable_npiv);
1132lpfc_param_init(enable_npiv, 0, 0, 1);
1133static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO,
1134 lpfc_enable_npiv_show, NULL);
James Smart92d7f7b2007-06-17 19:56:38 -05001135
dea31012005-04-17 16:05:31 -05001136/*
James Smartc01f3202006-08-18 17:47:08 -04001137# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
1138# until the timer expires. Value range is [0,255]. Default value is 30.
1139*/
1140static int lpfc_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
1141static int lpfc_devloss_tmo = LPFC_DEF_DEVLOSS_TMO;
1142module_param(lpfc_nodev_tmo, int, 0);
1143MODULE_PARM_DESC(lpfc_nodev_tmo,
1144 "Seconds driver will hold I/O waiting "
1145 "for a device to come back");
1146static ssize_t
1147lpfc_nodev_tmo_show(struct class_device *cdev, char *buf)
1148{
James Smart2e0fef82007-06-17 19:56:36 -05001149 struct Scsi_Host *shost = class_to_shost(cdev);
1150 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
James Smartc01f3202006-08-18 17:47:08 -04001151 int val = 0;
James Smart3de2a652007-08-02 11:09:59 -04001152 val = vport->cfg_devloss_tmo;
1153 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
James Smartc01f3202006-08-18 17:47:08 -04001154}
1155
1156static int
James Smart3de2a652007-08-02 11:09:59 -04001157lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
James Smartc01f3202006-08-18 17:47:08 -04001158{
James Smart3de2a652007-08-02 11:09:59 -04001159 if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
1160 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
1161 if (val != LPFC_DEF_DEVLOSS_TMO)
James Smarte8b62012007-08-02 11:10:09 -04001162 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1163 "0402 Ignoring nodev_tmo module "
1164 "parameter because devloss_tmo is "
1165 "set.\n");
James Smartc01f3202006-08-18 17:47:08 -04001166 return 0;
1167 }
1168
1169 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
James Smart3de2a652007-08-02 11:09:59 -04001170 vport->cfg_nodev_tmo = val;
1171 vport->cfg_devloss_tmo = val;
James Smartc01f3202006-08-18 17:47:08 -04001172 return 0;
1173 }
James Smarte8b62012007-08-02 11:10:09 -04001174 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1175 "0400 lpfc_nodev_tmo attribute cannot be set to"
1176 " %d, allowed range is [%d, %d]\n",
1177 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
James Smart3de2a652007-08-02 11:09:59 -04001178 vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
James Smartc01f3202006-08-18 17:47:08 -04001179 return -EINVAL;
1180}
1181
James Smart7054a602007-04-25 09:52:34 -04001182static void
James Smart3de2a652007-08-02 11:09:59 -04001183lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
James Smart7054a602007-04-25 09:52:34 -04001184{
James Smart858c9f62007-06-17 19:56:39 -05001185 struct Scsi_Host *shost;
James Smart7054a602007-04-25 09:52:34 -04001186 struct lpfc_nodelist *ndlp;
1187
James Smart51ef4c22007-08-02 11:10:31 -04001188 shost = lpfc_shost_from_vport(vport);
1189 spin_lock_irq(shost->host_lock);
1190 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
1191 if (ndlp->rport)
1192 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
1193 spin_unlock_irq(shost->host_lock);
James Smart7054a602007-04-25 09:52:34 -04001194}
1195
James Smartc01f3202006-08-18 17:47:08 -04001196static int
James Smart3de2a652007-08-02 11:09:59 -04001197lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
James Smartc01f3202006-08-18 17:47:08 -04001198{
James Smart3de2a652007-08-02 11:09:59 -04001199 if (vport->dev_loss_tmo_changed ||
1200 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
James Smarte8b62012007-08-02 11:10:09 -04001201 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1202 "0401 Ignoring change to nodev_tmo "
1203 "because devloss_tmo is set.\n");
James Smartc01f3202006-08-18 17:47:08 -04001204 return 0;
1205 }
James Smartc01f3202006-08-18 17:47:08 -04001206 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
James Smart3de2a652007-08-02 11:09:59 -04001207 vport->cfg_nodev_tmo = val;
1208 vport->cfg_devloss_tmo = val;
1209 lpfc_update_rport_devloss_tmo(vport);
James Smartc01f3202006-08-18 17:47:08 -04001210 return 0;
1211 }
James Smarte8b62012007-08-02 11:10:09 -04001212 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1213 "0403 lpfc_nodev_tmo attribute cannot be set to"
1214 "%d, allowed range is [%d, %d]\n",
1215 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
James Smartc01f3202006-08-18 17:47:08 -04001216 return -EINVAL;
1217}
1218
James Smart3de2a652007-08-02 11:09:59 -04001219lpfc_vport_param_store(nodev_tmo)
James Smartc01f3202006-08-18 17:47:08 -04001220
1221static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
1222 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
1223
1224/*
1225# lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
1226# disappear until the timer expires. Value range is [0,255]. Default
1227# value is 30.
1228*/
1229module_param(lpfc_devloss_tmo, int, 0);
1230MODULE_PARM_DESC(lpfc_devloss_tmo,
1231 "Seconds driver will hold I/O waiting "
1232 "for a device to come back");
James Smart3de2a652007-08-02 11:09:59 -04001233lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
1234 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
1235lpfc_vport_param_show(devloss_tmo)
James Smartc01f3202006-08-18 17:47:08 -04001236static int
James Smart3de2a652007-08-02 11:09:59 -04001237lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
James Smartc01f3202006-08-18 17:47:08 -04001238{
1239 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
James Smart3de2a652007-08-02 11:09:59 -04001240 vport->cfg_nodev_tmo = val;
1241 vport->cfg_devloss_tmo = val;
1242 vport->dev_loss_tmo_changed = 1;
1243 lpfc_update_rport_devloss_tmo(vport);
James Smartc01f3202006-08-18 17:47:08 -04001244 return 0;
1245 }
1246
James Smarte8b62012007-08-02 11:10:09 -04001247 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1248 "0404 lpfc_devloss_tmo attribute cannot be set to"
1249 " %d, allowed range is [%d, %d]\n",
1250 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
James Smartc01f3202006-08-18 17:47:08 -04001251 return -EINVAL;
1252}
1253
James Smart3de2a652007-08-02 11:09:59 -04001254lpfc_vport_param_store(devloss_tmo)
James Smartc01f3202006-08-18 17:47:08 -04001255static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1256 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
1257
1258/*
dea31012005-04-17 16:05:31 -05001259# lpfc_log_verbose: Only turn this flag on if you are willing to risk being
1260# deluged with LOTS of information.
1261# You can set a bit mask to record specific types of verbose messages:
1262#
1263# LOG_ELS 0x1 ELS events
1264# LOG_DISCOVERY 0x2 Link discovery events
1265# LOG_MBOX 0x4 Mailbox events
1266# LOG_INIT 0x8 Initialization events
1267# LOG_LINK_EVENT 0x10 Link events
dea31012005-04-17 16:05:31 -05001268# LOG_FCP 0x40 FCP traffic history
1269# LOG_NODE 0x80 Node table events
1270# LOG_MISC 0x400 Miscellaneous events
1271# LOG_SLI 0x800 SLI events
James Smartc7743952006-12-02 13:34:42 -05001272# LOG_FCP_ERROR 0x1000 Only log FCP errors
dea31012005-04-17 16:05:31 -05001273# LOG_LIBDFC 0x2000 LIBDFC events
1274# LOG_ALL_MSG 0xffff LOG all messages
1275*/
James Smarte8b62012007-08-02 11:10:09 -04001276LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,
1277 "Verbose logging bit-mask");
dea31012005-04-17 16:05:31 -05001278
1279/*
James Smart7ee5d432007-10-27 13:37:17 -04001280# lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
1281# objects that have been registered with the nameserver after login.
1282*/
1283LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1,
1284 "Deregister nameserver objects before LOGO");
1285
1286/*
dea31012005-04-17 16:05:31 -05001287# lun_queue_depth: This parameter is used to limit the number of outstanding
1288# commands per FCP LUN. Value range is [1,128]. Default value is 30.
1289*/
James Smart3de2a652007-08-02 11:09:59 -04001290LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 128,
1291 "Max number of FCP commands we can queue to a specific LUN");
dea31012005-04-17 16:05:31 -05001292
1293/*
Jamie Wellnitzb28485a2006-02-28 19:25:21 -05001294# hba_queue_depth: This parameter is used to limit the number of outstanding
1295# commands per lpfc HBA. Value range is [32,8192]. If this parameter
1296# value is greater than the maximum number of exchanges supported by the HBA,
1297# then maximum number of exchanges supported by the HBA is used to determine
1298# the hba_queue_depth.
1299*/
1300LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
1301 "Max number of FCP commands we can queue to a lpfc HBA");
1302
1303/*
James Smart92d7f7b2007-06-17 19:56:38 -05001304# peer_port_login: This parameter allows/prevents logins
1305# between peer ports hosted on the same physical port.
1306# When this parameter is set 0 peer ports of same physical port
1307# are not allowed to login to each other.
1308# When this parameter is set 1 peer ports of same physical port
1309# are allowed to login to each other.
1310# Default value of this parameter is 0.
1311*/
James Smart3de2a652007-08-02 11:09:59 -04001312LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
1313 "Allow peer ports on the same physical port to login to each "
1314 "other.");
James Smart92d7f7b2007-06-17 19:56:38 -05001315
1316/*
James Smart3de2a652007-08-02 11:09:59 -04001317# restrict_login: This parameter allows/prevents logins
James Smart92d7f7b2007-06-17 19:56:38 -05001318# between Virtual Ports and remote initiators.
1319# When this parameter is not set (0) Virtual Ports will accept PLOGIs from
1320# other initiators and will attempt to PLOGI all remote ports.
1321# When this parameter is set (1) Virtual Ports will reject PLOGIs from
1322# remote ports and will not attempt to PLOGI to other initiators.
1323# This parameter does not restrict to the physical port.
1324# This parameter does not restrict logins to Fabric resident remote ports.
1325# Default value of this parameter is 1.
1326*/
James Smart3de2a652007-08-02 11:09:59 -04001327static int lpfc_restrict_login = 1;
1328module_param(lpfc_restrict_login, int, 0);
1329MODULE_PARM_DESC(lpfc_restrict_login,
1330 "Restrict virtual ports login to remote initiators.");
1331lpfc_vport_param_show(restrict_login);
1332
1333static int
1334lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
1335{
1336 if (val < 0 || val > 1) {
James Smarte8b62012007-08-02 11:10:09 -04001337 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1338 "0449 lpfc_restrict_login attribute cannot "
1339 "be set to %d, allowed range is [0, 1]\n",
1340 val);
James Smart3de2a652007-08-02 11:09:59 -04001341 vport->cfg_restrict_login = 1;
1342 return -EINVAL;
1343 }
1344 if (vport->port_type == LPFC_PHYSICAL_PORT) {
1345 vport->cfg_restrict_login = 0;
1346 return 0;
1347 }
1348 vport->cfg_restrict_login = val;
1349 return 0;
1350}
1351
1352static int
1353lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
1354{
1355 if (val < 0 || val > 1) {
James Smarte8b62012007-08-02 11:10:09 -04001356 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1357 "0450 lpfc_restrict_login attribute cannot "
1358 "be set to %d, allowed range is [0, 1]\n",
1359 val);
James Smart3de2a652007-08-02 11:09:59 -04001360 vport->cfg_restrict_login = 1;
1361 return -EINVAL;
1362 }
1363 if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
James Smarte8b62012007-08-02 11:10:09 -04001364 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1365 "0468 lpfc_restrict_login must be 0 for "
1366 "Physical ports.\n");
James Smart3de2a652007-08-02 11:09:59 -04001367 vport->cfg_restrict_login = 0;
1368 return 0;
1369 }
1370 vport->cfg_restrict_login = val;
1371 return 0;
1372}
1373lpfc_vport_param_store(restrict_login);
1374static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
1375 lpfc_restrict_login_show, lpfc_restrict_login_store);
James Smart92d7f7b2007-06-17 19:56:38 -05001376
1377/*
dea31012005-04-17 16:05:31 -05001378# Some disk devices have a "select ID" or "select Target" capability.
1379# From a protocol standpoint "select ID" usually means select the
1380# Fibre channel "ALPA". In the FC-AL Profile there is an "informative
1381# annex" which contains a table that maps a "select ID" (a number
1382# between 0 and 7F) to an ALPA. By default, for compatibility with
1383# older drivers, the lpfc driver scans this table from low ALPA to high
1384# ALPA.
1385#
1386# Turning on the scan-down variable (on = 1, off = 0) will
1387# cause the lpfc driver to use an inverted table, effectively
1388# scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
1389#
1390# (Note: This "select ID" functionality is a LOOP ONLY characteristic
1391# and will not work across a fabric. Also this parameter will take
1392# effect only in the case when ALPA map is not available.)
1393*/
James Smart3de2a652007-08-02 11:09:59 -04001394LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
1395 "Start scanning for devices from highest ALPA to lowest");
dea31012005-04-17 16:05:31 -05001396
1397/*
dea31012005-04-17 16:05:31 -05001398# lpfc_topology: link topology for init link
1399# 0x0 = attempt loop mode then point-to-point
Jamie Wellnitz367c2712006-02-28 19:25:32 -05001400# 0x01 = internal loopback mode
dea31012005-04-17 16:05:31 -05001401# 0x02 = attempt point-to-point mode only
1402# 0x04 = attempt loop mode only
1403# 0x06 = attempt point-to-point mode then loop
1404# Set point-to-point mode if you want to run as an N_Port.
1405# Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
1406# Default value is 0.
1407*/
Jamie Wellnitz367c2712006-02-28 19:25:32 -05001408LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");
dea31012005-04-17 16:05:31 -05001409
1410/*
1411# lpfc_link_speed: Link speed selection for initializing the Fibre Channel
1412# connection.
1413# 0 = auto select (default)
1414# 1 = 1 Gigabaud
1415# 2 = 2 Gigabaud
1416# 4 = 4 Gigabaud
James Smartb87eab32007-04-25 09:53:28 -04001417# 8 = 8 Gigabaud
1418# Value range is [0,8]. Default value is 0.
dea31012005-04-17 16:05:31 -05001419*/
James Smartb87eab32007-04-25 09:53:28 -04001420LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");
dea31012005-04-17 16:05:31 -05001421
1422/*
1423# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
1424# Value range is [2,3]. Default value is 3.
1425*/
James Smart3de2a652007-08-02 11:09:59 -04001426LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
1427 "Select Fibre Channel class of service for FCP sequences");
dea31012005-04-17 16:05:31 -05001428
1429/*
1430# lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
1431# is [0,1]. Default value is 0.
1432*/
James Smart3de2a652007-08-02 11:09:59 -04001433LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
1434 "Use ADISC on rediscovery to authenticate FCP devices");
dea31012005-04-17 16:05:31 -05001435
1436/*
1437# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
1438# range is [0,1]. Default value is 0.
1439*/
1440LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
1441
1442/*
1443# lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
1444# cr_delay (msec) or cr_count outstanding commands. cr_delay can take
James Smart7054a602007-04-25 09:52:34 -04001445# value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
dea31012005-04-17 16:05:31 -05001446# is 0. Default value of cr_count is 1. The cr_count feature is disabled if
1447# cr_delay is set to 0.
1448*/
Jamie Wellnitz8189fd12006-02-28 19:25:35 -05001449LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an "
dea31012005-04-17 16:05:31 -05001450 "interrupt response is generated");
1451
Jamie Wellnitz8189fd12006-02-28 19:25:35 -05001452LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an "
dea31012005-04-17 16:05:31 -05001453 "interrupt response is generated");
1454
1455/*
Jamie Wellnitzcf5bf972006-02-28 22:33:08 -05001456# lpfc_multi_ring_support: Determines how many rings to spread available
1457# cmd/rsp IOCB entries across.
1458# Value range is [1,2]. Default value is 1.
1459*/
1460LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
1461 "SLI rings to spread IOCB entries across");
1462
1463/*
James Smarta4bc3372006-12-02 13:34:16 -05001464# lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
1465# identifies what rctl value to configure the additional ring for.
1466# Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
1467*/
1468LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1,
1469 255, "Identifies RCTL for additional ring configuration");
1470
1471/*
1472# lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
1473# identifies what type value to configure the additional ring for.
1474# Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
1475*/
1476LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1,
1477 255, "Identifies TYPE for additional ring configuration");
1478
1479/*
dea31012005-04-17 16:05:31 -05001480# lpfc_fdmi_on: controls FDMI support.
1481# 0 = no FDMI support
1482# 1 = support FDMI without attribute of hostname
1483# 2 = support FDMI with attribute of hostname
1484# Value range [0,2]. Default value is 0.
1485*/
James Smart3de2a652007-08-02 11:09:59 -04001486LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
dea31012005-04-17 16:05:31 -05001487
1488/*
1489# Specifies the maximum number of ELS cmds we can have outstanding (for
1490# discovery). Value range is [1,64]. Default value = 32.
1491*/
James Smart3de2a652007-08-02 11:09:59 -04001492LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
dea31012005-04-17 16:05:31 -05001493 "during discovery");
1494
1495/*
James Smart65a29c12006-07-06 15:50:50 -04001496# lpfc_max_luns: maximum allowed LUN.
1497# Value range is [0,65535]. Default value is 255.
1498# NOTE: The SCSI layer might probe all allowed LUN on some old targets.
dea31012005-04-17 16:05:31 -05001499*/
James Smart3de2a652007-08-02 11:09:59 -04001500LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN");
dea31012005-04-17 16:05:31 -05001501
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001502/*
1503# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
1504# Value range is [1,255], default value is 10.
1505*/
1506LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
1507 "Milliseconds driver will wait between polling FCP ring");
1508
James Smart4ff43242006-12-02 13:34:56 -05001509/*
1510# lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
1511# support this feature
1512# 0 = MSI disabled (default)
1513# 1 = MSI enabled
1514# Value range is [0,1]. Default value is 0.
1515*/
1516LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");
1517
James Smart13815c82008-01-11 01:52:48 -05001518/*
1519# lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
1520# 0 = HBA resets disabled
1521# 1 = HBA resets enabled (default)
1522# Value range is [0,1]. Default value is 1.
1523*/
1524LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
James Smartc3f28af2006-08-18 17:47:18 -04001525
James Smart13815c82008-01-11 01:52:48 -05001526/*
1527# lpfc_enable_hba_heartbeat: Enable HBA heartbeat timer..
1528# 0 = HBA Heartbeat disabled
1529# 1 = HBA Heartbeat enabled (default)
1530# Value range is [0,1]. Default value is 1.
1531*/
1532LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
James Smart92d7f7b2007-06-17 19:56:38 -05001533
James Smart2e0fef82007-06-17 19:56:36 -05001534struct class_device_attribute *lpfc_hba_attrs[] = {
dea31012005-04-17 16:05:31 -05001535 &class_device_attr_info,
1536 &class_device_attr_serialnum,
1537 &class_device_attr_modeldesc,
1538 &class_device_attr_modelname,
1539 &class_device_attr_programtype,
1540 &class_device_attr_portnum,
1541 &class_device_attr_fwrev,
1542 &class_device_attr_hdw,
1543 &class_device_attr_option_rom_version,
1544 &class_device_attr_state,
1545 &class_device_attr_num_discovered_ports,
1546 &class_device_attr_lpfc_drvr_version,
James Smart57127f12007-10-27 13:37:05 -04001547 &class_device_attr_lpfc_temp_sensor,
dea31012005-04-17 16:05:31 -05001548 &class_device_attr_lpfc_log_verbose,
1549 &class_device_attr_lpfc_lun_queue_depth,
Jamie Wellnitzb28485a2006-02-28 19:25:21 -05001550 &class_device_attr_lpfc_hba_queue_depth,
James Smart92d7f7b2007-06-17 19:56:38 -05001551 &class_device_attr_lpfc_peer_port_login,
dea31012005-04-17 16:05:31 -05001552 &class_device_attr_lpfc_nodev_tmo,
James Smartc01f3202006-08-18 17:47:08 -04001553 &class_device_attr_lpfc_devloss_tmo,
dea31012005-04-17 16:05:31 -05001554 &class_device_attr_lpfc_fcp_class,
1555 &class_device_attr_lpfc_use_adisc,
1556 &class_device_attr_lpfc_ack0,
1557 &class_device_attr_lpfc_topology,
1558 &class_device_attr_lpfc_scan_down,
1559 &class_device_attr_lpfc_link_speed,
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001560 &class_device_attr_lpfc_cr_delay,
1561 &class_device_attr_lpfc_cr_count,
Jamie Wellnitzcf5bf972006-02-28 22:33:08 -05001562 &class_device_attr_lpfc_multi_ring_support,
James Smarta4bc3372006-12-02 13:34:16 -05001563 &class_device_attr_lpfc_multi_ring_rctl,
1564 &class_device_attr_lpfc_multi_ring_type,
dea31012005-04-17 16:05:31 -05001565 &class_device_attr_lpfc_fdmi_on,
1566 &class_device_attr_lpfc_max_luns,
James Smart78b2d852007-08-02 11:10:21 -04001567 &class_device_attr_lpfc_enable_npiv,
dea31012005-04-17 16:05:31 -05001568 &class_device_attr_nport_evt_cnt,
Jamie Wellnitz41415862006-02-28 19:25:27 -05001569 &class_device_attr_board_mode,
James Smart92d7f7b2007-06-17 19:56:38 -05001570 &class_device_attr_max_vpi,
1571 &class_device_attr_used_vpi,
1572 &class_device_attr_max_rpi,
1573 &class_device_attr_used_rpi,
1574 &class_device_attr_max_xri,
1575 &class_device_attr_used_xri,
1576 &class_device_attr_npiv_info,
James Smart40496f02006-07-06 15:50:22 -04001577 &class_device_attr_issue_reset,
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001578 &class_device_attr_lpfc_poll,
1579 &class_device_attr_lpfc_poll_tmo,
James Smart4ff43242006-12-02 13:34:56 -05001580 &class_device_attr_lpfc_use_msi,
James Smarta12e07b2006-12-02 13:35:30 -05001581 &class_device_attr_lpfc_soft_wwnn,
James Smartc3f28af2006-08-18 17:47:18 -04001582 &class_device_attr_lpfc_soft_wwpn,
James Smarta12e07b2006-12-02 13:35:30 -05001583 &class_device_attr_lpfc_soft_wwn_enable,
James Smart13815c82008-01-11 01:52:48 -05001584 &class_device_attr_lpfc_enable_hba_reset,
1585 &class_device_attr_lpfc_enable_hba_heartbeat,
dea31012005-04-17 16:05:31 -05001586 NULL,
1587};
1588
James Smart3de2a652007-08-02 11:09:59 -04001589struct class_device_attribute *lpfc_vport_attrs[] = {
1590 &class_device_attr_info,
1591 &class_device_attr_state,
1592 &class_device_attr_num_discovered_ports,
1593 &class_device_attr_lpfc_drvr_version,
1594
1595 &class_device_attr_lpfc_log_verbose,
1596 &class_device_attr_lpfc_lun_queue_depth,
1597 &class_device_attr_lpfc_nodev_tmo,
1598 &class_device_attr_lpfc_devloss_tmo,
1599 &class_device_attr_lpfc_hba_queue_depth,
1600 &class_device_attr_lpfc_peer_port_login,
1601 &class_device_attr_lpfc_restrict_login,
1602 &class_device_attr_lpfc_fcp_class,
1603 &class_device_attr_lpfc_use_adisc,
1604 &class_device_attr_lpfc_fdmi_on,
1605 &class_device_attr_lpfc_max_luns,
1606 &class_device_attr_nport_evt_cnt,
James Smart3de2a652007-08-02 11:09:59 -04001607 &class_device_attr_npiv_info,
James Smart7ee5d432007-10-27 13:37:17 -04001608 &class_device_attr_lpfc_enable_da_id,
James Smart3de2a652007-08-02 11:09:59 -04001609 NULL,
1610};
1611
dea31012005-04-17 16:05:31 -05001612static ssize_t
Zhang Rui91a69022007-06-09 13:57:22 +08001613sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1614 char *buf, loff_t off, size_t count)
dea31012005-04-17 16:05:31 -05001615{
1616 size_t buf_off;
James Smart2e0fef82007-06-17 19:56:36 -05001617 struct class_device *cdev = container_of(kobj, struct class_device,
1618 kobj);
1619 struct Scsi_Host *shost = class_to_shost(cdev);
1620 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1621 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -05001622
1623 if ((off + count) > FF_REG_AREA_SIZE)
1624 return -ERANGE;
1625
1626 if (count == 0) return 0;
1627
1628 if (off % 4 || count % 4 || (unsigned long)buf % 4)
1629 return -EINVAL;
1630
James Smart2e0fef82007-06-17 19:56:36 -05001631 if (!(vport->fc_flag & FC_OFFLINE_MODE)) {
dea31012005-04-17 16:05:31 -05001632 return -EPERM;
1633 }
1634
James Smart2e0fef82007-06-17 19:56:36 -05001635 spin_lock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001636 for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t))
1637 writel(*((uint32_t *)(buf + buf_off)),
1638 phba->ctrl_regs_memmap_p + off + buf_off);
1639
James Smart2e0fef82007-06-17 19:56:36 -05001640 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001641
1642 return count;
1643}
1644
1645static ssize_t
Zhang Rui91a69022007-06-09 13:57:22 +08001646sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr,
1647 char *buf, loff_t off, size_t count)
dea31012005-04-17 16:05:31 -05001648{
1649 size_t buf_off;
1650 uint32_t * tmp_ptr;
James Smart2e0fef82007-06-17 19:56:36 -05001651 struct class_device *cdev = container_of(kobj, struct class_device,
1652 kobj);
1653 struct Scsi_Host *shost = class_to_shost(cdev);
1654 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1655 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -05001656
1657 if (off > FF_REG_AREA_SIZE)
1658 return -ERANGE;
1659
1660 if ((off + count) > FF_REG_AREA_SIZE)
1661 count = FF_REG_AREA_SIZE - off;
1662
1663 if (count == 0) return 0;
1664
1665 if (off % 4 || count % 4 || (unsigned long)buf % 4)
1666 return -EINVAL;
1667
James Smart2e0fef82007-06-17 19:56:36 -05001668 spin_lock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001669
1670 for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) {
1671 tmp_ptr = (uint32_t *)(buf + buf_off);
1672 *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off);
1673 }
1674
James Smart2e0fef82007-06-17 19:56:36 -05001675 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001676
1677 return count;
1678}
1679
1680static struct bin_attribute sysfs_ctlreg_attr = {
1681 .attr = {
1682 .name = "ctlreg",
1683 .mode = S_IRUSR | S_IWUSR,
dea31012005-04-17 16:05:31 -05001684 },
1685 .size = 256,
1686 .read = sysfs_ctlreg_read,
1687 .write = sysfs_ctlreg_write,
1688};
1689
1690
1691static void
James Smart2e0fef82007-06-17 19:56:36 -05001692sysfs_mbox_idle(struct lpfc_hba *phba)
dea31012005-04-17 16:05:31 -05001693{
1694 phba->sysfs_mbox.state = SMBOX_IDLE;
1695 phba->sysfs_mbox.offset = 0;
1696
1697 if (phba->sysfs_mbox.mbox) {
1698 mempool_free(phba->sysfs_mbox.mbox,
1699 phba->mbox_mem_pool);
1700 phba->sysfs_mbox.mbox = NULL;
1701 }
1702}
1703
1704static ssize_t
Zhang Rui91a69022007-06-09 13:57:22 +08001705sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1706 char *buf, loff_t off, size_t count)
dea31012005-04-17 16:05:31 -05001707{
James Smart2e0fef82007-06-17 19:56:36 -05001708 struct class_device *cdev = container_of(kobj, struct class_device,
1709 kobj);
1710 struct Scsi_Host *shost = class_to_shost(cdev);
1711 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1712 struct lpfc_hba *phba = vport->phba;
1713 struct lpfcMboxq *mbox = NULL;
dea31012005-04-17 16:05:31 -05001714
1715 if ((count + off) > MAILBOX_CMD_SIZE)
1716 return -ERANGE;
1717
1718 if (off % 4 || count % 4 || (unsigned long)buf % 4)
1719 return -EINVAL;
1720
1721 if (count == 0)
1722 return 0;
1723
1724 if (off == 0) {
1725 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1726 if (!mbox)
1727 return -ENOMEM;
James Smartfc6c12b2006-03-07 15:04:19 -05001728 memset(mbox, 0, sizeof (LPFC_MBOXQ_t));
dea31012005-04-17 16:05:31 -05001729 }
1730
James Smart2e0fef82007-06-17 19:56:36 -05001731 spin_lock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001732
1733 if (off == 0) {
1734 if (phba->sysfs_mbox.mbox)
1735 mempool_free(mbox, phba->mbox_mem_pool);
1736 else
1737 phba->sysfs_mbox.mbox = mbox;
1738 phba->sysfs_mbox.state = SMBOX_WRITING;
1739 } else {
1740 if (phba->sysfs_mbox.state != SMBOX_WRITING ||
1741 phba->sysfs_mbox.offset != off ||
James Smart92d7f7b2007-06-17 19:56:38 -05001742 phba->sysfs_mbox.mbox == NULL) {
dea31012005-04-17 16:05:31 -05001743 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001744 spin_unlock_irq(&phba->hbalock);
James Smart8f6d98d2006-08-01 07:34:00 -04001745 return -EAGAIN;
dea31012005-04-17 16:05:31 -05001746 }
1747 }
1748
1749 memcpy((uint8_t *) & phba->sysfs_mbox.mbox->mb + off,
1750 buf, count);
1751
1752 phba->sysfs_mbox.offset = off + count;
1753
James Smart2e0fef82007-06-17 19:56:36 -05001754 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001755
1756 return count;
1757}
1758
1759static ssize_t
Zhang Rui91a69022007-06-09 13:57:22 +08001760sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
1761 char *buf, loff_t off, size_t count)
dea31012005-04-17 16:05:31 -05001762{
James Smart2e0fef82007-06-17 19:56:36 -05001763 struct class_device *cdev = container_of(kobj, struct class_device,
1764 kobj);
1765 struct Scsi_Host *shost = class_to_shost(cdev);
1766 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1767 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -05001768 int rc;
1769
James Smart1dcb58e2007-04-25 09:51:30 -04001770 if (off > MAILBOX_CMD_SIZE)
dea31012005-04-17 16:05:31 -05001771 return -ERANGE;
1772
James Smart1dcb58e2007-04-25 09:51:30 -04001773 if ((count + off) > MAILBOX_CMD_SIZE)
1774 count = MAILBOX_CMD_SIZE - off;
dea31012005-04-17 16:05:31 -05001775
1776 if (off % 4 || count % 4 || (unsigned long)buf % 4)
1777 return -EINVAL;
1778
1779 if (off && count == 0)
1780 return 0;
1781
James Smart2e0fef82007-06-17 19:56:36 -05001782 spin_lock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001783
James Smart7af67052007-10-27 13:38:11 -04001784 if (phba->over_temp_state == HBA_OVER_TEMP) {
1785 sysfs_mbox_idle(phba);
1786 spin_unlock_irq(&phba->hbalock);
James Smart09372822008-01-11 01:52:54 -05001787 return -EACCES;
James Smart7af67052007-10-27 13:38:11 -04001788 }
1789
dea31012005-04-17 16:05:31 -05001790 if (off == 0 &&
1791 phba->sysfs_mbox.state == SMBOX_WRITING &&
1792 phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {
1793
1794 switch (phba->sysfs_mbox.mbox->mb.mbxCommand) {
1795 /* Offline only */
dea31012005-04-17 16:05:31 -05001796 case MBX_INIT_LINK:
1797 case MBX_DOWN_LINK:
1798 case MBX_CONFIG_LINK:
1799 case MBX_CONFIG_RING:
1800 case MBX_RESET_RING:
1801 case MBX_UNREG_LOGIN:
1802 case MBX_CLEAR_LA:
1803 case MBX_DUMP_CONTEXT:
1804 case MBX_RUN_DIAGS:
1805 case MBX_RESTART:
dea31012005-04-17 16:05:31 -05001806 case MBX_SET_MASK:
dea31012005-04-17 16:05:31 -05001807 case MBX_SET_DEBUG:
James Smart2e0fef82007-06-17 19:56:36 -05001808 if (!(vport->fc_flag & FC_OFFLINE_MODE)) {
dea31012005-04-17 16:05:31 -05001809 printk(KERN_WARNING "mbox_read:Command 0x%x "
1810 "is illegal in on-line state\n",
1811 phba->sysfs_mbox.mbox->mb.mbxCommand);
1812 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001813 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001814 return -EPERM;
1815 }
James Smarta8adb832007-10-27 13:37:53 -04001816 case MBX_WRITE_NV:
1817 case MBX_WRITE_VPARMS:
dea31012005-04-17 16:05:31 -05001818 case MBX_LOAD_SM:
1819 case MBX_READ_NV:
1820 case MBX_READ_CONFIG:
1821 case MBX_READ_RCONFIG:
1822 case MBX_READ_STATUS:
1823 case MBX_READ_XRI:
1824 case MBX_READ_REV:
1825 case MBX_READ_LNK_STAT:
1826 case MBX_DUMP_MEMORY:
1827 case MBX_DOWN_LOAD:
1828 case MBX_UPDATE_CFG:
Jamie Wellnitz41415862006-02-28 19:25:27 -05001829 case MBX_KILL_BOARD:
dea31012005-04-17 16:05:31 -05001830 case MBX_LOAD_AREA:
1831 case MBX_LOAD_EXP_ROM:
Jamie Wellnitz41415862006-02-28 19:25:27 -05001832 case MBX_BEACON:
1833 case MBX_DEL_LD_ENTRY:
James Smart09372822008-01-11 01:52:54 -05001834 case MBX_SET_VARIABLE:
1835 case MBX_WRITE_WWN:
dea31012005-04-17 16:05:31 -05001836 break;
1837 case MBX_READ_SPARM64:
1838 case MBX_READ_LA:
1839 case MBX_READ_LA64:
1840 case MBX_REG_LOGIN:
1841 case MBX_REG_LOGIN64:
1842 case MBX_CONFIG_PORT:
1843 case MBX_RUN_BIU_DIAG:
1844 printk(KERN_WARNING "mbox_read: Illegal Command 0x%x\n",
1845 phba->sysfs_mbox.mbox->mb.mbxCommand);
1846 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001847 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001848 return -EPERM;
1849 default:
1850 printk(KERN_WARNING "mbox_read: Unknown Command 0x%x\n",
1851 phba->sysfs_mbox.mbox->mb.mbxCommand);
1852 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001853 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001854 return -EPERM;
1855 }
1856
James Smart09372822008-01-11 01:52:54 -05001857 /* If HBA encountered an error attention, allow only DUMP
1858 * mailbox command until the HBA is restarted.
1859 */
1860 if ((phba->pport->stopped) &&
1861 (phba->sysfs_mbox.mbox->mb.mbxCommand
1862 != MBX_DUMP_MEMORY)) {
1863 sysfs_mbox_idle(phba);
1864 spin_unlock_irq(&phba->hbalock);
1865 return -EPERM;
1866 }
1867
James Smart92d7f7b2007-06-17 19:56:38 -05001868 phba->sysfs_mbox.mbox->vport = vport;
1869
James Smart2e0fef82007-06-17 19:56:36 -05001870 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) {
James Smart46fa3112007-04-25 09:51:45 -04001871 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001872 spin_unlock_irq(&phba->hbalock);
James Smart46fa3112007-04-25 09:51:45 -04001873 return -EAGAIN;
1874 }
1875
James Smart2e0fef82007-06-17 19:56:36 -05001876 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
dea31012005-04-17 16:05:31 -05001877 (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE))){
1878
James Smart2e0fef82007-06-17 19:56:36 -05001879 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001880 rc = lpfc_sli_issue_mbox (phba,
1881 phba->sysfs_mbox.mbox,
1882 MBX_POLL);
James Smart2e0fef82007-06-17 19:56:36 -05001883 spin_lock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001884
1885 } else {
James Smart2e0fef82007-06-17 19:56:36 -05001886 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001887 rc = lpfc_sli_issue_mbox_wait (phba,
1888 phba->sysfs_mbox.mbox,
James Smarta309a6b2006-08-01 07:33:43 -04001889 lpfc_mbox_tmo_val(phba,
1890 phba->sysfs_mbox.mbox->mb.mbxCommand) * HZ);
James Smart2e0fef82007-06-17 19:56:36 -05001891 spin_lock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001892 }
1893
1894 if (rc != MBX_SUCCESS) {
James Smart1dcb58e2007-04-25 09:51:30 -04001895 if (rc == MBX_TIMEOUT) {
James Smart1dcb58e2007-04-25 09:51:30 -04001896 phba->sysfs_mbox.mbox = NULL;
1897 }
dea31012005-04-17 16:05:31 -05001898 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001899 spin_unlock_irq(&phba->hbalock);
James Smart8f6d98d2006-08-01 07:34:00 -04001900 return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV;
dea31012005-04-17 16:05:31 -05001901 }
1902 phba->sysfs_mbox.state = SMBOX_READING;
1903 }
1904 else if (phba->sysfs_mbox.offset != off ||
1905 phba->sysfs_mbox.state != SMBOX_READING) {
1906 printk(KERN_WARNING "mbox_read: Bad State\n");
1907 sysfs_mbox_idle(phba);
James Smart2e0fef82007-06-17 19:56:36 -05001908 spin_unlock_irq(&phba->hbalock);
James Smart8f6d98d2006-08-01 07:34:00 -04001909 return -EAGAIN;
dea31012005-04-17 16:05:31 -05001910 }
1911
1912 memcpy(buf, (uint8_t *) & phba->sysfs_mbox.mbox->mb + off, count);
1913
1914 phba->sysfs_mbox.offset = off + count;
1915
James Smart1dcb58e2007-04-25 09:51:30 -04001916 if (phba->sysfs_mbox.offset == MAILBOX_CMD_SIZE)
dea31012005-04-17 16:05:31 -05001917 sysfs_mbox_idle(phba);
1918
James Smart2e0fef82007-06-17 19:56:36 -05001919 spin_unlock_irq(&phba->hbalock);
dea31012005-04-17 16:05:31 -05001920
1921 return count;
1922}
1923
1924static struct bin_attribute sysfs_mbox_attr = {
1925 .attr = {
1926 .name = "mbox",
1927 .mode = S_IRUSR | S_IWUSR,
dea31012005-04-17 16:05:31 -05001928 },
James Smart1dcb58e2007-04-25 09:51:30 -04001929 .size = MAILBOX_CMD_SIZE,
dea31012005-04-17 16:05:31 -05001930 .read = sysfs_mbox_read,
1931 .write = sysfs_mbox_write,
1932};
1933
1934int
James Smart2e0fef82007-06-17 19:56:36 -05001935lpfc_alloc_sysfs_attr(struct lpfc_vport *vport)
dea31012005-04-17 16:05:31 -05001936{
James Smart2e0fef82007-06-17 19:56:36 -05001937 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
dea31012005-04-17 16:05:31 -05001938 int error;
1939
James Smart2e0fef82007-06-17 19:56:36 -05001940 error = sysfs_create_bin_file(&shost->shost_classdev.kobj,
James Smart92d7f7b2007-06-17 19:56:38 -05001941 &sysfs_ctlreg_attr);
dea31012005-04-17 16:05:31 -05001942 if (error)
1943 goto out;
1944
James Smart2e0fef82007-06-17 19:56:36 -05001945 error = sysfs_create_bin_file(&shost->shost_classdev.kobj,
James Smart92d7f7b2007-06-17 19:56:38 -05001946 &sysfs_mbox_attr);
dea31012005-04-17 16:05:31 -05001947 if (error)
1948 goto out_remove_ctlreg_attr;
1949
1950 return 0;
1951out_remove_ctlreg_attr:
James Smart2e0fef82007-06-17 19:56:36 -05001952 sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr);
dea31012005-04-17 16:05:31 -05001953out:
1954 return error;
1955}
1956
1957void
James Smart2e0fef82007-06-17 19:56:36 -05001958lpfc_free_sysfs_attr(struct lpfc_vport *vport)
dea31012005-04-17 16:05:31 -05001959{
James Smart2e0fef82007-06-17 19:56:36 -05001960 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
dea31012005-04-17 16:05:31 -05001961
James Smart2e0fef82007-06-17 19:56:36 -05001962 sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_mbox_attr);
1963 sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr);
dea31012005-04-17 16:05:31 -05001964}
1965
1966
1967/*
1968 * Dynamic FC Host Attributes Support
1969 */
1970
1971static void
1972lpfc_get_host_port_id(struct Scsi_Host *shost)
1973{
James Smart2e0fef82007-06-17 19:56:36 -05001974 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1975
dea31012005-04-17 16:05:31 -05001976 /* note: fc_myDID already in cpu endianness */
James Smart2e0fef82007-06-17 19:56:36 -05001977 fc_host_port_id(shost) = vport->fc_myDID;
dea31012005-04-17 16:05:31 -05001978}
1979
1980static void
1981lpfc_get_host_port_type(struct Scsi_Host *shost)
1982{
James Smart2e0fef82007-06-17 19:56:36 -05001983 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1984 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -05001985
1986 spin_lock_irq(shost->host_lock);
1987
James Smart92d7f7b2007-06-17 19:56:38 -05001988 if (vport->port_type == LPFC_NPIV_PORT) {
1989 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
1990 } else if (lpfc_is_link_up(phba)) {
dea31012005-04-17 16:05:31 -05001991 if (phba->fc_topology == TOPOLOGY_LOOP) {
James Smart2e0fef82007-06-17 19:56:36 -05001992 if (vport->fc_flag & FC_PUBLIC_LOOP)
dea31012005-04-17 16:05:31 -05001993 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
1994 else
1995 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
1996 } else {
James Smart2e0fef82007-06-17 19:56:36 -05001997 if (vport->fc_flag & FC_FABRIC)
dea31012005-04-17 16:05:31 -05001998 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
1999 else
2000 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
2001 }
2002 } else
2003 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
2004
2005 spin_unlock_irq(shost->host_lock);
2006}
2007
2008static void
2009lpfc_get_host_port_state(struct Scsi_Host *shost)
2010{
James Smart2e0fef82007-06-17 19:56:36 -05002011 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2012 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -05002013
2014 spin_lock_irq(shost->host_lock);
2015
James Smart2e0fef82007-06-17 19:56:36 -05002016 if (vport->fc_flag & FC_OFFLINE_MODE)
dea31012005-04-17 16:05:31 -05002017 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
2018 else {
James Smart2e0fef82007-06-17 19:56:36 -05002019 switch (phba->link_state) {
2020 case LPFC_LINK_UNKNOWN:
dea31012005-04-17 16:05:31 -05002021 case LPFC_LINK_DOWN:
2022 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2023 break;
2024 case LPFC_LINK_UP:
dea31012005-04-17 16:05:31 -05002025 case LPFC_CLEAR_LA:
2026 case LPFC_HBA_READY:
2027 /* Links up, beyond this port_type reports state */
2028 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
2029 break;
2030 case LPFC_HBA_ERROR:
2031 fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
2032 break;
2033 default:
2034 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
2035 break;
2036 }
2037 }
2038
2039 spin_unlock_irq(shost->host_lock);
2040}
2041
2042static void
2043lpfc_get_host_speed(struct Scsi_Host *shost)
2044{
James Smart2e0fef82007-06-17 19:56:36 -05002045 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2046 struct lpfc_hba *phba = vport->phba;
dea31012005-04-17 16:05:31 -05002047
2048 spin_lock_irq(shost->host_lock);
2049
James Smart2e0fef82007-06-17 19:56:36 -05002050 if (lpfc_is_link_up(phba)) {
dea31012005-04-17 16:05:31 -05002051 switch(phba->fc_linkspeed) {
2052 case LA_1GHZ_LINK:
2053 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
2054 break;
2055 case LA_2GHZ_LINK:
2056 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
2057 break;
2058 case LA_4GHZ_LINK:
2059 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
2060 break;
James Smartb87eab32007-04-25 09:53:28 -04002061 case LA_8GHZ_LINK:
2062 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
2063 break;
dea31012005-04-17 16:05:31 -05002064 default:
2065 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
2066 break;
2067 }
James Smart09372822008-01-11 01:52:54 -05002068 } else
2069 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
dea31012005-04-17 16:05:31 -05002070
2071 spin_unlock_irq(shost->host_lock);
2072}
2073
2074static void
2075lpfc_get_host_fabric_name (struct Scsi_Host *shost)
2076{
James Smart2e0fef82007-06-17 19:56:36 -05002077 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2078 struct lpfc_hba *phba = vport->phba;
Andrew Vasquezf631b4b2005-08-31 15:23:12 -07002079 u64 node_name;
dea31012005-04-17 16:05:31 -05002080
2081 spin_lock_irq(shost->host_lock);
2082
James Smart2e0fef82007-06-17 19:56:36 -05002083 if ((vport->fc_flag & FC_FABRIC) ||
dea31012005-04-17 16:05:31 -05002084 ((phba->fc_topology == TOPOLOGY_LOOP) &&
James Smart2e0fef82007-06-17 19:56:36 -05002085 (vport->fc_flag & FC_PUBLIC_LOOP)))
Andrew Morton68ce1eb2005-09-21 09:46:54 -07002086 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
dea31012005-04-17 16:05:31 -05002087 else
2088 /* fabric is local port if there is no F/FL_Port */
James Smart09372822008-01-11 01:52:54 -05002089 node_name = 0;
dea31012005-04-17 16:05:31 -05002090
2091 spin_unlock_irq(shost->host_lock);
2092
Andrew Vasquezf631b4b2005-08-31 15:23:12 -07002093 fc_host_fabric_name(shost) = node_name;
dea31012005-04-17 16:05:31 -05002094}
2095
dea31012005-04-17 16:05:31 -05002096static struct fc_host_statistics *
2097lpfc_get_stats(struct Scsi_Host *shost)
2098{
James Smart2e0fef82007-06-17 19:56:36 -05002099 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2100 struct lpfc_hba *phba = vport->phba;
2101 struct lpfc_sli *psli = &phba->sli;
James.Smart@Emulex.Comf888ba32005-08-10 15:03:01 -04002102 struct fc_host_statistics *hs = &phba->link_stats;
James Smart64ba8812006-08-02 15:24:34 -04002103 struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets;
dea31012005-04-17 16:05:31 -05002104 LPFC_MBOXQ_t *pmboxq;
2105 MAILBOX_t *pmb;
James Smart64ba8812006-08-02 15:24:34 -04002106 unsigned long seconds;
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002107 int rc = 0;
dea31012005-04-17 16:05:31 -05002108
James Smart92d7f7b2007-06-17 19:56:38 -05002109 /*
2110 * prevent udev from issuing mailbox commands until the port is
2111 * configured.
2112 */
James Smart2e0fef82007-06-17 19:56:36 -05002113 if (phba->link_state < LPFC_LINK_DOWN ||
2114 !phba->mbox_mem_pool ||
2115 (phba->sli.sli_flag & LPFC_SLI2_ACTIVE) == 0)
James Smart92d7f7b2007-06-17 19:56:38 -05002116 return NULL;
James Smart2e0fef82007-06-17 19:56:36 -05002117
2118 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
James Smart46fa3112007-04-25 09:51:45 -04002119 return NULL;
2120
dea31012005-04-17 16:05:31 -05002121 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2122 if (!pmboxq)
2123 return NULL;
2124 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
2125
2126 pmb = &pmboxq->mb;
2127 pmb->mbxCommand = MBX_READ_STATUS;
2128 pmb->mbxOwner = OWN_HOST;
2129 pmboxq->context1 = NULL;
James Smart92d7f7b2007-06-17 19:56:38 -05002130 pmboxq->vport = vport;
dea31012005-04-17 16:05:31 -05002131
James Smart2e0fef82007-06-17 19:56:36 -05002132 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002133 (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
dea31012005-04-17 16:05:31 -05002134 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002135 else
dea31012005-04-17 16:05:31 -05002136 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2137
2138 if (rc != MBX_SUCCESS) {
James Smart858c9f62007-06-17 19:56:39 -05002139 if (rc != MBX_TIMEOUT)
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002140 mempool_free(pmboxq, phba->mbox_mem_pool);
dea31012005-04-17 16:05:31 -05002141 return NULL;
2142 }
2143
James.Smart@Emulex.Comf888ba32005-08-10 15:03:01 -04002144 memset(hs, 0, sizeof (struct fc_host_statistics));
2145
dea31012005-04-17 16:05:31 -05002146 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
2147 hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256);
2148 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
2149 hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256);
2150
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002151 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
dea31012005-04-17 16:05:31 -05002152 pmb->mbxCommand = MBX_READ_LNK_STAT;
2153 pmb->mbxOwner = OWN_HOST;
2154 pmboxq->context1 = NULL;
James Smart92d7f7b2007-06-17 19:56:38 -05002155 pmboxq->vport = vport;
dea31012005-04-17 16:05:31 -05002156
James Smart2e0fef82007-06-17 19:56:36 -05002157 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002158 (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
dea31012005-04-17 16:05:31 -05002159 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
James.Smart@Emulex.Com433c3572005-10-28 20:28:56 -04002160 else
dea31012005-04-17 16:05:31 -05002161 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2162
2163 if (rc != MBX_SUCCESS) {
James Smart858c9f62007-06-17 19:56:39 -05002164 if (rc != MBX_TIMEOUT)
James Smart92d7f7b2007-06-17 19:56:38 -05002165 mempool_free(pmboxq, phba->mbox_mem_pool);
dea31012005-04-17 16:05:31 -05002166 return NULL;
2167 }
2168
2169 hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
2170 hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
2171 hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
2172 hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
2173 hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
2174 hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
2175 hs->error_frames = pmb->un.varRdLnk.crcCnt;
2176
James Smart64ba8812006-08-02 15:24:34 -04002177 hs->link_failure_count -= lso->link_failure_count;
2178 hs->loss_of_sync_count -= lso->loss_of_sync_count;
2179 hs->loss_of_signal_count -= lso->loss_of_signal_count;
2180 hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count;
2181 hs->invalid_tx_word_count -= lso->invalid_tx_word_count;
2182 hs->invalid_crc_count -= lso->invalid_crc_count;
2183 hs->error_frames -= lso->error_frames;
2184
dea31012005-04-17 16:05:31 -05002185 if (phba->fc_topology == TOPOLOGY_LOOP) {
2186 hs->lip_count = (phba->fc_eventTag >> 1);
James Smart64ba8812006-08-02 15:24:34 -04002187 hs->lip_count -= lso->link_events;
dea31012005-04-17 16:05:31 -05002188 hs->nos_count = -1;
2189 } else {
2190 hs->lip_count = -1;
2191 hs->nos_count = (phba->fc_eventTag >> 1);
James Smart64ba8812006-08-02 15:24:34 -04002192 hs->nos_count -= lso->link_events;
dea31012005-04-17 16:05:31 -05002193 }
2194
2195 hs->dumped_frames = -1;
2196
James Smart64ba8812006-08-02 15:24:34 -04002197 seconds = get_seconds();
2198 if (seconds < psli->stats_start)
2199 hs->seconds_since_last_reset = seconds +
2200 ((unsigned long)-1 - psli->stats_start);
2201 else
2202 hs->seconds_since_last_reset = seconds - psli->stats_start;
dea31012005-04-17 16:05:31 -05002203
James Smart1dcb58e2007-04-25 09:51:30 -04002204 mempool_free(pmboxq, phba->mbox_mem_pool);
2205
dea31012005-04-17 16:05:31 -05002206 return hs;
2207}
2208
James Smart64ba8812006-08-02 15:24:34 -04002209static void
2210lpfc_reset_stats(struct Scsi_Host *shost)
2211{
James Smart2e0fef82007-06-17 19:56:36 -05002212 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2213 struct lpfc_hba *phba = vport->phba;
2214 struct lpfc_sli *psli = &phba->sli;
2215 struct lpfc_lnk_stat *lso = &psli->lnk_stat_offsets;
James Smart64ba8812006-08-02 15:24:34 -04002216 LPFC_MBOXQ_t *pmboxq;
2217 MAILBOX_t *pmb;
2218 int rc = 0;
2219
James Smart2e0fef82007-06-17 19:56:36 -05002220 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)
James Smart46fa3112007-04-25 09:51:45 -04002221 return;
2222
James Smart64ba8812006-08-02 15:24:34 -04002223 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2224 if (!pmboxq)
2225 return;
2226 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
2227
2228 pmb = &pmboxq->mb;
2229 pmb->mbxCommand = MBX_READ_STATUS;
2230 pmb->mbxOwner = OWN_HOST;
2231 pmb->un.varWords[0] = 0x1; /* reset request */
2232 pmboxq->context1 = NULL;
James Smart92d7f7b2007-06-17 19:56:38 -05002233 pmboxq->vport = vport;
James Smart64ba8812006-08-02 15:24:34 -04002234
James Smart2e0fef82007-06-17 19:56:36 -05002235 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
James Smart64ba8812006-08-02 15:24:34 -04002236 (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
2237 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
2238 else
2239 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2240
2241 if (rc != MBX_SUCCESS) {
James Smart858c9f62007-06-17 19:56:39 -05002242 if (rc != MBX_TIMEOUT)
James Smart64ba8812006-08-02 15:24:34 -04002243 mempool_free(pmboxq, phba->mbox_mem_pool);
2244 return;
2245 }
2246
2247 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
2248 pmb->mbxCommand = MBX_READ_LNK_STAT;
2249 pmb->mbxOwner = OWN_HOST;
2250 pmboxq->context1 = NULL;
James Smart92d7f7b2007-06-17 19:56:38 -05002251 pmboxq->vport = vport;
James Smart64ba8812006-08-02 15:24:34 -04002252
James Smart2e0fef82007-06-17 19:56:36 -05002253 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
James Smart64ba8812006-08-02 15:24:34 -04002254 (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
2255 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
2256 else
2257 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2258
2259 if (rc != MBX_SUCCESS) {
James Smart858c9f62007-06-17 19:56:39 -05002260 if (rc != MBX_TIMEOUT)
James Smart64ba8812006-08-02 15:24:34 -04002261 mempool_free( pmboxq, phba->mbox_mem_pool);
2262 return;
2263 }
2264
2265 lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
2266 lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
2267 lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
2268 lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
2269 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
2270 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
2271 lso->error_frames = pmb->un.varRdLnk.crcCnt;
2272 lso->link_events = (phba->fc_eventTag >> 1);
2273
2274 psli->stats_start = get_seconds();
2275
James Smart1dcb58e2007-04-25 09:51:30 -04002276 mempool_free(pmboxq, phba->mbox_mem_pool);
2277
James Smart64ba8812006-08-02 15:24:34 -04002278 return;
2279}
dea31012005-04-17 16:05:31 -05002280
2281/*
2282 * The LPFC driver treats linkdown handling as target loss events so there
2283 * are no sysfs handlers for link_down_tmo.
2284 */
James Smart685f0bf2007-04-25 09:53:08 -04002285
2286static struct lpfc_nodelist *
2287lpfc_get_node_by_target(struct scsi_target *starget)
dea31012005-04-17 16:05:31 -05002288{
James Smart2e0fef82007-06-17 19:56:36 -05002289 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2290 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
James Smart685f0bf2007-04-25 09:53:08 -04002291 struct lpfc_nodelist *ndlp;
dea31012005-04-17 16:05:31 -05002292
2293 spin_lock_irq(shost->host_lock);
James Smart685f0bf2007-04-25 09:53:08 -04002294 /* Search for this, mapped, target ID */
James Smart2e0fef82007-06-17 19:56:36 -05002295 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
James Smart685f0bf2007-04-25 09:53:08 -04002296 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
2297 starget->id == ndlp->nlp_sid) {
2298 spin_unlock_irq(shost->host_lock);
2299 return ndlp;
dea31012005-04-17 16:05:31 -05002300 }
2301 }
2302 spin_unlock_irq(shost->host_lock);
James Smart685f0bf2007-04-25 09:53:08 -04002303 return NULL;
2304}
dea31012005-04-17 16:05:31 -05002305
James Smart685f0bf2007-04-25 09:53:08 -04002306static void
2307lpfc_get_starget_port_id(struct scsi_target *starget)
2308{
2309 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
2310
2311 fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1;
dea31012005-04-17 16:05:31 -05002312}
2313
2314static void
2315lpfc_get_starget_node_name(struct scsi_target *starget)
2316{
James Smart685f0bf2007-04-25 09:53:08 -04002317 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
dea31012005-04-17 16:05:31 -05002318
James Smart685f0bf2007-04-25 09:53:08 -04002319 fc_starget_node_name(starget) =
2320 ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0;
dea31012005-04-17 16:05:31 -05002321}
2322
2323static void
2324lpfc_get_starget_port_name(struct scsi_target *starget)
2325{
James Smart685f0bf2007-04-25 09:53:08 -04002326 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
dea31012005-04-17 16:05:31 -05002327
James Smart685f0bf2007-04-25 09:53:08 -04002328 fc_starget_port_name(starget) =
2329 ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0;
dea31012005-04-17 16:05:31 -05002330}
2331
2332static void
dea31012005-04-17 16:05:31 -05002333lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
2334{
dea31012005-04-17 16:05:31 -05002335 if (timeout)
James Smartc01f3202006-08-18 17:47:08 -04002336 rport->dev_loss_tmo = timeout;
dea31012005-04-17 16:05:31 -05002337 else
James Smartc01f3202006-08-18 17:47:08 -04002338 rport->dev_loss_tmo = 1;
dea31012005-04-17 16:05:31 -05002339}
2340
2341
2342#define lpfc_rport_show_function(field, format_string, sz, cast) \
2343static ssize_t \
2344lpfc_show_rport_##field (struct class_device *cdev, char *buf) \
2345{ \
2346 struct fc_rport *rport = transport_class_to_rport(cdev); \
2347 struct lpfc_rport_data *rdata = rport->hostdata; \
2348 return snprintf(buf, sz, format_string, \
2349 (rdata->target) ? cast rdata->target->field : 0); \
2350}
2351
2352#define lpfc_rport_rd_attr(field, format_string, sz) \
2353 lpfc_rport_show_function(field, format_string, sz, ) \
2354static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
2355
2356
2357struct fc_function_template lpfc_transport_functions = {
2358 /* fixed attributes the driver supports */
2359 .show_host_node_name = 1,
2360 .show_host_port_name = 1,
2361 .show_host_supported_classes = 1,
2362 .show_host_supported_fc4s = 1,
dea31012005-04-17 16:05:31 -05002363 .show_host_supported_speeds = 1,
2364 .show_host_maxframe_size = 1,
2365
2366 /* dynamic attributes the driver supports */
2367 .get_host_port_id = lpfc_get_host_port_id,
2368 .show_host_port_id = 1,
2369
2370 .get_host_port_type = lpfc_get_host_port_type,
2371 .show_host_port_type = 1,
2372
2373 .get_host_port_state = lpfc_get_host_port_state,
2374 .show_host_port_state = 1,
2375
2376 /* active_fc4s is shown but doesn't change (thus no get function) */
2377 .show_host_active_fc4s = 1,
2378
2379 .get_host_speed = lpfc_get_host_speed,
2380 .show_host_speed = 1,
2381
2382 .get_host_fabric_name = lpfc_get_host_fabric_name,
2383 .show_host_fabric_name = 1,
2384
2385 /*
2386 * The LPFC driver treats linkdown handling as target loss events
2387 * so there are no sysfs handlers for link_down_tmo.
2388 */
2389
2390 .get_fc_host_stats = lpfc_get_stats,
James Smart64ba8812006-08-02 15:24:34 -04002391 .reset_fc_host_stats = lpfc_reset_stats,
dea31012005-04-17 16:05:31 -05002392
2393 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
2394 .show_rport_maxframe_size = 1,
2395 .show_rport_supported_classes = 1,
2396
dea31012005-04-17 16:05:31 -05002397 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
2398 .show_rport_dev_loss_tmo = 1,
2399
2400 .get_starget_port_id = lpfc_get_starget_port_id,
2401 .show_starget_port_id = 1,
2402
2403 .get_starget_node_name = lpfc_get_starget_node_name,
2404 .show_starget_node_name = 1,
2405
2406 .get_starget_port_name = lpfc_get_starget_port_name,
2407 .show_starget_port_name = 1,
Andrew Vasquez91ca7b02005-10-27 16:03:37 -07002408
2409 .issue_fc_host_lip = lpfc_issue_lip,
James Smartc01f3202006-08-18 17:47:08 -04002410 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
2411 .terminate_rport_io = lpfc_terminate_rport_io,
James Smart92d7f7b2007-06-17 19:56:38 -05002412
James Smart92d7f7b2007-06-17 19:56:38 -05002413 .dd_fcvport_size = sizeof(struct lpfc_vport *),
2414};
2415
James Smart98c9ea52007-10-27 13:37:33 -04002416struct fc_function_template lpfc_vport_transport_functions = {
2417 /* fixed attributes the driver supports */
2418 .show_host_node_name = 1,
2419 .show_host_port_name = 1,
2420 .show_host_supported_classes = 1,
2421 .show_host_supported_fc4s = 1,
2422 .show_host_supported_speeds = 1,
2423 .show_host_maxframe_size = 1,
2424
2425 /* dynamic attributes the driver supports */
2426 .get_host_port_id = lpfc_get_host_port_id,
2427 .show_host_port_id = 1,
2428
2429 .get_host_port_type = lpfc_get_host_port_type,
2430 .show_host_port_type = 1,
2431
2432 .get_host_port_state = lpfc_get_host_port_state,
2433 .show_host_port_state = 1,
2434
2435 /* active_fc4s is shown but doesn't change (thus no get function) */
2436 .show_host_active_fc4s = 1,
2437
2438 .get_host_speed = lpfc_get_host_speed,
2439 .show_host_speed = 1,
2440
2441 .get_host_fabric_name = lpfc_get_host_fabric_name,
2442 .show_host_fabric_name = 1,
2443
2444 /*
2445 * The LPFC driver treats linkdown handling as target loss events
2446 * so there are no sysfs handlers for link_down_tmo.
2447 */
2448
2449 .get_fc_host_stats = lpfc_get_stats,
2450 .reset_fc_host_stats = lpfc_reset_stats,
2451
2452 .dd_fcrport_size = sizeof(struct lpfc_rport_data),
2453 .show_rport_maxframe_size = 1,
2454 .show_rport_supported_classes = 1,
2455
2456 .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
2457 .show_rport_dev_loss_tmo = 1,
2458
2459 .get_starget_port_id = lpfc_get_starget_port_id,
2460 .show_starget_port_id = 1,
2461
2462 .get_starget_node_name = lpfc_get_starget_node_name,
2463 .show_starget_node_name = 1,
2464
2465 .get_starget_port_name = lpfc_get_starget_port_name,
2466 .show_starget_port_name = 1,
2467
2468 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
2469 .terminate_rport_io = lpfc_terminate_rport_io,
2470
2471 .vport_disable = lpfc_vport_disable,
2472};
2473
dea31012005-04-17 16:05:31 -05002474void
2475lpfc_get_cfgparam(struct lpfc_hba *phba)
2476{
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -04002477 lpfc_cr_delay_init(phba, lpfc_cr_delay);
2478 lpfc_cr_count_init(phba, lpfc_cr_count);
Jamie Wellnitzcf5bf972006-02-28 22:33:08 -05002479 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
James Smarta4bc3372006-12-02 13:34:16 -05002480 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
2481 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -04002482 lpfc_ack0_init(phba, lpfc_ack0);
2483 lpfc_topology_init(phba, lpfc_topology);
James.Smart@Emulex.Com7bcbb752005-10-28 20:29:13 -04002484 lpfc_link_speed_init(phba, lpfc_link_speed);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05002485 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
James Smart78b2d852007-08-02 11:10:21 -04002486 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
James Smart4ff43242006-12-02 13:34:56 -05002487 lpfc_use_msi_init(phba, lpfc_use_msi);
James Smart13815c82008-01-11 01:52:48 -05002488 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
2489 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05002490 phba->cfg_poll = lpfc_poll;
James Smarta12e07b2006-12-02 13:35:30 -05002491 phba->cfg_soft_wwnn = 0L;
James Smartc3f28af2006-08-18 17:47:18 -04002492 phba->cfg_soft_wwpn = 0L;
dea31012005-04-17 16:05:31 -05002493 /*
2494 * The total number of segments is the configuration value plus 2
2495 * since the IOCB need a command and response bde.
2496 */
2497 phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
dea31012005-04-17 16:05:31 -05002498 /*
2499 * Since the sg_tablesize is module parameter, the sg_dma_buf_size
2500 * used to create the sg_dma_buf_pool must be dynamically calculated
2501 */
2502 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
2503 sizeof(struct fcp_rsp) +
2504 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
James Smart7054a602007-04-25 09:52:34 -04002505 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
James Smart3de2a652007-08-02 11:09:59 -04002506 return;
2507}
Jamie Wellnitzb28485a2006-02-28 19:25:21 -05002508
James Smart3de2a652007-08-02 11:09:59 -04002509void
2510lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
2511{
James Smarte8b62012007-08-02 11:10:09 -04002512 lpfc_log_verbose_init(vport, lpfc_log_verbose);
James Smart3de2a652007-08-02 11:09:59 -04002513 lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
2514 lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
2515 lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
2516 lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
2517 lpfc_restrict_login_init(vport, lpfc_restrict_login);
2518 lpfc_fcp_class_init(vport, lpfc_fcp_class);
2519 lpfc_use_adisc_init(vport, lpfc_use_adisc);
2520 lpfc_fdmi_on_init(vport, lpfc_fdmi_on);
2521 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
2522 lpfc_max_luns_init(vport, lpfc_max_luns);
2523 lpfc_scan_down_init(vport, lpfc_scan_down);
James Smart7ee5d432007-10-27 13:37:17 -04002524 lpfc_enable_da_id_init(vport, lpfc_enable_da_id);
dea31012005-04-17 16:05:31 -05002525 return;
2526}