4 * Copyright (C) 2004 - 2009 Vladislav Bolkhovitin <vst@vlnb.net>
5 * Copyright (C) 2004 - 2005 Leonid Stoljar
6 * Copyright (C) 2006 Nathaniel Clark <nate@misrule.us>
7 * Copyright (C) 2007 - 2009 ID7 Ltd.
9 * Additional file for the target driver support.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
22 * This should be included only from within qla2xxx module.
29 extern request_t *qla2x00_req_pkt(scsi_qla_host_t *ha);
31 #ifdef CONFIG_SCSI_QLA2XXX_TARGET
33 #include "qla2x_tgt_def.h"
35 extern struct qla_tgt_data qla_target;
37 /* Called under HW lock */
38 static inline void qla_set_tgt_mode(scsi_qla_host_t *ha)
40 #ifdef CONFIG_SCSI_QLA2XXX_TARGET_DISABLE_INI_MODE
41 ha->host->active_mode = MODE_TARGET;
43 ha->host->active_mode |= MODE_TARGET;
47 /* Called under HW lock */
48 static inline void qla_clear_tgt_mode(scsi_qla_host_t *ha)
50 #ifdef CONFIG_SCSI_QLA2XXX_TARGET_DISABLE_INI_MODE
51 ha->host->active_mode = MODE_INITIATOR;
53 ha->host->active_mode &= ~MODE_TARGET;
57 static inline bool qla_tgt_mode_enabled(scsi_qla_host_t *ha)
59 return ha->host->active_mode & MODE_TARGET;
62 /********************************************************************\
63 * ISP Queue types left out of new QLogic driver (from old version)
64 \********************************************************************/
67 * qla2x00_do_en_dis_lun
68 * Issue enable or disable LUN entry IOCB.
71 * ha = adapter block pointer.
73 * Caller MUST have hardware lock held. This function might release it,
77 __qla2x00_send_enable_lun(scsi_qla_host_t *ha, int enable)
81 BUG_ON(IS_FWI2_CAPABLE(ha));
83 pkt = (elun_entry_t *)qla2x00_req_pkt(ha);
85 pkt->entry_type = ENABLE_LUN_TYPE;
87 pkt->command_count = QLA2X00_COMMAND_COUNT_INIT;
88 pkt->immed_notify_count = QLA2X00_IMMED_NOTIFY_COUNT_INIT;
89 pkt->timeout = 0xffff;
91 pkt->command_count = 0;
92 pkt->immed_notify_count = 0;
95 DEBUG2(printk(KERN_DEBUG
96 "scsi%lu:ENABLE_LUN IOCB imm %u cmd %u timeout %u\n",
97 ha->host_no, pkt->immed_notify_count,
98 pkt->command_count, pkt->timeout));
100 /* Issue command to ISP */
104 qla_clear_tgt_mode(ha);
105 #if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3)
107 printk("%s: **** FAILED ****\n", __func__);
114 * qla2x00_send_enable_lun
115 * Issue enable LUN entry IOCB.
118 * ha = adapter block pointer.
119 * enable = enable/disable flag.
122 qla2x00_send_enable_lun(scsi_qla_host_t *ha, bool enable)
124 if (!IS_FWI2_CAPABLE(ha)) {
126 spin_lock_irqsave(&ha->hardware_lock, flags);
127 __qla2x00_send_enable_lun(ha, enable);
128 spin_unlock_irqrestore(&ha->hardware_lock, flags);
132 extern void qla2xxx_add_targets(void);
134 #endif /* CONFIG_SCSI_QLA2XXX_TARGET */
136 #endif /* __QLA2X_TGT_H */