| 
									
										
										
										
											2006-09-19 10:28:00 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QLogic iSCSI HBA Driver | 
					
						
							| 
									
										
										
										
											2013-08-16 07:03:04 -04:00
										 |  |  |  * Copyright (c)  2003-2013 QLogic Corporation | 
					
						
							| 
									
										
										
										
											2006-09-19 10:28:00 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * See LICENSE.qla4xxx for copyright and licensing details. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * qla4xxx_lookup_ddb_by_fw_index | 
					
						
							|  |  |  |  *	This routine locates a device handle given the firmware device | 
					
						
							|  |  |  |  *	database index.	 If device doesn't exist, returns NULL. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Input: | 
					
						
							|  |  |  |  *	ha - Pointer to host adapter structure. | 
					
						
							|  |  |  |  *	fw_ddb_index - Firmware's device database index | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns: | 
					
						
							|  |  |  |  *	Pointer to the corresponding internal device database structure | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static inline struct ddb_entry * | 
					
						
							|  |  |  | qla4xxx_lookup_ddb_by_fw_index(struct scsi_qla_host *ha, uint32_t fw_ddb_index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct ddb_entry *ddb_entry = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ((fw_ddb_index < MAX_DDB_ENTRIES) && | 
					
						
							|  |  |  | 	    (ha->fw_ddb_index_map[fw_ddb_index] != | 
					
						
							|  |  |  | 		(struct ddb_entry *) INVALID_ENTRY)) { | 
					
						
							|  |  |  | 		ddb_entry = ha->fw_ddb_index_map[fw_ddb_index]; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-28 15:53:44 +05:30
										 |  |  | 	DEBUG3(printk("scsi%d: %s: ddb [%d], ddb_entry = %p\n", | 
					
						
							| 
									
										
										
										
											2006-09-19 10:28:00 -07:00
										 |  |  | 	    ha->host_no, __func__, fw_ddb_index, ddb_entry)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ddb_entry; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void | 
					
						
							|  |  |  | __qla4xxx_enable_intrs(struct scsi_qla_host *ha) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2006-11-15 17:38:40 -08:00
										 |  |  | 	if (is_qla4022(ha) | is_qla4032(ha)) { | 
					
						
							| 
									
										
										
										
											2006-09-19 10:28:00 -07:00
										 |  |  | 		writel(set_rmask(IMR_SCSI_INTR_ENABLE), | 
					
						
							|  |  |  | 		       &ha->reg->u1.isp4022.intr_mask); | 
					
						
							|  |  |  | 		readl(&ha->reg->u1.isp4022.intr_mask); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		writel(set_rmask(CSR_SCSI_INTR_ENABLE), &ha->reg->ctrl_status); | 
					
						
							|  |  |  | 		readl(&ha->reg->ctrl_status); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	set_bit(AF_INTERRUPTS_ON, &ha->flags); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void | 
					
						
							|  |  |  | __qla4xxx_disable_intrs(struct scsi_qla_host *ha) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2006-11-15 17:38:40 -08:00
										 |  |  | 	if (is_qla4022(ha) | is_qla4032(ha)) { | 
					
						
							| 
									
										
										
										
											2006-09-19 10:28:00 -07:00
										 |  |  | 		writel(clr_rmask(IMR_SCSI_INTR_ENABLE), | 
					
						
							|  |  |  | 		       &ha->reg->u1.isp4022.intr_mask); | 
					
						
							|  |  |  | 		readl(&ha->reg->u1.isp4022.intr_mask); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		writel(clr_rmask(CSR_SCSI_INTR_ENABLE), &ha->reg->ctrl_status); | 
					
						
							|  |  |  | 		readl(&ha->reg->ctrl_status); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	clear_bit(AF_INTERRUPTS_ON, &ha->flags); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void | 
					
						
							|  |  |  | qla4xxx_enable_intrs(struct scsi_qla_host *ha) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned long flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	spin_lock_irqsave(&ha->hardware_lock, flags); | 
					
						
							|  |  |  | 	__qla4xxx_enable_intrs(ha); | 
					
						
							|  |  |  | 	spin_unlock_irqrestore(&ha->hardware_lock, flags); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void | 
					
						
							|  |  |  | qla4xxx_disable_intrs(struct scsi_qla_host *ha) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned long flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	spin_lock_irqsave(&ha->hardware_lock, flags); | 
					
						
							|  |  |  | 	__qla4xxx_disable_intrs(ha); | 
					
						
							|  |  |  | 	spin_unlock_irqrestore(&ha->hardware_lock, flags); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-09-17 07:54:49 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static inline int qla4xxx_get_chap_type(struct ql4_chap_table *chap_entry) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (chap_entry->flags & BIT_7) | 
					
						
							|  |  |  | 		type = LOCAL_CHAP; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		type = BIDI_CHAP; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return type; | 
					
						
							|  |  |  | } |