diff options
Diffstat (limited to 'drivers/scsi/bfa/bfa_cb_ioim.h')
-rw-r--r-- | drivers/scsi/bfa/bfa_cb_ioim.h | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfa_cb_ioim.h b/drivers/scsi/bfa/bfa_cb_ioim.h new file mode 100644 index 000000000000..a989a94c38da --- /dev/null +++ b/drivers/scsi/bfa/bfa_cb_ioim.h | |||
@@ -0,0 +1,169 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. | ||
3 | * All rights reserved | ||
4 | * www.brocade.com | ||
5 | * | ||
6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. | ||
7 | * | ||
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 | ||
11 | * | ||
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. | ||
16 | */ | ||
17 | |||
18 | #ifndef __BFA_HCB_IOIM_H__ | ||
19 | #define __BFA_HCB_IOIM_H__ | ||
20 | |||
21 | #include "bfa_os_inc.h" | ||
22 | /* | ||
23 | * task attribute values in FCP-2 FCP_CMND IU | ||
24 | */ | ||
25 | #define SIMPLE_Q 0 | ||
26 | #define HEAD_OF_Q 1 | ||
27 | #define ORDERED_Q 2 | ||
28 | #define ACA_Q 4 | ||
29 | #define UNTAGGED 5 | ||
30 | |||
31 | static inline lun_t | ||
32 | bfad_int_to_lun(u32 luno) | ||
33 | { | ||
34 | union { | ||
35 | u16 scsi_lun[4]; | ||
36 | lun_t bfa_lun; | ||
37 | } lun; | ||
38 | |||
39 | lun.bfa_lun = 0; | ||
40 | lun.scsi_lun[0] = bfa_os_htons(luno); | ||
41 | |||
42 | return lun.bfa_lun; | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * Get LUN for the I/O request | ||
47 | */ | ||
48 | #define bfa_cb_ioim_get_lun(__dio) \ | ||
49 | bfad_int_to_lun(((struct scsi_cmnd *)__dio)->device->lun) | ||
50 | |||
51 | /** | ||
52 | * Get CDB for the I/O request | ||
53 | */ | ||
54 | static inline u8 * | ||
55 | bfa_cb_ioim_get_cdb(struct bfad_ioim_s *dio) | ||
56 | { | ||
57 | struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; | ||
58 | |||
59 | return (u8 *) cmnd->cmnd; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Get I/O direction (read/write) for the I/O request | ||
64 | */ | ||
65 | static inline enum fcp_iodir | ||
66 | bfa_cb_ioim_get_iodir(struct bfad_ioim_s *dio) | ||
67 | { | ||
68 | struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; | ||
69 | enum dma_data_direction dmadir; | ||
70 | |||
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; | ||
76 | else | ||
77 | return FCP_IODIR_NONE; | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * Get IO size in bytes for the I/O request | ||
82 | */ | ||
83 | static inline u32 | ||
84 | bfa_cb_ioim_get_size(struct bfad_ioim_s *dio) | ||
85 | { | ||
86 | struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; | ||
87 | |||
88 | return scsi_bufflen(cmnd); | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * Get timeout for the I/O request | ||
93 | */ | ||
94 | static inline u8 | ||
95 | bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio) | ||
96 | { | ||
97 | struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; | ||
98 | /* | ||
99 | * TBD: need a timeout for scsi passthru | ||
100 | */ | ||
101 | if (cmnd->device->host == NULL) | ||
102 | return 4; | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * Get Command Reference Number for the I/O request. 0 if none. | ||
109 | */ | ||
110 | static inline u8 | ||
111 | bfa_cb_ioim_get_crn(struct bfad_ioim_s *dio) | ||
112 | { | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * Get SAM-3 priority for the I/O request. 0 is default. | ||
118 | */ | ||
119 | static inline u8 | ||
120 | bfa_cb_ioim_get_priority(struct bfad_ioim_s *dio) | ||
121 | { | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * Get task attributes for the I/O request. Default is FCP_TASK_ATTR_SIMPLE(0). | ||
127 | */ | ||
128 | static inline u8 | ||
129 | bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio) | ||
130 | { | ||
131 | struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; | ||
132 | u8 task_attr = UNTAGGED; | ||
133 | |||
134 | if (cmnd->device->tagged_supported) { | ||
135 | switch (cmnd->tag) { | ||
136 | case HEAD_OF_QUEUE_TAG: | ||
137 | task_attr = HEAD_OF_Q; | ||
138 | break; | ||
139 | case ORDERED_QUEUE_TAG: | ||
140 | task_attr = ORDERED_Q; | ||
141 | break; | ||
142 | default: | ||
143 | task_attr = SIMPLE_Q; | ||
144 | break; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | return task_attr; | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * Get CDB length in bytes for the I/O request. Default is FCP_CMND_CDB_LEN(16). | ||
153 | */ | ||
154 | static inline u8 | ||
155 | bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio) | ||
156 | { | ||
157 | struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio; | ||
158 | |||
159 | return cmnd->cmd_len; | ||
160 | } | ||
161 | |||
162 | /** | ||
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. | ||
166 | */ | ||
167 | #define bfa_cb_ioim_get_reqq(__dio) BFA_FALSE | ||
168 | |||
169 | #endif /* __BFA_HCB_IOIM_H__ */ | ||