aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_inline.h
diff options
context:
space:
mode:
authorGiridhar Malavali <giridhar.malavali@qlogic.com>2012-02-09 14:15:36 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-19 09:14:08 -0500
commit9ba56b95a588906a65664a9299a9f8ac1a0f6a91 (patch)
tree93786c52320c2a7276c99cc4d9b3672ca6e0a50d /drivers/scsi/qla2xxx/qla_inline.h
parent69e5f1ea61a3e84c03103c6a18ee9cacef4cbb9e (diff)
[SCSI] qla2xxx: Consolidation of SRB processing.
Rework the structures related to SRB processing to minimize the memory allocations per I/O and manage resources associated with and completions from common routines. Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_inline.h')
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 7cc4f36cd539..3ea0cedc6e77 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -72,16 +72,19 @@ static inline void
72qla2x00_clean_dsd_pool(struct qla_hw_data *ha, srb_t *sp) 72qla2x00_clean_dsd_pool(struct qla_hw_data *ha, srb_t *sp)
73{ 73{
74 struct dsd_dma *dsd_ptr, *tdsd_ptr; 74 struct dsd_dma *dsd_ptr, *tdsd_ptr;
75 struct crc_context *ctx;
76
77 ctx = (struct crc_context *)GET_CMD_CTX_SP(sp);
75 78
76 /* clean up allocated prev pool */ 79 /* clean up allocated prev pool */
77 list_for_each_entry_safe(dsd_ptr, tdsd_ptr, 80 list_for_each_entry_safe(dsd_ptr, tdsd_ptr,
78 &((struct crc_context *)sp->ctx)->dsd_list, list) { 81 &ctx->dsd_list, list) {
79 dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr, 82 dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr,
80 dsd_ptr->dsd_list_dma); 83 dsd_ptr->dsd_list_dma);
81 list_del(&dsd_ptr->list); 84 list_del(&dsd_ptr->list);
82 kfree(dsd_ptr); 85 kfree(dsd_ptr);
83 } 86 }
84 INIT_LIST_HEAD(&((struct crc_context *)sp->ctx)->dsd_list); 87 INIT_LIST_HEAD(&ctx->dsd_list);
85} 88}
86 89
87static inline void 90static inline void
@@ -113,8 +116,7 @@ qla2x00_hba_err_chk_enabled(srb_t *sp)
113 return 0; 116 return 0;
114 * 117 *
115 */ 118 */
116 119 switch (scsi_get_prot_op(GET_CMD_SP(sp))) {
117 switch (scsi_get_prot_op(sp->cmd)) {
118 case SCSI_PROT_READ_STRIP: 120 case SCSI_PROT_READ_STRIP:
119 case SCSI_PROT_WRITE_INSERT: 121 case SCSI_PROT_WRITE_INSERT:
120 if (ql2xenablehba_err_chk >= 1) 122 if (ql2xenablehba_err_chk >= 1)
@@ -144,3 +146,38 @@ qla2x00_reset_active(scsi_qla_host_t *vha)
144 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || 146 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
145 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); 147 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
146} 148}
149
150static inline srb_t *
151qla2x00_get_sp(scsi_qla_host_t *vha, fc_port_t *fcport, gfp_t flag)
152{
153 srb_t *sp = NULL;
154 struct qla_hw_data *ha = vha->hw;
155 uint8_t bail;
156
157 QLA_VHA_MARK_BUSY(vha, bail);
158 if (unlikely(bail))
159 return NULL;
160
161 sp = mempool_alloc(ha->srb_mempool, flag);
162 if (!sp)
163 goto done;
164
165 memset(sp, 0, sizeof(*sp));
166 sp->fcport = fcport;
167 sp->iocbs = 1;
168done:
169 if (!sp)
170 QLA_VHA_MARK_NOT_BUSY(vha);
171 return sp;
172}
173
174static inline void
175qla2x00_init_timer(srb_t *sp, unsigned long tmo)
176{
177 init_timer(&sp->u.iocb_cmd.timer);
178 sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ;
179 sp->u.iocb_cmd.timer.data = (unsigned long)sp;
180 sp->u.iocb_cmd.timer.function = qla2x00_sp_timeout;
181 add_timer(&sp->u.iocb_cmd.timer);
182 sp->free = qla2x00_sp_free;
183}