/** * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query. * @ha: HA context * @list: switch info entries to populate * * Returns 0 on success. */ int qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_gpn_id(ha, list)); } for (i = 0; i < MAX_FIBRE_DEVICES; i++) { /* Issue GPN_ID */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, GPN_ID_REQ_SIZE, GPN_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, GPN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id */ ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed " "(%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected " "request, gpn_id_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { /* Save portname */ memcpy(list[i].port_name, ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); } /* Last device exit. */ if (list[i].d_id.b.rsvd_1 != 0) break; } return (rval); }
/** * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command. * @ha: HA context * @list: switch info entries to populate * * This command uses the old Exectute SNS Command mailbox routine. * * NOTE: Non-Nx_Ports are not requested. * * Returns 0 on success. */ static int qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; uint8_t *entry; struct sns_cmd_pkt *sns_cmd; /* Issue GID_PT. */ /* Prepare SNS command request. */ sns_cmd = qla2x00_prep_sns_cmd(ha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN, GID_PT_SNS_DATA_SIZE); /* Prepare SNS command arguments -- port_type. */ sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE; /* Execute SNS command. */ rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n", ha->host_no, rval)); } else if (sns_cmd->p.gid_data[8] != 0x80 || sns_cmd->p.gid_data[9] != 0x02) { DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, " "gid_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16)); rval = QLA_FUNCTION_FAILED; } else { /* Set port IDs in switch info list. */ for (i = 0; i < MAX_FIBRE_DEVICES; i++) { entry = &sns_cmd->p.gid_data[(i * 4) + 16]; list[i].d_id.b.domain = entry[1]; list[i].d_id.b.area = entry[2]; list[i].d_id.b.al_pa = entry[3]; /* Last one exit. */ if (entry[0] & BIT_7) { list[i].d_id.b.rsvd_1 = entry[0]; break; } } /* * If we've used all available slots, then the switch is * reporting back more devices that we can handle with this * single call. Return a failed status, and let GA_NXT handle * the overload. */ if (i == MAX_FIBRE_DEVICES) rval = QLA_FUNCTION_FAILED; } return (rval); }
/** * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA. * @ha: HA context * * Returns 0 on success. */ int qla2x00_rff_id(scsi_qla_host_t *ha) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on " "ISP2100/ISP2200.\n", ha->host_no)); return (QLA_SUCCESS); } /* Issue RFF_ID */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, RFF_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain; ct_req->req.rff_id.port_id[1] = ha->d_id.b.area; ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa; ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): RFF_ID failed, rejected " "request, rff_id_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n", ha->host_no)); } return (rval); }
/** * qla2x00_mbx_completion() - Process mailbox command completions. * @ha: SCSI driver HA context * @mb0: Mailbox0 register */ static void qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0) { uint16_t cnt; uint16_t *wptr; device_reg_t *reg = ha->iobase; /* Load return mailbox registers. */ ha->flags.mbox_int = TRUE; ha->mailbox_out[0] = mb0; wptr = (uint16_t *)MAILBOX_REG(ha, reg, 1); for (cnt = 1; cnt < ha->mbx_count; cnt++) { if (IS_QLA2200(ha) && cnt == 8) wptr = (uint16_t *)MAILBOX_REG(ha, reg, 8); if (cnt == 4 || cnt == 5) ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); else ha->mailbox_out[cnt] = RD_REG_WORD(wptr); wptr++; } if (ha->mcp) { DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", __func__, ha->host_no, ha->mcp->mb[0])); } else { DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", __func__, ha->host_no)); } }
/** * qla2x00_marker() - Send a marker IOCB to the firmware. * @ha: HA context * @loop_id: loop ID * @lun: LUN * @type: marker modifier * * Can be called from both normal and interrupt context. * * Returns non-zero if a failure occured, else zero. */ int __qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun, uint8_t type) { mrk_entry_t *pkt; pkt = (mrk_entry_t *)qla2x00_req_pkt(ha); if (pkt == NULL) { DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); return (QLA_FUNCTION_FAILED); } pkt->entry_type = MARKER_TYPE; pkt->modifier = type; if (type != MK_SYNC_ALL) { pkt->lun = cpu_to_le16(lun); SET_TARGET_ID(ha, pkt->target, loop_id); } /* Issue command to ISP */ qla2x00_isp_cmd(ha); return (QLA_SUCCESS); }
/** * qla24xx_mbx_completion() - Process mailbox command completions. * @ha: SCSI driver HA context * @mb0: Mailbox0 register */ static void qla24xx_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0) { uint16_t cnt; uint16_t __iomem *wptr; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; /* Load return mailbox registers. */ ha->flags.mbox_int = 1; ha->mailbox_out[0] = mb0; wptr = (uint16_t __iomem *)®->mailbox1; for (cnt = 1; cnt < ha->mbx_count; cnt++) { ha->mailbox_out[cnt] = RD_REG_WORD(wptr); wptr++; } if (ha->mcp) { DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", __func__, ha->host_no, ha->mcp->mb[0])); } else { DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", __func__, ha->host_no)); } }
/** * qla2x00_marker() - Send a marker IOCB to the firmware. * @ha: HA context * @loop_id: loop ID * @lun: LUN * @type: marker modifier * * Can be called from both normal and interrupt context. * * Returns non-zero if a failure occured, else zero. */ int __qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun, uint8_t type) { mrk_entry_t *mrk; struct mrk_entry_24xx *mrk24; mrk24 = NULL; mrk = (mrk_entry_t *)qla2x00_req_pkt(ha); if (mrk == NULL) { DEBUG2_3(printk("%s(%ld): failed to allocate Marker IOCB.\n", __func__, ha->host_no)); return (QLA_FUNCTION_FAILED); } mrk->entry_type = MARKER_TYPE; mrk->modifier = type; if (type != MK_SYNC_ALL) { if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { mrk24 = (struct mrk_entry_24xx *) mrk; mrk24->nport_handle = cpu_to_le16(loop_id); mrk24->lun[1] = LSB(lun); mrk24->lun[2] = MSB(lun); } else { SET_TARGET_ID(ha, mrk->target, loop_id); mrk->lun = cpu_to_le16(lun); } } wmb(); qla2x00_isp_cmd(ha); return (QLA_SUCCESS); }
/** * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. * HBA. * @ha: HA context * * This command uses the old Exectute SNS Command mailbox routine. * * Returns 0 on success. */ static int qla2x00_sns_rnn_id(scsi_qla_host_t *ha) { int rval; struct sns_cmd_pkt *sns_cmd; /* Issue RNN_ID. */ /* Prepare SNS command request. */ sns_cmd = qla2x00_prep_sns_cmd(ha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN, RNN_ID_SNS_DATA_SIZE); /* Prepare SNS command arguments -- port_id, nodename. */ sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa; sns_cmd->p.cmd.param[1] = ha->d_id.b.area; sns_cmd->p.cmd.param[2] = ha->d_id.b.domain; sns_cmd->p.cmd.param[4] = ha->init_cb->node_name[7]; sns_cmd->p.cmd.param[5] = ha->init_cb->node_name[6]; sns_cmd->p.cmd.param[6] = ha->init_cb->node_name[5]; sns_cmd->p.cmd.param[7] = ha->init_cb->node_name[4]; sns_cmd->p.cmd.param[8] = ha->init_cb->node_name[3]; sns_cmd->p.cmd.param[9] = ha->init_cb->node_name[2]; sns_cmd->p.cmd.param[10] = ha->init_cb->node_name[1]; sns_cmd->p.cmd.param[11] = ha->init_cb->node_name[0]; /* Execute SNS command. */ rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n", ha->host_no, rval)); } else if (sns_cmd->p.rnn_data[8] != 0x80 || sns_cmd->p.rnn_data[9] != 0x02) { DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, " "rnn_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16)); rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n", ha->host_no)); } return (rval); }
/** * qla2x00_req_pkt() - Retrieve a request packet from the request ring. * @ha: HA context * * Note: The caller must hold the hardware lock before calling this routine. * * Returns NULL if function failed, else, a pointer to the request packet. */ request_t * qla2x00_req_pkt(scsi_qla_host_t *ha) { device_reg_t *reg = ha->iobase; request_t *pkt = NULL; uint16_t cnt; uint32_t *dword_ptr; uint32_t timer; uint16_t req_cnt = 1; /* Wait 1 second for slot. */ for (timer = HZ; timer; timer--) { if ((req_cnt + 2) >= ha->req_q_cnt) { /* Calculate number of free request entries. */ cnt = qla2x00_debounce_register(ISP_REQ_Q_OUT(ha, reg)); if (ha->req_ring_index < cnt) ha->req_q_cnt = cnt - ha->req_ring_index; else ha->req_q_cnt = ha->request_q_length - (ha->req_ring_index - cnt); } /* If room for request in request ring. */ if ((req_cnt + 2) < ha->req_q_cnt) { ha->req_q_cnt--; pkt = ha->request_ring_ptr; /* Zero out packet. */ dword_ptr = (uint32_t *)pkt; for (cnt = 0; cnt < REQUEST_ENTRY_SIZE / 4; cnt++) *dword_ptr++ = 0; /* Set system defined field. */ pkt->sys_define = (uint8_t)ha->req_ring_index; /* Set entry count. */ pkt->entry_count = 1; break; } /* Release ring specific lock */ spin_unlock(&ha->hardware_lock); udelay(2); /* 2 us */ /* Check for pending interrupts. */ /* During init we issue marker directly */ if (!ha->marker_needed) qla2x00_poll(ha); spin_lock_irq(&ha->hardware_lock); } if (!pkt) { DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); } return (pkt); }
/** * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query. * @ha: HA context * @list: switch info entries to populate * * This command uses the old Exectute SNS Command mailbox routine. * * Returns 0 on success. */ static int qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; struct sns_cmd_pkt *sns_cmd; for (i = 0; i < MAX_FIBRE_DEVICES; i++) { /* Issue GPN_ID */ /* Prepare SNS command request. */ sns_cmd = qla2x00_prep_sns_cmd(ha, GPN_ID_CMD, GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE); /* Prepare SNS command arguments -- port_id. */ sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; /* Execute SNS command. */ rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed " "(%d).\n", ha->host_no, rval)); } else if (sns_cmd->p.gpn_data[8] != 0x80 || sns_cmd->p.gpn_data[9] != 0x02) { DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected " "request, gpn_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16)); rval = QLA_FUNCTION_FAILED; } else { /* Save portname */ memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16], WWN_SIZE); } /* Last device exit. */ if (list[i].d_id.b.rsvd_1 != 0) break; } return (rval); }
static int qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt, struct ct_sns_rsp *ct_rsp, const char *routine) { int rval; uint16_t comp_status; rval = QLA_FUNCTION_FAILED; if (ms_pkt->entry_status != 0) { DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n", ha->host_no, routine, ms_pkt->entry_status)); } else { if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) comp_status = ((struct ct_entry_24xx *)ms_pkt)->comp_status; else comp_status = le16_to_cpu(ms_pkt->status); switch (comp_status) { case CS_COMPLETE: case CS_DATA_UNDERRUN: case CS_DATA_OVERRUN: /* Overrun? */ if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): %s failed, " "rejected request:\n", ha->host_no, routine)); DEBUG2_3(qla2x00_dump_buffer( (uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); } else rval = QLA_SUCCESS; break; default: DEBUG2_3(printk("scsi(%ld): %s failed, completion " "status (%x).\n", ha->host_no, routine, comp_status)); break; } } return rval; }
/** * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query. * @ha: HA context * @list: switch info entries to populate * * Returns 0 on success. */ int qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_gpn_id(ha, list)); } for (i = 0; i < MAX_FIBRE_DEVICES; i++) { /* Issue GPN_ID */ /* Prepare common MS IOCB */ ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GPN_ID_REQ_SIZE, GPN_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, GPN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id */ ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed " "(%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GPN_ID") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { /* Save portname */ memcpy(list[i].port_name, ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); } /* Last device exit. */ if (list[i].d_id.b.rsvd_1 != 0) break; } return (rval); }
/** * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA. * @ha: HA context * * Returns 0 on success. */ int qla2x00_rff_id(scsi_qla_host_t *ha) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on " "ISP2100/ISP2200.\n", ha->host_no)); return (QLA_SUCCESS); } /* Issue RFF_ID */ /* Prepare common MS IOCB */ ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, RFF_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain; ct_req->req.rff_id.port_id[1] = ha->d_id.b.area; ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa; ct_req->req.rff_id.fc4_feature = BIT_1; ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFF_ID") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n", ha->host_no)); } return (rval); }
/** * qla2x00_fdmi_dhba() - * @ha: HA context * * Returns 0 on success. */ static int qla2x00_fdmi_dhba(scsi_qla_host_t *ha) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; /* Issue RPA */ /* Prepare common MS IOCB */ ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE, DHBA_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD, DHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- portname. */ memcpy(ct_req->req.dhba.port_name, ha->port_name, WWN_SIZE); DEBUG13(printk("%s(%ld): DHBA portname=" "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no, ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1], ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3], ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5], ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7])); /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "DHBA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n", ha->host_no)); } return rval; }
/** * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. * @ha: HA context * * Returns 0 on success. */ int qla2x00_rnn_id(scsi_qla_host_t *ha) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_rnn_id(ha)); } /* Issue RNN_ID */ /* Prepare common MS IOCB */ ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, RNN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id, node_name */ ct_req->req.rnn_id.port_id[0] = ha->d_id.b.domain; ct_req->req.rnn_id.port_id[1] = ha->d_id.b.area; ct_req->req.rnn_id.port_id[2] = ha->d_id.b.al_pa; memcpy(ct_req->req.rnn_id.node_name, ha->node_name, WWN_SIZE); /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RNN_ID") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n", ha->host_no)); } return (rval); }
/** * qla2x00_ms_req_pkt() - Retrieve a Management Server request packet from * the request ring. * @ha: HA context * @sp: pointer to handle post function call * * Note: The caller must hold the hardware lock before calling this routine. * * Returns NULL if function failed, else, a pointer to the request packet. */ request_t * qla2x00_ms_req_pkt(scsi_qla_host_t *ha, srb_t *sp) { device_reg_t *reg = ha->iobase; request_t *pkt = NULL; uint16_t cnt, i, index; uint32_t *dword_ptr; uint32_t timer; uint8_t found = 0; uint16_t req_cnt = 1; /* Wait 1 second for slot. */ for (timer = HZ; timer; timer--) { if ((req_cnt + 2) >= ha->req_q_cnt) { /* Calculate number of free request entries. */ cnt = qla2x00_debounce_register(ISP_REQ_Q_OUT(ha, reg)); if (ha->req_ring_index < cnt) { ha->req_q_cnt = cnt - ha->req_ring_index; } else { ha->req_q_cnt = ha->request_q_length - (ha->req_ring_index - cnt); } } /* Check for room in outstanding command list. */ cnt = ha->current_outstanding_cmd; for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { cnt++; if (cnt == MAX_OUTSTANDING_COMMANDS) cnt = 1; if (ha->outstanding_cmds[cnt] == 0) { found = 1; ha->current_outstanding_cmd = cnt; break; } } /* If room for request in request ring. */ if (found && (req_cnt + 2) < ha->req_q_cnt) { pkt = ha->request_ring_ptr; /* Zero out packet. */ dword_ptr = (uint32_t *)pkt; for (i = 0; i < REQUEST_ENTRY_SIZE / 4; i++ ) *dword_ptr++ = 0; DEBUG5(printk("%s(): putting sp=%p in " "outstanding_cmds[%x]\n", __func__, sp, cnt)); ha->outstanding_cmds[cnt] = sp; /* save the handle */ sp->cmd->host_scribble = (unsigned char *) (u_long) cnt; CMD_SP(sp->cmd) = (void *)sp; ha->req_q_cnt--; pkt->handle = (uint32_t)cnt; /* Set system defined field. */ pkt->sys_define = (uint8_t)ha->req_ring_index; pkt->entry_status = 0; break; } /* Release ring specific lock */ spin_unlock(&ha->hardware_lock); udelay(20); /* Check for pending interrupts. */ qla2x00_poll(ha); spin_lock_irq(&ha->hardware_lock); } if (!pkt) { DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); } return (pkt); }
/** * qla2x00_fdmi_rhba() - * @ha: HA context * * Returns 0 on success. */ static int qla2x00_fdmi_rhba(scsi_qla_host_t *ha) { int rval, alen; uint32_t size, sn; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_hba_attr *eiter; /* Issue RHBA */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, RHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ memcpy(ct_req->req.rhba.hba_identifier, ha->port_name, WWN_SIZE); ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); memcpy(ct_req->req.rhba.port_name, ha->port_name, WWN_SIZE); size = 2 * WWN_SIZE + 4 + 4; /* Attributes */ ct_req->req.rhba.attrs.count = __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); entries = ct_req->req.rhba.hba_identifier; /* Nodename. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); memcpy(eiter->a.node_name, ha->node_name, WWN_SIZE); size += 4 + WWN_SIZE; DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no, eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], eiter->a.node_name[6], eiter->a.node_name[7])); /* Manufacturer. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); strcpy(eiter->a.manufacturer, "QLogic Corporation"); alen = strlen(eiter->a.manufacturer); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, ha->host_no, eiter->a.manufacturer)); /* Serial number. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); alen = strlen(eiter->a.serial_num); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, ha->host_no, eiter->a.serial_num)); /* Model name. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); strcpy(eiter->a.model, ha->model_number); alen = strlen(eiter->a.model); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, ha->host_no, eiter->a.model)); /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); if (ha->model_desc) strncpy(eiter->a.model_desc, ha->model_desc, 80); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, ha->host_no, eiter->a.model_desc)); /* Hardware version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); strcpy(eiter->a.hw_version, ha->adapter_id); alen = strlen(eiter->a.hw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, ha->host_no, eiter->a.hw_version)); /* Driver version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION); strcpy(eiter->a.driver_version, qla2x00_version_str); alen = strlen(eiter->a.driver_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, ha->host_no, eiter->a.driver_version)); /* Option ROM version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); strcpy(eiter->a.orom_version, "0.00"); alen = strlen(eiter->a.orom_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, ha->host_no, eiter->a.orom_version)); /* Firmware version */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); ha->isp_ops.fw_version_str(ha, eiter->a.fw_version); alen = strlen(eiter->a.fw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, ha->host_no, eiter->a.fw_version)); /* Update MS request size. */ qla2x00_update_ms_fdmi_iocb(ha, size + 16); DEBUG13(printk("%s(%ld): RHBA identifier=" "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, ha->host_no, ct_req->req.rhba.hba_identifier[0], ct_req->req.rhba.hba_identifier[1], ct_req->req.rhba.hba_identifier[2], ct_req->req.rhba.hba_identifier[3], ct_req->req.rhba.hba_identifier[4], ct_req->req.rhba.hba_identifier[5], ct_req->req.rhba.hba_identifier[6], ct_req->req.rhba.hba_identifier[7], size)); DEBUG13(qla2x00_dump_buffer(entries, size)); /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RHBA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && ct_rsp->header.explanation_code == CT_EXPL_ALREADY_REGISTERED) { DEBUG2_13(printk("%s(%ld): HBA already registered.\n", __func__, ha->host_no)); rval = QLA_ALREADY_REGISTERED; } } else { DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n", ha->host_no)); } return rval; }
/** * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA. * @ha: HA context * * Returns 0 on success. */ int qla2x00_rsnn_nn(scsi_qla_host_t *ha) { int rval; uint8_t *snn; uint8_t version[20]; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on " "ISP2100/ISP2200.\n", ha->host_no)); return (QLA_SUCCESS); } /* Issue RSNN_NN */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = qla2x00_prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, RSNN_NN_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- node_name, symbolic node_name, size */ memcpy(ct_req->req.rsnn_nn.node_name, ha->init_cb->node_name, WWN_SIZE); /* Prepare the Symbolic Node Name */ /* Board type */ snn = ct_req->req.rsnn_nn.sym_node_name; strcpy(snn, ha->model_number); /* Firmware version */ strcat(snn, " FW:v"); sprintf(version, "%d.%02d.%02d", ha->fw_major_version, ha->fw_minor_version, ha->fw_subminor_version); strcat(snn, version); /* Driver version */ strcat(snn, " DVR:v"); strcat(snn, qla2x00_version_str); /* Calculate SNN length */ ct_req->req.rsnn_nn.name_len = (uint8_t)strlen(snn); /* Update MS IOCB request */ ms_pkt->req_bytecount = cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len); ms_pkt->dseg_req_length = ms_pkt->req_bytecount; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): RSNN_NN failed, rejected " "request, rsnn_id_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n", ha->host_no)); } return (rval); }
/** * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command. * @ha: HA context * @list: switch info entries to populate * * NOTE: Non-Nx_Ports are not requested. * * Returns 0 on success. */ int qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; struct ct_sns_gid_pt_data *gid_data; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_gid_pt(ha, list)); } gid_data = NULL; /* Issue GID_PT */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, GID_PT_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_type */ ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, " "gid_pt_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { /* Set port IDs in switch info list. */ for (i = 0; i < MAX_FIBRE_DEVICES; i++) { gid_data = &ct_rsp->rsp.gid_pt.entries[i]; list[i].d_id.b.domain = gid_data->port_id[0]; list[i].d_id.b.area = gid_data->port_id[1]; list[i].d_id.b.al_pa = gid_data->port_id[2]; /* Last one exit. */ if (gid_data->control_byte & BIT_7) { list[i].d_id.b.rsvd_1 = gid_data->control_byte; break; } } /* * If we've used all available slots, then the switch is * reporting back more devices than we can handle with this * single call. Return a failed status, and let GA_NXT handle * the overload. */ if (i == MAX_FIBRE_DEVICES) rval = QLA_FUNCTION_FAILED; } return (rval); }
/** * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command. * @ha: HA context * @fcport: fcport entry to updated * * Returns 0 on success. */ int qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_ga_nxt(ha, fcport)); } /* Issue GA_NXT */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, GA_NXT_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id */ ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain; ct_req->req.port_id.port_id[1] = fcport->d_id.b.area; ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, " "ga_nxt_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { /* Populate fc_port_t entry. */ fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0]; fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1]; fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2]; memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name, WWN_SIZE); memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name, WWN_SIZE); if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE && ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE) fcport->d_id.b.domain = 0xf0; DEBUG2_3(printk("scsi(%ld): GA_NXT entry - " "nn %02x%02x%02x%02x%02x%02x%02x%02x " "pn %02x%02x%02x%02x%02x%02x%02x%02x " "portid=%02x%02x%02x.\n", ha->host_no, fcport->node_name[0], fcport->node_name[1], fcport->node_name[2], fcport->node_name[3], fcport->node_name[4], fcport->node_name[5], fcport->node_name[6], fcport->node_name[7], fcport->port_name[0], fcport->port_name[1], fcport->port_name[2], fcport->port_name[3], fcport->port_name[4], fcport->port_name[5], fcport->port_name[6], fcport->port_name[7], fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa)); } return (rval); }
/** * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command. * @ha: HA context * @fcport: fcport entry to updated * * This command uses the old Exectute SNS Command mailbox routine. * * Returns 0 on success. */ static int qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) { int rval; struct sns_cmd_pkt *sns_cmd; /* Issue GA_NXT. */ /* Prepare SNS command request. */ sns_cmd = qla2x00_prep_sns_cmd(ha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN, GA_NXT_SNS_DATA_SIZE); /* Prepare SNS command arguments -- port_id. */ sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa; sns_cmd->p.cmd.param[1] = fcport->d_id.b.area; sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain; /* Execute SNS command. */ rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n", ha->host_no, rval)); } else if (sns_cmd->p.gan_data[8] != 0x80 || sns_cmd->p.gan_data[9] != 0x02) { DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, " "ga_nxt_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16)); rval = QLA_FUNCTION_FAILED; } else { /* Populate fc_port_t entry. */ fcport->d_id.b.domain = sns_cmd->p.gan_data[17]; fcport->d_id.b.area = sns_cmd->p.gan_data[18]; fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19]; memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE); memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE); if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE && sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE) fcport->d_id.b.domain = 0xf0; DEBUG2_3(printk("scsi(%ld): GA_NXT entry - " "nn %02x%02x%02x%02x%02x%02x%02x%02x " "pn %02x%02x%02x%02x%02x%02x%02x%02x " "portid=%02x%02x%02x.\n", ha->host_no, fcport->node_name[0], fcport->node_name[1], fcport->node_name[2], fcport->node_name[3], fcport->node_name[4], fcport->node_name[5], fcport->node_name[6], fcport->node_name[7], fcport->port_name[0], fcport->port_name[1], fcport->port_name[2], fcport->port_name[3], fcport->port_name[4], fcport->port_name[5], fcport->port_name[6], fcport->port_name[7], fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa)); } return (rval); }
/** * qla2x00_fdmi_rpa() - * @ha: HA context * * Returns 0 on success. */ static int qla2x00_fdmi_rpa(scsi_qla_host_t *ha) { int rval, alen; uint32_t size, max_frame_size; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_port_attr *eiter; struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; /* Issue RPA */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, RPA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ memcpy(ct_req->req.rpa.port_name, ha->port_name, WWN_SIZE); size = WWN_SIZE + 4; /* Attributes */ ct_req->req.rpa.attrs.count = __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); entries = ct_req->req.rpa.port_name; /* FC4 types. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES); eiter->len = __constant_cpu_to_be16(4 + 32); eiter->a.fc4_types[2] = 0x01; size += 4 + 32; DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__, ha->host_no, eiter->a.fc4_types[2], eiter->a.fc4_types[1])); /* Supported speed. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); eiter->len = __constant_cpu_to_be16(4 + 4); if (IS_QLA25XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32(4); else if (IS_QLA24XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32(8); else if (IS_QLA23XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32(2); else eiter->a.sup_speed = __constant_cpu_to_be32(1); size += 4 + 4; DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, eiter->a.sup_speed)); /* Current speed. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); eiter->len = __constant_cpu_to_be16(4 + 4); switch (ha->link_data_rate) { case 0: eiter->a.cur_speed = __constant_cpu_to_be32(1); break; case 1: eiter->a.cur_speed = __constant_cpu_to_be32(2); break; case 3: eiter->a.cur_speed = __constant_cpu_to_be32(8); break; case 4: eiter->a.cur_speed = __constant_cpu_to_be32(4); break; } size += 4 + 4; DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no, eiter->a.cur_speed)); /* Max frame size. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); eiter->len = __constant_cpu_to_be16(4 + 4); max_frame_size = IS_QLA24XX(ha) || IS_QLA25XX(ha) ? (uint32_t) icb24->frame_payload_size: (uint32_t) ha->init_cb->frame_payload_size; eiter->a.max_frame_size = cpu_to_be32(max_frame_size); size += 4 + 4; DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no, eiter->a.max_frame_size)); /* OS device name. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); sprintf(eiter->a.os_dev_name, "/proc/scsi/qla2xxx/%ld", ha->host_no); alen = strlen(eiter->a.os_dev_name); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no, eiter->a.os_dev_name)); /* Update MS request size. */ qla2x00_update_ms_fdmi_iocb(ha, size + 16); DEBUG13(printk("%s(%ld): RPA portname=" "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, ha->host_no, ct_req->req.rpa.port_name[0], ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], ct_req->req.rpa.port_name[7], size)); DEBUG13(qla2x00_dump_buffer(entries, size)); /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RPA exiting normally.\n", ha->host_no)); } return rval; }