xref: /freebsd-src/sys/dev/aacraid/aacraid_endian.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
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 #ifndef AACRAID_ENDIAN_H
29d8c51c6fSLeandro Lupori #define AACRAID_ENDIAN_H
30d8c51c6fSLeandro Lupori 
31d8c51c6fSLeandro Lupori #include <sys/endian.h>
32d8c51c6fSLeandro Lupori 
33d8c51c6fSLeandro Lupori #if _BYTE_ORDER == _LITTLE_ENDIAN
34d8c51c6fSLeandro Lupori 
35d8c51c6fSLeandro Lupori /* On Little-Endian (LE) hosts, make all FIB data conversion functions empty. */
36d8c51c6fSLeandro Lupori 
37d8c51c6fSLeandro Lupori /* Convert from Little-Endian to host order (TOH) */
38d8c51c6fSLeandro Lupori #define aac_fib_header_toh(ptr)
39d8c51c6fSLeandro Lupori #define aac_adapter_info_toh(ptr)
40d8c51c6fSLeandro Lupori #define aac_container_creation_toh(ptr)
41d8c51c6fSLeandro Lupori #define aac_mntobj_toh(ptr)
42d8c51c6fSLeandro Lupori #define aac_mntinforesp_toh(ptr)
43d8c51c6fSLeandro Lupori #define aac_fsa_ctm_toh(ptr)
44d8c51c6fSLeandro Lupori #define aac_cnt_config_toh(ptr)
45d8c51c6fSLeandro Lupori #define aac_ctcfg_resp_toh(ptr)
46d8c51c6fSLeandro Lupori #define aac_getbusinf_toh(ptr)
47d8c51c6fSLeandro Lupori #define aac_vmi_businf_resp_toh(ptr)
48d8c51c6fSLeandro Lupori #define aac_srb_response_toh(ptr)
49d8c51c6fSLeandro Lupori 
50d8c51c6fSLeandro Lupori /* Convert from host order to Little-Endian (TOLE) */
51d8c51c6fSLeandro Lupori #define aac_adapter_init_tole(ptr)
52d8c51c6fSLeandro Lupori #define aac_fib_header_tole(ptr)
53d8c51c6fSLeandro Lupori #define aac_mntinfo_tole(ptr)
54d8c51c6fSLeandro Lupori #define aac_fsa_ctm_tole(ptr)
55d8c51c6fSLeandro Lupori #define aac_cnt_config_tole(ptr)
56d8c51c6fSLeandro Lupori #define aac_raw_io_tole(ptr)
57d8c51c6fSLeandro Lupori #define aac_raw_io2_tole(ptr)
58d8c51c6fSLeandro Lupori #define aac_fib_xporthdr_tole(ptr)
59d8c51c6fSLeandro Lupori #define aac_ctcfg_tole(ptr)
60d8c51c6fSLeandro Lupori #define aac_vmioctl_tole(ptr)
61d8c51c6fSLeandro Lupori #define aac_pause_command_tole(ptr)
62d8c51c6fSLeandro Lupori #define aac_srb_tole(ptr)
63d8c51c6fSLeandro Lupori #define aac_sge_ieee1212_tole(ptr)
64d8c51c6fSLeandro Lupori #define aac_sg_entryraw_tole(ptr)
65d8c51c6fSLeandro Lupori #define aac_sg_entry_tole(ptr)
66d8c51c6fSLeandro Lupori #define aac_sg_entry64_tole(ptr)
67d8c51c6fSLeandro Lupori #define aac_blockread_tole(ptr)
68d8c51c6fSLeandro Lupori #define aac_blockwrite_tole(ptr)
69d8c51c6fSLeandro Lupori #define aac_blockread64_tole(ptr)
70d8c51c6fSLeandro Lupori #define aac_blockwrite64_tole(ptr)
71d8c51c6fSLeandro Lupori 
72d8c51c6fSLeandro Lupori #else /* _BYTE_ORDER != _LITTLE_ENDIAN */
73d8c51c6fSLeandro Lupori 
74d8c51c6fSLeandro Lupori /* Convert from Little-Endian to host order (TOH) */
75d8c51c6fSLeandro Lupori void aac_fib_header_toh(struct aac_fib_header *ptr);
76d8c51c6fSLeandro Lupori void aac_adapter_info_toh(struct aac_adapter_info *ptr);
77d8c51c6fSLeandro Lupori void aac_container_creation_toh(struct aac_container_creation *ptr);
78d8c51c6fSLeandro Lupori void aac_mntobj_toh(struct aac_mntobj *ptr);
79d8c51c6fSLeandro Lupori void aac_mntinforesp_toh(struct aac_mntinforesp *ptr);
80d8c51c6fSLeandro Lupori void aac_fsa_ctm_toh(struct aac_fsa_ctm *ptr);
81d8c51c6fSLeandro Lupori void aac_cnt_config_toh(struct aac_cnt_config *ptr);
82d8c51c6fSLeandro Lupori void aac_ctcfg_resp_toh(struct aac_ctcfg_resp *ptr);
83d8c51c6fSLeandro Lupori void aac_getbusinf_toh(struct aac_getbusinf *ptr);
84d8c51c6fSLeandro Lupori void aac_vmi_businf_resp_toh(struct aac_vmi_businf_resp *ptr);
85d8c51c6fSLeandro Lupori void aac_srb_response_toh(struct aac_srb_response *ptr);
86d8c51c6fSLeandro Lupori 
87d8c51c6fSLeandro Lupori /* Convert from host order to Little-Endian (TOLE) */
88d8c51c6fSLeandro Lupori void aac_adapter_init_tole(struct aac_adapter_init *ptr);
89d8c51c6fSLeandro Lupori void aac_fib_header_tole(struct aac_fib_header *ptr);
90d8c51c6fSLeandro Lupori void aac_mntinfo_tole(struct aac_mntinfo *ptr);
91d8c51c6fSLeandro Lupori void aac_fsa_ctm_tole(struct aac_fsa_ctm *ptr);
92d8c51c6fSLeandro Lupori void aac_cnt_config_tole(struct aac_cnt_config *ptr);
93d8c51c6fSLeandro Lupori void aac_raw_io_tole(struct aac_raw_io *ptr);
94d8c51c6fSLeandro Lupori void aac_raw_io2_tole(struct aac_raw_io2 *ptr);
95d8c51c6fSLeandro Lupori void aac_fib_xporthdr_tole(struct aac_fib_xporthdr *ptr);
96d8c51c6fSLeandro Lupori void aac_ctcfg_tole(struct aac_ctcfg *ptr);
97d8c51c6fSLeandro Lupori void aac_vmioctl_tole(struct aac_vmioctl *ptr);
98d8c51c6fSLeandro Lupori void aac_pause_command_tole(struct aac_pause_command *ptr);
99d8c51c6fSLeandro Lupori void aac_srb_tole(struct aac_srb *ptr);
100d8c51c6fSLeandro Lupori void aac_sge_ieee1212_tole(struct aac_sge_ieee1212 *ptr);
101d8c51c6fSLeandro Lupori void aac_sg_entryraw_tole(struct aac_sg_entryraw *ptr);
102d8c51c6fSLeandro Lupori void aac_sg_entry_tole(struct aac_sg_entry *ptr);
103d8c51c6fSLeandro Lupori void aac_sg_entry64_tole(struct aac_sg_entry64 *ptr);
104d8c51c6fSLeandro Lupori void aac_blockread_tole(struct aac_blockread *ptr);
105d8c51c6fSLeandro Lupori void aac_blockwrite_tole(struct aac_blockwrite *ptr);
106d8c51c6fSLeandro Lupori void aac_blockread64_tole(struct aac_blockread64 *ptr);
107d8c51c6fSLeandro Lupori void aac_blockwrite64_tole(struct aac_blockwrite64 *ptr);
108d8c51c6fSLeandro Lupori 
109d8c51c6fSLeandro Lupori #endif
110d8c51c6fSLeandro Lupori 
111d8c51c6fSLeandro Lupori #endif
112