blob: 655b7bb644d9bc1ad93d5794a708ae2ad610aca1 [file] [log] [blame]
David Somayajuluafaf5a22006-09-19 10:28:00 -07001/*
2 * QLogic iSCSI HBA Driver
Vikas Chaudhary4a4f51e2013-08-16 07:03:04 -04003 * Copyright (c) 2003-2013 QLogic Corporation
David Somayajuluafaf5a22006-09-19 10:28:00 -07004 *
5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */
7
8/*
9 *
10 * qla4xxx_lookup_ddb_by_fw_index
11 * This routine locates a device handle given the firmware device
12 * database index. If device doesn't exist, returns NULL.
13 *
14 * Input:
15 * ha - Pointer to host adapter structure.
16 * fw_ddb_index - Firmware's device database index
17 *
18 * Returns:
19 * Pointer to the corresponding internal device database structure
20 */
21static inline struct ddb_entry *
22qla4xxx_lookup_ddb_by_fw_index(struct scsi_qla_host *ha, uint32_t fw_ddb_index)
23{
24 struct ddb_entry *ddb_entry = NULL;
25
26 if ((fw_ddb_index < MAX_DDB_ENTRIES) &&
27 (ha->fw_ddb_index_map[fw_ddb_index] !=
28 (struct ddb_entry *) INVALID_ENTRY)) {
29 ddb_entry = ha->fw_ddb_index_map[fw_ddb_index];
30 }
31
Vikas Chaudharyf4f5df232010-07-28 15:53:44 +053032 DEBUG3(printk("scsi%d: %s: ddb [%d], ddb_entry = %p\n",
David Somayajuluafaf5a22006-09-19 10:28:00 -070033 ha->host_no, __func__, fw_ddb_index, ddb_entry));
34
35 return ddb_entry;
36}
37
38static inline void
39__qla4xxx_enable_intrs(struct scsi_qla_host *ha)
40{
David C Somayajulud9150582006-11-15 17:38:40 -080041 if (is_qla4022(ha) | is_qla4032(ha)) {
David Somayajuluafaf5a22006-09-19 10:28:00 -070042 writel(set_rmask(IMR_SCSI_INTR_ENABLE),
43 &ha->reg->u1.isp4022.intr_mask);
44 readl(&ha->reg->u1.isp4022.intr_mask);
45 } else {
46 writel(set_rmask(CSR_SCSI_INTR_ENABLE), &ha->reg->ctrl_status);
47 readl(&ha->reg->ctrl_status);
48 }
49 set_bit(AF_INTERRUPTS_ON, &ha->flags);
50}
51
52static inline void
53__qla4xxx_disable_intrs(struct scsi_qla_host *ha)
54{
David C Somayajulud9150582006-11-15 17:38:40 -080055 if (is_qla4022(ha) | is_qla4032(ha)) {
David Somayajuluafaf5a22006-09-19 10:28:00 -070056 writel(clr_rmask(IMR_SCSI_INTR_ENABLE),
57 &ha->reg->u1.isp4022.intr_mask);
58 readl(&ha->reg->u1.isp4022.intr_mask);
59 } else {
60 writel(clr_rmask(CSR_SCSI_INTR_ENABLE), &ha->reg->ctrl_status);
61 readl(&ha->reg->ctrl_status);
62 }
63 clear_bit(AF_INTERRUPTS_ON, &ha->flags);
64}
65
66static inline void
67qla4xxx_enable_intrs(struct scsi_qla_host *ha)
68{
69 unsigned long flags;
70
71 spin_lock_irqsave(&ha->hardware_lock, flags);
72 __qla4xxx_enable_intrs(ha);
73 spin_unlock_irqrestore(&ha->hardware_lock, flags);
74}
75
76static inline void
77qla4xxx_disable_intrs(struct scsi_qla_host *ha)
78{
79 unsigned long flags;
80
81 spin_lock_irqsave(&ha->hardware_lock, flags);
82 __qla4xxx_disable_intrs(ha);
83 spin_unlock_irqrestore(&ha->hardware_lock, flags);
84}
Adheer Chandravanshi26ffd7b2013-09-17 07:54:49 -040085
86static inline int qla4xxx_get_chap_type(struct ql4_chap_table *chap_entry)
87{
88 int type;
89
90 if (chap_entry->flags & BIT_7)
91 type = LOCAL_CHAP;
92 else
93 type = BIDI_CHAP;
94
95 return type;
96}