⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qla_gs.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 4 页
字号:
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_fdmi_dhba() - * @ha: HA context * * Returns 0 on success. */static intqla2x00_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_fdmi_rpa() - * @ha: HA context * * Returns 0 on success. */static intqla2x00_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;}/** * qla2x00_fdmi_register() - * @ha: HA context * * Returns 0 on success. */intqla2x00_fdmi_register(scsi_qla_host_t *ha){	int rval;	rval = qla2x00_mgmt_svr_login(ha);	if (rval)		return rval;	rval = qla2x00_fdmi_rhba(ha);	if (rval) {		if (rval != QLA_ALREADY_REGISTERED)			return rval;		rval = qla2x00_fdmi_dhba(ha);		if (rval)			return rval;		rval = qla2x00_fdmi_rhba(ha);		if (rval)			return rval;	}	rval = qla2x00_fdmi_rpa(ha);	return rval;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -