/* Set the lun if we were able to pull it from the device's unit directory */ if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); SBP2_DEBUG("sbp2_query_logins: set lun to %d", ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun)); } 
scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); 
static int sbp2_login_device(struct scsi_id_instance_data *scsi_id){	struct sbp2scsi_host_info *hi = scsi_id->hi;	quadlet_t data[2];	SBP2_DEBUG("sbp2_login_device");	if (!scsi_id->login_orb) {		SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!");		return(-EIO);	}	if (!exclusive_login) {		if (sbp2_query_logins(scsi_id)) {			SBP2_INFO("Device does not support any more concurrent logins");			return(-EIO);		}	}	/* Set-up login ORB, assume no password */	scsi_id->login_orb->password_hi = 0;	scsi_id->login_orb->password_lo = 0;	SBP2_DEBUG("sbp2_login_device: password_hi/lo initialized");	scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma;	scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);	SBP2_DEBUG("sbp2_login_device: login_response_hi/lo initialized");	scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);	scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0);	/* One second reconnect time */	scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login);	/* Exclusive access to device */	scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1);	/* Notify us of login complete */	/* Set the lun if we were able to pull it from the device's unit directory */	if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) {		scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun);		SBP2_DEBUG("sbp2_query_logins: set lun to %d",			   ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun));	}	SBP2_DEBUG("sbp2_login_device: lun_misc initialized");	scsi_id->login_orb->passwd_resp_lengths =		ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response));	SBP2_DEBUG("sbp2_login_device: passwd_resp_lengths initialized");	scsi_id->login_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO +					     SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id);	scsi_id->login_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) |					      SBP2_STATUS_FIFO_ADDRESS_HI);	SBP2_DEBUG("sbp2_login_device: status FIFO initialized");	/*	 * Byte swap ORB if necessary	 */	sbp2util_cpu_to_be32_buffer(scsi_id->login_orb, sizeof(struct sbp2_login_orb));	SBP2_DEBUG("sbp2_login_device: orb byte-swapped");	sbp2util_packet_dump(scsi_id->login_orb, sizeof(struct sbp2_login_orb),			     "sbp2 login orb", scsi_id->login_orb_dma);	/*	 * Initialize login response and status fifo	 */	memset(scsi_id->login_response, 0, sizeof(struct sbp2_login_response));	memset(&scsi_id->status_block, 0, sizeof(struct sbp2_status_block));	SBP2_DEBUG("sbp2_login_device: login_response/status FIFO memset");	/*	 * Ok, let's write to the target's management agent register	 */	data[0] = ORB_SET_NODE_ID(hi->host->node_id);	data[1] = scsi_id->login_orb_dma;	sbp2util_cpu_to_be32_buffer(data, 8);	atomic_set(&scsi_id->sbp2_login_complete, 0);	SBP2_DEBUG("sbp2_login_device: prepared to write to %08x",		   (unsigned int)scsi_id->sbp2_management_agent_addr);	hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8);	SBP2_DEBUG("sbp2_login_device: written");	/*	 * Wait for login status (up to 20 seconds)...	 */	if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) {		SBP2_ERR("Error logging into SBP-2 device - login timed-out");		return(-EIO);	}	/*	 * Sanity. Make sure status returned matches login orb.	 */	if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {		SBP2_ERR("Error logging into SBP-2 device - login timed-out");		return(-EIO);	}	/*	 * Check status	 */	if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) ||	    STATUS_GET_DEAD_BIT(scsi_id->status_block.ORB_offset_hi_misc) ||	    STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {		SBP2_ERR("Error logging into SBP-2 device - login failed");		return(-EIO);	}	/*	 * Byte swap the login response, for use when reconnecting or	 * logging out.	 */	sbp2util_cpu_to_be32_buffer(scsi_id->login_response, sizeof(struct sbp2_login_response));	/*	 * Grab our command block agent address from the login response.	 */	SBP2_DEBUG("command_block_agent_hi = %x",		   (unsigned int)scsi_id->login_response->command_block_agent_hi);	SBP2_DEBUG("command_block_agent_lo = %x",		   (unsigned int)scsi_id->login_response->command_block_agent_lo);	scsi_id->sbp2_command_block_agent_addr =		((u64)scsi_id->login_response->command_block_agent_hi) << 32;	scsi_id->sbp2_command_block_agent_addr |= ((u64)scsi_id->login_response->command_block_agent_lo);	scsi_id->sbp2_command_block_agent_addr &= 0x0000ffffffffffffULL;	SBP2_INFO("Logged into SBP-2 device");	return(0);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e309fc6d71d61bb0f049ab6d0da10c845da9513f/sbp2.c/clean/drivers/ieee1394/sbp2.c