]>
Commit | Line | Data |
---|---|---|
dea3101e JB |
1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | |
c44ce173 | 3 | * Fibre Channel Host Bus Adapters. * |
9399627f | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
c44ce173 | 5 | * EMULEX and SLI are trademarks of Emulex. * |
dea3101e | 6 | * www.emulex.com * |
c44ce173 | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
dea3101e JB |
8 | * * |
9 | * This program is free software; you can redistribute it and/or * | |
c44ce173 JSEC |
10 | * 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. * | |
dea3101e JB |
20 | *******************************************************************/ |
21 | ||
dea3101e JB |
22 | #include <linux/blkdev.h> |
23 | #include <linux/pci.h> | |
24 | #include <linux/interrupt.h> | |
25 | ||
f888ba3c JSEC |
26 | #include <scsi/scsi_device.h> |
27 | #include <scsi/scsi_transport_fc.h> | |
28 | ||
91886523 JSEC |
29 | #include <scsi/scsi.h> |
30 | ||
dea3101e JB |
31 | #include "lpfc_hw.h" |
32 | #include "lpfc_sli.h" | |
ea2151b4 | 33 | #include "lpfc_nl.h" |
dea3101e JB |
34 | #include "lpfc_disc.h" |
35 | #include "lpfc_scsi.h" | |
36 | #include "lpfc.h" | |
37 | #include "lpfc_logmsg.h" | |
38 | #include "lpfc_crtn.h" | |
39 | #include "lpfc_compat.h" | |
40 | ||
e59058c4 JS |
41 | /** |
42 | * lpfc_dump_mem: Prepare a mailbox command for retrieving HBA's VPD memory. | |
43 | * @phba: pointer to lpfc hba data structure. | |
44 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
45 | * @offset: offset for dumping VPD memory mailbox command. | |
46 | * | |
47 | * The dump mailbox command provides a method for the device driver to obtain | |
48 | * various types of information from the HBA device. | |
49 | * | |
50 | * This routine prepares the mailbox command for dumping HBA Vital Product | |
51 | * Data (VPD) memory. This mailbox command is to be used for retrieving a | |
52 | * portion (DMP_RSP_SIZE bytes) of a HBA's VPD from the HBA at an address | |
53 | * offset specified by the offset parameter. | |
54 | **/ | |
dea3101e JB |
55 | void |
56 | lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | |
57 | { | |
58 | MAILBOX_t *mb; | |
59 | void *ctx; | |
60 | ||
61 | mb = &pmb->mb; | |
62 | ctx = pmb->context2; | |
63 | ||
64 | /* Setup to dump VPD region */ | |
65 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
66 | mb->mbxCommand = MBX_DUMP_MEMORY; | |
67 | mb->un.varDmp.cv = 1; | |
68 | mb->un.varDmp.type = DMP_NV_PARAMS; | |
69 | mb->un.varDmp.entry_index = offset; | |
70 | mb->un.varDmp.region_id = DMP_REGION_VPD; | |
71 | mb->un.varDmp.word_cnt = (DMP_RSP_SIZE / sizeof (uint32_t)); | |
72 | mb->un.varDmp.co = 0; | |
73 | mb->un.varDmp.resp_offset = 0; | |
74 | pmb->context2 = ctx; | |
75 | mb->mbxOwner = OWN_HOST; | |
76 | return; | |
77 | } | |
78 | ||
97207482 JS |
79 | /** |
80 | * lpfc_dump_mem: Prepare a mailbox command for retrieving wakeup params. | |
81 | * @phba: pointer to lpfc hba data structure. | |
82 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
83 | * This function create a dump memory mailbox command to dump wake up | |
84 | * parameters. | |
85 | */ | |
86 | void | |
87 | lpfc_dump_wakeup_param(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
88 | { | |
89 | MAILBOX_t *mb; | |
90 | void *ctx; | |
91 | ||
92 | mb = &pmb->mb; | |
93 | /* Save context so that we can restore after memset */ | |
94 | ctx = pmb->context2; | |
95 | ||
96 | /* Setup to dump VPD region */ | |
97 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | |
98 | mb->mbxCommand = MBX_DUMP_MEMORY; | |
99 | mb->mbxOwner = OWN_HOST; | |
100 | mb->un.varDmp.cv = 1; | |
101 | mb->un.varDmp.type = DMP_NV_PARAMS; | |
102 | mb->un.varDmp.entry_index = 0; | |
103 | mb->un.varDmp.region_id = WAKE_UP_PARMS_REGION_ID; | |
104 | mb->un.varDmp.word_cnt = WAKE_UP_PARMS_WORD_SIZE; | |
105 | mb->un.varDmp.co = 0; | |
106 | mb->un.varDmp.resp_offset = 0; | |
107 | pmb->context2 = ctx; | |
108 | return; | |
109 | } | |
110 | ||
e59058c4 JS |
111 | /** |
112 | * lpfc_read_nv: Prepare a mailbox command for reading HBA's NVRAM param. | |
113 | * @phba: pointer to lpfc hba data structure. | |
114 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
115 | * | |
116 | * The read NVRAM mailbox command returns the HBA's non-volatile parameters | |
117 | * that are used as defaults when the Fibre Channel link is brought on-line. | |
118 | * | |
119 | * This routine prepares the mailbox command for reading information stored | |
120 | * in the HBA's NVRAM. Specifically, the HBA's WWNN and WWPN. | |
121 | **/ | |
dea3101e JB |
122 | void |
123 | lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
124 | { | |
125 | MAILBOX_t *mb; | |
126 | ||
127 | mb = &pmb->mb; | |
128 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
129 | mb->mbxCommand = MBX_READ_NV; | |
130 | mb->mbxOwner = OWN_HOST; | |
131 | return; | |
132 | } | |
133 | ||
e59058c4 JS |
134 | /** |
135 | * lpfc_config_async: Prepare a mailbox command for enabling HBA async event. | |
136 | * @phba: pointer to lpfc hba data structure. | |
137 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
138 | * @ring: ring number for the asynchronous event to be configured. | |
139 | * | |
140 | * The asynchronous event enable mailbox command is used to enable the | |
141 | * asynchronous event posting via the ASYNC_STATUS_CN IOCB response and | |
142 | * specifies the default ring to which events are posted. | |
143 | * | |
144 | * This routine prepares the mailbox command for enabling HBA asynchronous | |
145 | * event support on a IOCB ring. | |
146 | **/ | |
57127f15 JS |
147 | void |
148 | lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, | |
149 | uint32_t ring) | |
150 | { | |
151 | MAILBOX_t *mb; | |
152 | ||
153 | mb = &pmb->mb; | |
154 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
155 | mb->mbxCommand = MBX_ASYNCEVT_ENABLE; | |
156 | mb->un.varCfgAsyncEvent.ring = ring; | |
157 | mb->mbxOwner = OWN_HOST; | |
158 | return; | |
159 | } | |
160 | ||
e59058c4 JS |
161 | /** |
162 | * lpfc_heart_beat: Prepare a mailbox command for heart beat. | |
163 | * @phba: pointer to lpfc hba data structure. | |
164 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
165 | * | |
166 | * The heart beat mailbox command is used to detect an unresponsive HBA, which | |
167 | * is defined as any device where no error attention is sent and both mailbox | |
168 | * and rings are not processed. | |
169 | * | |
170 | * This routine prepares the mailbox command for issuing a heart beat in the | |
171 | * form of mailbox command to the HBA. The timely completion of the heart | |
172 | * beat mailbox command indicates the health of the HBA. | |
173 | **/ | |
858c9f6c JS |
174 | void |
175 | lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
176 | { | |
177 | MAILBOX_t *mb; | |
178 | ||
179 | mb = &pmb->mb; | |
180 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
181 | mb->mbxCommand = MBX_HEARTBEAT; | |
182 | mb->mbxOwner = OWN_HOST; | |
183 | return; | |
184 | } | |
185 | ||
e59058c4 JS |
186 | /** |
187 | * lpfc_read_la: Prepare a mailbox command for reading HBA link attention. | |
188 | * @phba: pointer to lpfc hba data structure. | |
189 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
190 | * @mp: DMA buffer memory for reading the link attention information into. | |
191 | * | |
192 | * The read link attention mailbox command is issued to read the Link Event | |
193 | * Attention information indicated by the HBA port when the Link Event bit | |
194 | * of the Host Attention (HSTATT) register is set to 1. A Link Event | |
195 | * Attention occurs based on an exception detected at the Fibre Channel link | |
196 | * interface. | |
197 | * | |
198 | * This routine prepares the mailbox command for reading HBA link attention | |
199 | * information. A DMA memory has been set aside and address passed to the | |
200 | * HBA through @mp for the HBA to DMA link attention information into the | |
201 | * memory as part of the execution of the mailbox command. | |
202 | * | |
203 | * Return codes | |
204 | * 0 - Success (currently always return 0) | |
205 | **/ | |
dea3101e JB |
206 | int |
207 | lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp) | |
208 | { | |
209 | MAILBOX_t *mb; | |
210 | struct lpfc_sli *psli; | |
211 | ||
212 | psli = &phba->sli; | |
213 | mb = &pmb->mb; | |
214 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
215 | ||
216 | INIT_LIST_HEAD(&mp->list); | |
217 | mb->mbxCommand = MBX_READ_LA64; | |
218 | mb->un.varReadLA.un.lilpBde64.tus.f.bdeSize = 128; | |
219 | mb->un.varReadLA.un.lilpBde64.addrHigh = putPaddrHigh(mp->phys); | |
220 | mb->un.varReadLA.un.lilpBde64.addrLow = putPaddrLow(mp->phys); | |
221 | ||
222 | /* Save address for later completion and set the owner to host so that | |
223 | * the FW knows this mailbox is available for processing. | |
224 | */ | |
225 | pmb->context1 = (uint8_t *) mp; | |
226 | mb->mbxOwner = OWN_HOST; | |
92d7f7b0 | 227 | return (0); |
dea3101e JB |
228 | } |
229 | ||
e59058c4 JS |
230 | /** |
231 | * lpfc_clear_la: Prepare a mailbox command for clearing HBA link attention. | |
232 | * @phba: pointer to lpfc hba data structure. | |
233 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
234 | * | |
235 | * The clear link attention mailbox command is issued to clear the link event | |
236 | * attention condition indicated by the Link Event bit of the Host Attention | |
237 | * (HSTATT) register. The link event attention condition is cleared only if | |
238 | * the event tag specified matches that of the current link event counter. | |
239 | * The current event tag is read using the read link attention event mailbox | |
240 | * command. | |
241 | * | |
242 | * This routine prepares the mailbox command for clearing HBA link attention | |
243 | * information. | |
244 | **/ | |
dea3101e JB |
245 | void |
246 | lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
247 | { | |
248 | MAILBOX_t *mb; | |
249 | ||
250 | mb = &pmb->mb; | |
251 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
252 | ||
253 | mb->un.varClearLA.eventTag = phba->fc_eventTag; | |
254 | mb->mbxCommand = MBX_CLEAR_LA; | |
255 | mb->mbxOwner = OWN_HOST; | |
256 | return; | |
257 | } | |
258 | ||
e59058c4 JS |
259 | /** |
260 | * lpfc_config_link: Prepare a mailbox command for configuring link on a HBA. | |
261 | * @phba: pointer to lpfc hba data structure. | |
262 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
263 | * | |
264 | * The configure link mailbox command is used before the initialize link | |
265 | * mailbox command to override default value and to configure link-oriented | |
266 | * parameters such as DID address and various timers. Typically, this | |
267 | * command would be used after an F_Port login to set the returned DID address | |
268 | * and the fabric timeout values. This command is not valid before a configure | |
269 | * port command has configured the HBA port. | |
270 | * | |
271 | * This routine prepares the mailbox command for configuring link on a HBA. | |
272 | **/ | |
dea3101e JB |
273 | void |
274 | lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
275 | { | |
2e0fef85 | 276 | struct lpfc_vport *vport = phba->pport; |
dea3101e JB |
277 | MAILBOX_t *mb = &pmb->mb; |
278 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
279 | ||
280 | /* NEW_FEATURE | |
281 | * SLI-2, Coalescing Response Feature. | |
282 | */ | |
283 | if (phba->cfg_cr_delay) { | |
284 | mb->un.varCfgLnk.cr = 1; | |
285 | mb->un.varCfgLnk.ci = 1; | |
286 | mb->un.varCfgLnk.cr_delay = phba->cfg_cr_delay; | |
287 | mb->un.varCfgLnk.cr_count = phba->cfg_cr_count; | |
288 | } | |
289 | ||
2e0fef85 | 290 | mb->un.varCfgLnk.myId = vport->fc_myDID; |
dea3101e JB |
291 | mb->un.varCfgLnk.edtov = phba->fc_edtov; |
292 | mb->un.varCfgLnk.arbtov = phba->fc_arbtov; | |
293 | mb->un.varCfgLnk.ratov = phba->fc_ratov; | |
294 | mb->un.varCfgLnk.rttov = phba->fc_rttov; | |
295 | mb->un.varCfgLnk.altov = phba->fc_altov; | |
296 | mb->un.varCfgLnk.crtov = phba->fc_crtov; | |
297 | mb->un.varCfgLnk.citov = phba->fc_citov; | |
298 | ||
299 | if (phba->cfg_ack0) | |
300 | mb->un.varCfgLnk.ack0_enable = 1; | |
301 | ||
302 | mb->mbxCommand = MBX_CONFIG_LINK; | |
303 | mb->mbxOwner = OWN_HOST; | |
304 | return; | |
305 | } | |
306 | ||
9399627f JS |
307 | /** |
308 | * lpfc_config_msi: Prepare a mailbox command for configuring msi-x. | |
309 | * @phba: pointer to lpfc hba data structure. | |
310 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
311 | * | |
312 | * The configure MSI-X mailbox command is used to configure the HBA's SLI-3 | |
313 | * MSI-X multi-message interrupt vector association to interrupt attention | |
314 | * conditions. | |
315 | * | |
316 | * Return codes | |
317 | * 0 - Success | |
318 | * -EINVAL - Failure | |
319 | **/ | |
320 | int | |
321 | lpfc_config_msi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |
322 | { | |
323 | MAILBOX_t *mb = &pmb->mb; | |
324 | uint32_t attentionConditions[2]; | |
325 | ||
326 | /* Sanity check */ | |
327 | if (phba->cfg_use_msi != 2) { | |
328 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
329 | "0475 Not configured for supporting MSI-X " | |
330 | "cfg_use_msi: 0x%x\n", phba->cfg_use_msi); | |
331 | return -EINVAL; | |
332 | } | |
333 | ||
334 | if (phba->sli_rev < 3) { | |
335 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
336 | "0476 HBA not supporting SLI-3 or later " | |
337 | "SLI Revision: 0x%x\n", phba->sli_rev); | |
338 | return -EINVAL; | |
339 | } | |
340 | ||
341 | /* Clear mailbox command fields */ | |
342 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | |
343 | ||
344 | /* | |
345 | * SLI-3, Message Signaled Interrupt Fearure. | |
346 | */ | |
347 | ||
348 | /* Multi-message attention configuration */ | |
349 | attentionConditions[0] = (HA_R0ATT | HA_R1ATT | HA_R2ATT | HA_ERATT | | |
350 | HA_LATT | HA_MBATT); | |
351 | attentionConditions[1] = 0; | |
352 | ||
353 | mb->un.varCfgMSI.attentionConditions[0] = attentionConditions[0]; | |
354 | mb->un.varCfgMSI.attentionConditions[1] = attentionConditions[1]; | |
355 | ||
356 | /* | |
357 | * Set up message number to HA bit association | |
358 | */ | |
359 | #ifdef __BIG_ENDIAN_BITFIELD | |
360 | /* RA0 (FCP Ring) */ | |
361 | mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS] = 1; | |
362 | /* RA1 (Other Protocol Extra Ring) */ | |
363 | mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS] = 1; | |
364 | #else /* __LITTLE_ENDIAN_BITFIELD */ | |
365 | /* RA0 (FCP Ring) */ | |
366 | mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS^3] = 1; | |
367 | /* RA1 (Other Protocol Extra Ring) */ | |
368 | mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS^3] = 1; | |
369 | #endif | |
370 | /* Multi-message interrupt autoclear configuration*/ | |
371 | mb->un.varCfgMSI.autoClearHA[0] = attentionConditions[0]; | |
372 | mb->un.varCfgMSI.autoClearHA[1] = attentionConditions[1]; | |
373 | ||
374 | /* For now, HBA autoclear does not work reliably, disable it */ | |
375 | mb->un.varCfgMSI.autoClearHA[0] = 0; | |
376 | mb->un.varCfgMSI.autoClearHA[1] = 0; | |
377 | ||
378 | /* Set command and owner bit */ | |
379 | mb->mbxCommand = MBX_CONFIG_MSI; | |
380 | mb->mbxOwner = OWN_HOST; | |
381 | ||
382 | return 0; | |
383 | } | |
384 | ||
e59058c4 JS |
385 | /** |
386 | * lpfc_init_link: Prepare a mailbox command for initialize link on a HBA. | |
387 | * @phba: pointer to lpfc hba data structure. | |
388 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
389 | * @topology: the link topology for the link to be initialized to. | |
390 | * @linkspeed: the link speed for the link to be initialized to. | |
391 | * | |
392 | * The initialize link mailbox command is used to initialize the Fibre | |
393 | * Channel link. This command must follow a configure port command that | |
394 | * establishes the mode of operation. | |
395 | * | |
396 | * This routine prepares the mailbox command for initializing link on a HBA | |
397 | * with the specified link topology and speed. | |
398 | **/ | |
dea3101e JB |
399 | void |
400 | lpfc_init_link(struct lpfc_hba * phba, | |
401 | LPFC_MBOXQ_t * pmb, uint32_t topology, uint32_t linkspeed) | |
402 | { | |
403 | lpfc_vpd_t *vpd; | |
404 | struct lpfc_sli *psli; | |
405 | MAILBOX_t *mb; | |
406 | ||
407 | mb = &pmb->mb; | |
408 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
409 | ||
410 | psli = &phba->sli; | |
411 | switch (topology) { | |
412 | case FLAGS_TOPOLOGY_MODE_LOOP_PT: | |
413 | mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP; | |
414 | mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER; | |
415 | break; | |
416 | case FLAGS_TOPOLOGY_MODE_PT_PT: | |
417 | mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT; | |
418 | break; | |
419 | case FLAGS_TOPOLOGY_MODE_LOOP: | |
420 | mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP; | |
421 | break; | |
422 | case FLAGS_TOPOLOGY_MODE_PT_LOOP: | |
423 | mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT; | |
424 | mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER; | |
425 | break; | |
367c2713 JW |
426 | case FLAGS_LOCAL_LB: |
427 | mb->un.varInitLnk.link_flags = FLAGS_LOCAL_LB; | |
428 | break; | |
dea3101e JB |
429 | } |
430 | ||
4b0b91d4 JS |
431 | /* Enable asynchronous ABTS responses from firmware */ |
432 | mb->un.varInitLnk.link_flags |= FLAGS_IMED_ABORT; | |
433 | ||
dea3101e JB |
434 | /* NEW_FEATURE |
435 | * Setting up the link speed | |
436 | */ | |
437 | vpd = &phba->vpd; | |
438 | if (vpd->rev.feaLevelHigh >= 0x02){ | |
92d7f7b0 | 439 | switch(linkspeed){ |
dea3101e JB |
440 | case LINK_SPEED_1G: |
441 | case LINK_SPEED_2G: | |
442 | case LINK_SPEED_4G: | |
b87eab38 | 443 | case LINK_SPEED_8G: |
dea3101e JB |
444 | mb->un.varInitLnk.link_flags |= |
445 | FLAGS_LINK_SPEED; | |
446 | mb->un.varInitLnk.link_speed = linkspeed; | |
447 | break; | |
448 | case LINK_SPEED_AUTO: | |
449 | default: | |
450 | mb->un.varInitLnk.link_speed = | |
451 | LINK_SPEED_AUTO; | |
452 | break; | |
453 | } | |
454 | ||
455 | } | |
456 | else | |
457 | mb->un.varInitLnk.link_speed = LINK_SPEED_AUTO; | |
458 | ||
459 | mb->mbxCommand = (volatile uint8_t)MBX_INIT_LINK; | |
460 | mb->mbxOwner = OWN_HOST; | |
461 | mb->un.varInitLnk.fabric_AL_PA = phba->fc_pref_ALPA; | |
462 | return; | |
463 | } | |
464 | ||
e59058c4 JS |
465 | /** |
466 | * lpfc_read_sparam: Prepare a mailbox command for reading HBA parameters. | |
467 | * @phba: pointer to lpfc hba data structure. | |
468 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
469 | * @vpi: virtual N_Port identifier. | |
470 | * | |
471 | * The read service parameter mailbox command is used to read the HBA port | |
472 | * service parameters. The service parameters are read into the buffer | |
473 | * specified directly by a BDE in the mailbox command. These service | |
474 | * parameters may then be used to build the payload of an N_Port/F_POrt | |
475 | * login request and reply (LOGI/ACC). | |
476 | * | |
477 | * This routine prepares the mailbox command for reading HBA port service | |
478 | * parameters. The DMA memory is allocated in this function and the addresses | |
479 | * are populated into the mailbox command for the HBA to DMA the service | |
480 | * parameters into. | |
481 | * | |
482 | * Return codes | |
483 | * 0 - Success | |
484 | * 1 - DMA memory allocation failed | |
485 | **/ | |
dea3101e | 486 | int |
92d7f7b0 | 487 | lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) |
dea3101e JB |
488 | { |
489 | struct lpfc_dmabuf *mp; | |
490 | MAILBOX_t *mb; | |
491 | struct lpfc_sli *psli; | |
492 | ||
493 | psli = &phba->sli; | |
494 | mb = &pmb->mb; | |
495 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
496 | ||
497 | mb->mbxOwner = OWN_HOST; | |
498 | ||
499 | /* Get a buffer to hold the HBAs Service Parameters */ | |
500 | ||
98c9ea5c JS |
501 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
502 | if (mp) | |
503 | mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); | |
504 | if (!mp || !mp->virt) { | |
c9475cb0 | 505 | kfree(mp); |
dea3101e JB |
506 | mb->mbxCommand = MBX_READ_SPARM64; |
507 | /* READ_SPARAM: no buffers */ | |
e8b62011 JS |
508 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, |
509 | "0301 READ_SPARAM: no buffers\n"); | |
92d7f7b0 | 510 | return (1); |
dea3101e JB |
511 | } |
512 | INIT_LIST_HEAD(&mp->list); | |
513 | mb->mbxCommand = MBX_READ_SPARM64; | |
514 | mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm); | |
515 | mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys); | |
516 | mb->un.varRdSparm.un.sp64.addrLow = putPaddrLow(mp->phys); | |
92d7f7b0 | 517 | mb->un.varRdSparm.vpi = vpi; |
dea3101e JB |
518 | |
519 | /* save address for completion */ | |
520 | pmb->context1 = mp; | |
521 | ||
92d7f7b0 | 522 | return (0); |
dea3101e JB |
523 | } |
524 | ||
e59058c4 JS |
525 | /** |
526 | * lpfc_unreg_did: Prepare a mailbox command for unregistering DID. | |
527 | * @phba: pointer to lpfc hba data structure. | |
528 | * @vpi: virtual N_Port identifier. | |
529 | * @did: remote port identifier. | |
530 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
531 | * | |
532 | * The unregister DID mailbox command is used to unregister an N_Port/F_Port | |
533 | * login for an unknown RPI by specifying the DID of a remote port. This | |
534 | * command frees an RPI context in the HBA port. This has the effect of | |
535 | * performing an implicit N_Port/F_Port logout. | |
536 | * | |
537 | * This routine prepares the mailbox command for unregistering a remote | |
538 | * N_Port/F_Port (DID) login. | |
539 | **/ | |
dea3101e | 540 | void |
92d7f7b0 JS |
541 | lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did, |
542 | LPFC_MBOXQ_t * pmb) | |
dea3101e JB |
543 | { |
544 | MAILBOX_t *mb; | |
545 | ||
546 | mb = &pmb->mb; | |
547 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
548 | ||
549 | mb->un.varUnregDID.did = did; | |
92d7f7b0 | 550 | mb->un.varUnregDID.vpi = vpi; |
dea3101e JB |
551 | |
552 | mb->mbxCommand = MBX_UNREG_D_ID; | |
553 | mb->mbxOwner = OWN_HOST; | |
554 | return; | |
555 | } | |
556 | ||
e59058c4 JS |
557 | /** |
558 | * lpfc_read_config: Prepare a mailbox command for reading HBA configuration. | |
559 | * @phba: pointer to lpfc hba data structure. | |
560 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
561 | * | |
562 | * The read configuration mailbox command is used to read the HBA port | |
563 | * configuration parameters. This mailbox command provides a method for | |
564 | * seeing any parameters that may have changed via various configuration | |
565 | * mailbox commands. | |
566 | * | |
567 | * This routine prepares the mailbox command for reading out HBA configuration | |
568 | * parameters. | |
569 | **/ | |
dea3101e JB |
570 | void |
571 | lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
572 | { | |
573 | MAILBOX_t *mb; | |
574 | ||
575 | mb = &pmb->mb; | |
576 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
577 | ||
578 | mb->mbxCommand = MBX_READ_CONFIG; | |
579 | mb->mbxOwner = OWN_HOST; | |
580 | return; | |
581 | } | |
582 | ||
e59058c4 JS |
583 | /** |
584 | * lpfc_read_lnk_stat: Prepare a mailbox command for reading HBA link stats. | |
585 | * @phba: pointer to lpfc hba data structure. | |
586 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
587 | * | |
588 | * The read link status mailbox command is used to read the link status from | |
589 | * the HBA. Link status includes all link-related error counters. These | |
590 | * counters are maintained by the HBA and originated in the link hardware | |
591 | * unit. Note that all of these counters wrap. | |
592 | * | |
593 | * This routine prepares the mailbox command for reading out HBA link status. | |
594 | **/ | |
7bb3b137 JW |
595 | void |
596 | lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
597 | { | |
598 | MAILBOX_t *mb; | |
599 | ||
600 | mb = &pmb->mb; | |
601 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
602 | ||
603 | mb->mbxCommand = MBX_READ_LNK_STAT; | |
604 | mb->mbxOwner = OWN_HOST; | |
605 | return; | |
606 | } | |
607 | ||
e59058c4 JS |
608 | /** |
609 | * lpfc_reg_login: Prepare a mailbox command for registering remote login. | |
610 | * @phba: pointer to lpfc hba data structure. | |
611 | * @vpi: virtual N_Port identifier. | |
612 | * @did: remote port identifier. | |
613 | * @param: pointer to memory holding the server parameters. | |
614 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
615 | * @flag: action flag to be passed back for the complete function. | |
616 | * | |
617 | * The registration login mailbox command is used to register an N_Port or | |
618 | * F_Port login. This registration allows the HBA to cache the remote N_Port | |
619 | * service parameters internally and thereby make the appropriate FC-2 | |
620 | * decisions. The remote port service parameters are handed off by the driver | |
621 | * to the HBA using a descriptor entry that directly identifies a buffer in | |
622 | * host memory. In exchange, the HBA returns an RPI identifier. | |
623 | * | |
624 | * This routine prepares the mailbox command for registering remote port login. | |
625 | * The function allocates DMA buffer for passing the service parameters to the | |
626 | * HBA with the mailbox command. | |
627 | * | |
628 | * Return codes | |
629 | * 0 - Success | |
630 | * 1 - DMA memory allocation failed | |
631 | **/ | |
dea3101e | 632 | int |
92d7f7b0 JS |
633 | lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, |
634 | uint8_t *param, LPFC_MBOXQ_t *pmb, uint32_t flag) | |
dea3101e | 635 | { |
2e0fef85 | 636 | MAILBOX_t *mb = &pmb->mb; |
dea3101e JB |
637 | uint8_t *sparam; |
638 | struct lpfc_dmabuf *mp; | |
dea3101e | 639 | |
dea3101e JB |
640 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); |
641 | ||
642 | mb->un.varRegLogin.rpi = 0; | |
92d7f7b0 | 643 | mb->un.varRegLogin.vpi = vpi; |
dea3101e JB |
644 | mb->un.varRegLogin.did = did; |
645 | mb->un.varWords[30] = flag; /* Set flag to issue action on cmpl */ | |
646 | ||
647 | mb->mbxOwner = OWN_HOST; | |
648 | ||
649 | /* Get a buffer to hold NPorts Service Parameters */ | |
98c9ea5c JS |
650 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
651 | if (mp) | |
652 | mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); | |
653 | if (!mp || !mp->virt) { | |
c9475cb0 | 654 | kfree(mp); |
dea3101e JB |
655 | mb->mbxCommand = MBX_REG_LOGIN64; |
656 | /* REG_LOGIN: no buffers */ | |
92d7f7b0 | 657 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, |
e8b62011 JS |
658 | "0302 REG_LOGIN: no buffers, VPI:%d DID:x%x, " |
659 | "flag x%x\n", vpi, did, flag); | |
92d7f7b0 | 660 | return (1); |
dea3101e JB |
661 | } |
662 | INIT_LIST_HEAD(&mp->list); | |
663 | sparam = mp->virt; | |
664 | ||
665 | /* Copy param's into a new buffer */ | |
666 | memcpy(sparam, param, sizeof (struct serv_parm)); | |
667 | ||
668 | /* save address for completion */ | |
669 | pmb->context1 = (uint8_t *) mp; | |
670 | ||
671 | mb->mbxCommand = MBX_REG_LOGIN64; | |
672 | mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm); | |
673 | mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys); | |
674 | mb->un.varRegLogin.un.sp64.addrLow = putPaddrLow(mp->phys); | |
675 | ||
92d7f7b0 | 676 | return (0); |
dea3101e JB |
677 | } |
678 | ||
e59058c4 JS |
679 | /** |
680 | * lpfc_unreg_login: Prepare a mailbox command for unregistering remote login. | |
681 | * @phba: pointer to lpfc hba data structure. | |
682 | * @vpi: virtual N_Port identifier. | |
683 | * @rpi: remote port identifier | |
684 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
685 | * | |
686 | * The unregistration login mailbox command is used to unregister an N_Port | |
687 | * or F_Port login. This command frees an RPI context in the HBA. It has the | |
688 | * effect of performing an implicit N_Port/F_Port logout. | |
689 | * | |
690 | * This routine prepares the mailbox command for unregistering remote port | |
691 | * login. | |
692 | **/ | |
dea3101e | 693 | void |
92d7f7b0 JS |
694 | lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi, |
695 | LPFC_MBOXQ_t * pmb) | |
dea3101e JB |
696 | { |
697 | MAILBOX_t *mb; | |
698 | ||
699 | mb = &pmb->mb; | |
700 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
701 | ||
702 | mb->un.varUnregLogin.rpi = (uint16_t) rpi; | |
703 | mb->un.varUnregLogin.rsvd1 = 0; | |
92d7f7b0 | 704 | mb->un.varUnregLogin.vpi = vpi; |
dea3101e JB |
705 | |
706 | mb->mbxCommand = MBX_UNREG_LOGIN; | |
707 | mb->mbxOwner = OWN_HOST; | |
708 | return; | |
709 | } | |
710 | ||
e59058c4 JS |
711 | /** |
712 | * lpfc_reg_vpi: Prepare a mailbox command for registering vport identifier. | |
713 | * @phba: pointer to lpfc hba data structure. | |
714 | * @vpi: virtual N_Port identifier. | |
715 | * @sid: Fibre Channel S_ID (N_Port_ID assigned to a virtual N_Port). | |
716 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
717 | * | |
718 | * The registration vport identifier mailbox command is used to activate a | |
719 | * virtual N_Port after it has acquired an N_Port_ID. The HBA validates the | |
720 | * N_Port_ID against the information in the selected virtual N_Port context | |
721 | * block and marks it active to allow normal processing of IOCB commands and | |
722 | * received unsolicited exchanges. | |
723 | * | |
724 | * This routine prepares the mailbox command for registering a virtual N_Port. | |
725 | **/ | |
92d7f7b0 JS |
726 | void |
727 | lpfc_reg_vpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t sid, | |
728 | LPFC_MBOXQ_t *pmb) | |
729 | { | |
730 | MAILBOX_t *mb = &pmb->mb; | |
731 | ||
732 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
733 | ||
734 | mb->un.varRegVpi.vpi = vpi; | |
735 | mb->un.varRegVpi.sid = sid; | |
736 | ||
737 | mb->mbxCommand = MBX_REG_VPI; | |
738 | mb->mbxOwner = OWN_HOST; | |
739 | return; | |
740 | ||
741 | } | |
742 | ||
e59058c4 JS |
743 | /** |
744 | * lpfc_unreg_vpi: Prepare a mailbox command for unregistering vport id. | |
745 | * @phba: pointer to lpfc hba data structure. | |
746 | * @vpi: virtual N_Port identifier. | |
747 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
748 | * | |
749 | * The unregistration vport identifier mailbox command is used to inactivate | |
750 | * a virtual N_Port. The driver must have logged out and unregistered all | |
751 | * remote N_Ports to abort any activity on the virtual N_Port. The HBA will | |
752 | * unregisters any default RPIs associated with the specified vpi, aborting | |
753 | * any active exchanges. The HBA will post the mailbox response after making | |
754 | * the virtual N_Port inactive. | |
755 | * | |
756 | * This routine prepares the mailbox command for unregistering a virtual | |
757 | * N_Port. | |
758 | **/ | |
92d7f7b0 JS |
759 | void |
760 | lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb) | |
761 | { | |
762 | MAILBOX_t *mb = &pmb->mb; | |
763 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
764 | ||
765 | mb->un.varUnregVpi.vpi = vpi; | |
766 | ||
767 | mb->mbxCommand = MBX_UNREG_VPI; | |
768 | mb->mbxOwner = OWN_HOST; | |
769 | return; | |
770 | ||
771 | } | |
772 | ||
e59058c4 JS |
773 | /** |
774 | * lpfc_config_pcb_setup: Set up IOCB rings in the Port Control Block (PCB) | |
775 | * @phba: pointer to lpfc hba data structure. | |
776 | * | |
777 | * This routine sets up and initializes the IOCB rings in the Port Control | |
778 | * Block (PCB). | |
779 | **/ | |
dea3101e JB |
780 | static void |
781 | lpfc_config_pcb_setup(struct lpfc_hba * phba) | |
782 | { | |
783 | struct lpfc_sli *psli = &phba->sli; | |
784 | struct lpfc_sli_ring *pring; | |
34b02dcd | 785 | PCB_t *pcbp = phba->pcb; |
dea3101e JB |
786 | dma_addr_t pdma_addr; |
787 | uint32_t offset; | |
2e0fef85 | 788 | uint32_t iocbCnt = 0; |
dea3101e JB |
789 | int i; |
790 | ||
dea3101e JB |
791 | pcbp->maxRing = (psli->num_rings - 1); |
792 | ||
dea3101e JB |
793 | for (i = 0; i < psli->num_rings; i++) { |
794 | pring = &psli->ring[i]; | |
2e0fef85 | 795 | |
ed957684 | 796 | pring->sizeCiocb = phba->sli_rev == 3 ? SLI3_IOCB_CMD_SIZE: |
92d7f7b0 | 797 | SLI2_IOCB_CMD_SIZE; |
ed957684 | 798 | pring->sizeRiocb = phba->sli_rev == 3 ? SLI3_IOCB_RSP_SIZE: |
92d7f7b0 | 799 | SLI2_IOCB_RSP_SIZE; |
dea3101e JB |
800 | /* A ring MUST have both cmd and rsp entries defined to be |
801 | valid */ | |
802 | if ((pring->numCiocb == 0) || (pring->numRiocb == 0)) { | |
803 | pcbp->rdsc[i].cmdEntries = 0; | |
804 | pcbp->rdsc[i].rspEntries = 0; | |
805 | pcbp->rdsc[i].cmdAddrHigh = 0; | |
806 | pcbp->rdsc[i].rspAddrHigh = 0; | |
807 | pcbp->rdsc[i].cmdAddrLow = 0; | |
808 | pcbp->rdsc[i].rspAddrLow = 0; | |
809 | pring->cmdringaddr = NULL; | |
810 | pring->rspringaddr = NULL; | |
811 | continue; | |
812 | } | |
813 | /* Command ring setup for ring */ | |
34b02dcd | 814 | pring->cmdringaddr = (void *)&phba->IOCBs[iocbCnt]; |
dea3101e JB |
815 | pcbp->rdsc[i].cmdEntries = pring->numCiocb; |
816 | ||
34b02dcd JS |
817 | offset = (uint8_t *) &phba->IOCBs[iocbCnt] - |
818 | (uint8_t *) phba->slim2p.virt; | |
819 | pdma_addr = phba->slim2p.phys + offset; | |
dea3101e JB |
820 | pcbp->rdsc[i].cmdAddrHigh = putPaddrHigh(pdma_addr); |
821 | pcbp->rdsc[i].cmdAddrLow = putPaddrLow(pdma_addr); | |
822 | iocbCnt += pring->numCiocb; | |
823 | ||
824 | /* Response ring setup for ring */ | |
34b02dcd | 825 | pring->rspringaddr = (void *) &phba->IOCBs[iocbCnt]; |
dea3101e JB |
826 | |
827 | pcbp->rdsc[i].rspEntries = pring->numRiocb; | |
34b02dcd JS |
828 | offset = (uint8_t *)&phba->IOCBs[iocbCnt] - |
829 | (uint8_t *)phba->slim2p.virt; | |
830 | pdma_addr = phba->slim2p.phys + offset; | |
dea3101e JB |
831 | pcbp->rdsc[i].rspAddrHigh = putPaddrHigh(pdma_addr); |
832 | pcbp->rdsc[i].rspAddrLow = putPaddrLow(pdma_addr); | |
833 | iocbCnt += pring->numRiocb; | |
834 | } | |
835 | } | |
836 | ||
e59058c4 JS |
837 | /** |
838 | * lpfc_read_rev: Prepare a mailbox command for reading HBA revision. | |
839 | * @phba: pointer to lpfc hba data structure. | |
840 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
841 | * | |
842 | * The read revision mailbox command is used to read the revision levels of | |
843 | * the HBA components. These components include hardware units, resident | |
844 | * firmware, and available firmware. HBAs that supports SLI-3 mode of | |
845 | * operation provide different response information depending on the version | |
846 | * requested by the driver. | |
847 | * | |
848 | * This routine prepares the mailbox command for reading HBA revision | |
849 | * information. | |
850 | **/ | |
dea3101e JB |
851 | void |
852 | lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
853 | { | |
2e0fef85 | 854 | MAILBOX_t *mb = &pmb->mb; |
dea3101e JB |
855 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); |
856 | mb->un.varRdRev.cv = 1; | |
ed957684 | 857 | mb->un.varRdRev.v3req = 1; /* Request SLI3 info */ |
dea3101e JB |
858 | mb->mbxCommand = MBX_READ_REV; |
859 | mb->mbxOwner = OWN_HOST; | |
860 | return; | |
861 | } | |
862 | ||
e59058c4 JS |
863 | /** |
864 | * lpfc_build_hbq_profile2: Set up the HBQ Selection Profile 2. | |
865 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | |
866 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | |
867 | * | |
868 | * The Host Buffer Queue (HBQ) Selection Profile 2 specifies that the HBA | |
869 | * tests the incoming frames' R_CTL/TYPE fields with works 10:15 and performs | |
870 | * the Sequence Length Test using the fields in the Selection Profile 2 | |
871 | * extension in words 20:31. | |
872 | **/ | |
ed957684 JS |
873 | static void |
874 | lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb, | |
875 | struct lpfc_hbq_init *hbq_desc) | |
876 | { | |
877 | hbqmb->profiles.profile2.seqlenbcnt = hbq_desc->seqlenbcnt; | |
878 | hbqmb->profiles.profile2.maxlen = hbq_desc->maxlen; | |
879 | hbqmb->profiles.profile2.seqlenoff = hbq_desc->seqlenoff; | |
880 | } | |
881 | ||
e59058c4 JS |
882 | /** |
883 | * lpfc_build_hbq_profile3: Set up the HBQ Selection Profile 3. | |
884 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | |
885 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | |
886 | * | |
887 | * The Host Buffer Queue (HBQ) Selection Profile 3 specifies that the HBA | |
888 | * tests the incoming frame's R_CTL/TYPE fields with words 10:15 and performs | |
889 | * the Sequence Length Test and Byte Field Test using the fields in the | |
890 | * Selection Profile 3 extension in words 20:31. | |
891 | **/ | |
ed957684 JS |
892 | static void |
893 | lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb, | |
894 | struct lpfc_hbq_init *hbq_desc) | |
895 | { | |
896 | hbqmb->profiles.profile3.seqlenbcnt = hbq_desc->seqlenbcnt; | |
897 | hbqmb->profiles.profile3.maxlen = hbq_desc->maxlen; | |
898 | hbqmb->profiles.profile3.cmdcodeoff = hbq_desc->cmdcodeoff; | |
899 | hbqmb->profiles.profile3.seqlenoff = hbq_desc->seqlenoff; | |
900 | memcpy(&hbqmb->profiles.profile3.cmdmatch, hbq_desc->cmdmatch, | |
901 | sizeof(hbqmb->profiles.profile3.cmdmatch)); | |
902 | } | |
903 | ||
e59058c4 JS |
904 | /** |
905 | * lpfc_build_hbq_profile5: Set up the HBQ Selection Profile 5. | |
906 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | |
907 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | |
908 | * | |
909 | * The Host Buffer Queue (HBQ) Selection Profile 5 specifies a header HBQ. The | |
910 | * HBA tests the initial frame of an incoming sequence using the frame's | |
911 | * R_CTL/TYPE fields with words 10:15 and performs the Sequence Length Test | |
912 | * and Byte Field Test using the fields in the Selection Profile 5 extension | |
913 | * words 20:31. | |
914 | **/ | |
ed957684 JS |
915 | static void |
916 | lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb, | |
917 | struct lpfc_hbq_init *hbq_desc) | |
918 | { | |
919 | hbqmb->profiles.profile5.seqlenbcnt = hbq_desc->seqlenbcnt; | |
920 | hbqmb->profiles.profile5.maxlen = hbq_desc->maxlen; | |
921 | hbqmb->profiles.profile5.cmdcodeoff = hbq_desc->cmdcodeoff; | |
922 | hbqmb->profiles.profile5.seqlenoff = hbq_desc->seqlenoff; | |
923 | memcpy(&hbqmb->profiles.profile5.cmdmatch, hbq_desc->cmdmatch, | |
924 | sizeof(hbqmb->profiles.profile5.cmdmatch)); | |
925 | } | |
926 | ||
e59058c4 JS |
927 | /** |
928 | * lpfc_config_hbq: Prepare a mailbox command for configuring an HBQ. | |
929 | * @phba: pointer to lpfc hba data structure. | |
930 | * @id: HBQ identifier. | |
931 | * @hbq_desc: pointer to the HBA descriptor data structure. | |
932 | * @hbq_entry_index: index of the HBQ entry data structures. | |
933 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
934 | * | |
935 | * The configure HBQ (Host Buffer Queue) mailbox command is used to configure | |
936 | * an HBQ. The configuration binds events that require buffers to a particular | |
937 | * ring and HBQ based on a selection profile. | |
938 | * | |
939 | * This routine prepares the mailbox command for configuring an HBQ. | |
940 | **/ | |
ed957684 | 941 | void |
51ef4c26 JS |
942 | lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id, |
943 | struct lpfc_hbq_init *hbq_desc, | |
ed957684 JS |
944 | uint32_t hbq_entry_index, LPFC_MBOXQ_t *pmb) |
945 | { | |
946 | int i; | |
947 | MAILBOX_t *mb = &pmb->mb; | |
948 | struct config_hbq_var *hbqmb = &mb->un.varCfgHbq; | |
949 | ||
950 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
51ef4c26 | 951 | hbqmb->hbqId = id; |
ed957684 JS |
952 | hbqmb->entry_count = hbq_desc->entry_count; /* # entries in HBQ */ |
953 | hbqmb->recvNotify = hbq_desc->rn; /* Receive | |
954 | * Notification */ | |
955 | hbqmb->numMask = hbq_desc->mask_count; /* # R_CTL/TYPE masks | |
956 | * # in words 0-19 */ | |
92d7f7b0 | 957 | hbqmb->profile = hbq_desc->profile; /* Selection profile: |
ed957684 JS |
958 | * 0 = all, |
959 | * 7 = logentry */ | |
960 | hbqmb->ringMask = hbq_desc->ring_mask; /* Binds HBQ to a ring | |
961 | * e.g. Ring0=b0001, | |
962 | * ring2=b0100 */ | |
963 | hbqmb->headerLen = hbq_desc->headerLen; /* 0 if not profile 4 | |
964 | * or 5 */ | |
965 | hbqmb->logEntry = hbq_desc->logEntry; /* Set to 1 if this | |
966 | * HBQ will be used | |
967 | * for LogEntry | |
968 | * buffers */ | |
969 | hbqmb->hbqaddrLow = putPaddrLow(phba->hbqslimp.phys) + | |
970 | hbq_entry_index * sizeof(struct lpfc_hbq_entry); | |
971 | hbqmb->hbqaddrHigh = putPaddrHigh(phba->hbqslimp.phys); | |
972 | ||
973 | mb->mbxCommand = MBX_CONFIG_HBQ; | |
974 | mb->mbxOwner = OWN_HOST; | |
975 | ||
92d7f7b0 JS |
976 | /* Copy info for profiles 2,3,5. Other |
977 | * profiles this area is reserved | |
978 | */ | |
ed957684 JS |
979 | if (hbq_desc->profile == 2) |
980 | lpfc_build_hbq_profile2(hbqmb, hbq_desc); | |
981 | else if (hbq_desc->profile == 3) | |
982 | lpfc_build_hbq_profile3(hbqmb, hbq_desc); | |
983 | else if (hbq_desc->profile == 5) | |
984 | lpfc_build_hbq_profile5(hbqmb, hbq_desc); | |
985 | ||
986 | /* Return if no rctl / type masks for this HBQ */ | |
987 | if (!hbq_desc->mask_count) | |
988 | return; | |
989 | ||
990 | /* Otherwise we setup specific rctl / type masks for this HBQ */ | |
991 | for (i = 0; i < hbq_desc->mask_count; i++) { | |
992 | hbqmb->hbqMasks[i].tmatch = hbq_desc->hbqMasks[i].tmatch; | |
993 | hbqmb->hbqMasks[i].tmask = hbq_desc->hbqMasks[i].tmask; | |
994 | hbqmb->hbqMasks[i].rctlmatch = hbq_desc->hbqMasks[i].rctlmatch; | |
995 | hbqmb->hbqMasks[i].rctlmask = hbq_desc->hbqMasks[i].rctlmask; | |
996 | } | |
997 | ||
998 | return; | |
999 | } | |
1000 | ||
e59058c4 JS |
1001 | /** |
1002 | * lpfc_config_ring: Prepare a mailbox command for configuring an IOCB ring. | |
1003 | * @phba: pointer to lpfc hba data structure. | |
1004 | * @ring: | |
1005 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
1006 | * | |
1007 | * The configure ring mailbox command is used to configure an IOCB ring. This | |
1008 | * configuration binds from one to six of HBA RC_CTL/TYPE mask entries to the | |
1009 | * ring. This is used to map incoming sequences to a particular ring whose | |
1010 | * RC_CTL/TYPE mask entry matches that of the sequence. The driver should not | |
1011 | * attempt to configure a ring whose number is greater than the number | |
1012 | * specified in the Port Control Block (PCB). It is an error to issue the | |
1013 | * configure ring command more than once with the same ring number. The HBA | |
1014 | * returns an error if the driver attempts this. | |
1015 | * | |
1016 | * This routine prepares the mailbox command for configuring IOCB ring. | |
1017 | **/ | |
dea3101e JB |
1018 | void |
1019 | lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb) | |
1020 | { | |
1021 | int i; | |
1022 | MAILBOX_t *mb = &pmb->mb; | |
1023 | struct lpfc_sli *psli; | |
1024 | struct lpfc_sli_ring *pring; | |
1025 | ||
1026 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | |
1027 | ||
1028 | mb->un.varCfgRing.ring = ring; | |
1029 | mb->un.varCfgRing.maxOrigXchg = 0; | |
1030 | mb->un.varCfgRing.maxRespXchg = 0; | |
1031 | mb->un.varCfgRing.recvNotify = 1; | |
1032 | ||
1033 | psli = &phba->sli; | |
1034 | pring = &psli->ring[ring]; | |
1035 | mb->un.varCfgRing.numMask = pring->num_mask; | |
1036 | mb->mbxCommand = MBX_CONFIG_RING; | |
1037 | mb->mbxOwner = OWN_HOST; | |
1038 | ||
1039 | /* Is this ring configured for a specific profile */ | |
1040 | if (pring->prt[0].profile) { | |
1041 | mb->un.varCfgRing.profile = pring->prt[0].profile; | |
1042 | return; | |
1043 | } | |
1044 | ||
1045 | /* Otherwise we setup specific rctl / type masks for this ring */ | |
1046 | for (i = 0; i < pring->num_mask; i++) { | |
1047 | mb->un.varCfgRing.rrRegs[i].rval = pring->prt[i].rctl; | |
1048 | if (mb->un.varCfgRing.rrRegs[i].rval != FC_ELS_REQ) | |
1049 | mb->un.varCfgRing.rrRegs[i].rmask = 0xff; | |
1050 | else | |
1051 | mb->un.varCfgRing.rrRegs[i].rmask = 0xfe; | |
1052 | mb->un.varCfgRing.rrRegs[i].tval = pring->prt[i].type; | |
1053 | mb->un.varCfgRing.rrRegs[i].tmask = 0xff; | |
1054 | } | |
1055 | ||
1056 | return; | |
1057 | } | |
1058 | ||
e59058c4 JS |
1059 | /** |
1060 | * lpfc_config_port: Prepare a mailbox command for configuring port. | |
1061 | * @phba: pointer to lpfc hba data structure. | |
1062 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
1063 | * | |
1064 | * The configure port mailbox command is used to identify the Port Control | |
1065 | * Block (PCB) in the driver memory. After this command is issued, the | |
1066 | * driver must not access the mailbox in the HBA without first resetting | |
1067 | * the HBA. The HBA may copy the PCB information to internal storage for | |
1068 | * subsequent use; the driver can not change the PCB information unless it | |
1069 | * resets the HBA. | |
1070 | * | |
1071 | * This routine prepares the mailbox command for configuring port. | |
1072 | **/ | |
dea3101e | 1073 | void |
92d7f7b0 | 1074 | lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
dea3101e | 1075 | { |
ed957684 | 1076 | MAILBOX_t __iomem *mb_slim = (MAILBOX_t __iomem *) phba->MBslimaddr; |
dea3101e JB |
1077 | MAILBOX_t *mb = &pmb->mb; |
1078 | dma_addr_t pdma_addr; | |
1079 | uint32_t bar_low, bar_high; | |
1080 | size_t offset; | |
4cc2da1d | 1081 | struct lpfc_hgp hgp; |
f91b392c | 1082 | int i; |
ed957684 | 1083 | uint32_t pgp_offset; |
dea3101e JB |
1084 | |
1085 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | |
1086 | mb->mbxCommand = MBX_CONFIG_PORT; | |
1087 | mb->mbxOwner = OWN_HOST; | |
1088 | ||
1089 | mb->un.varCfgPort.pcbLen = sizeof(PCB_t); | |
1090 | ||
34b02dcd JS |
1091 | offset = (uint8_t *)phba->pcb - (uint8_t *)phba->slim2p.virt; |
1092 | pdma_addr = phba->slim2p.phys + offset; | |
dea3101e JB |
1093 | mb->un.varCfgPort.pcbLow = putPaddrLow(pdma_addr); |
1094 | mb->un.varCfgPort.pcbHigh = putPaddrHigh(pdma_addr); | |
1095 | ||
97207482 JS |
1096 | /* Always Host Group Pointer is in SLIM */ |
1097 | mb->un.varCfgPort.hps = 1; | |
1098 | ||
ed957684 JS |
1099 | /* If HBA supports SLI=3 ask for it */ |
1100 | ||
92d7f7b0 | 1101 | if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) { |
ed957684 | 1102 | mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ |
34b02dcd JS |
1103 | mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ |
1104 | mb->un.varCfgPort.cinb = 1; /* Interrupt Notification Block */ | |
51ef4c26 | 1105 | mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); |
78b2d852 | 1106 | if (phba->max_vpi && phba->cfg_enable_npiv && |
92d7f7b0 JS |
1107 | phba->vpd.sli3Feat.cmv) { |
1108 | mb->un.varCfgPort.max_vpi = phba->max_vpi; | |
1109 | mb->un.varCfgPort.cmv = 1; | |
92d7f7b0 JS |
1110 | } else |
1111 | mb->un.varCfgPort.max_vpi = phba->max_vpi = 0; | |
1112 | } else | |
1113 | phba->sli_rev = 2; | |
1114 | mb->un.varCfgPort.sli_mode = phba->sli_rev; | |
ed957684 | 1115 | |
dea3101e | 1116 | /* Now setup pcb */ |
34b02dcd JS |
1117 | phba->pcb->type = TYPE_NATIVE_SLI2; |
1118 | phba->pcb->feature = FEATURE_INITIAL_SLI2; | |
dea3101e JB |
1119 | |
1120 | /* Setup Mailbox pointers */ | |
34b02dcd JS |
1121 | phba->pcb->mailBoxSize = sizeof(MAILBOX_t); |
1122 | offset = (uint8_t *)phba->mbox - (uint8_t *)phba->slim2p.virt; | |
1123 | pdma_addr = phba->slim2p.phys + offset; | |
1124 | phba->pcb->mbAddrHigh = putPaddrHigh(pdma_addr); | |
1125 | phba->pcb->mbAddrLow = putPaddrLow(pdma_addr); | |
dea3101e JB |
1126 | |
1127 | /* | |
1128 | * Setup Host Group ring pointer. | |
1129 | * | |
1130 | * For efficiency reasons, the ring get/put pointers can be | |
1131 | * placed in adapter memory (SLIM) rather than in host memory. | |
1132 | * This allows firmware to avoid PCI reads/writes when updating | |
1133 | * and checking pointers. | |
1134 | * | |
1135 | * The firmware recognizes the use of SLIM memory by comparing | |
1136 | * the address of the get/put pointers structure with that of | |
1137 | * the SLIM BAR (BAR0). | |
1138 | * | |
1139 | * Caution: be sure to use the PCI config space value of BAR0/BAR1 | |
1140 | * (the hardware's view of the base address), not the OS's | |
1141 | * value of pci_resource_start() as the OS value may be a cookie | |
1142 | * for ioremap/iomap. | |
1143 | */ | |
1144 | ||
1145 | ||
1146 | pci_read_config_dword(phba->pcidev, PCI_BASE_ADDRESS_0, &bar_low); | |
1147 | pci_read_config_dword(phba->pcidev, PCI_BASE_ADDRESS_1, &bar_high); | |
1148 | ||
ed957684 JS |
1149 | /* |
1150 | * Set up HGP - Port Memory | |
1151 | * | |
1152 | * The port expects the host get/put pointers to reside in memory | |
1153 | * following the "non-diagnostic" mode mailbox (32 words, 0x80 bytes) | |
1154 | * area of SLIM. In SLI-2 mode, there's an additional 16 reserved | |
1155 | * words (0x40 bytes). This area is not reserved if HBQs are | |
1156 | * configured in SLI-3. | |
1157 | * | |
1158 | * CR0Put - SLI2(no HBQs) = 0xc0, With HBQs = 0x80 | |
1159 | * RR0Get 0xc4 0x84 | |
1160 | * CR1Put 0xc8 0x88 | |
1161 | * RR1Get 0xcc 0x8c | |
1162 | * CR2Put 0xd0 0x90 | |
1163 | * RR2Get 0xd4 0x94 | |
1164 | * CR3Put 0xd8 0x98 | |
1165 | * RR3Get 0xdc 0x9c | |
1166 | * | |
1167 | * Reserved 0xa0-0xbf | |
1168 | * If HBQs configured: | |
1169 | * HBQ 0 Put ptr 0xc0 | |
1170 | * HBQ 1 Put ptr 0xc4 | |
1171 | * HBQ 2 Put ptr 0xc8 | |
1172 | * ...... | |
1173 | * HBQ(M-1)Put Pointer 0xc0+(M-1)*4 | |
1174 | * | |
1175 | */ | |
1176 | ||
1177 | if (phba->sli_rev == 3) { | |
1178 | phba->host_gp = &mb_slim->us.s3.host[0]; | |
1179 | phba->hbq_put = &mb_slim->us.s3.hbq_put[0]; | |
1180 | } else { | |
1181 | phba->host_gp = &mb_slim->us.s2.host[0]; | |
1182 | phba->hbq_put = NULL; | |
1183 | } | |
dea3101e JB |
1184 | |
1185 | /* mask off BAR0's flag bits 0 - 3 */ | |
34b02dcd JS |
1186 | phba->pcb->hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) + |
1187 | (void __iomem *)phba->host_gp - | |
ed957684 | 1188 | (void __iomem *)phba->MBslimaddr; |
dea3101e | 1189 | if (bar_low & PCI_BASE_ADDRESS_MEM_TYPE_64) |
34b02dcd | 1190 | phba->pcb->hgpAddrHigh = bar_high; |
dea3101e | 1191 | else |
34b02dcd | 1192 | phba->pcb->hgpAddrHigh = 0; |
dea3101e | 1193 | /* write HGP data to SLIM at the required longword offset */ |
4cc2da1d | 1194 | memset(&hgp, 0, sizeof(struct lpfc_hgp)); |
f91b392c JSEC |
1195 | |
1196 | for (i=0; i < phba->sli.num_rings; i++) { | |
ed957684 JS |
1197 | lpfc_memcpy_to_slim(phba->host_gp + i, &hgp, |
1198 | sizeof(*phba->host_gp)); | |
f91b392c | 1199 | } |
dea3101e JB |
1200 | |
1201 | /* Setup Port Group ring pointer */ | |
34b02dcd JS |
1202 | if (phba->sli3_options & LPFC_SLI3_INB_ENABLED) { |
1203 | pgp_offset = offsetof(struct lpfc_sli2_slim, | |
1204 | mbx.us.s3_inb_pgp.port); | |
1205 | phba->hbq_get = phba->mbox->us.s3_inb_pgp.hbq_get; | |
1206 | } else if (phba->sli_rev == 3) { | |
1207 | pgp_offset = offsetof(struct lpfc_sli2_slim, | |
1208 | mbx.us.s3_pgp.port); | |
1209 | phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; | |
1210 | } else | |
1211 | pgp_offset = offsetof(struct lpfc_sli2_slim, mbx.us.s2.port); | |
1212 | pdma_addr = phba->slim2p.phys + pgp_offset; | |
1213 | phba->pcb->pgpAddrHigh = putPaddrHigh(pdma_addr); | |
1214 | phba->pcb->pgpAddrLow = putPaddrLow(pdma_addr); | |
dea3101e JB |
1215 | |
1216 | /* Use callback routine to setp rings in the pcb */ | |
1217 | lpfc_config_pcb_setup(phba); | |
1218 | ||
1219 | /* special handling for LC HBAs */ | |
1220 | if (lpfc_is_LC_HBA(phba->pcidev->device)) { | |
1221 | uint32_t hbainit[5]; | |
1222 | ||
1223 | lpfc_hba_init(phba, hbainit); | |
1224 | ||
1225 | memcpy(&mb->un.varCfgPort.hbainit, hbainit, 20); | |
1226 | } | |
1227 | ||
1228 | /* Swap PCB if needed */ | |
34b02dcd | 1229 | lpfc_sli_pcimem_bcopy(phba->pcb, phba->pcb, sizeof(PCB_t)); |
dea3101e JB |
1230 | } |
1231 | ||
e59058c4 JS |
1232 | /** |
1233 | * lpfc_kill_board: Prepare a mailbox command for killing board. | |
1234 | * @phba: pointer to lpfc hba data structure. | |
1235 | * @pmb: pointer to the driver internal queue element for mailbox command. | |
1236 | * | |
1237 | * The kill board mailbox command is used to tell firmware to perform a | |
1238 | * graceful shutdown of a channel on a specified board to prepare for reset. | |
1239 | * When the kill board mailbox command is received, the ER3 bit is set to 1 | |
1240 | * in the Host Status register and the ER Attention bit is set to 1 in the | |
1241 | * Host Attention register of the HBA function that received the kill board | |
1242 | * command. | |
1243 | * | |
1244 | * This routine prepares the mailbox command for killing the board in | |
1245 | * preparation for a graceful shutdown. | |
1246 | **/ | |
41415862 JW |
1247 | void |
1248 | lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
1249 | { | |
1250 | MAILBOX_t *mb = &pmb->mb; | |
1251 | ||
1252 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | |
1253 | mb->mbxCommand = MBX_KILL_BOARD; | |
1254 | mb->mbxOwner = OWN_HOST; | |
1255 | return; | |
1256 | } | |
1257 | ||
e59058c4 JS |
1258 | /** |
1259 | * lpfc_mbox_put: Put a mailbox cmd into the tail of driver's mailbox queue. | |
1260 | * @phba: pointer to lpfc hba data structure. | |
1261 | * @mbq: pointer to the driver internal queue element for mailbox command. | |
1262 | * | |
1263 | * Driver maintains a internal mailbox command queue implemented as a linked | |
1264 | * list. When a mailbox command is issued, it shall be put into the mailbox | |
1265 | * command queue such that they shall be processed orderly as HBA can process | |
1266 | * one mailbox command at a time. | |
1267 | **/ | |
dea3101e JB |
1268 | void |
1269 | lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |
1270 | { | |
1271 | struct lpfc_sli *psli; | |
1272 | ||
1273 | psli = &phba->sli; | |
1274 | ||
1275 | list_add_tail(&mbq->list, &psli->mboxq); | |
1276 | ||
1277 | psli->mboxq_cnt++; | |
1278 | ||
1279 | return; | |
1280 | } | |
1281 | ||
e59058c4 JS |
1282 | /** |
1283 | * lpfc_mbox_get: Remove a mailbox cmd from the head of driver's mailbox queue. | |
1284 | * @phba: pointer to lpfc hba data structure. | |
1285 | * | |
1286 | * Driver maintains a internal mailbox command queue implemented as a linked | |
1287 | * list. When a mailbox command is issued, it shall be put into the mailbox | |
1288 | * command queue such that they shall be processed orderly as HBA can process | |
1289 | * one mailbox command at a time. After HBA finished processing a mailbox | |
1290 | * command, the driver will remove a pending mailbox command from the head of | |
1291 | * the mailbox command queue and send to the HBA for processing. | |
1292 | * | |
1293 | * Return codes | |
1294 | * pointer to the driver internal queue element for mailbox command. | |
1295 | **/ | |
dea3101e JB |
1296 | LPFC_MBOXQ_t * |
1297 | lpfc_mbox_get(struct lpfc_hba * phba) | |
1298 | { | |
1299 | LPFC_MBOXQ_t *mbq = NULL; | |
1300 | struct lpfc_sli *psli = &phba->sli; | |
1301 | ||
2e0fef85 | 1302 | list_remove_head((&psli->mboxq), mbq, LPFC_MBOXQ_t, list); |
92d7f7b0 | 1303 | if (mbq) |
dea3101e | 1304 | psli->mboxq_cnt--; |
dea3101e JB |
1305 | |
1306 | return mbq; | |
1307 | } | |
a309a6b6 | 1308 | |
e59058c4 JS |
1309 | /** |
1310 | * lpfc_mbox_cmpl_put: Put mailbox command into mailbox command complete list. | |
1311 | * @phba: pointer to lpfc hba data structure. | |
1312 | * @mbq: pointer to the driver internal queue element for mailbox command. | |
1313 | * | |
1314 | * This routine put the completed mailbox command into the mailbox command | |
1315 | * complete list. This routine is called from driver interrupt handler | |
1316 | * context.The mailbox complete list is used by the driver worker thread | |
1317 | * to process mailbox complete callback functions outside the driver interrupt | |
1318 | * handler. | |
1319 | **/ | |
92d7f7b0 JS |
1320 | void |
1321 | lpfc_mbox_cmpl_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |
1322 | { | |
b1c11812 | 1323 | /* This function expects to be called from interrupt context */ |
92d7f7b0 JS |
1324 | spin_lock(&phba->hbalock); |
1325 | list_add_tail(&mbq->list, &phba->sli.mboxq_cmpl); | |
1326 | spin_unlock(&phba->hbalock); | |
1327 | return; | |
1328 | } | |
1329 | ||
e59058c4 JS |
1330 | /** |
1331 | * lpfc_mbox_tmo_val: Retrieve mailbox command timeout value. | |
1332 | * @phba: pointer to lpfc hba data structure. | |
1333 | * @cmd: mailbox command code. | |
1334 | * | |
1335 | * This routine retrieves the proper timeout value according to the mailbox | |
1336 | * command code. | |
1337 | * | |
1338 | * Return codes | |
1339 | * Timeout value to be used for the given mailbox command | |
1340 | **/ | |
a309a6b6 JS |
1341 | int |
1342 | lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd) | |
1343 | { | |
1344 | switch (cmd) { | |
1345 | case MBX_WRITE_NV: /* 0x03 */ | |
1346 | case MBX_UPDATE_CFG: /* 0x1B */ | |
1347 | case MBX_DOWN_LOAD: /* 0x1C */ | |
1348 | case MBX_DEL_LD_ENTRY: /* 0x1D */ | |
1349 | case MBX_LOAD_AREA: /* 0x81 */ | |
09372820 | 1350 | case MBX_WRITE_WWN: /* 0x98 */ |
a309a6b6 JS |
1351 | case MBX_LOAD_EXP_ROM: /* 0x9C */ |
1352 | return LPFC_MBOX_TMO_FLASH_CMD; | |
1353 | } | |
1354 | return LPFC_MBOX_TMO; | |
1355 | } |