]>
Commit | Line | Data |
---|---|---|
7725ccfd | 1 | /* |
a36c61f9 | 2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. |
7725ccfd JH |
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 | ||
a36c61f9 KG |
18 | #ifndef __BFA_HCB_IOIM_H__ |
19 | #define __BFA_HCB_IOIM_H__ | |
7725ccfd | 20 | |
a36c61f9 | 21 | #include "bfa_os_inc.h" |
7725ccfd JH |
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 | |
a36c61f9 | 28 | #define ACA_Q 4 |
7725ccfd JH |
29 | #define UNTAGGED 5 |
30 | ||
31 | static inline lun_t | |
32 | bfad_int_to_lun(u32 luno) | |
33 | { | |
34 | union { | |
a36c61f9 KG |
35 | u16 scsi_lun[4]; |
36 | lun_t bfa_lun; | |
7725ccfd JH |
37 | } lun; |
38 | ||
39 | lun.bfa_lun = 0; | |
ba816ea8 | 40 | lun.scsi_lun[0] = cpu_to_be16(luno); |
7725ccfd | 41 | |
f8ceafde | 42 | return lun.bfa_lun; |
7725ccfd JH |
43 | } |
44 | ||
acdc79a6 | 45 | /* |
7725ccfd JH |
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 | ||
acdc79a6 | 51 | /* |
7725ccfd JH |
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 | ||
f8ceafde | 59 | return (u8 *) cmnd->cmnd; |
7725ccfd JH |
60 | } |
61 | ||
acdc79a6 | 62 | /* |
7725ccfd JH |
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 | ||
acdc79a6 | 80 | /* |
7725ccfd JH |
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 | ||
f8ceafde | 88 | return scsi_bufflen(cmnd); |
7725ccfd JH |
89 | } |
90 | ||
acdc79a6 | 91 | /* |
7725ccfd JH |
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 | ||
acdc79a6 | 107 | /* |
7725ccfd JH |
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 | ||
acdc79a6 | 116 | /* |
7725ccfd JH |
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 | ||
acdc79a6 | 125 | /* |
7725ccfd JH |
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; | |
a36c61f9 | 132 | u8 task_attr = UNTAGGED; |
7725ccfd JH |
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 | ||
acdc79a6 | 151 | /* |
7725ccfd JH |
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 | ||
f8ceafde | 159 | return cmnd->cmd_len; |
7725ccfd JH |
160 | } |
161 | ||
acdc79a6 | 162 | /* |
36d345a7 JH |
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 | |
7725ccfd | 168 | |
a36c61f9 | 169 | #endif /* __BFA_HCB_IOIM_H__ */ |