2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/delay.h>
12 qla2x00_mbx_sem_timeout(unsigned long data
)
14 struct semaphore
*sem_ptr
= (struct semaphore
*)data
;
16 DEBUG11(printk("qla2x00_sem_timeout: entered.\n"));
18 if (sem_ptr
!= NULL
) {
22 DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n"));
26 * qla2x00_mailbox_command
27 * Issue mailbox command and waits for completion.
30 * ha = adapter block pointer.
31 * mcp = driver internal mbx struct pointer.
34 * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data.
37 * 0 : QLA_SUCCESS = cmd performed success
38 * 1 : QLA_FUNCTION_FAILED (error encountered)
39 * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered)
45 qla2x00_mailbox_command(scsi_qla_host_t
*pvha
, mbx_cmd_t
*mcp
)
48 unsigned long flags
= 0;
49 device_reg_t __iomem
*reg
;
50 struct timer_list tmp_intr_timer
;
55 uint16_t __iomem
*optr
;
58 unsigned long wait_time
;
59 scsi_qla_host_t
*ha
= to_qla_parent(pvha
);
62 io_lock_on
= ha
->flags
.init_done
;
65 abort_active
= test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
67 DEBUG11(printk("%s(%ld): entered.\n", __func__
, pvha
->host_no
));
70 * Wait for active mailbox commands to finish by waiting at most tov
71 * seconds. This is to serialize actual issuing of mailbox cmds during
75 if (qla2x00_down_timeout(&ha
->mbx_cmd_sem
, mcp
->tov
* HZ
)) {
76 /* Timeout occurred. Return error. */
77 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
78 "Exiting.\n", __func__
, ha
->host_no
));
79 return QLA_FUNCTION_TIMEOUT
;
83 ha
->flags
.mbox_busy
= 1;
84 /* Save mailbox command for debug */
87 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n",
88 ha
->host_no
, mcp
->mb
[0]));
90 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
92 /* Load mailbox registers. */
93 if (IS_FWI2_CAPABLE(ha
))
94 optr
= (uint16_t __iomem
*)®
->isp24
.mailbox0
;
96 optr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 0);
100 mboxes
= mcp
->out_mb
;
102 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
103 if (IS_QLA2200(ha
) && cnt
== 8)
105 (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 8);
107 WRT_REG_WORD(optr
, *iptr
);
114 #if defined(QL_DEBUG_LEVEL_1)
115 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n",
116 __func__
, ha
->host_no
);
117 qla2x00_dump_buffer((uint8_t *)mcp
->mb
, 16);
119 qla2x00_dump_buffer(((uint8_t *)mcp
->mb
+ 0x10), 16);
121 qla2x00_dump_buffer(((uint8_t *)mcp
->mb
+ 0x20), 8);
123 printk("%s(%ld): I/O address = %p.\n", __func__
, ha
->host_no
, optr
);
124 qla2x00_dump_regs(ha
);
127 /* Issue set host interrupt command to send cmd out. */
128 ha
->flags
.mbox_int
= 0;
129 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
131 /* Unlock mbx registers and wait for interrupt */
132 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. "
133 "jiffies=%lx.\n", __func__
, ha
->host_no
, jiffies
));
135 /* Wait for mbx cmd completion until timeout */
137 if (!abort_active
&& io_lock_on
) {
138 /* sleep on completion semaphore */
139 DEBUG11(printk("%s(%ld): INTERRUPT MODE. Initializing timer.\n",
140 __func__
, ha
->host_no
));
142 init_timer(&tmp_intr_timer
);
143 tmp_intr_timer
.data
= (unsigned long)&ha
->mbx_intr_sem
;
144 tmp_intr_timer
.expires
= jiffies
+ mcp
->tov
* HZ
;
145 tmp_intr_timer
.function
=
146 (void (*)(unsigned long))qla2x00_mbx_sem_timeout
;
148 DEBUG11(printk("%s(%ld): Adding timer.\n", __func__
,
150 add_timer(&tmp_intr_timer
);
152 DEBUG11(printk("%s(%ld): going to unlock & sleep. "
153 "time=0x%lx.\n", __func__
, ha
->host_no
, jiffies
));
155 set_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
157 if (IS_FWI2_CAPABLE(ha
))
158 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
160 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
161 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
163 /* Wait for either the timer to expire
164 * or the mbox completion interrupt
166 down(&ha
->mbx_intr_sem
);
168 DEBUG11(printk("%s(%ld): waking up. time=0x%lx\n", __func__
,
169 ha
->host_no
, jiffies
));
170 clear_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
172 /* delete the timer */
173 del_timer(&tmp_intr_timer
);
175 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__
,
176 ha
->host_no
, command
));
178 if (IS_FWI2_CAPABLE(ha
))
179 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
181 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
182 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
184 wait_time
= jiffies
+ mcp
->tov
* HZ
; /* wait at most tov secs */
185 while (!ha
->flags
.mbox_int
) {
186 if (time_after(jiffies
, wait_time
))
189 /* Check for pending interrupts. */
192 if (command
!= MBC_LOAD_RISC_RAM_EXTENDED
&&
198 /* Check whether we timed out */
199 if (ha
->flags
.mbox_int
) {
202 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__
,
203 ha
->host_no
, command
));
205 /* Got interrupt. Clear the flag. */
206 ha
->flags
.mbox_int
= 0;
207 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
209 if (ha
->mailbox_out
[0] != MBS_COMMAND_COMPLETE
)
210 rval
= QLA_FUNCTION_FAILED
;
212 /* Load return mailbox registers. */
214 iptr
= (uint16_t *)&ha
->mailbox_out
[0];
216 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
226 #if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3) || \
227 defined(QL_DEBUG_LEVEL_11)
231 if (IS_FWI2_CAPABLE(ha
)) {
232 mb0
= RD_REG_WORD(®
->isp24
.mailbox0
);
233 ictrl
= RD_REG_DWORD(®
->isp24
.ictrl
);
235 mb0
= RD_MAILBOX_REG(ha
, ®
->isp
, 0);
236 ictrl
= RD_REG_WORD(®
->isp
.ictrl
);
238 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n",
239 __func__
, ha
->host_no
, command
);
240 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__
,
241 ha
->host_no
, ictrl
, jiffies
);
242 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__
,
244 qla2x00_dump_regs(ha
);
247 rval
= QLA_FUNCTION_TIMEOUT
;
250 ha
->flags
.mbox_busy
= 0;
256 DEBUG11(printk("%s(%ld): checking for additional resp "
257 "interrupt.\n", __func__
, ha
->host_no
));
259 /* polling mode for non isp_abort commands. */
263 if (rval
== QLA_FUNCTION_TIMEOUT
&&
264 mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
) {
265 if (!io_lock_on
|| (mcp
->flags
& IOCTL_CMD
)) {
266 /* not in dpc. schedule it for dpc to take over. */
267 DEBUG(printk("%s(%ld): timeout schedule "
268 "isp_abort_needed.\n", __func__
, ha
->host_no
));
269 DEBUG2_3_11(printk("%s(%ld): timeout schedule "
270 "isp_abort_needed.\n", __func__
, ha
->host_no
));
271 qla_printk(KERN_WARNING
, ha
,
272 "Mailbox command timeout occured. Scheduling ISP "
274 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
275 qla2xxx_wake_dpc(ha
);
276 } else if (!abort_active
) {
277 /* call abort directly since we are in the DPC thread */
278 DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
279 __func__
, ha
->host_no
));
280 DEBUG2_3_11(printk("%s(%ld): timeout calling "
281 "abort_isp\n", __func__
, ha
->host_no
));
282 qla_printk(KERN_WARNING
, ha
,
283 "Mailbox command timeout occured. Issuing ISP "
286 set_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
287 clear_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
288 if (qla2x00_abort_isp(ha
)) {
289 /* Failed. retry later. */
290 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
292 clear_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
293 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__
,
295 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n",
296 __func__
, ha
->host_no
));
300 /* Allow next mbx cmd to come in. */
302 up(&ha
->mbx_cmd_sem
);
305 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
306 "mbx2=%x, cmd=%x ****\n", __func__
, ha
->host_no
,
307 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], command
));
309 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
316 qla2x00_load_ram(scsi_qla_host_t
*ha
, dma_addr_t req_dma
, uint32_t risc_addr
,
317 uint32_t risc_code_size
)
321 mbx_cmd_t
*mcp
= &mc
;
323 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
325 if (MSW(risc_addr
) || IS_FWI2_CAPABLE(ha
)) {
326 mcp
->mb
[0] = MBC_LOAD_RISC_RAM_EXTENDED
;
327 mcp
->mb
[8] = MSW(risc_addr
);
328 mcp
->out_mb
= MBX_8
|MBX_0
;
330 mcp
->mb
[0] = MBC_LOAD_RISC_RAM
;
333 mcp
->mb
[1] = LSW(risc_addr
);
334 mcp
->mb
[2] = MSW(req_dma
);
335 mcp
->mb
[3] = LSW(req_dma
);
336 mcp
->mb
[6] = MSW(MSD(req_dma
));
337 mcp
->mb
[7] = LSW(MSD(req_dma
));
338 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
339 if (IS_FWI2_CAPABLE(ha
)) {
340 mcp
->mb
[4] = MSW(risc_code_size
);
341 mcp
->mb
[5] = LSW(risc_code_size
);
342 mcp
->out_mb
|= MBX_5
|MBX_4
;
344 mcp
->mb
[4] = LSW(risc_code_size
);
345 mcp
->out_mb
|= MBX_4
;
351 rval
= qla2x00_mailbox_command(ha
, mcp
);
353 if (rval
!= QLA_SUCCESS
) {
354 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
355 ha
->host_no
, rval
, mcp
->mb
[0]));
357 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
365 * Start adapter firmware.
368 * ha = adapter block pointer.
369 * TARGET_QUEUE_LOCK must be released.
370 * ADAPTER_STATE_LOCK must be released.
373 * qla2x00 local function return status code.
379 qla2x00_execute_fw(scsi_qla_host_t
*ha
, uint32_t risc_addr
)
383 mbx_cmd_t
*mcp
= &mc
;
385 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
387 mcp
->mb
[0] = MBC_EXECUTE_FIRMWARE
;
390 if (IS_FWI2_CAPABLE(ha
)) {
391 mcp
->mb
[1] = MSW(risc_addr
);
392 mcp
->mb
[2] = LSW(risc_addr
);
395 mcp
->out_mb
|= MBX_4
|MBX_3
|MBX_2
|MBX_1
;
398 mcp
->mb
[1] = LSW(risc_addr
);
399 mcp
->out_mb
|= MBX_1
;
400 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
402 mcp
->out_mb
|= MBX_2
;
408 rval
= qla2x00_mailbox_command(ha
, mcp
);
410 if (rval
!= QLA_SUCCESS
) {
411 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
412 ha
->host_no
, rval
, mcp
->mb
[0]));
414 if (IS_FWI2_CAPABLE(ha
)) {
415 DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
416 __func__
, ha
->host_no
, mcp
->mb
[1]));
418 DEBUG11(printk("%s(%ld): done.\n", __func__
,
427 * qla2x00_get_fw_version
428 * Get firmware version.
431 * ha: adapter state pointer.
432 * major: pointer for major number.
433 * minor: pointer for minor number.
434 * subminor: pointer for subminor number.
437 * qla2x00 local function return status code.
443 qla2x00_get_fw_version(scsi_qla_host_t
*ha
, uint16_t *major
, uint16_t *minor
,
444 uint16_t *subminor
, uint16_t *attributes
, uint32_t *memory
)
448 mbx_cmd_t
*mcp
= &mc
;
450 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
452 mcp
->mb
[0] = MBC_GET_FIRMWARE_VERSION
;
454 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
457 rval
= qla2x00_mailbox_command(ha
, mcp
);
459 /* Return mailbox data. */
462 *subminor
= mcp
->mb
[3];
463 *attributes
= mcp
->mb
[6];
464 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
465 *memory
= 0x1FFFF; /* Defaults to 128KB. */
467 *memory
= (mcp
->mb
[5] << 16) | mcp
->mb
[4];
469 if (rval
!= QLA_SUCCESS
) {
471 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
475 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
480 * qla2x00_get_fw_options
481 * Set firmware options.
484 * ha = adapter block pointer.
485 * fwopt = pointer for firmware options.
488 * qla2x00 local function return status code.
494 qla2x00_get_fw_options(scsi_qla_host_t
*ha
, uint16_t *fwopts
)
498 mbx_cmd_t
*mcp
= &mc
;
500 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
502 mcp
->mb
[0] = MBC_GET_FIRMWARE_OPTION
;
504 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
507 rval
= qla2x00_mailbox_command(ha
, mcp
);
509 if (rval
!= QLA_SUCCESS
) {
511 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
514 fwopts
[0] = mcp
->mb
[0];
515 fwopts
[1] = mcp
->mb
[1];
516 fwopts
[2] = mcp
->mb
[2];
517 fwopts
[3] = mcp
->mb
[3];
519 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
527 * qla2x00_set_fw_options
528 * Set firmware options.
531 * ha = adapter block pointer.
532 * fwopt = pointer for firmware options.
535 * qla2x00 local function return status code.
541 qla2x00_set_fw_options(scsi_qla_host_t
*ha
, uint16_t *fwopts
)
545 mbx_cmd_t
*mcp
= &mc
;
547 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
549 mcp
->mb
[0] = MBC_SET_FIRMWARE_OPTION
;
550 mcp
->mb
[1] = fwopts
[1];
551 mcp
->mb
[2] = fwopts
[2];
552 mcp
->mb
[3] = fwopts
[3];
553 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
555 if (IS_FWI2_CAPABLE(ha
)) {
558 mcp
->mb
[10] = fwopts
[10];
559 mcp
->mb
[11] = fwopts
[11];
560 mcp
->mb
[12] = 0; /* Undocumented, but used */
561 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
565 rval
= qla2x00_mailbox_command(ha
, mcp
);
567 fwopts
[0] = mcp
->mb
[0];
569 if (rval
!= QLA_SUCCESS
) {
571 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__
,
572 ha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
575 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
582 * qla2x00_mbx_reg_test
583 * Mailbox register wrap test.
586 * ha = adapter block pointer.
587 * TARGET_QUEUE_LOCK must be released.
588 * ADAPTER_STATE_LOCK must be released.
591 * qla2x00 local function return status code.
597 qla2x00_mbx_reg_test(scsi_qla_host_t
*ha
)
601 mbx_cmd_t
*mcp
= &mc
;
603 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha
->host_no
));
605 mcp
->mb
[0] = MBC_MAILBOX_REGISTER_TEST
;
613 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
614 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
617 rval
= qla2x00_mailbox_command(ha
, mcp
);
619 if (rval
== QLA_SUCCESS
) {
620 if (mcp
->mb
[1] != 0xAAAA || mcp
->mb
[2] != 0x5555 ||
621 mcp
->mb
[3] != 0xAA55 || mcp
->mb
[4] != 0x55AA)
622 rval
= QLA_FUNCTION_FAILED
;
623 if (mcp
->mb
[5] != 0xA5A5 || mcp
->mb
[6] != 0x5A5A ||
624 mcp
->mb
[7] != 0x2525)
625 rval
= QLA_FUNCTION_FAILED
;
628 if (rval
!= QLA_SUCCESS
) {
630 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
634 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
642 * qla2x00_verify_checksum
643 * Verify firmware checksum.
646 * ha = adapter block pointer.
647 * TARGET_QUEUE_LOCK must be released.
648 * ADAPTER_STATE_LOCK must be released.
651 * qla2x00 local function return status code.
657 qla2x00_verify_checksum(scsi_qla_host_t
*ha
, uint32_t risc_addr
)
661 mbx_cmd_t
*mcp
= &mc
;
663 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
665 mcp
->mb
[0] = MBC_VERIFY_CHECKSUM
;
668 if (IS_FWI2_CAPABLE(ha
)) {
669 mcp
->mb
[1] = MSW(risc_addr
);
670 mcp
->mb
[2] = LSW(risc_addr
);
671 mcp
->out_mb
|= MBX_2
|MBX_1
;
672 mcp
->in_mb
|= MBX_2
|MBX_1
;
674 mcp
->mb
[1] = LSW(risc_addr
);
675 mcp
->out_mb
|= MBX_1
;
681 rval
= qla2x00_mailbox_command(ha
, mcp
);
683 if (rval
!= QLA_SUCCESS
) {
684 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__
,
685 ha
->host_no
, rval
, IS_FWI2_CAPABLE(ha
) ?
686 (mcp
->mb
[2] << 16) | mcp
->mb
[1]: mcp
->mb
[1]));
688 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
696 * Issue IOCB using mailbox command
699 * ha = adapter state pointer.
700 * buffer = buffer pointer.
701 * phys_addr = physical address of buffer.
702 * size = size of buffer.
703 * TARGET_QUEUE_LOCK must be released.
704 * ADAPTER_STATE_LOCK must be released.
707 * qla2x00 local function return status code.
713 qla2x00_issue_iocb(scsi_qla_host_t
*ha
, void* buffer
, dma_addr_t phys_addr
,
718 mbx_cmd_t
*mcp
= &mc
;
720 mcp
->mb
[0] = MBC_IOCB_COMMAND_A64
;
722 mcp
->mb
[2] = MSW(phys_addr
);
723 mcp
->mb
[3] = LSW(phys_addr
);
724 mcp
->mb
[6] = MSW(MSD(phys_addr
));
725 mcp
->mb
[7] = LSW(MSD(phys_addr
));
726 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
727 mcp
->in_mb
= MBX_2
|MBX_0
;
730 rval
= qla2x00_mailbox_command(ha
, mcp
);
732 if (rval
!= QLA_SUCCESS
) {
734 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
736 DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
739 sts_entry_t
*sts_entry
= (sts_entry_t
*) buffer
;
741 /* Mask reserved bits. */
742 sts_entry
->entry_status
&=
743 IS_FWI2_CAPABLE(ha
) ? RF_MASK_24XX
:RF_MASK
;
750 * qla2x00_abort_command
751 * Abort command aborts a specified IOCB.
754 * ha = adapter block pointer.
755 * sp = SB structure pointer.
758 * qla2x00 local function return status code.
764 qla2x00_abort_command(scsi_qla_host_t
*ha
, srb_t
*sp
)
766 unsigned long flags
= 0;
771 mbx_cmd_t
*mcp
= &mc
;
773 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha
->host_no
));
777 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
778 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
779 if (ha
->outstanding_cmds
[handle
] == sp
)
782 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
784 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
785 /* command not found */
786 return QLA_FUNCTION_FAILED
;
789 mcp
->mb
[0] = MBC_ABORT_COMMAND
;
790 if (HAS_EXTENDED_IDS(ha
))
791 mcp
->mb
[1] = fcport
->loop_id
;
793 mcp
->mb
[1] = fcport
->loop_id
<< 8;
794 mcp
->mb
[2] = (uint16_t)handle
;
795 mcp
->mb
[3] = (uint16_t)(handle
>> 16);
796 mcp
->mb
[6] = (uint16_t)sp
->cmd
->device
->lun
;
797 mcp
->out_mb
= MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
801 rval
= qla2x00_mailbox_command(ha
, mcp
);
803 if (rval
!= QLA_SUCCESS
) {
804 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
807 sp
->flags
|= SRB_ABORT_PENDING
;
808 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
817 * qla2x00_abort_target
818 * Issue abort target mailbox command.
821 * ha = adapter block pointer.
824 * qla2x00 local function return status code.
830 qla2x00_abort_target(fc_port_t
*fcport
)
834 mbx_cmd_t
*mcp
= &mc
;
840 DEBUG11(printk("%s(%ld): entered.\n", __func__
, fcport
->ha
->host_no
));
843 mcp
->mb
[0] = MBC_ABORT_TARGET
;
844 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
845 if (HAS_EXTENDED_IDS(ha
)) {
846 mcp
->mb
[1] = fcport
->loop_id
;
848 mcp
->out_mb
|= MBX_10
;
850 mcp
->mb
[1] = fcport
->loop_id
<< 8;
852 mcp
->mb
[2] = ha
->loop_reset_delay
;
857 rval
= qla2x00_mailbox_command(ha
, mcp
);
859 /* Issue marker command. */
860 ha
->marker_needed
= 1;
862 if (rval
!= QLA_SUCCESS
) {
863 DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n",
867 DEBUG11(printk("qla2x00_abort_target(%ld): done.\n",
876 * qla2x00_get_adapter_id
877 * Get adapter ID and topology.
880 * ha = adapter block pointer.
881 * id = pointer for loop ID.
882 * al_pa = pointer for AL_PA.
883 * area = pointer for area.
884 * domain = pointer for domain.
885 * top = pointer for topology.
886 * TARGET_QUEUE_LOCK must be released.
887 * ADAPTER_STATE_LOCK must be released.
890 * qla2x00 local function return status code.
896 qla2x00_get_adapter_id(scsi_qla_host_t
*ha
, uint16_t *id
, uint8_t *al_pa
,
897 uint8_t *area
, uint8_t *domain
, uint16_t *top
, uint16_t *sw_cap
)
901 mbx_cmd_t
*mcp
= &mc
;
903 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
906 mcp
->mb
[0] = MBC_GET_ADAPTER_LOOP_ID
;
907 mcp
->mb
[9] = ha
->vp_idx
;
909 mcp
->in_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
912 rval
= qla2x00_mailbox_command(ha
, mcp
);
913 if (mcp
->mb
[0] == MBS_COMMAND_ERROR
)
914 rval
= QLA_COMMAND_ERROR
;
918 *al_pa
= LSB(mcp
->mb
[2]);
919 *area
= MSB(mcp
->mb
[2]);
920 *domain
= LSB(mcp
->mb
[3]);
922 *sw_cap
= mcp
->mb
[7];
924 if (rval
!= QLA_SUCCESS
) {
926 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
930 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
938 * qla2x00_get_retry_cnt
939 * Get current firmware login retry count and delay.
942 * ha = adapter block pointer.
943 * retry_cnt = pointer to login retry count.
944 * tov = pointer to login timeout value.
947 * qla2x00 local function return status code.
953 qla2x00_get_retry_cnt(scsi_qla_host_t
*ha
, uint8_t *retry_cnt
, uint8_t *tov
,
959 mbx_cmd_t
*mcp
= &mc
;
961 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
964 mcp
->mb
[0] = MBC_GET_RETRY_COUNT
;
966 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
969 rval
= qla2x00_mailbox_command(ha
, mcp
);
971 if (rval
!= QLA_SUCCESS
) {
973 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
974 ha
->host_no
, mcp
->mb
[0]));
976 /* Convert returned data and check our values. */
977 *r_a_tov
= mcp
->mb
[3] / 2;
978 ratov
= (mcp
->mb
[3]/2) / 10; /* mb[3] value is in 100ms */
979 if (mcp
->mb
[1] * ratov
> (*retry_cnt
) * (*tov
)) {
980 /* Update to the larger values */
981 *retry_cnt
= (uint8_t)mcp
->mb
[1];
985 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
986 "ratov=%d.\n", ha
->host_no
, mcp
->mb
[3], ratov
));
993 * qla2x00_init_firmware
994 * Initialize adapter firmware.
997 * ha = adapter block pointer.
998 * dptr = Initialization control block pointer.
999 * size = size of initialization control block.
1000 * TARGET_QUEUE_LOCK must be released.
1001 * ADAPTER_STATE_LOCK must be released.
1004 * qla2x00 local function return status code.
1010 qla2x00_init_firmware(scsi_qla_host_t
*ha
, uint16_t size
)
1014 mbx_cmd_t
*mcp
= &mc
;
1016 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1019 if (ha
->flags
.npiv_supported
)
1020 mcp
->mb
[0] = MBC_MID_INITIALIZE_FIRMWARE
;
1022 mcp
->mb
[0] = MBC_INITIALIZE_FIRMWARE
;
1024 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
1025 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
1028 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
1029 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
1030 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
1031 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_0
;
1032 mcp
->buf_size
= size
;
1033 mcp
->flags
= MBX_DMA_OUT
;
1035 rval
= qla2x00_mailbox_command(ha
, mcp
);
1037 if (rval
!= QLA_SUCCESS
) {
1039 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
1041 ha
->host_no
, rval
, mcp
->mb
[0]));
1044 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
1052 * qla2x00_get_port_database
1053 * Issue normal/enhanced get port database mailbox command
1054 * and copy device name as necessary.
1057 * ha = adapter state pointer.
1058 * dev = structure pointer.
1059 * opt = enhanced cmd option byte.
1062 * qla2x00 local function return status code.
1068 qla2x00_get_port_database(scsi_qla_host_t
*ha
, fc_port_t
*fcport
, uint8_t opt
)
1072 mbx_cmd_t
*mcp
= &mc
;
1073 port_database_t
*pd
;
1074 struct port_database_24xx
*pd24
;
1077 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
1080 pd
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pd_dma
);
1082 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database "
1083 "structure.\n", __func__
, ha
->host_no
));
1084 return QLA_MEMORY_ALLOC_FAILED
;
1086 memset(pd
, 0, max(PORT_DATABASE_SIZE
, PORT_DATABASE_24XX_SIZE
));
1088 mcp
->mb
[0] = MBC_GET_PORT_DATABASE
;
1089 if (opt
!= 0 && !IS_FWI2_CAPABLE(ha
))
1090 mcp
->mb
[0] = MBC_ENHANCED_GET_PORT_DATABASE
;
1091 mcp
->mb
[2] = MSW(pd_dma
);
1092 mcp
->mb
[3] = LSW(pd_dma
);
1093 mcp
->mb
[6] = MSW(MSD(pd_dma
));
1094 mcp
->mb
[7] = LSW(MSD(pd_dma
));
1095 mcp
->mb
[9] = ha
->vp_idx
;
1096 mcp
->out_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
1098 if (IS_FWI2_CAPABLE(ha
)) {
1099 mcp
->mb
[1] = fcport
->loop_id
;
1101 mcp
->out_mb
|= MBX_10
|MBX_1
;
1102 mcp
->in_mb
|= MBX_1
;
1103 } else if (HAS_EXTENDED_IDS(ha
)) {
1104 mcp
->mb
[1] = fcport
->loop_id
;
1106 mcp
->out_mb
|= MBX_10
|MBX_1
;
1108 mcp
->mb
[1] = fcport
->loop_id
<< 8 | opt
;
1109 mcp
->out_mb
|= MBX_1
;
1111 mcp
->buf_size
= IS_FWI2_CAPABLE(ha
) ?
1112 PORT_DATABASE_24XX_SIZE
: PORT_DATABASE_SIZE
;
1113 mcp
->flags
= MBX_DMA_IN
;
1114 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1115 rval
= qla2x00_mailbox_command(ha
, mcp
);
1116 if (rval
!= QLA_SUCCESS
)
1119 if (IS_FWI2_CAPABLE(ha
)) {
1120 pd24
= (struct port_database_24xx
*) pd
;
1122 /* Check for logged in state. */
1123 if (pd24
->current_login_state
!= PDS_PRLI_COMPLETE
&&
1124 pd24
->last_login_state
!= PDS_PRLI_COMPLETE
) {
1125 DEBUG2(printk("%s(%ld): Unable to verify "
1126 "login-state (%x/%x) for loop_id %x\n",
1127 __func__
, ha
->host_no
,
1128 pd24
->current_login_state
,
1129 pd24
->last_login_state
, fcport
->loop_id
));
1130 rval
= QLA_FUNCTION_FAILED
;
1134 /* Names are little-endian. */
1135 memcpy(fcport
->node_name
, pd24
->node_name
, WWN_SIZE
);
1136 memcpy(fcport
->port_name
, pd24
->port_name
, WWN_SIZE
);
1138 /* Get port_id of device. */
1139 fcport
->d_id
.b
.domain
= pd24
->port_id
[0];
1140 fcport
->d_id
.b
.area
= pd24
->port_id
[1];
1141 fcport
->d_id
.b
.al_pa
= pd24
->port_id
[2];
1142 fcport
->d_id
.b
.rsvd_1
= 0;
1144 /* If not target must be initiator or unknown type. */
1145 if ((pd24
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1146 fcport
->port_type
= FCT_INITIATOR
;
1148 fcport
->port_type
= FCT_TARGET
;
1150 /* Check for logged in state. */
1151 if (pd
->master_state
!= PD_STATE_PORT_LOGGED_IN
&&
1152 pd
->slave_state
!= PD_STATE_PORT_LOGGED_IN
) {
1153 rval
= QLA_FUNCTION_FAILED
;
1157 /* Names are little-endian. */
1158 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
1159 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
1161 /* Get port_id of device. */
1162 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
1163 fcport
->d_id
.b
.area
= pd
->port_id
[3];
1164 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
1165 fcport
->d_id
.b
.rsvd_1
= 0;
1167 /* Check for device require authentication. */
1168 pd
->common_features
& BIT_5
? (fcport
->flags
|= FCF_AUTH_REQ
) :
1169 (fcport
->flags
&= ~FCF_AUTH_REQ
);
1171 /* If not target must be initiator or unknown type. */
1172 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1173 fcport
->port_type
= FCT_INITIATOR
;
1175 fcport
->port_type
= FCT_TARGET
;
1177 /* Passback COS information. */
1178 fcport
->supported_classes
= (pd
->options
& BIT_4
) ?
1179 FC_COS_CLASS2
: FC_COS_CLASS3
;
1183 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
1185 if (rval
!= QLA_SUCCESS
) {
1186 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
1187 __func__
, ha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1189 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
1196 * qla2x00_get_firmware_state
1197 * Get adapter firmware state.
1200 * ha = adapter block pointer.
1201 * dptr = pointer for firmware state.
1202 * TARGET_QUEUE_LOCK must be released.
1203 * ADAPTER_STATE_LOCK must be released.
1206 * qla2x00 local function return status code.
1212 qla2x00_get_firmware_state(scsi_qla_host_t
*ha
, uint16_t *dptr
)
1216 mbx_cmd_t
*mcp
= &mc
;
1218 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
1221 mcp
->mb
[0] = MBC_GET_FIRMWARE_STATE
;
1222 mcp
->out_mb
= MBX_0
;
1223 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
1226 rval
= qla2x00_mailbox_command(ha
, mcp
);
1228 /* Return firmware state. */
1231 if (rval
!= QLA_SUCCESS
) {
1233 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
1234 "failed=%x.\n", ha
->host_no
, rval
));
1237 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
1245 * qla2x00_get_port_name
1246 * Issue get port name mailbox command.
1247 * Returned name is in big endian format.
1250 * ha = adapter block pointer.
1251 * loop_id = loop ID of device.
1252 * name = pointer for name.
1253 * TARGET_QUEUE_LOCK must be released.
1254 * ADAPTER_STATE_LOCK must be released.
1257 * qla2x00 local function return status code.
1263 qla2x00_get_port_name(scsi_qla_host_t
*ha
, uint16_t loop_id
, uint8_t *name
,
1268 mbx_cmd_t
*mcp
= &mc
;
1270 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
1273 mcp
->mb
[0] = MBC_GET_PORT_NAME
;
1274 mcp
->mb
[9] = ha
->vp_idx
;
1275 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
1276 if (HAS_EXTENDED_IDS(ha
)) {
1277 mcp
->mb
[1] = loop_id
;
1279 mcp
->out_mb
|= MBX_10
;
1281 mcp
->mb
[1] = loop_id
<< 8 | opt
;
1284 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1287 rval
= qla2x00_mailbox_command(ha
, mcp
);
1289 if (rval
!= QLA_SUCCESS
) {
1291 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
1292 ha
->host_no
, rval
));
1295 /* This function returns name in big endian. */
1296 name
[0] = MSB(mcp
->mb
[2]);
1297 name
[1] = LSB(mcp
->mb
[2]);
1298 name
[2] = MSB(mcp
->mb
[3]);
1299 name
[3] = LSB(mcp
->mb
[3]);
1300 name
[4] = MSB(mcp
->mb
[6]);
1301 name
[5] = LSB(mcp
->mb
[6]);
1302 name
[6] = MSB(mcp
->mb
[7]);
1303 name
[7] = LSB(mcp
->mb
[7]);
1306 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
1315 * Issue LIP reset mailbox command.
1318 * ha = adapter block pointer.
1319 * TARGET_QUEUE_LOCK must be released.
1320 * ADAPTER_STATE_LOCK must be released.
1323 * qla2x00 local function return status code.
1329 qla2x00_lip_reset(scsi_qla_host_t
*ha
)
1333 mbx_cmd_t
*mcp
= &mc
;
1335 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
1337 if (IS_FWI2_CAPABLE(ha
)) {
1338 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1341 mcp
->mb
[3] = ha
->loop_reset_delay
;
1342 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1344 mcp
->mb
[0] = MBC_LIP_RESET
;
1345 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1346 if (HAS_EXTENDED_IDS(ha
)) {
1347 mcp
->mb
[1] = 0x00ff;
1349 mcp
->out_mb
|= MBX_10
;
1351 mcp
->mb
[1] = 0xff00;
1353 mcp
->mb
[2] = ha
->loop_reset_delay
;
1359 rval
= qla2x00_mailbox_command(ha
, mcp
);
1361 if (rval
!= QLA_SUCCESS
) {
1363 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
1364 __func__
, ha
->host_no
, rval
));
1367 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
1378 * ha = adapter block pointer.
1379 * sns = pointer for command.
1380 * cmd_size = command size.
1381 * buf_size = response/command size.
1382 * TARGET_QUEUE_LOCK must be released.
1383 * ADAPTER_STATE_LOCK must be released.
1386 * qla2x00 local function return status code.
1392 qla2x00_send_sns(scsi_qla_host_t
*ha
, dma_addr_t sns_phys_address
,
1393 uint16_t cmd_size
, size_t buf_size
)
1397 mbx_cmd_t
*mcp
= &mc
;
1399 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
1402 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
1403 "tov=%d.\n", ha
->retry_count
, ha
->login_timeout
, mcp
->tov
));
1405 mcp
->mb
[0] = MBC_SEND_SNS_COMMAND
;
1406 mcp
->mb
[1] = cmd_size
;
1407 mcp
->mb
[2] = MSW(sns_phys_address
);
1408 mcp
->mb
[3] = LSW(sns_phys_address
);
1409 mcp
->mb
[6] = MSW(MSD(sns_phys_address
));
1410 mcp
->mb
[7] = LSW(MSD(sns_phys_address
));
1411 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1412 mcp
->in_mb
= MBX_0
|MBX_1
;
1413 mcp
->buf_size
= buf_size
;
1414 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
;
1415 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1416 rval
= qla2x00_mailbox_command(ha
, mcp
);
1418 if (rval
!= QLA_SUCCESS
) {
1420 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1421 "mb[1]=%x.\n", ha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1422 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1423 "mb[1]=%x.\n", ha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1426 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha
->host_no
));
1433 qla24xx_login_fabric(scsi_qla_host_t
*ha
, uint16_t loop_id
, uint8_t domain
,
1434 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1438 struct logio_entry_24xx
*lg
;
1442 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
1444 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1446 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
1447 __func__
, ha
->host_no
));
1448 return QLA_MEMORY_ALLOC_FAILED
;
1450 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1452 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1453 lg
->entry_count
= 1;
1454 lg
->nport_handle
= cpu_to_le16(loop_id
);
1455 lg
->control_flags
= __constant_cpu_to_le16(LCF_COMMAND_PLOGI
);
1457 lg
->control_flags
|= __constant_cpu_to_le16(LCF_COND_PLOGI
);
1459 lg
->control_flags
|= __constant_cpu_to_le16(LCF_SKIP_PRLI
);
1460 lg
->port_id
[0] = al_pa
;
1461 lg
->port_id
[1] = area
;
1462 lg
->port_id
[2] = domain
;
1463 lg
->vp_index
= cpu_to_le16(ha
->vp_idx
);
1464 rval
= qla2x00_issue_iocb(ha
, lg
, lg_dma
, 0);
1465 if (rval
!= QLA_SUCCESS
) {
1466 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
1467 "(%x).\n", __func__
, ha
->host_no
, rval
));
1468 } else if (lg
->entry_status
!= 0) {
1469 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1470 "-- error status (%x).\n", __func__
, ha
->host_no
,
1472 rval
= QLA_FUNCTION_FAILED
;
1473 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1474 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1475 iop
[1] = le32_to_cpu(lg
->io_parameter
[1]);
1477 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1478 "-- completion status (%x) ioparam=%x/%x.\n", __func__
,
1479 ha
->host_no
, le16_to_cpu(lg
->comp_status
), iop
[0],
1483 case LSC_SCODE_PORTID_USED
:
1484 mb
[0] = MBS_PORT_ID_USED
;
1485 mb
[1] = LSW(iop
[1]);
1487 case LSC_SCODE_NPORT_USED
:
1488 mb
[0] = MBS_LOOP_ID_USED
;
1490 case LSC_SCODE_NOLINK
:
1491 case LSC_SCODE_NOIOCB
:
1492 case LSC_SCODE_NOXCB
:
1493 case LSC_SCODE_CMD_FAILED
:
1494 case LSC_SCODE_NOFABRIC
:
1495 case LSC_SCODE_FW_NOT_READY
:
1496 case LSC_SCODE_NOT_LOGGED_IN
:
1497 case LSC_SCODE_NOPCB
:
1498 case LSC_SCODE_ELS_REJECT
:
1499 case LSC_SCODE_CMD_PARAM_ERR
:
1500 case LSC_SCODE_NONPORT
:
1501 case LSC_SCODE_LOGGED_IN
:
1502 case LSC_SCODE_NOFLOGI_ACC
:
1504 mb
[0] = MBS_COMMAND_ERROR
;
1508 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
1510 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1512 mb
[0] = MBS_COMMAND_COMPLETE
;
1514 if (iop
[0] & BIT_4
) {
1520 /* Passback COS information. */
1522 if (lg
->io_parameter
[7] || lg
->io_parameter
[8])
1523 mb
[10] |= BIT_0
; /* Class 2. */
1524 if (lg
->io_parameter
[9] || lg
->io_parameter
[10])
1525 mb
[10] |= BIT_1
; /* Class 3. */
1528 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1534 * qla2x00_login_fabric
1535 * Issue login fabric port mailbox command.
1538 * ha = adapter block pointer.
1539 * loop_id = device loop ID.
1540 * domain = device domain.
1541 * area = device area.
1542 * al_pa = device AL_PA.
1543 * status = pointer for return status.
1544 * opt = command options.
1545 * TARGET_QUEUE_LOCK must be released.
1546 * ADAPTER_STATE_LOCK must be released.
1549 * qla2x00 local function return status code.
1555 qla2x00_login_fabric(scsi_qla_host_t
*ha
, uint16_t loop_id
, uint8_t domain
,
1556 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1560 mbx_cmd_t
*mcp
= &mc
;
1562 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha
->host_no
));
1564 mcp
->mb
[0] = MBC_LOGIN_FABRIC_PORT
;
1565 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1566 if (HAS_EXTENDED_IDS(ha
)) {
1567 mcp
->mb
[1] = loop_id
;
1569 mcp
->out_mb
|= MBX_10
;
1571 mcp
->mb
[1] = (loop_id
<< 8) | opt
;
1573 mcp
->mb
[2] = domain
;
1574 mcp
->mb
[3] = area
<< 8 | al_pa
;
1576 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_2
|MBX_1
|MBX_0
;
1577 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1579 rval
= qla2x00_mailbox_command(ha
, mcp
);
1581 /* Return mailbox statuses. */
1588 /* COS retrieved from Get-Port-Database mailbox command. */
1592 if (rval
!= QLA_SUCCESS
) {
1593 /* RLU tmp code: need to change main mailbox_command function to
1594 * return ok even when the mailbox completion value is not
1595 * SUCCESS. The caller needs to be responsible to interpret
1596 * the return values of this mailbox command if we're not
1597 * to change too much of the existing code.
1599 if (mcp
->mb
[0] == 0x4001 || mcp
->mb
[0] == 0x4002 ||
1600 mcp
->mb
[0] == 0x4003 || mcp
->mb
[0] == 0x4005 ||
1601 mcp
->mb
[0] == 0x4006)
1605 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
1606 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha
->host_no
, rval
,
1607 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
1610 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
1618 * qla2x00_login_local_device
1619 * Issue login loop port mailbox command.
1622 * ha = adapter block pointer.
1623 * loop_id = device loop ID.
1624 * opt = command options.
1627 * Return status code.
1634 qla2x00_login_local_device(scsi_qla_host_t
*ha
, fc_port_t
*fcport
,
1635 uint16_t *mb_ret
, uint8_t opt
)
1639 mbx_cmd_t
*mcp
= &mc
;
1641 if (IS_FWI2_CAPABLE(ha
))
1642 return qla24xx_login_fabric(ha
, fcport
->loop_id
,
1643 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1644 fcport
->d_id
.b
.al_pa
, mb_ret
, opt
);
1646 DEBUG3(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
1648 mcp
->mb
[0] = MBC_LOGIN_LOOP_PORT
;
1649 if (HAS_EXTENDED_IDS(ha
))
1650 mcp
->mb
[1] = fcport
->loop_id
;
1652 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1654 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1655 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_1
|MBX_0
;
1656 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1658 rval
= qla2x00_mailbox_command(ha
, mcp
);
1660 /* Return mailbox statuses. */
1661 if (mb_ret
!= NULL
) {
1662 mb_ret
[0] = mcp
->mb
[0];
1663 mb_ret
[1] = mcp
->mb
[1];
1664 mb_ret
[6] = mcp
->mb
[6];
1665 mb_ret
[7] = mcp
->mb
[7];
1668 if (rval
!= QLA_SUCCESS
) {
1669 /* AV tmp code: need to change main mailbox_command function to
1670 * return ok even when the mailbox completion value is not
1671 * SUCCESS. The caller needs to be responsible to interpret
1672 * the return values of this mailbox command if we're not
1673 * to change too much of the existing code.
1675 if (mcp
->mb
[0] == 0x4005 || mcp
->mb
[0] == 0x4006)
1678 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1679 "mb[6]=%x mb[7]=%x.\n", __func__
, ha
->host_no
, rval
,
1680 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]));
1681 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1682 "mb[6]=%x mb[7]=%x.\n", __func__
, ha
->host_no
, rval
,
1683 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]));
1686 DEBUG3(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
1693 qla24xx_fabric_logout(scsi_qla_host_t
*ha
, uint16_t loop_id
, uint8_t domain
,
1694 uint8_t area
, uint8_t al_pa
)
1697 struct logio_entry_24xx
*lg
;
1700 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
1702 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1704 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n",
1705 __func__
, ha
->host_no
));
1706 return QLA_MEMORY_ALLOC_FAILED
;
1708 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1710 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1711 lg
->entry_count
= 1;
1712 lg
->nport_handle
= cpu_to_le16(loop_id
);
1714 __constant_cpu_to_le16(LCF_COMMAND_LOGO
|LCF_IMPL_LOGO
);
1715 lg
->port_id
[0] = al_pa
;
1716 lg
->port_id
[1] = area
;
1717 lg
->port_id
[2] = domain
;
1718 lg
->vp_index
= cpu_to_le16(ha
->vp_idx
);
1719 rval
= qla2x00_issue_iocb(ha
, lg
, lg_dma
, 0);
1720 if (rval
!= QLA_SUCCESS
) {
1721 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
1722 "(%x).\n", __func__
, ha
->host_no
, rval
));
1723 } else if (lg
->entry_status
!= 0) {
1724 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1725 "-- error status (%x).\n", __func__
, ha
->host_no
,
1727 rval
= QLA_FUNCTION_FAILED
;
1728 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1729 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1730 "-- completion status (%x) ioparam=%x/%x.\n", __func__
,
1731 ha
->host_no
, le16_to_cpu(lg
->comp_status
),
1732 le32_to_cpu(lg
->io_parameter
[0]),
1733 le32_to_cpu(lg
->io_parameter
[1])));
1736 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
1739 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1745 * qla2x00_fabric_logout
1746 * Issue logout fabric port mailbox command.
1749 * ha = adapter block pointer.
1750 * loop_id = device loop ID.
1751 * TARGET_QUEUE_LOCK must be released.
1752 * ADAPTER_STATE_LOCK must be released.
1755 * qla2x00 local function return status code.
1761 qla2x00_fabric_logout(scsi_qla_host_t
*ha
, uint16_t loop_id
, uint8_t domain
,
1762 uint8_t area
, uint8_t al_pa
)
1766 mbx_cmd_t
*mcp
= &mc
;
1768 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
1771 mcp
->mb
[0] = MBC_LOGOUT_FABRIC_PORT
;
1772 mcp
->out_mb
= MBX_1
|MBX_0
;
1773 if (HAS_EXTENDED_IDS(ha
)) {
1774 mcp
->mb
[1] = loop_id
;
1776 mcp
->out_mb
|= MBX_10
;
1778 mcp
->mb
[1] = loop_id
<< 8;
1781 mcp
->in_mb
= MBX_1
|MBX_0
;
1784 rval
= qla2x00_mailbox_command(ha
, mcp
);
1786 if (rval
!= QLA_SUCCESS
) {
1788 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
1789 "mbx1=%x.\n", ha
->host_no
, rval
, mcp
->mb
[1]));
1792 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
1800 * qla2x00_full_login_lip
1801 * Issue full login LIP mailbox command.
1804 * ha = adapter block pointer.
1805 * TARGET_QUEUE_LOCK must be released.
1806 * ADAPTER_STATE_LOCK must be released.
1809 * qla2x00 local function return status code.
1815 qla2x00_full_login_lip(scsi_qla_host_t
*ha
)
1819 mbx_cmd_t
*mcp
= &mc
;
1821 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
1824 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1825 mcp
->mb
[1] = IS_FWI2_CAPABLE(ha
) ? BIT_3
: 0;
1828 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1832 rval
= qla2x00_mailbox_command(ha
, mcp
);
1834 if (rval
!= QLA_SUCCESS
) {
1836 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
1837 ha
->host_no
, rval
));
1840 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
1848 * qla2x00_get_id_list
1851 * ha = adapter block pointer.
1854 * qla2x00 local function return status code.
1860 qla2x00_get_id_list(scsi_qla_host_t
*ha
, void *id_list
, dma_addr_t id_list_dma
,
1865 mbx_cmd_t
*mcp
= &mc
;
1867 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
1870 if (id_list
== NULL
)
1871 return QLA_FUNCTION_FAILED
;
1873 mcp
->mb
[0] = MBC_GET_ID_LIST
;
1874 mcp
->out_mb
= MBX_0
;
1875 if (IS_FWI2_CAPABLE(ha
)) {
1876 mcp
->mb
[2] = MSW(id_list_dma
);
1877 mcp
->mb
[3] = LSW(id_list_dma
);
1878 mcp
->mb
[6] = MSW(MSD(id_list_dma
));
1879 mcp
->mb
[7] = LSW(MSD(id_list_dma
));
1881 mcp
->mb
[9] = ha
->vp_idx
;
1882 mcp
->out_mb
|= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
;
1884 mcp
->mb
[1] = MSW(id_list_dma
);
1885 mcp
->mb
[2] = LSW(id_list_dma
);
1886 mcp
->mb
[3] = MSW(MSD(id_list_dma
));
1887 mcp
->mb
[6] = LSW(MSD(id_list_dma
));
1888 mcp
->out_mb
|= MBX_6
|MBX_3
|MBX_2
|MBX_1
;
1890 mcp
->in_mb
= MBX_1
|MBX_0
;
1893 rval
= qla2x00_mailbox_command(ha
, mcp
);
1895 if (rval
!= QLA_SUCCESS
) {
1897 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
1898 ha
->host_no
, rval
));
1900 *entries
= mcp
->mb
[1];
1901 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
1909 * qla2x00_get_resource_cnts
1910 * Get current firmware resource counts.
1913 * ha = adapter block pointer.
1916 * qla2x00 local function return status code.
1922 qla2x00_get_resource_cnts(scsi_qla_host_t
*ha
, uint16_t *cur_xchg_cnt
,
1923 uint16_t *orig_xchg_cnt
, uint16_t *cur_iocb_cnt
,
1924 uint16_t *orig_iocb_cnt
, uint16_t *max_npiv_vports
)
1928 mbx_cmd_t
*mcp
= &mc
;
1930 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
1932 mcp
->mb
[0] = MBC_GET_RESOURCE_COUNTS
;
1933 mcp
->out_mb
= MBX_0
;
1934 mcp
->in_mb
= MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1937 rval
= qla2x00_mailbox_command(ha
, mcp
);
1939 if (rval
!= QLA_SUCCESS
) {
1941 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__
,
1942 ha
->host_no
, mcp
->mb
[0]));
1944 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
1945 "mb7=%x mb10=%x mb11=%x.\n", __func__
, ha
->host_no
,
1946 mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3], mcp
->mb
[6], mcp
->mb
[7],
1947 mcp
->mb
[10], mcp
->mb
[11]));
1950 *cur_xchg_cnt
= mcp
->mb
[3];
1952 *orig_xchg_cnt
= mcp
->mb
[6];
1954 *cur_iocb_cnt
= mcp
->mb
[7];
1956 *orig_iocb_cnt
= mcp
->mb
[10];
1957 if (max_npiv_vports
)
1958 *max_npiv_vports
= mcp
->mb
[11];
1964 #if defined(QL_DEBUG_LEVEL_3)
1966 * qla2x00_get_fcal_position_map
1967 * Get FCAL (LILP) position map using mailbox command
1970 * ha = adapter state pointer.
1971 * pos_map = buffer pointer (can be NULL).
1974 * qla2x00 local function return status code.
1980 qla2x00_get_fcal_position_map(scsi_qla_host_t
*ha
, char *pos_map
)
1984 mbx_cmd_t
*mcp
= &mc
;
1986 dma_addr_t pmap_dma
;
1988 pmap
= dma_pool_alloc(ha
->s_dma_pool
, GFP_ATOMIC
, &pmap_dma
);
1990 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
1991 __func__
, ha
->host_no
));
1992 return QLA_MEMORY_ALLOC_FAILED
;
1994 memset(pmap
, 0, FCAL_MAP_SIZE
);
1996 mcp
->mb
[0] = MBC_GET_FC_AL_POSITION_MAP
;
1997 mcp
->mb
[2] = MSW(pmap_dma
);
1998 mcp
->mb
[3] = LSW(pmap_dma
);
1999 mcp
->mb
[6] = MSW(MSD(pmap_dma
));
2000 mcp
->mb
[7] = LSW(MSD(pmap_dma
));
2001 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2002 mcp
->in_mb
= MBX_1
|MBX_0
;
2003 mcp
->buf_size
= FCAL_MAP_SIZE
;
2004 mcp
->flags
= MBX_DMA_IN
;
2005 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2006 rval
= qla2x00_mailbox_command(ha
, mcp
);
2008 if (rval
== QLA_SUCCESS
) {
2009 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
2010 "size (%x)\n", __func__
, ha
->host_no
, mcp
->mb
[0],
2011 mcp
->mb
[1], (unsigned)pmap
[0]));
2012 DEBUG11(qla2x00_dump_buffer(pmap
, pmap
[0] + 1));
2015 memcpy(pos_map
, pmap
, FCAL_MAP_SIZE
);
2017 dma_pool_free(ha
->s_dma_pool
, pmap
, pmap_dma
);
2019 if (rval
!= QLA_SUCCESS
) {
2020 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2021 ha
->host_no
, rval
));
2023 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2031 * qla2x00_get_link_status
2034 * ha = adapter block pointer.
2035 * loop_id = device loop ID.
2036 * ret_buf = pointer to link status return buffer.
2040 * BIT_0 = mem alloc error.
2041 * BIT_1 = mailbox error.
2044 qla2x00_get_link_status(scsi_qla_host_t
*ha
, uint16_t loop_id
,
2045 link_stat_t
*ret_buf
, uint16_t *status
)
2049 mbx_cmd_t
*mcp
= &mc
;
2050 link_stat_t
*stat_buf
;
2051 dma_addr_t stat_buf_dma
;
2053 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2055 stat_buf
= dma_pool_alloc(ha
->s_dma_pool
, GFP_ATOMIC
, &stat_buf_dma
);
2056 if (stat_buf
== NULL
) {
2057 DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
2058 __func__
, ha
->host_no
));
2061 memset(stat_buf
, 0, sizeof(link_stat_t
));
2063 mcp
->mb
[0] = MBC_GET_LINK_STATUS
;
2064 mcp
->mb
[2] = MSW(stat_buf_dma
);
2065 mcp
->mb
[3] = LSW(stat_buf_dma
);
2066 mcp
->mb
[6] = MSW(MSD(stat_buf_dma
));
2067 mcp
->mb
[7] = LSW(MSD(stat_buf_dma
));
2068 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2070 if (IS_FWI2_CAPABLE(ha
)) {
2071 mcp
->mb
[1] = loop_id
;
2074 mcp
->out_mb
|= MBX_10
|MBX_4
|MBX_1
;
2075 mcp
->in_mb
|= MBX_1
;
2076 } else if (HAS_EXTENDED_IDS(ha
)) {
2077 mcp
->mb
[1] = loop_id
;
2079 mcp
->out_mb
|= MBX_10
|MBX_1
;
2081 mcp
->mb
[1] = loop_id
<< 8;
2082 mcp
->out_mb
|= MBX_1
;
2085 mcp
->flags
= IOCTL_CMD
;
2086 rval
= qla2x00_mailbox_command(ha
, mcp
);
2088 if (rval
== QLA_SUCCESS
) {
2089 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2090 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2091 __func__
, ha
->host_no
, mcp
->mb
[0]));
2092 status
[0] = mcp
->mb
[0];
2095 /* copy over data -- firmware data is LE. */
2096 ret_buf
->link_fail_cnt
=
2097 le32_to_cpu(stat_buf
->link_fail_cnt
);
2098 ret_buf
->loss_sync_cnt
=
2099 le32_to_cpu(stat_buf
->loss_sync_cnt
);
2100 ret_buf
->loss_sig_cnt
=
2101 le32_to_cpu(stat_buf
->loss_sig_cnt
);
2102 ret_buf
->prim_seq_err_cnt
=
2103 le32_to_cpu(stat_buf
->prim_seq_err_cnt
);
2104 ret_buf
->inval_xmit_word_cnt
=
2105 le32_to_cpu(stat_buf
->inval_xmit_word_cnt
);
2106 ret_buf
->inval_crc_cnt
=
2107 le32_to_cpu(stat_buf
->inval_crc_cnt
);
2109 DEBUG11(printk("%s(%ld): stat dump: fail_cnt=%d "
2110 "loss_sync=%d loss_sig=%d seq_err=%d "
2111 "inval_xmt_word=%d inval_crc=%d.\n", __func__
,
2112 ha
->host_no
, stat_buf
->link_fail_cnt
,
2113 stat_buf
->loss_sync_cnt
, stat_buf
->loss_sig_cnt
,
2114 stat_buf
->prim_seq_err_cnt
,
2115 stat_buf
->inval_xmit_word_cnt
,
2116 stat_buf
->inval_crc_cnt
));
2120 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2121 ha
->host_no
, rval
));
2125 dma_pool_free(ha
->s_dma_pool
, stat_buf
, stat_buf_dma
);
2131 qla24xx_get_isp_stats(scsi_qla_host_t
*ha
, uint32_t *dwbuf
, uint32_t dwords
,
2136 mbx_cmd_t
*mcp
= &mc
;
2137 uint32_t *sbuf
, *siter
;
2138 dma_addr_t sbuf_dma
;
2140 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2142 if (dwords
> (DMA_POOL_SIZE
/ 4)) {
2143 DEBUG2_3_11(printk("%s(%ld): Unabled to retrieve %d DWORDs "
2144 "(max %d).\n", __func__
, ha
->host_no
, dwords
,
2145 DMA_POOL_SIZE
/ 4));
2148 sbuf
= dma_pool_alloc(ha
->s_dma_pool
, GFP_ATOMIC
, &sbuf_dma
);
2150 DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
2151 __func__
, ha
->host_no
));
2154 memset(sbuf
, 0, DMA_POOL_SIZE
);
2156 mcp
->mb
[0] = MBC_GET_LINK_PRIV_STATS
;
2157 mcp
->mb
[2] = MSW(sbuf_dma
);
2158 mcp
->mb
[3] = LSW(sbuf_dma
);
2159 mcp
->mb
[6] = MSW(MSD(sbuf_dma
));
2160 mcp
->mb
[7] = LSW(MSD(sbuf_dma
));
2161 mcp
->mb
[8] = dwords
;
2163 mcp
->out_mb
= MBX_10
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2164 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
2166 mcp
->flags
= IOCTL_CMD
;
2167 rval
= qla2x00_mailbox_command(ha
, mcp
);
2169 if (rval
== QLA_SUCCESS
) {
2170 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2171 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2172 __func__
, ha
->host_no
, mcp
->mb
[0]));
2173 status
[0] = mcp
->mb
[0];
2176 /* Copy over data -- firmware data is LE. */
2179 *dwbuf
++ = le32_to_cpu(*siter
++);
2183 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2184 ha
->host_no
, rval
));
2188 dma_pool_free(ha
->s_dma_pool
, sbuf
, sbuf_dma
);
2194 qla24xx_abort_command(scsi_qla_host_t
*ha
, srb_t
*sp
)
2198 unsigned long flags
= 0;
2200 struct abort_entry_24xx
*abt
;
2204 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2206 fcport
= sp
->fcport
;
2208 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2209 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
2210 if (ha
->outstanding_cmds
[handle
] == sp
)
2213 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2214 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
2215 /* Command not found. */
2216 return QLA_FUNCTION_FAILED
;
2219 abt
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &abt_dma
);
2221 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n",
2222 __func__
, ha
->host_no
));
2223 return QLA_MEMORY_ALLOC_FAILED
;
2225 memset(abt
, 0, sizeof(struct abort_entry_24xx
));
2227 abt
->entry_type
= ABORT_IOCB_TYPE
;
2228 abt
->entry_count
= 1;
2229 abt
->nport_handle
= cpu_to_le16(fcport
->loop_id
);
2230 abt
->handle_to_abort
= handle
;
2231 abt
->port_id
[0] = fcport
->d_id
.b
.al_pa
;
2232 abt
->port_id
[1] = fcport
->d_id
.b
.area
;
2233 abt
->port_id
[2] = fcport
->d_id
.b
.domain
;
2234 abt
->vp_index
= fcport
->vp_idx
;
2235 rval
= qla2x00_issue_iocb(ha
, abt
, abt_dma
, 0);
2236 if (rval
!= QLA_SUCCESS
) {
2237 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
2238 __func__
, ha
->host_no
, rval
));
2239 } else if (abt
->entry_status
!= 0) {
2240 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2241 "-- error status (%x).\n", __func__
, ha
->host_no
,
2242 abt
->entry_status
));
2243 rval
= QLA_FUNCTION_FAILED
;
2244 } else if (abt
->nport_handle
!= __constant_cpu_to_le16(0)) {
2245 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2246 "-- completion status (%x).\n", __func__
, ha
->host_no
,
2247 le16_to_cpu(abt
->nport_handle
)));
2248 rval
= QLA_FUNCTION_FAILED
;
2250 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2251 sp
->flags
|= SRB_ABORT_PENDING
;
2254 dma_pool_free(ha
->s_dma_pool
, abt
, abt_dma
);
2259 struct tsk_mgmt_cmd
{
2261 struct tsk_mgmt_entry tsk
;
2262 struct sts_entry_24xx sts
;
2267 qla24xx_abort_target(fc_port_t
*fcport
)
2270 struct tsk_mgmt_cmd
*tsk
;
2272 scsi_qla_host_t
*ha
, *pha
;
2277 DEBUG11(printk("%s(%ld): entered.\n", __func__
, fcport
->ha
->host_no
));
2280 pha
= to_qla_parent(ha
);
2281 tsk
= dma_pool_alloc(pha
->s_dma_pool
, GFP_KERNEL
, &tsk_dma
);
2283 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
2284 "IOCB.\n", __func__
, ha
->host_no
));
2285 return QLA_MEMORY_ALLOC_FAILED
;
2287 memset(tsk
, 0, sizeof(struct tsk_mgmt_cmd
));
2289 tsk
->p
.tsk
.entry_type
= TSK_MGMT_IOCB_TYPE
;
2290 tsk
->p
.tsk
.entry_count
= 1;
2291 tsk
->p
.tsk
.nport_handle
= cpu_to_le16(fcport
->loop_id
);
2292 tsk
->p
.tsk
.timeout
= __constant_cpu_to_le16(25);
2293 tsk
->p
.tsk
.control_flags
= __constant_cpu_to_le32(TCF_TARGET_RESET
);
2294 tsk
->p
.tsk
.port_id
[0] = fcport
->d_id
.b
.al_pa
;
2295 tsk
->p
.tsk
.port_id
[1] = fcport
->d_id
.b
.area
;
2296 tsk
->p
.tsk
.port_id
[2] = fcport
->d_id
.b
.domain
;
2297 tsk
->p
.tsk
.vp_index
= fcport
->vp_idx
;
2299 rval
= qla2x00_issue_iocb(ha
, tsk
, tsk_dma
, 0);
2300 if (rval
!= QLA_SUCCESS
) {
2301 DEBUG2_3_11(printk("%s(%ld): failed to issue Target Reset IOCB "
2302 "(%x).\n", __func__
, ha
->host_no
, rval
));
2304 } else if (tsk
->p
.sts
.entry_status
!= 0) {
2305 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2306 "-- error status (%x).\n", __func__
, ha
->host_no
,
2307 tsk
->p
.sts
.entry_status
));
2308 rval
= QLA_FUNCTION_FAILED
;
2310 } else if (tsk
->p
.sts
.comp_status
!=
2311 __constant_cpu_to_le16(CS_COMPLETE
)) {
2312 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2313 "-- completion status (%x).\n", __func__
,
2314 ha
->host_no
, le16_to_cpu(tsk
->p
.sts
.comp_status
)));
2315 rval
= QLA_FUNCTION_FAILED
;
2319 /* Issue marker IOCB. */
2320 rval
= qla2x00_marker(ha
, fcport
->loop_id
, 0, MK_SYNC_ID
);
2321 if (rval
!= QLA_SUCCESS
) {
2322 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2323 "(%x).\n", __func__
, ha
->host_no
, rval
));
2325 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2329 dma_pool_free(pha
->s_dma_pool
, tsk
, tsk_dma
);
2335 qla2x00_system_error(scsi_qla_host_t
*ha
)
2339 mbx_cmd_t
*mcp
= &mc
;
2341 if (!IS_FWI2_CAPABLE(ha
))
2342 return QLA_FUNCTION_FAILED
;
2344 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2346 mcp
->mb
[0] = MBC_GEN_SYSTEM_ERROR
;
2347 mcp
->out_mb
= MBX_0
;
2351 rval
= qla2x00_mailbox_command(ha
, mcp
);
2353 if (rval
!= QLA_SUCCESS
) {
2354 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2355 ha
->host_no
, rval
));
2357 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2364 * qla2x00_get_serdes_params() -
2370 qla2x00_get_serdes_params(scsi_qla_host_t
*ha
, uint16_t *sw_em_1g
,
2371 uint16_t *sw_em_2g
, uint16_t *sw_em_4g
)
2375 mbx_cmd_t
*mcp
= &mc
;
2377 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2379 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
2381 mcp
->out_mb
= MBX_1
|MBX_0
;
2382 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_0
;
2385 rval
= qla2x00_mailbox_command(ha
, mcp
);
2387 if (rval
!= QLA_SUCCESS
) {
2389 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
2390 ha
->host_no
, rval
, mcp
->mb
[0]));
2392 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2395 *sw_em_1g
= mcp
->mb
[2];
2397 *sw_em_2g
= mcp
->mb
[3];
2399 *sw_em_4g
= mcp
->mb
[4];
2406 * qla2x00_set_serdes_params() -
2412 qla2x00_set_serdes_params(scsi_qla_host_t
*ha
, uint16_t sw_em_1g
,
2413 uint16_t sw_em_2g
, uint16_t sw_em_4g
)
2417 mbx_cmd_t
*mcp
= &mc
;
2419 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2421 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
2423 mcp
->mb
[2] = sw_em_1g
| BIT_15
;
2424 mcp
->mb
[3] = sw_em_2g
| BIT_15
;
2425 mcp
->mb
[4] = sw_em_4g
| BIT_15
;
2426 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2430 rval
= qla2x00_mailbox_command(ha
, mcp
);
2432 if (rval
!= QLA_SUCCESS
) {
2434 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
2435 ha
->host_no
, rval
, mcp
->mb
[0]));
2438 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2445 qla2x00_stop_firmware(scsi_qla_host_t
*ha
)
2449 mbx_cmd_t
*mcp
= &mc
;
2451 if (!IS_FWI2_CAPABLE(ha
))
2452 return QLA_FUNCTION_FAILED
;
2454 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2456 mcp
->mb
[0] = MBC_STOP_FIRMWARE
;
2457 mcp
->out_mb
= MBX_0
;
2461 rval
= qla2x00_mailbox_command(ha
, mcp
);
2463 if (rval
!= QLA_SUCCESS
) {
2464 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2465 ha
->host_no
, rval
));
2467 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2474 qla2x00_trace_control(scsi_qla_host_t
*ha
, uint16_t ctrl
, dma_addr_t eft_dma
,
2479 mbx_cmd_t
*mcp
= &mc
;
2481 if (!IS_FWI2_CAPABLE(ha
))
2482 return QLA_FUNCTION_FAILED
;
2484 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2486 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2488 mcp
->out_mb
= MBX_1
|MBX_0
;
2489 mcp
->in_mb
= MBX_1
|MBX_0
;
2490 if (ctrl
== TC_ENABLE
) {
2491 mcp
->mb
[2] = LSW(eft_dma
);
2492 mcp
->mb
[3] = MSW(eft_dma
);
2493 mcp
->mb
[4] = LSW(MSD(eft_dma
));
2494 mcp
->mb
[5] = MSW(MSD(eft_dma
));
2495 mcp
->mb
[6] = buffers
;
2497 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
;
2501 rval
= qla2x00_mailbox_command(ha
, mcp
);
2503 if (rval
!= QLA_SUCCESS
) {
2504 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2505 __func__
, ha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2507 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2514 qla2x00_read_sfp(scsi_qla_host_t
*ha
, dma_addr_t sfp_dma
, uint16_t addr
,
2515 uint16_t off
, uint16_t count
)
2519 mbx_cmd_t
*mcp
= &mc
;
2521 if (!IS_FWI2_CAPABLE(ha
))
2522 return QLA_FUNCTION_FAILED
;
2524 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2526 mcp
->mb
[0] = MBC_READ_SFP
;
2528 mcp
->mb
[2] = MSW(sfp_dma
);
2529 mcp
->mb
[3] = LSW(sfp_dma
);
2530 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
2531 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
2535 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2539 rval
= qla2x00_mailbox_command(ha
, mcp
);
2541 if (rval
!= QLA_SUCCESS
) {
2542 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
2543 ha
->host_no
, rval
, mcp
->mb
[0]));
2545 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2552 qla2x00_get_idma_speed(scsi_qla_host_t
*ha
, uint16_t loop_id
,
2553 uint16_t *port_speed
, uint16_t *mb
)
2557 mbx_cmd_t
*mcp
= &mc
;
2559 if (!IS_IIDMA_CAPABLE(ha
))
2560 return QLA_FUNCTION_FAILED
;
2562 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2564 mcp
->mb
[0] = MBC_PORT_PARAMS
;
2565 mcp
->mb
[1] = loop_id
;
2566 mcp
->mb
[2] = mcp
->mb
[3] = mcp
->mb
[4] = mcp
->mb
[5] = 0;
2567 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2568 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_1
|MBX_0
;
2571 rval
= qla2x00_mailbox_command(ha
, mcp
);
2573 /* Return mailbox statuses. */
2582 if (rval
!= QLA_SUCCESS
) {
2583 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2584 ha
->host_no
, rval
));
2586 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2588 *port_speed
= mcp
->mb
[3];
2595 qla2x00_set_idma_speed(scsi_qla_host_t
*ha
, uint16_t loop_id
,
2596 uint16_t port_speed
, uint16_t *mb
)
2600 mbx_cmd_t
*mcp
= &mc
;
2602 if (!IS_IIDMA_CAPABLE(ha
))
2603 return QLA_FUNCTION_FAILED
;
2605 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2607 mcp
->mb
[0] = MBC_PORT_PARAMS
;
2608 mcp
->mb
[1] = loop_id
;
2610 mcp
->mb
[3] = port_speed
& (BIT_2
|BIT_1
|BIT_0
);
2611 mcp
->mb
[4] = mcp
->mb
[5] = 0;
2612 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2613 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_1
|MBX_0
;
2616 rval
= qla2x00_mailbox_command(ha
, mcp
);
2618 /* Return mailbox statuses. */
2627 if (rval
!= QLA_SUCCESS
) {
2628 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2629 ha
->host_no
, rval
));
2631 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2638 * qla24xx_get_vp_database
2639 * Get the VP's database for all configured ports.
2642 * ha = adapter block pointer.
2643 * size = size of initialization control block.
2646 * qla2x00 local function return status code.
2652 qla24xx_get_vp_database(scsi_qla_host_t
*ha
, uint16_t size
)
2656 mbx_cmd_t
*mcp
= &mc
;
2658 DEBUG11(printk("scsi(%ld):%s - entered.\n",
2659 ha
->host_no
, __func__
));
2661 mcp
->mb
[0] = MBC_MID_GET_VP_DATABASE
;
2662 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
2663 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
2666 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
2667 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
2668 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2669 mcp
->in_mb
= MBX_1
|MBX_0
;
2670 mcp
->buf_size
= size
;
2671 mcp
->flags
= MBX_DMA_OUT
;
2672 mcp
->tov
= MBX_TOV_SECONDS
;
2673 rval
= qla2x00_mailbox_command(ha
, mcp
);
2675 if (rval
!= QLA_SUCCESS
) {
2677 DEBUG2_3_11(printk("%s(%ld): failed=%x "
2679 __func__
, ha
->host_no
, rval
, mcp
->mb
[0]));
2682 DEBUG11(printk("%s(%ld): done.\n",
2683 __func__
, ha
->host_no
));
2690 qla24xx_get_vp_entry(scsi_qla_host_t
*ha
, uint16_t size
, int vp_id
)
2694 mbx_cmd_t
*mcp
= &mc
;
2696 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2698 mcp
->mb
[0] = MBC_MID_GET_VP_ENTRY
;
2699 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
2700 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
2703 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
2704 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
2706 mcp
->out_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2708 mcp
->buf_size
= size
;
2709 mcp
->flags
= MBX_DMA_OUT
;
2711 rval
= qla2x00_mailbox_command(ha
, mcp
);
2713 if (rval
!= QLA_SUCCESS
) {
2715 DEBUG2_3_11(printk("qla24xx_get_vp_entry(%ld): failed=%x "
2717 ha
->host_no
, rval
, mcp
->mb
[0]));
2720 DEBUG11(printk("qla24xx_get_vp_entry(%ld): done.\n",
2728 qla24xx_report_id_acquisition(scsi_qla_host_t
*ha
,
2729 struct vp_rpt_id_entry_24xx
*rptid_entry
)
2732 scsi_qla_host_t
*vha
;
2734 if (rptid_entry
->entry_status
!= 0)
2736 if (rptid_entry
->entry_status
!= __constant_cpu_to_le16(CS_COMPLETE
))
2739 if (rptid_entry
->format
== 0) {
2740 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
2741 " number of VPs acquired %d\n", __func__
, ha
->host_no
,
2742 MSB(rptid_entry
->vp_count
), LSB(rptid_entry
->vp_count
)));
2743 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__
,
2744 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
2745 rptid_entry
->port_id
[0]));
2746 } else if (rptid_entry
->format
== 1) {
2747 vp_idx
= LSB(rptid_entry
->vp_idx
);
2748 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
2750 "with port id %02x%02x%02x\n",__func__
,ha
->host_no
,
2751 vp_idx
, MSB(rptid_entry
->vp_idx
),
2752 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
2753 rptid_entry
->port_id
[0]));
2757 if (MSB(rptid_entry
->vp_idx
) == 1)
2760 list_for_each_entry(vha
, &ha
->vp_list
, vp_list
)
2761 if (vp_idx
== vha
->vp_idx
)
2767 vha
->d_id
.b
.domain
= rptid_entry
->port_id
[2];
2768 vha
->d_id
.b
.area
= rptid_entry
->port_id
[1];
2769 vha
->d_id
.b
.al_pa
= rptid_entry
->port_id
[0];
2772 * Cannot configure here as we are still sitting on the
2773 * response queue. Handle it in dpc context.
2775 set_bit(VP_IDX_ACQUIRED
, &vha
->vp_flags
);
2776 set_bit(VP_DPC_NEEDED
, &ha
->dpc_flags
);
2778 wake_up_process(ha
->dpc_thread
);
2783 * qla24xx_modify_vp_config
2784 * Change VP configuration for vha
2787 * vha = adapter block pointer.
2790 * qla2xxx local function return status code.
2796 qla24xx_modify_vp_config(scsi_qla_host_t
*vha
)
2799 struct vp_config_entry_24xx
*vpmod
;
2800 dma_addr_t vpmod_dma
;
2801 scsi_qla_host_t
*pha
;
2803 /* This can be called by the parent */
2804 pha
= to_qla_parent(vha
);
2806 vpmod
= dma_pool_alloc(pha
->s_dma_pool
, GFP_KERNEL
, &vpmod_dma
);
2808 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
2809 "IOCB.\n", __func__
, pha
->host_no
));
2810 return QLA_MEMORY_ALLOC_FAILED
;
2813 memset(vpmod
, 0, sizeof(struct vp_config_entry_24xx
));
2814 vpmod
->entry_type
= VP_CONFIG_IOCB_TYPE
;
2815 vpmod
->entry_count
= 1;
2816 vpmod
->command
= VCT_COMMAND_MOD_ENABLE_VPS
;
2817 vpmod
->vp_count
= 1;
2818 vpmod
->vp_index1
= vha
->vp_idx
;
2819 vpmod
->options_idx1
= BIT_3
|BIT_4
|BIT_5
;
2820 memcpy(vpmod
->node_name_idx1
, vha
->node_name
, WWN_SIZE
);
2821 memcpy(vpmod
->port_name_idx1
, vha
->port_name
, WWN_SIZE
);
2822 vpmod
->entry_count
= 1;
2824 rval
= qla2x00_issue_iocb(pha
, vpmod
, vpmod_dma
, 0);
2825 if (rval
!= QLA_SUCCESS
) {
2826 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
2827 "(%x).\n", __func__
, pha
->host_no
, rval
));
2828 } else if (vpmod
->comp_status
!= 0) {
2829 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2830 "-- error status (%x).\n", __func__
, pha
->host_no
,
2831 vpmod
->comp_status
));
2832 rval
= QLA_FUNCTION_FAILED
;
2833 } else if (vpmod
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
2834 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2835 "-- completion status (%x).\n", __func__
, pha
->host_no
,
2836 le16_to_cpu(vpmod
->comp_status
)));
2837 rval
= QLA_FUNCTION_FAILED
;
2840 DEBUG11(printk("%s(%ld): done.\n", __func__
, pha
->host_no
));
2841 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_INITIALIZING
);
2843 dma_pool_free(pha
->s_dma_pool
, vpmod
, vpmod_dma
);
2849 * qla24xx_control_vp
2850 * Enable a virtual port for given host
2853 * ha = adapter block pointer.
2854 * vhba = virtual adapter (unused)
2855 * index = index number for enabled VP
2858 * qla2xxx local function return status code.
2864 qla24xx_control_vp(scsi_qla_host_t
*vha
, int cmd
)
2868 struct vp_ctrl_entry_24xx
*vce
;
2870 scsi_qla_host_t
*ha
= vha
->parent
;
2871 int vp_index
= vha
->vp_idx
;
2873 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__
,
2874 ha
->host_no
, vp_index
));
2876 if (vp_index
== 0 || vp_index
>= MAX_MULTI_ID_LOOP
)
2877 return QLA_PARAMETER_ERROR
;
2879 vce
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vce_dma
);
2881 DEBUG2_3(printk("%s(%ld): "
2882 "failed to allocate VP Control IOCB.\n", __func__
,
2884 return QLA_MEMORY_ALLOC_FAILED
;
2886 memset(vce
, 0, sizeof(struct vp_ctrl_entry_24xx
));
2888 vce
->entry_type
= VP_CTRL_IOCB_TYPE
;
2889 vce
->entry_count
= 1;
2890 vce
->command
= cpu_to_le16(cmd
);
2891 vce
->vp_count
= __constant_cpu_to_le16(1);
2893 /* index map in firmware starts with 1; decrement index
2894 * this is ok as we never use index 0
2896 map
= (vp_index
- 1) / 8;
2897 pos
= (vp_index
- 1) & 7;
2898 down(&ha
->vport_sem
);
2899 vce
->vp_idx_map
[map
] |= 1 << pos
;
2902 rval
= qla2x00_issue_iocb(ha
, vce
, vce_dma
, 0);
2903 if (rval
!= QLA_SUCCESS
) {
2904 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
2905 "(%x).\n", __func__
, ha
->host_no
, rval
));
2906 printk("%s(%ld): failed to issue VP control IOCB"
2907 "(%x).\n", __func__
, ha
->host_no
, rval
);
2908 } else if (vce
->entry_status
!= 0) {
2909 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2910 "-- error status (%x).\n", __func__
, ha
->host_no
,
2911 vce
->entry_status
));
2912 printk("%s(%ld): failed to complete IOCB "
2913 "-- error status (%x).\n", __func__
, ha
->host_no
,
2915 rval
= QLA_FUNCTION_FAILED
;
2916 } else if (vce
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
2917 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2918 "-- completion status (%x).\n", __func__
, ha
->host_no
,
2919 le16_to_cpu(vce
->comp_status
)));
2920 printk("%s(%ld): failed to complete IOCB "
2921 "-- completion status (%x).\n", __func__
, ha
->host_no
,
2922 le16_to_cpu(vce
->comp_status
));
2923 rval
= QLA_FUNCTION_FAILED
;
2925 DEBUG2(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
2928 dma_pool_free(ha
->s_dma_pool
, vce
, vce_dma
);
2934 * qla2x00_send_change_request
2935 * Receive or disable RSCN request from fabric controller
2938 * ha = adapter block pointer
2939 * format = registration format:
2941 * 1 - Fabric detected registration
2942 * 2 - N_port detected registration
2943 * 3 - Full registration
2944 * FF - clear registration
2945 * vp_idx = Virtual port index
2948 * qla2x00 local function return status code.
2955 qla2x00_send_change_request(scsi_qla_host_t
*ha
, uint16_t format
,
2960 mbx_cmd_t
*mcp
= &mc
;
2963 * This command is implicitly executed by firmware during login for the
2967 return QLA_FUNCTION_FAILED
;
2969 mcp
->mb
[0] = MBC_SEND_CHANGE_REQUEST
;
2970 mcp
->mb
[1] = format
;
2971 mcp
->mb
[9] = vp_idx
;
2972 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
2973 mcp
->in_mb
= MBX_0
|MBX_1
;
2974 mcp
->tov
= MBX_TOV_SECONDS
;
2976 rval
= qla2x00_mailbox_command(ha
, mcp
);
2978 if (rval
== QLA_SUCCESS
) {
2979 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2989 qla2x00_dump_ram(scsi_qla_host_t
*ha
, dma_addr_t req_dma
, uint32_t addr
,
2994 mbx_cmd_t
*mcp
= &mc
;
2996 DEBUG11(printk("%s(%ld): entered.\n", __func__
, ha
->host_no
));
2998 if (MSW(addr
) || IS_FWI2_CAPABLE(ha
)) {
2999 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
3000 mcp
->mb
[8] = MSW(addr
);
3001 mcp
->out_mb
= MBX_8
|MBX_0
;
3003 mcp
->mb
[0] = MBC_DUMP_RISC_RAM
;
3004 mcp
->out_mb
= MBX_0
;
3006 mcp
->mb
[1] = LSW(addr
);
3007 mcp
->mb
[2] = MSW(req_dma
);
3008 mcp
->mb
[3] = LSW(req_dma
);
3009 mcp
->mb
[6] = MSW(MSD(req_dma
));
3010 mcp
->mb
[7] = LSW(MSD(req_dma
));
3011 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
3012 if (IS_FWI2_CAPABLE(ha
)) {
3013 mcp
->mb
[4] = MSW(size
);
3014 mcp
->mb
[5] = LSW(size
);
3015 mcp
->out_mb
|= MBX_5
|MBX_4
;
3017 mcp
->mb
[4] = LSW(size
);
3018 mcp
->out_mb
|= MBX_4
;
3024 rval
= qla2x00_mailbox_command(ha
, mcp
);
3026 if (rval
!= QLA_SUCCESS
) {
3027 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3028 ha
->host_no
, rval
, mcp
->mb
[0]));
3030 DEBUG11(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));