2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
18 #ifndef __BFA_HCB_IOIM_H__
19 #define __BFA_HCB_IOIM_H__
21 #include "bfa_os_inc.h"
23 * task attribute values in FCP-2 FCP_CMND IU
32 bfad_int_to_lun(u32 luno)
40 lun.scsi_lun[0] = bfa_os_htons(luno);
46 * Get LUN for the I/O request
48 #define bfa_cb_ioim_get_lun(__dio) \
49 bfad_int_to_lun(((struct scsi_cmnd *)__dio)->device->lun)
52 * Get CDB for the I/O request
55 bfa_cb_ioim_get_cdb(struct bfad_ioim_s *dio)
57 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
59 return (u8 *) cmnd->cmnd;
63 * Get I/O direction (read/write) for the I/O request
65 static inline enum fcp_iodir
66 bfa_cb_ioim_get_iodir(struct bfad_ioim_s *dio)
68 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
69 enum dma_data_direction dmadir;
71 dmadir = cmnd->sc_data_direction;
72 if (dmadir == DMA_TO_DEVICE)
73 return FCP_IODIR_WRITE;
74 else if (dmadir == DMA_FROM_DEVICE)
75 return FCP_IODIR_READ;
77 return FCP_IODIR_NONE;
81 * Get IO size in bytes for the I/O request
84 bfa_cb_ioim_get_size(struct bfad_ioim_s *dio)
86 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
88 return scsi_bufflen(cmnd);
92 * Get timeout for the I/O request
95 bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio)
97 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
99 * TBD: need a timeout for scsi passthru
101 if (cmnd->device->host == NULL)
108 * Get Command Reference Number for the I/O request. 0 if none.
111 bfa_cb_ioim_get_crn(struct bfad_ioim_s *dio)
117 * Get SAM-3 priority for the I/O request. 0 is default.
120 bfa_cb_ioim_get_priority(struct bfad_ioim_s *dio)
126 * Get task attributes for the I/O request. Default is FCP_TASK_ATTR_SIMPLE(0).
129 bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio)
131 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
132 u8 task_attr = UNTAGGED;
134 if (cmnd->device->tagged_supported) {
136 case HEAD_OF_QUEUE_TAG:
137 task_attr = HEAD_OF_Q;
139 case ORDERED_QUEUE_TAG:
140 task_attr = ORDERED_Q;
143 task_attr = SIMPLE_Q;
152 * Get CDB length in bytes for the I/O request. Default is FCP_CMND_CDB_LEN(16).
155 bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio)
157 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
159 return cmnd->cmd_len;
163 * Assign queue to be used for the I/O request. This value depends on whether
164 * the driver wants to use the queues via any specific algorithm. Currently,
165 * this is not supported.
167 #define bfa_cb_ioim_get_reqq(__dio) BFA_FALSE
169 #endif /* __BFA_HCB_IOIM_H__ */