xref: /freebsd-src/sys/dev/aacraid/aacraid_endian.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
1d8c51c6fSLeandro Lupori /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3d8c51c6fSLeandro Lupori  *
4d8c51c6fSLeandro Lupori  * Copyright (c) 2019 Leandro Lupori
5d8c51c6fSLeandro Lupori  *
6d8c51c6fSLeandro Lupori  * Redistribution and use in source and binary forms, with or without
7d8c51c6fSLeandro Lupori  * modification, are permitted provided that the following conditions
8d8c51c6fSLeandro Lupori  * are met:
9d8c51c6fSLeandro Lupori  * 1. Redistributions of source code must retain the above copyright
10d8c51c6fSLeandro Lupori  *    notice, this list of conditions and the following disclaimer.
11d8c51c6fSLeandro Lupori  * 2. Redistributions in binary form must reproduce the above copyright
12d8c51c6fSLeandro Lupori  *    notice, this list of conditions and the following disclaimer in the
13d8c51c6fSLeandro Lupori  *    documentation and/or other materials provided with the distribution.
14d8c51c6fSLeandro Lupori  *
15d8c51c6fSLeandro Lupori  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16d8c51c6fSLeandro Lupori  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17d8c51c6fSLeandro Lupori  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18d8c51c6fSLeandro Lupori  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19d8c51c6fSLeandro Lupori  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20d8c51c6fSLeandro Lupori  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21d8c51c6fSLeandro Lupori  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22d8c51c6fSLeandro Lupori  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23d8c51c6fSLeandro Lupori  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24d8c51c6fSLeandro Lupori  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25d8c51c6fSLeandro Lupori  * SUCH DAMAGE.
26d8c51c6fSLeandro Lupori  */
27d8c51c6fSLeandro Lupori 
28d8c51c6fSLeandro Lupori #include <sys/param.h>
29d8c51c6fSLeandro Lupori #include <sys/types.h>
30d8c51c6fSLeandro Lupori 
31d8c51c6fSLeandro Lupori #include <dev/aacraid/aacraid_reg.h>
32d8c51c6fSLeandro Lupori #include <dev/aacraid/aacraid_endian.h>
33d8c51c6fSLeandro Lupori 
34d8c51c6fSLeandro Lupori #if _BYTE_ORDER != _LITTLE_ENDIAN
35d8c51c6fSLeandro Lupori 
36d8c51c6fSLeandro Lupori #define TOH2(field, bits)	field = le##bits##toh(field)
37d8c51c6fSLeandro Lupori #define TOH(field, bits)	TOH2(field, bits)
38d8c51c6fSLeandro Lupori 
39d8c51c6fSLeandro Lupori #define TOLE2(field, bits)	field = htole##bits(field)
40d8c51c6fSLeandro Lupori #define TOLE(field, bits)	TOLE2(field, bits)
41d8c51c6fSLeandro Lupori 
42d8c51c6fSLeandro Lupori /* Convert from Little-Endian to host order (TOH) */
43d8c51c6fSLeandro Lupori 
44d8c51c6fSLeandro Lupori void
aac_fib_header_toh(struct aac_fib_header * ptr)45d8c51c6fSLeandro Lupori aac_fib_header_toh(struct aac_fib_header *ptr)
46d8c51c6fSLeandro Lupori {
47d8c51c6fSLeandro Lupori 	TOH(ptr->XferState, 32);
48d8c51c6fSLeandro Lupori 	TOH(ptr->Command, 16);
49d8c51c6fSLeandro Lupori 	TOH(ptr->Size, 16);
50d8c51c6fSLeandro Lupori 	TOH(ptr->SenderSize, 16);
51d8c51c6fSLeandro Lupori 	TOH(ptr->SenderFibAddress, 32);
52d8c51c6fSLeandro Lupori 	TOH(ptr->u.ReceiverFibAddress, 32);
53d8c51c6fSLeandro Lupori 	TOH(ptr->Handle, 32);
54d8c51c6fSLeandro Lupori 	TOH(ptr->Previous, 32);
55d8c51c6fSLeandro Lupori 	TOH(ptr->Next, 32);
56d8c51c6fSLeandro Lupori }
57d8c51c6fSLeandro Lupori 
58d8c51c6fSLeandro Lupori void
aac_adapter_info_toh(struct aac_adapter_info * ptr)59d8c51c6fSLeandro Lupori aac_adapter_info_toh(struct aac_adapter_info *ptr)
60d8c51c6fSLeandro Lupori {
61d8c51c6fSLeandro Lupori 	TOH(ptr->PlatformBase, 32);
62d8c51c6fSLeandro Lupori 	TOH(ptr->CpuArchitecture, 32);
63d8c51c6fSLeandro Lupori 	TOH(ptr->CpuVariant, 32);
64d8c51c6fSLeandro Lupori 	TOH(ptr->ClockSpeed, 32);
65d8c51c6fSLeandro Lupori 	TOH(ptr->ExecutionMem, 32);
66d8c51c6fSLeandro Lupori 	TOH(ptr->BufferMem, 32);
67d8c51c6fSLeandro Lupori 	TOH(ptr->TotalMem, 32);
68d8c51c6fSLeandro Lupori 
69d8c51c6fSLeandro Lupori 	TOH(ptr->KernelRevision.buildNumber, 32);
70d8c51c6fSLeandro Lupori 	TOH(ptr->MonitorRevision.buildNumber, 32);
71d8c51c6fSLeandro Lupori 	TOH(ptr->HardwareRevision.buildNumber, 32);
72d8c51c6fSLeandro Lupori 	TOH(ptr->BIOSRevision.buildNumber, 32);
73d8c51c6fSLeandro Lupori 
74d8c51c6fSLeandro Lupori 	TOH(ptr->ClusteringEnabled, 32);
75d8c51c6fSLeandro Lupori 	TOH(ptr->ClusterChannelMask, 32);
76d8c51c6fSLeandro Lupori 	TOH(ptr->SerialNumber, 64);
77d8c51c6fSLeandro Lupori 	TOH(ptr->batteryPlatform, 32);
78d8c51c6fSLeandro Lupori 	TOH(ptr->SupportedOptions, 32);
79d8c51c6fSLeandro Lupori 	TOH(ptr->OemVariant, 32);
80d8c51c6fSLeandro Lupori }
81d8c51c6fSLeandro Lupori 
82d8c51c6fSLeandro Lupori void
aac_container_creation_toh(struct aac_container_creation * ptr)83d8c51c6fSLeandro Lupori aac_container_creation_toh(struct aac_container_creation *ptr)
84d8c51c6fSLeandro Lupori {
85d8c51c6fSLeandro Lupori 	u_int32_t *date = (u_int32_t *)ptr + 1;
86d8c51c6fSLeandro Lupori 
87d8c51c6fSLeandro Lupori 	*date = le32toh(*date);
88d8c51c6fSLeandro Lupori 	TOH(ptr->ViaAdapterSerialNumber, 64);
89d8c51c6fSLeandro Lupori }
90d8c51c6fSLeandro Lupori 
91d8c51c6fSLeandro Lupori void
aac_mntobj_toh(struct aac_mntobj * ptr)92d8c51c6fSLeandro Lupori aac_mntobj_toh(struct aac_mntobj *ptr)
93d8c51c6fSLeandro Lupori {
94d8c51c6fSLeandro Lupori 	TOH(ptr->ObjectId, 32);
95d8c51c6fSLeandro Lupori 	aac_container_creation_toh(&ptr->CreateInfo);
96d8c51c6fSLeandro Lupori 	TOH(ptr->Capacity, 32);
97d8c51c6fSLeandro Lupori 	TOH(ptr->VolType, 32);
98d8c51c6fSLeandro Lupori 	TOH(ptr->ObjType, 32);
99d8c51c6fSLeandro Lupori 	TOH(ptr->ContentState, 32);
100d8c51c6fSLeandro Lupori 	TOH(ptr->ObjExtension.BlockDevice.BlockSize, 32);
101d8c51c6fSLeandro Lupori 	TOH(ptr->ObjExtension.BlockDevice.bdLgclPhysMap, 32);
102d8c51c6fSLeandro Lupori 	TOH(ptr->AlterEgoId, 32);
103d8c51c6fSLeandro Lupori 	TOH(ptr->CapacityHigh, 32);
104d8c51c6fSLeandro Lupori }
105d8c51c6fSLeandro Lupori 
106d8c51c6fSLeandro Lupori void
aac_mntinforesp_toh(struct aac_mntinforesp * ptr)107d8c51c6fSLeandro Lupori aac_mntinforesp_toh(struct aac_mntinforesp *ptr)
108d8c51c6fSLeandro Lupori {
109d8c51c6fSLeandro Lupori 	TOH(ptr->Status, 32);
110d8c51c6fSLeandro Lupori 	TOH(ptr->MntType, 32);
111d8c51c6fSLeandro Lupori 	TOH(ptr->MntRespCount, 32);
112d8c51c6fSLeandro Lupori 	aac_mntobj_toh(&ptr->MntTable[0]);
113d8c51c6fSLeandro Lupori }
114d8c51c6fSLeandro Lupori 
115d8c51c6fSLeandro Lupori void
aac_fsa_ctm_toh(struct aac_fsa_ctm * ptr)116d8c51c6fSLeandro Lupori aac_fsa_ctm_toh(struct aac_fsa_ctm *ptr)
117d8c51c6fSLeandro Lupori {
118d8c51c6fSLeandro Lupori 	int i;
119d8c51c6fSLeandro Lupori 
120d8c51c6fSLeandro Lupori 	TOH(ptr->command, 32);
121d8c51c6fSLeandro Lupori 	for (i = 0; i < CT_FIB_PARAMS; i++)
122d8c51c6fSLeandro Lupori 		TOH(ptr->param[i], 32);
123d8c51c6fSLeandro Lupori }
124d8c51c6fSLeandro Lupori 
125d8c51c6fSLeandro Lupori void
aac_cnt_config_toh(struct aac_cnt_config * ptr)126d8c51c6fSLeandro Lupori aac_cnt_config_toh(struct aac_cnt_config *ptr)
127d8c51c6fSLeandro Lupori {
128d8c51c6fSLeandro Lupori 	TOH(ptr->Command, 32);
129d8c51c6fSLeandro Lupori 	aac_fsa_ctm_toh(&ptr->CTCommand);
130d8c51c6fSLeandro Lupori }
131d8c51c6fSLeandro Lupori 
132d8c51c6fSLeandro Lupori void
aac_ctcfg_resp_toh(struct aac_ctcfg_resp * ptr)133d8c51c6fSLeandro Lupori aac_ctcfg_resp_toh(struct aac_ctcfg_resp *ptr)
134d8c51c6fSLeandro Lupori {
135d8c51c6fSLeandro Lupori 	TOH(ptr->Status, 32);
136d8c51c6fSLeandro Lupori 	TOH(ptr->resp, 32);
137d8c51c6fSLeandro Lupori 	TOH(ptr->param, 32);
138d8c51c6fSLeandro Lupori }
139d8c51c6fSLeandro Lupori 
140d8c51c6fSLeandro Lupori void
aac_getbusinf_toh(struct aac_getbusinf * ptr)141d8c51c6fSLeandro Lupori aac_getbusinf_toh(struct aac_getbusinf *ptr)
142d8c51c6fSLeandro Lupori {
143d8c51c6fSLeandro Lupori 	TOH(ptr->ProbeComplete, 32);
144d8c51c6fSLeandro Lupori 	TOH(ptr->BusCount, 32);
145d8c51c6fSLeandro Lupori 	TOH(ptr->TargetsPerBus, 32);
146d8c51c6fSLeandro Lupori }
147d8c51c6fSLeandro Lupori 
148d8c51c6fSLeandro Lupori void
aac_vmi_businf_resp_toh(struct aac_vmi_businf_resp * ptr)149d8c51c6fSLeandro Lupori aac_vmi_businf_resp_toh(struct aac_vmi_businf_resp *ptr)
150d8c51c6fSLeandro Lupori {
151d8c51c6fSLeandro Lupori 	TOH(ptr->Status, 32);
152d8c51c6fSLeandro Lupori 	TOH(ptr->ObjType, 32);
153d8c51c6fSLeandro Lupori 	TOH(ptr->MethId, 32);
154d8c51c6fSLeandro Lupori 	TOH(ptr->ObjId, 32);
155d8c51c6fSLeandro Lupori 	TOH(ptr->IoctlCmd, 32);
156d8c51c6fSLeandro Lupori 	aac_getbusinf_toh(&ptr->BusInf);
157d8c51c6fSLeandro Lupori }
158d8c51c6fSLeandro Lupori 
159d8c51c6fSLeandro Lupori void
aac_srb_response_toh(struct aac_srb_response * ptr)160d8c51c6fSLeandro Lupori aac_srb_response_toh(struct aac_srb_response *ptr)
161d8c51c6fSLeandro Lupori {
162d8c51c6fSLeandro Lupori 	TOH(ptr->fib_status, 32);
163d8c51c6fSLeandro Lupori 	TOH(ptr->srb_status, 32);
164d8c51c6fSLeandro Lupori 	TOH(ptr->scsi_status, 32);
165d8c51c6fSLeandro Lupori 	TOH(ptr->data_len, 32);
166d8c51c6fSLeandro Lupori 	TOH(ptr->sense_len, 32);
167d8c51c6fSLeandro Lupori }
168d8c51c6fSLeandro Lupori 
169d8c51c6fSLeandro Lupori /* Convert from host order to Little-Endian (TOLE) */
170d8c51c6fSLeandro Lupori 
171d8c51c6fSLeandro Lupori void
aac_adapter_init_tole(struct aac_adapter_init * ptr)172d8c51c6fSLeandro Lupori aac_adapter_init_tole(struct aac_adapter_init *ptr)
173d8c51c6fSLeandro Lupori {
174d8c51c6fSLeandro Lupori 	TOLE(ptr->InitStructRevision, 32);
175d8c51c6fSLeandro Lupori 	TOLE(ptr->NoOfMSIXVectors, 32);
176d8c51c6fSLeandro Lupori 	TOLE(ptr->FilesystemRevision, 32);
177d8c51c6fSLeandro Lupori 	TOLE(ptr->CommHeaderAddress, 32);
178d8c51c6fSLeandro Lupori 	TOLE(ptr->FastIoCommAreaAddress, 32);
179d8c51c6fSLeandro Lupori 	TOLE(ptr->AdapterFibsPhysicalAddress, 32);
180d8c51c6fSLeandro Lupori 	TOLE(ptr->AdapterFibsVirtualAddress, 32);
181d8c51c6fSLeandro Lupori 	TOLE(ptr->AdapterFibsSize, 32);
182d8c51c6fSLeandro Lupori 	TOLE(ptr->AdapterFibAlign, 32);
183d8c51c6fSLeandro Lupori 	TOLE(ptr->PrintfBufferAddress, 32);
184d8c51c6fSLeandro Lupori 	TOLE(ptr->PrintfBufferSize, 32);
185d8c51c6fSLeandro Lupori 	TOLE(ptr->HostPhysMemPages, 32);
186d8c51c6fSLeandro Lupori 	TOLE(ptr->HostElapsedSeconds, 32);
187d8c51c6fSLeandro Lupori 	TOLE(ptr->InitFlags, 32);
188d8c51c6fSLeandro Lupori 	TOLE(ptr->MaxIoCommands, 32);
189d8c51c6fSLeandro Lupori 	TOLE(ptr->MaxIoSize, 32);
190d8c51c6fSLeandro Lupori 	TOLE(ptr->MaxFibSize, 32);
191d8c51c6fSLeandro Lupori 	TOLE(ptr->MaxNumAif, 32);
192d8c51c6fSLeandro Lupori 	TOLE(ptr->HostRRQ_AddrLow, 32);
193d8c51c6fSLeandro Lupori 	TOLE(ptr->HostRRQ_AddrHigh, 32);
194d8c51c6fSLeandro Lupori }
195d8c51c6fSLeandro Lupori 
196d8c51c6fSLeandro Lupori void
aac_fib_header_tole(struct aac_fib_header * ptr)197d8c51c6fSLeandro Lupori aac_fib_header_tole(struct aac_fib_header *ptr)
198d8c51c6fSLeandro Lupori {
199d8c51c6fSLeandro Lupori 	TOLE(ptr->XferState, 32);
200d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 16);
201d8c51c6fSLeandro Lupori 	TOLE(ptr->Size, 16);
202d8c51c6fSLeandro Lupori 	TOLE(ptr->SenderSize, 16);
203d8c51c6fSLeandro Lupori 	TOLE(ptr->SenderFibAddress, 32);
204d8c51c6fSLeandro Lupori 	TOLE(ptr->u.ReceiverFibAddress, 32);
205d8c51c6fSLeandro Lupori 	TOLE(ptr->Handle, 32);
206d8c51c6fSLeandro Lupori 	TOLE(ptr->Previous, 32);
207d8c51c6fSLeandro Lupori 	TOLE(ptr->Next, 32);
208d8c51c6fSLeandro Lupori }
209d8c51c6fSLeandro Lupori 
210d8c51c6fSLeandro Lupori void
aac_mntinfo_tole(struct aac_mntinfo * ptr)211d8c51c6fSLeandro Lupori aac_mntinfo_tole(struct aac_mntinfo *ptr)
212d8c51c6fSLeandro Lupori {
213d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
214d8c51c6fSLeandro Lupori 	TOLE(ptr->MntType, 32);
215d8c51c6fSLeandro Lupori 	TOLE(ptr->MntCount, 32);
216d8c51c6fSLeandro Lupori }
217d8c51c6fSLeandro Lupori 
218d8c51c6fSLeandro Lupori void
aac_fsa_ctm_tole(struct aac_fsa_ctm * ptr)219d8c51c6fSLeandro Lupori aac_fsa_ctm_tole(struct aac_fsa_ctm *ptr)
220d8c51c6fSLeandro Lupori {
221d8c51c6fSLeandro Lupori 	int i;
222d8c51c6fSLeandro Lupori 
223d8c51c6fSLeandro Lupori 	TOLE(ptr->command, 32);
224d8c51c6fSLeandro Lupori 	for (i = 0; i < CT_FIB_PARAMS; i++)
225d8c51c6fSLeandro Lupori 		TOLE(ptr->param[i], 32);
226d8c51c6fSLeandro Lupori }
227d8c51c6fSLeandro Lupori 
228d8c51c6fSLeandro Lupori void
aac_cnt_config_tole(struct aac_cnt_config * ptr)229d8c51c6fSLeandro Lupori aac_cnt_config_tole(struct aac_cnt_config *ptr)
230d8c51c6fSLeandro Lupori {
231d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
232d8c51c6fSLeandro Lupori 	aac_fsa_ctm_tole(&ptr->CTCommand);
233d8c51c6fSLeandro Lupori }
234d8c51c6fSLeandro Lupori 
235d8c51c6fSLeandro Lupori void
aac_raw_io_tole(struct aac_raw_io * ptr)236d8c51c6fSLeandro Lupori aac_raw_io_tole(struct aac_raw_io *ptr)
237d8c51c6fSLeandro Lupori {
238d8c51c6fSLeandro Lupori 	TOLE(ptr->BlockNumber, 64);
239d8c51c6fSLeandro Lupori 	TOLE(ptr->ByteCount, 32);
240d8c51c6fSLeandro Lupori 	TOLE(ptr->ContainerId, 16);
241d8c51c6fSLeandro Lupori 	TOLE(ptr->Flags, 16);
242d8c51c6fSLeandro Lupori 	TOLE(ptr->BpTotal, 16);
243d8c51c6fSLeandro Lupori 	TOLE(ptr->BpComplete, 16);
244d8c51c6fSLeandro Lupori }
245d8c51c6fSLeandro Lupori 
246d8c51c6fSLeandro Lupori void
aac_raw_io2_tole(struct aac_raw_io2 * ptr)247d8c51c6fSLeandro Lupori aac_raw_io2_tole(struct aac_raw_io2 *ptr)
248d8c51c6fSLeandro Lupori {
249d8c51c6fSLeandro Lupori 	TOLE(ptr->strtBlkLow, 32);
250d8c51c6fSLeandro Lupori 	TOLE(ptr->strtBlkHigh, 32);
251d8c51c6fSLeandro Lupori 	TOLE(ptr->byteCnt, 32);
252d8c51c6fSLeandro Lupori 	TOLE(ptr->ldNum, 16);
253d8c51c6fSLeandro Lupori 	TOLE(ptr->flags, 16);
254d8c51c6fSLeandro Lupori 	TOLE(ptr->sgeFirstSize, 32);
255d8c51c6fSLeandro Lupori 	TOLE(ptr->sgeNominalSize, 32);
256d8c51c6fSLeandro Lupori }
257d8c51c6fSLeandro Lupori 
258d8c51c6fSLeandro Lupori void
aac_fib_xporthdr_tole(struct aac_fib_xporthdr * ptr)259d8c51c6fSLeandro Lupori aac_fib_xporthdr_tole(struct aac_fib_xporthdr *ptr)
260d8c51c6fSLeandro Lupori {
261d8c51c6fSLeandro Lupori 	TOLE(ptr->HostAddress, 64);
262d8c51c6fSLeandro Lupori 	TOLE(ptr->Size, 32);
263d8c51c6fSLeandro Lupori 	TOLE(ptr->Handle, 32);
264d8c51c6fSLeandro Lupori }
265d8c51c6fSLeandro Lupori 
266d8c51c6fSLeandro Lupori void
aac_ctcfg_tole(struct aac_ctcfg * ptr)267d8c51c6fSLeandro Lupori aac_ctcfg_tole(struct aac_ctcfg *ptr)
268d8c51c6fSLeandro Lupori {
269d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
270d8c51c6fSLeandro Lupori 	TOLE(ptr->cmd, 32);
271d8c51c6fSLeandro Lupori 	TOLE(ptr->param, 32);
272d8c51c6fSLeandro Lupori }
273d8c51c6fSLeandro Lupori 
274d8c51c6fSLeandro Lupori void
aac_vmioctl_tole(struct aac_vmioctl * ptr)275d8c51c6fSLeandro Lupori aac_vmioctl_tole(struct aac_vmioctl *ptr)
276d8c51c6fSLeandro Lupori {
277d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
278d8c51c6fSLeandro Lupori 	TOLE(ptr->ObjType, 32);
279d8c51c6fSLeandro Lupori 	TOLE(ptr->MethId, 32);
280d8c51c6fSLeandro Lupori 	TOLE(ptr->ObjId, 32);
281d8c51c6fSLeandro Lupori 	TOLE(ptr->IoctlCmd, 32);
282d8c51c6fSLeandro Lupori 	TOLE(ptr->IoctlBuf[0], 32);
283d8c51c6fSLeandro Lupori }
284d8c51c6fSLeandro Lupori 
285d8c51c6fSLeandro Lupori void
aac_pause_command_tole(struct aac_pause_command * ptr)286d8c51c6fSLeandro Lupori aac_pause_command_tole(struct aac_pause_command *ptr)
287d8c51c6fSLeandro Lupori {
288d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
289d8c51c6fSLeandro Lupori 	TOLE(ptr->Type, 32);
290d8c51c6fSLeandro Lupori 	TOLE(ptr->Timeout, 32);
291d8c51c6fSLeandro Lupori 	TOLE(ptr->Min, 32);
292d8c51c6fSLeandro Lupori 	TOLE(ptr->NoRescan, 32);
293d8c51c6fSLeandro Lupori 	TOLE(ptr->Parm3, 32);
294d8c51c6fSLeandro Lupori 	TOLE(ptr->Parm4, 32);
295d8c51c6fSLeandro Lupori 	TOLE(ptr->Count, 32);
296d8c51c6fSLeandro Lupori }
297d8c51c6fSLeandro Lupori 
298d8c51c6fSLeandro Lupori void
aac_srb_tole(struct aac_srb * ptr)299d8c51c6fSLeandro Lupori aac_srb_tole(struct aac_srb *ptr)
300d8c51c6fSLeandro Lupori {
301d8c51c6fSLeandro Lupori 	TOLE(ptr->function, 32);
302d8c51c6fSLeandro Lupori 	TOLE(ptr->bus, 32);
303d8c51c6fSLeandro Lupori 	TOLE(ptr->target, 32);
304d8c51c6fSLeandro Lupori 	TOLE(ptr->lun, 32);
305d8c51c6fSLeandro Lupori 	TOLE(ptr->timeout, 32);
306d8c51c6fSLeandro Lupori 	TOLE(ptr->flags, 32);
307d8c51c6fSLeandro Lupori 	TOLE(ptr->data_len, 32);
308d8c51c6fSLeandro Lupori 	TOLE(ptr->retry_limit, 32);
309d8c51c6fSLeandro Lupori 	TOLE(ptr->cdb_len, 32);
310d8c51c6fSLeandro Lupori }
311d8c51c6fSLeandro Lupori 
312d8c51c6fSLeandro Lupori void
aac_sge_ieee1212_tole(struct aac_sge_ieee1212 * ptr)313d8c51c6fSLeandro Lupori aac_sge_ieee1212_tole(struct aac_sge_ieee1212 *ptr)
314d8c51c6fSLeandro Lupori {
315d8c51c6fSLeandro Lupori 	TOLE(ptr->addrLow, 32);
316d8c51c6fSLeandro Lupori 	TOLE(ptr->addrHigh, 32);
317d8c51c6fSLeandro Lupori 	TOLE(ptr->length, 32);
318d8c51c6fSLeandro Lupori 	TOLE(ptr->flags, 32);
319d8c51c6fSLeandro Lupori }
320d8c51c6fSLeandro Lupori 
321d8c51c6fSLeandro Lupori void
aac_sg_entryraw_tole(struct aac_sg_entryraw * ptr)322d8c51c6fSLeandro Lupori aac_sg_entryraw_tole(struct aac_sg_entryraw *ptr)
323d8c51c6fSLeandro Lupori {
324d8c51c6fSLeandro Lupori 	TOLE(ptr->Next, 32);
325d8c51c6fSLeandro Lupori 	TOLE(ptr->Prev, 32);
326d8c51c6fSLeandro Lupori 	TOLE(ptr->SgAddress, 64);
327d8c51c6fSLeandro Lupori 	TOLE(ptr->SgByteCount, 32);
328d8c51c6fSLeandro Lupori 	TOLE(ptr->Flags, 32);
329d8c51c6fSLeandro Lupori }
330d8c51c6fSLeandro Lupori 
331d8c51c6fSLeandro Lupori void
aac_sg_entry_tole(struct aac_sg_entry * ptr)332d8c51c6fSLeandro Lupori aac_sg_entry_tole(struct aac_sg_entry *ptr)
333d8c51c6fSLeandro Lupori {
334d8c51c6fSLeandro Lupori 	TOLE(ptr->SgAddress, 32);
335d8c51c6fSLeandro Lupori 	TOLE(ptr->SgByteCount, 32);
336d8c51c6fSLeandro Lupori }
337d8c51c6fSLeandro Lupori 
338d8c51c6fSLeandro Lupori void
aac_sg_entry64_tole(struct aac_sg_entry64 * ptr)339d8c51c6fSLeandro Lupori aac_sg_entry64_tole(struct aac_sg_entry64 *ptr)
340d8c51c6fSLeandro Lupori {
341d8c51c6fSLeandro Lupori 	TOLE(ptr->SgAddress, 64);
342d8c51c6fSLeandro Lupori 	TOLE(ptr->SgByteCount, 32);
343d8c51c6fSLeandro Lupori }
344d8c51c6fSLeandro Lupori 
345d8c51c6fSLeandro Lupori void
aac_blockread_tole(struct aac_blockread * ptr)346d8c51c6fSLeandro Lupori aac_blockread_tole(struct aac_blockread *ptr)
347d8c51c6fSLeandro Lupori {
348d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
349d8c51c6fSLeandro Lupori 	TOLE(ptr->ContainerId, 32);
350d8c51c6fSLeandro Lupori 	TOLE(ptr->BlockNumber, 32);
351d8c51c6fSLeandro Lupori 	TOLE(ptr->ByteCount, 32);
352d8c51c6fSLeandro Lupori }
353d8c51c6fSLeandro Lupori 
354d8c51c6fSLeandro Lupori void
aac_blockwrite_tole(struct aac_blockwrite * ptr)355d8c51c6fSLeandro Lupori aac_blockwrite_tole(struct aac_blockwrite *ptr)
356d8c51c6fSLeandro Lupori {
357d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
358d8c51c6fSLeandro Lupori 	TOLE(ptr->ContainerId, 32);
359d8c51c6fSLeandro Lupori 	TOLE(ptr->BlockNumber, 32);
360d8c51c6fSLeandro Lupori 	TOLE(ptr->ByteCount, 32);
361d8c51c6fSLeandro Lupori 	TOLE(ptr->Stable, 32);
362d8c51c6fSLeandro Lupori }
363d8c51c6fSLeandro Lupori 
364d8c51c6fSLeandro Lupori void
aac_blockread64_tole(struct aac_blockread64 * ptr)365d8c51c6fSLeandro Lupori aac_blockread64_tole(struct aac_blockread64 *ptr)
366d8c51c6fSLeandro Lupori {
367d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
368d8c51c6fSLeandro Lupori 	TOLE(ptr->ContainerId, 16);
369d8c51c6fSLeandro Lupori 	TOLE(ptr->SectorCount, 16);
370d8c51c6fSLeandro Lupori 	TOLE(ptr->BlockNumber, 32);
371d8c51c6fSLeandro Lupori 	TOLE(ptr->Pad, 16);
372d8c51c6fSLeandro Lupori 	TOLE(ptr->Flags, 16);
373d8c51c6fSLeandro Lupori }
374d8c51c6fSLeandro Lupori 
375d8c51c6fSLeandro Lupori void
aac_blockwrite64_tole(struct aac_blockwrite64 * ptr)376d8c51c6fSLeandro Lupori aac_blockwrite64_tole(struct aac_blockwrite64 *ptr)
377d8c51c6fSLeandro Lupori {
378d8c51c6fSLeandro Lupori 	TOLE(ptr->Command, 32);
379d8c51c6fSLeandro Lupori 	TOLE(ptr->ContainerId, 16);
380d8c51c6fSLeandro Lupori 	TOLE(ptr->SectorCount, 16);
381d8c51c6fSLeandro Lupori 	TOLE(ptr->BlockNumber, 32);
382d8c51c6fSLeandro Lupori 	TOLE(ptr->Pad, 16);
383d8c51c6fSLeandro Lupori 	TOLE(ptr->Flags, 16);
384d8c51c6fSLeandro Lupori }
385d8c51c6fSLeandro Lupori 
386d8c51c6fSLeandro Lupori #endif
387