qla_mbx.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 2,453 行 · 第 1/4 页
C
2,453 行
ha->host_no, rval)); } else { fwopts[1] = mcp->mb[1]; fwopts[2] = mcp->mb[2]; fwopts[3] = mcp->mb[3]; DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); } return rval;}/* * qla2x00_set_fw_options * Set firmware options. * * Input: * ha = adapter block pointer. * fwopt = pointer for firmware options. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; mcp->mb[1] = fwopts[1]; mcp->mb[2] = fwopts[2]; mcp->mb[3] = fwopts[3]; mcp->mb[10] = fwopts[10]; mcp->mb[11] = fwopts[11]; mcp->mb[12] = 0; /* Undocumented, but used */ mcp->out_mb = MBX_12|MBX_11|MBX_10|MBX_3|MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, ha->host_no, rval)); } else { /*EMPTY*/ DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); } return rval;}/* * qla2x00_read_ram_word * * Input: * ha = adapter block pointer. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_read_ram_word(scsi_qla_host_t *ha, uint16_t addr, uint16_t *data){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_read_ram_word(%ld): entered.\n", ha->host_no);) mcp->mb[0] = MBC_READ_RAM_WORD; mcp->mb[1] = addr; mcp->out_mb = MBX_1|MBX_0; mcp->in_mb = MBX_0|MBX_2; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("qla2x00_read_ram_word(%ld): failed=%x.\n", ha->host_no, rval);) } else { *data = mcp->mb[2]; DEBUG11(printk("qla2x00_read_ram_word(%ld): done.\n", ha->host_no);) } return rval;}/* * qla2x00_write_ram_word * * Input: * ha = adapter block pointer. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_write_ram_word(scsi_qla_host_t *ha, uint16_t addr, uint16_t data){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_write_ram_word(%ld): entered.\n", ha->host_no);) mcp->mb[0] = MBC_WRITE_RAM_WORD; mcp->mb[1] = addr; mcp->mb[2] = data; mcp->out_mb = MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("qla2x00_write_ram_word(%ld): failed=%x.\n", ha->host_no, rval);) } else { /*EMPTY*/ DEBUG11(printk("qla2x00_write_ram_word(%ld): done.\n", ha->host_no);) } return rval;}/* * qla2x00_write_ram_word_ext * * Input: * ha = adapter block pointer. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_write_ram_word_ext(scsi_qla_host_t *ha, uint32_t addr, uint16_t data){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; mcp->mb[1] = LSW(addr); mcp->mb[2] = data; mcp->mb[8] = MSW(addr); mcp->out_mb = MBX_8|MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, ha->host_no, rval)); } else { /*EMPTY*/ DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); } return rval;}/* * qla2x00_mbx_reg_test * Mailbox register wrap test. * * Input: * ha = adapter block pointer. * TARGET_QUEUE_LOCK must be released. * ADAPTER_STATE_LOCK must be released. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_mbx_reg_test(scsi_qla_host_t *ha){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no);) mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; mcp->mb[1] = 0xAAAA; mcp->mb[2] = 0x5555; mcp->mb[3] = 0xAA55; mcp->mb[4] = 0x55AA; mcp->mb[5] = 0xA5A5; mcp->mb[6] = 0x5A5A; mcp->mb[7] = 0x2525; mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval == QLA_SUCCESS) { if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) rval = QLA_FUNCTION_FAILED; if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || mcp->mb[7] != 0x2525) rval = QLA_FUNCTION_FAILED; } if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n", ha->host_no, rval);) } else { /*EMPTY*/ DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n", ha->host_no);) } return rval;}/* * qla2x00_verify_checksum * Verify firmware checksum. * * Input: * ha = adapter block pointer. * TARGET_QUEUE_LOCK must be released. * ADAPTER_STATE_LOCK must be released. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_verify_checksum(scsi_qla_host_t *ha){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_verify_checksum(%ld): entered.\n", ha->host_no);) mcp->mb[0] = MBC_VERIFY_CHECKSUM; mcp->mb[1] = *ha->brd_info->fw_info[0].fwstart; mcp->out_mb = MBX_1|MBX_0; mcp->in_mb = MBX_2|MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("qla2x00_verify_checksum(%ld): failed=%x.\n", ha->host_no, rval);) } else { /*EMPTY*/ DEBUG11(printk("qla2x00_verify_checksum(%ld): done.\n", ha->host_no);) } return rval;}/* * qla2x00_issue_iocb * Issue IOCB using mailbox command * * Input: * ha = adapter state pointer. * buffer = buffer pointer. * phys_addr = physical address of buffer. * size = size of buffer. * TARGET_QUEUE_LOCK must be released. * ADAPTER_STATE_LOCK must be released. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_issue_iocb(scsi_qla_host_t *ha, void* buffer, dma_addr_t phys_addr, size_t size){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; mcp->mb[0] = MBC_IOCB_COMMAND_A64; mcp->mb[1] = 0; mcp->mb[2] = MSW(phys_addr); mcp->mb[3] = LSW(phys_addr); mcp->mb[6] = MSW(MSD(phys_addr)); mcp->mb[7] = LSW(MSD(phys_addr)); mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_2|MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x", ha->host_no,rval);) DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x", ha->host_no,rval);) } else { /*EMPTY*/ } return rval;}/* * qla2x00_abort_command * Abort command aborts a specified IOCB. * * Input: * ha = adapter block pointer. * sp = SB structure pointer. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp){ unsigned long flags = 0; fc_port_t *fcport; int rval; uint32_t handle; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);) fcport = sp->fclun->fcport; if (atomic_read(&ha->loop_state) == LOOP_DOWN || atomic_read(&fcport->state) == FCS_DEVICE_LOST) { return 1; } spin_lock_irqsave(&ha->hardware_lock, flags); for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { if (ha->outstanding_cmds[handle] == sp) break; } spin_unlock_irqrestore(&ha->hardware_lock, flags); if (handle == MAX_OUTSTANDING_COMMANDS) { /* command not found */ return QLA_FUNCTION_FAILED; } mcp->mb[0] = MBC_ABORT_COMMAND; if (HAS_EXTENDED_IDS(ha)) mcp->mb[1] = fcport->loop_id; else mcp->mb[1] = fcport->loop_id << 8; mcp->mb[2] = (uint16_t)handle; mcp->mb[3] = (uint16_t)(handle >> 16); mcp->mb[6] = (uint16_t)sp->fclun->lun; mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n", ha->host_no, rval);) } else { sp->flags |= SRB_ABORT_PENDING; DEBUG11(printk("qla2x00_abort_command(%ld): done.\n", ha->host_no);) } return rval;}/* * qla2x00_abort_device * * Input: * ha = adapter block pointer. * loop_id = FC loop ID * lun = SCSI LUN. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_abort_device(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_abort_device(%ld): entered.\n", ha->host_no);) mcp->mb[0] = MBC_ABORT_DEVICE; if (HAS_EXTENDED_IDS(ha)) mcp->mb[1] = loop_id; else mcp->mb[1] = loop_id << 8; mcp->mb[2] = lun; mcp->out_mb = MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); /* Issue marker command. */ qla2x00_marker(ha, loop_id, lun, MK_SYNC_ID_LUN); if (rval != QLA_SUCCESS) { qla_printk(KERN_WARNING, ha, "Failed Abort Device Mailbox command. Scheduling ISP " "abort.\n"); set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); if (ha->dpc_wait && !ha->dpc_active) up(ha->dpc_wait); DEBUG2_3_11(printk("qla2x00_abort_device(%ld): failed=%x.\n", ha->host_no, rval);) } else { /*EMPTY*/ DEBUG11(printk("qla2x00_abort_device(%ld): done.\n", ha->host_no);) } return rval;}#if USE_ABORT_TGT/* * qla2x00_abort_target * Issue abort target mailbox command. * * Input: * ha = adapter block pointer. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_abort_target(fc_port_t *fcport){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; DEBUG11(printk("qla2x00_abort_target(%ld): entered.\n", fcport->ha->host_no);) if (fcport == NULL) { /* no target to abort */ return 0; } mcp->mb[0] = MBC_ABORT_TARGET; mcp->out_mb = MBX_2|MBX_1|MBX_0; if (HAS_EXTENDED_IDS(fcport->ha)) { mcp->mb[1] = fcport->loop_id; mcp->mb[10] = 0; mcp->out_mb |= MBX_10; } else { mcp->mb[1] = fcport->loop_id << 8; } mcp->mb[2] = fcport->ha->loop_reset_delay; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(fcport->ha, mcp); /* Issue marker command. */ fcport->ha->marker_needed = 1; if (rval != QLA_SUCCESS) { DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n", fcport->ha->host_no, rval);) } else { /*EMPTY*/ DEBUG11(printk("qla2x00_abort_target(%ld): done.\n", fcport->ha->host_no);) } return rval;}#endif/* * qla2x00_target_reset * Issue target reset mailbox command. * * Input: * ha = adapter block pointer. * TARGET_QUEUE_LOCK must be released. * ADAPTER_STATE_LOCK must be released. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context. */intqla2x00_target_reset(scsi_qla_host_t *ha, uint16_t b, uint16_t t){ int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; os_tgt_t *tgt; DEBUG11(printk("qla2x00_target_reset(%ld): entered.\n", ha->host_no);) tgt = TGT_Q(ha, t); if (tgt->fcport == NULL) { /* no target to abort */ return 0; } if (atomic_read(&tgt->fcport->state) != FCS_ONLINE) { /* target not online */ return 0; } mcp->mb[0] = MBC_TARGET_RESET; if (HAS_EXTENDED_IDS(ha)) mcp->mb[1] = tgt->fcport->loop_id; else mcp->mb[1] = tgt->fcport->loop_id << 8; mcp->mb[2] = ha->loop_reset_delay; mcp->out_mb = MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3_11(printk("qla2x00_target_reset(%ld): failed=%x.\n", ha->host_no, rval);) } else { /*EMPTY*/ DEBUG11(printk("qla2x00_target_reset(%ld): done.\n", ha->host_no);) } return rval;}/* * qla2x00_get_adapter_id * Get adapter ID and topology. * * Input: * ha = adapter block pointer. * id = pointer for loop ID. * al_pa = pointer for AL_PA. * area = pointer for area. * domain = pointer for domain. * top = pointer for topology. * TARGET_QUEUE_LOCK must be released. * ADAPTER_STATE_LOCK must be released. * * Returns: * qla2x00 local function return status code. * * Context: * Kernel context.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?