qla_mbx.c

来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 2,453 行 · 第 1/4 页

C
2,453
字号
	if (HAS_EXTENDED_IDS(ha)) {		mcp->mb[1] = loop_id;		mcp->mb[10] = opt;		mcp->out_mb |= MBX_10;	} else {		mcp->mb[1] = (loop_id << 8) | opt;	}	mcp->mb[2] = domain;	mcp->mb[3] = area << 8 | al_pa;	mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0;	mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);	mcp->flags = 0;	rval = qla2x00_mailbox_command(ha, mcp);	/* Return mailbox statuses. */	if (mb != NULL) {		mb[0] = mcp->mb[0];		mb[1] = mcp->mb[1];		mb[2] = mcp->mb[2];		mb[6] = mcp->mb[6];		mb[7] = mcp->mb[7];	}	if (rval != QLA_SUCCESS) {		/* RLU tmp code: need to change main mailbox_command function to		 * return ok even when the mailbox completion value is not		 * SUCCESS. The caller needs to be responsible to interpret		 * the return values of this mailbox command if we're not		 * to change too much of the existing code.		 */		if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 ||		    mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 ||		    mcp->mb[0] == 0x4006)			rval = QLA_SUCCESS;		/*EMPTY*/		DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "		    "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha->host_no, rval,		    mcp->mb[0], mcp->mb[1], mcp->mb[2]);)	} else {		/*EMPTY*/		DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",		    ha->host_no);)	}	return rval;}/* * qla2x00_login_local_device *           Issue login loop port mailbox command. *     * Input: *           ha = adapter block pointer. *           loop_id = device loop ID. *           opt = command options. *           * Returns: *            Return status code. *              * Context: *            Kernel context. *              */intqla2x00_login_local_device(scsi_qla_host_t *ha, uint16_t loop_id,    uint16_t *mb_ret, uint8_t opt){	int rval;	mbx_cmd_t mc;	mbx_cmd_t *mcp = &mc;	DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no);)	mcp->mb[0] = MBC_LOGIN_LOOP_PORT;	if (HAS_EXTENDED_IDS(ha))		mcp->mb[1] = loop_id;	else		mcp->mb[1] = loop_id << 8;	mcp->mb[2] = opt;	mcp->out_mb = MBX_2|MBX_1|MBX_0; 	mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0;	mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);	mcp->flags = 0;	rval = qla2x00_mailbox_command(ha, mcp); 	/* Return mailbox statuses. */ 	if (mb_ret != NULL) { 		mb_ret[0] = mcp->mb[0]; 		mb_ret[1] = mcp->mb[1]; 		mb_ret[6] = mcp->mb[6]; 		mb_ret[7] = mcp->mb[7]; 	}	if (rval != QLA_SUCCESS) { 		/* AV tmp code: need to change main mailbox_command function to 		 * return ok even when the mailbox completion value is not 		 * SUCCESS. The caller needs to be responsible to interpret 		 * the return values of this mailbox command if we're not 		 * to change too much of the existing code. 		 */ 		if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) 			rval = QLA_SUCCESS;		DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "		    "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval,		    mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);)		DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "		    "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval,		    mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);)	} else {		/*EMPTY*/		DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no);)	}	return (rval);}/* * qla2x00_fabric_logout *	Issue logout fabric port mailbox command. * * Input: *	ha = adapter block pointer. *	loop_id = device loop ID. *	TARGET_QUEUE_LOCK must be released. *	ADAPTER_STATE_LOCK must be released. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id){	int rval;	mbx_cmd_t mc;	mbx_cmd_t *mcp = &mc;	DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",	    ha->host_no);)	mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;	mcp->out_mb = MBX_1|MBX_0;	if (HAS_EXTENDED_IDS(ha)) {		mcp->mb[1] = loop_id;		mcp->mb[10] = 0;		mcp->out_mb |= MBX_10;	} else {		mcp->mb[1] = loop_id << 8;	}	mcp->in_mb = MBX_1|MBX_0;	mcp->tov = 30;	mcp->flags = 0;	rval = qla2x00_mailbox_command(ha, mcp);	if (rval != QLA_SUCCESS) {		/*EMPTY*/		DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "		    "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1]);)	} else {		/*EMPTY*/		DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",		    ha->host_no);)	}	return rval;}/* * qla2x00_full_login_lip *	Issue full login LIP 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_full_login_lip(scsi_qla_host_t *ha){	int rval;	mbx_cmd_t mc;	mbx_cmd_t *mcp = &mc;	DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",	    ha->host_no);)	mcp->mb[0] = MBC_LIP_FULL_LOGIN;	mcp->mb[1] = 0;	mcp->mb[2] = 0;	mcp->mb[3] = 0;	mcp->out_mb = 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("qla2x00_full_login_lip(%ld): failed=%x.\n",		    ha->instance, rval);)	} else {		/*EMPTY*/		DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",		    ha->host_no);)	}	return rval;}/* * qla2x00_get_id_list * * Input: *	ha = adapter block pointer. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,    uint16_t *entries){	int rval;	mbx_cmd_t mc;	mbx_cmd_t *mcp = &mc;	DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",	    ha->host_no);)	if (id_list == NULL)		return QLA_FUNCTION_FAILED;	mcp->mb[0] = MBC_GET_ID_LIST;	mcp->mb[1] = MSW(id_list_dma);	mcp->mb[2] = LSW(id_list_dma);	mcp->mb[3] = MSW(MSD(id_list_dma));	mcp->mb[6] = LSW(MSD(id_list_dma));	mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;	mcp->in_mb = MBX_1|MBX_0;	mcp->tov = 30;	mcp->flags = 0;	rval = qla2x00_mailbox_command(ha, mcp);	if (rval != QLA_SUCCESS) {		/*EMPTY*/		DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",		    ha->host_no, rval);)	} else {		*entries = mcp->mb[1];		DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",		    ha->host_no);)	}	return rval;}/* * qla2x00_lun_reset *	Issue lun reset mailbox command. * * Input: *	ha = adapter block pointer. *	loop_id = device loop ID. *      lun = lun to be reset. *	TARGET_QUEUE_LOCK must be released. *	ADAPTER_STATE_LOCK must be released. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_lun_reset(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun){	int		rval;	mbx_cmd_t	mc;	mbx_cmd_t	*mcp = &mc;	mcp->mb[0] = MBC_LUN_RESET;	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);	if (rval != QLA_SUCCESS) {		/*EMPTY*/		printk(KERN_WARNING "qla2x00_lun_reset(%d): failed = %d",		    (int)ha->instance, rval);	} else {		/*EMPTY*/	}	return rval;}/* * qla2x00_send_rnid_mbx *	Issue RNID ELS using mailbox command * * Input: *	ha = adapter state pointer. *	loop_id = loop ID of the target device. *	data_fmt = currently supports only 0xDF. *	buffer = buffer pointer. *	buf_size = size of buffer. *	mb_reg = pointer to return mailbox registers. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_send_rnid_mbx(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t data_fmt,    dma_addr_t buf_phys_addr, size_t buf_size, uint16_t *mb_reg){	int		rval;	mbx_cmd_t	mc;	mbx_cmd_t	*mcp = &mc;	DEBUG11(printk("qla2x00_send_rnid_mbx(%ld): entered.\n",	    ha->host_no);)	mcp->mb[0] = MBC_SEND_RNID_ELS;	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;	if (HAS_EXTENDED_IDS(ha)) {		mcp->mb[1] = loop_id;		mcp->mb[10] = data_fmt;		mcp->out_mb |= MBX_10;	} else {		mcp->mb[1] = (loop_id << 8) | data_fmt;	}	mcp->mb[2] = MSW(buf_phys_addr);	mcp->mb[3] = LSW(buf_phys_addr);	mcp->mb[6] = MSW(MSD(buf_phys_addr));	mcp->mb[7] = LSW(MSD(buf_phys_addr));	mcp->in_mb = MBX_1|MBX_0;	mcp->buf_size = buf_size;	mcp->flags = MBX_DMA_IN;	mcp->tov = 30;	rval = qla2x00_mailbox_command(ha, mcp);	if (rval != QLA_SUCCESS) {		memcpy(mb_reg, mcp->mb, 2 * 2); /* 2 status regs */		DEBUG2_3_11(printk("qla2x00_send_rnid_mbx(%ld): failed=%x "		    "mb[1]=%x.\n",		    ha->host_no, mcp->mb[0], mcp->mb[1]);)	} else {		/*EMPTY*/	 	DEBUG11(printk("qla2x00_send_rnid_mbx(%ld): done.\n",		     ha->host_no);)	}	return (rval);}/* * qla2x00_set_rnid_params_mbx *	Set RNID parameters using mailbox command * * Input: *	ha = adapter state pointer. *	buffer = buffer pointer. *	buf_size = size of buffer. *	mb_reg = pointer to return mailbox registers. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_set_rnid_params_mbx(scsi_qla_host_t *ha, dma_addr_t buf_phys_addr,    size_t buf_size, uint16_t *mb_reg){	int		rval;	mbx_cmd_t	mc;	mbx_cmd_t	*mcp = &mc;	DEBUG11(printk("qla2x00_set_rnid_params_mbx(%ld): entered.\n",	    ha->host_no);)	mcp->mb[0] = MBC_SET_RNID_PARAMS;	mcp->mb[1] = 0;	mcp->mb[2] = MSW(buf_phys_addr);	mcp->mb[3] = LSW(buf_phys_addr);	mcp->mb[6] = MSW(MSD(buf_phys_addr));	mcp->mb[7] = LSW(MSD(buf_phys_addr));	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;	mcp->in_mb = MBX_1|MBX_0;	mcp->buf_size = buf_size;	mcp->flags = MBX_DMA_OUT;	mcp->tov = 30;	rval = qla2x00_mailbox_command(ha, mcp);	if (rval != QLA_SUCCESS) {		memcpy(mb_reg, mcp->mb, 2 * 2); /* 2 status regs */		DEBUG2_3_11(printk("qla2x00_set_rnid_params_mbx(%ld): "		    "failed=%x mb[1]=%x.\n", ha->host_no, mcp->mb[0],		    mcp->mb[1]);)	} else {		/*EMPTY*/		DEBUG11(printk("qla2x00_set_rnid_params_mbx(%ld): done.\n",		    ha->host_no);)	}	return (rval);}/* * qla2x00_get_rnid_params_mbx *	Get RNID parameters using mailbox command * * Input: *	ha = adapter state pointer. *	buffer = buffer pointer. *	buf_size = size of buffer. *	mb_reg = pointer to return mailbox registers. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_get_rnid_params_mbx(scsi_qla_host_t *ha, dma_addr_t buf_phys_addr,    size_t buf_size, uint16_t *mb_reg){	int		rval;	mbx_cmd_t	mc;	mbx_cmd_t	*mcp = &mc;	DEBUG11(printk("qla2x00_get_rnid_params_mbx(%ld): entered.\n",	    ha->host_no);)	mcp->mb[0] = MBC_GET_RNID_PARAMS;	mcp->mb[1] = 0;	mcp->mb[2] = MSW(buf_phys_addr);	mcp->mb[3] = LSW(buf_phys_addr);	mcp->mb[6] = MSW(MSD(buf_phys_addr));	mcp->mb[7] = LSW(MSD(buf_phys_addr));	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;	mcp->in_mb = MBX_1|MBX_0;	mcp->buf_size = buf_size;	mcp->flags = MBX_DMA_IN;	mcp->tov = 30;	rval = qla2x00_mailbox_command(ha, mcp);	if (rval != QLA_SUCCESS) {		memcpy(mb_reg, mcp->mb, 2 * 2); /* 2 status regs */		DEBUG2_3_11(printk("qla2x00_get_rnid_params_mbx(%ld): "		    "failed=%x mb[1]=%x.\n", ha->host_no, mcp->mb[0],		    mcp->mb[1]);)	} else {		/*EMPTY*/		DEBUG11(printk("qla2x00_get_rnid_params_mbx(%ld): done.\n",		    ha->host_no);)	}	return (rval);}/* * qla2x00_get_resource_cnts *	Get current firmware resource counts. * * Input: *	ha = adapter block pointer. * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,    uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, uint16_t *orig_iocb_cnt){	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_GET_RESOURCE_COUNTS;	mcp->out_mb = MBX_0;	mcp->in_mb = MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|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, mcp->mb[0]);)	} else {		DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "		    "mb7=%x mb10=%x.\n", __func__, ha->host_no,		    mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7], 		    mcp->mb[10]));		if (cur_xchg_cnt)			*cur_xchg_cnt = mcp->mb[3];		if (orig_xchg_cnt)			*orig_xchg_cnt = mcp->mb[6];		if (cur_iocb_cnt)			*cur_iocb_cnt = mcp->mb[7];		if (orig_iocb_cnt)			*orig_iocb_cnt = mcp->mb[10];	}	return (rval);}#if defined(QL_DEBUG_LEVEL_3)/* * qla2x00_get_fcal_position_map *	Get FCAL (LILP) position map using mailbox command * * Input: *	ha = adapter state pointer. *	pos_map = buffer pointer (can be NULL). * * Returns: *	qla2x00 local function return status code. * * Context: *	Kernel context. */intqla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map){	int rval;	mbx_cmd_t mc;	mbx_cmd_t *mcp = &mc;	char *pmap;	dma_addr_t pmap_dma;	pmap = pci_alloc_consistent(ha->pdev, FCAL_MAP_SIZE, &pmap_dma);	if (pmap  == NULL) {		DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",		    __func__, ha->host_no));		return QLA_MEMORY_ALLOC_FAILED;	}	memset(pmap, 0, FCAL_MAP_SIZE);	mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP;	mcp->mb[2] = MSW(pmap_dma);	mcp->mb[3] = LSW(pmap_dma);	mcp->mb[6] = MSW(MSD(pmap_dma));	mcp->mb[7] = LSW(MSD(pmap_dma));	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;	mcp->in_mb = MBX_1|MBX_0;	mcp->buf_size = FCAL_MAP_SIZE;	mcp->flags = MBX_DMA_IN;	mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);	rval = qla2x00_mailbox_command(ha, mcp);	if (rval == QLA_SUCCESS) {		DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "		    "size (%x)\n", __func__, ha->host_no, mcp->mb[0],		    mcp->mb[1], (unsigned)pmap[0]));		DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1));		if (pos_map)			memcpy(pos_map, pmap, FCAL_MAP_SIZE);	}	pci_free_consistent(ha->pdev, FCAL_MAP_SIZE, pmap, pmap_dma);	if (rval != QLA_SUCCESS) {		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,		    ha->host_no, rval));	} else {		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));	}	return rval;}#endif

⌨️ 快捷键说明

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