xref: /freebsd/sys/dev/aacraid/aacraid_endian.h (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2019 Leandro Lupori
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 
30 #ifndef AACRAID_ENDIAN_H
31 #define AACRAID_ENDIAN_H
32 
33 #include <sys/endian.h>
34 
35 #if _BYTE_ORDER == _LITTLE_ENDIAN
36 
37 /* On Little-Endian (LE) hosts, make all FIB data conversion functions empty. */
38 
39 /* Convert from Little-Endian to host order (TOH) */
40 #define aac_fib_header_toh(ptr)
41 #define aac_adapter_info_toh(ptr)
42 #define aac_container_creation_toh(ptr)
43 #define aac_mntobj_toh(ptr)
44 #define aac_mntinforesp_toh(ptr)
45 #define aac_fsa_ctm_toh(ptr)
46 #define aac_cnt_config_toh(ptr)
47 #define aac_ctcfg_resp_toh(ptr)
48 #define aac_getbusinf_toh(ptr)
49 #define aac_vmi_businf_resp_toh(ptr)
50 #define aac_srb_response_toh(ptr)
51 
52 /* Convert from host order to Little-Endian (TOLE) */
53 #define aac_adapter_init_tole(ptr)
54 #define aac_fib_header_tole(ptr)
55 #define aac_mntinfo_tole(ptr)
56 #define aac_fsa_ctm_tole(ptr)
57 #define aac_cnt_config_tole(ptr)
58 #define aac_raw_io_tole(ptr)
59 #define aac_raw_io2_tole(ptr)
60 #define aac_fib_xporthdr_tole(ptr)
61 #define aac_ctcfg_tole(ptr)
62 #define aac_vmioctl_tole(ptr)
63 #define aac_pause_command_tole(ptr)
64 #define aac_srb_tole(ptr)
65 #define aac_sge_ieee1212_tole(ptr)
66 #define aac_sg_entryraw_tole(ptr)
67 #define aac_sg_entry_tole(ptr)
68 #define aac_sg_entry64_tole(ptr)
69 #define aac_blockread_tole(ptr)
70 #define aac_blockwrite_tole(ptr)
71 #define aac_blockread64_tole(ptr)
72 #define aac_blockwrite64_tole(ptr)
73 
74 #else /* _BYTE_ORDER != _LITTLE_ENDIAN */
75 
76 /* Convert from Little-Endian to host order (TOH) */
77 void aac_fib_header_toh(struct aac_fib_header *ptr);
78 void aac_adapter_info_toh(struct aac_adapter_info *ptr);
79 void aac_container_creation_toh(struct aac_container_creation *ptr);
80 void aac_mntobj_toh(struct aac_mntobj *ptr);
81 void aac_mntinforesp_toh(struct aac_mntinforesp *ptr);
82 void aac_fsa_ctm_toh(struct aac_fsa_ctm *ptr);
83 void aac_cnt_config_toh(struct aac_cnt_config *ptr);
84 void aac_ctcfg_resp_toh(struct aac_ctcfg_resp *ptr);
85 void aac_getbusinf_toh(struct aac_getbusinf *ptr);
86 void aac_vmi_businf_resp_toh(struct aac_vmi_businf_resp *ptr);
87 void aac_srb_response_toh(struct aac_srb_response *ptr);
88 
89 /* Convert from host order to Little-Endian (TOLE) */
90 void aac_adapter_init_tole(struct aac_adapter_init *ptr);
91 void aac_fib_header_tole(struct aac_fib_header *ptr);
92 void aac_mntinfo_tole(struct aac_mntinfo *ptr);
93 void aac_fsa_ctm_tole(struct aac_fsa_ctm *ptr);
94 void aac_cnt_config_tole(struct aac_cnt_config *ptr);
95 void aac_raw_io_tole(struct aac_raw_io *ptr);
96 void aac_raw_io2_tole(struct aac_raw_io2 *ptr);
97 void aac_fib_xporthdr_tole(struct aac_fib_xporthdr *ptr);
98 void aac_ctcfg_tole(struct aac_ctcfg *ptr);
99 void aac_vmioctl_tole(struct aac_vmioctl *ptr);
100 void aac_pause_command_tole(struct aac_pause_command *ptr);
101 void aac_srb_tole(struct aac_srb *ptr);
102 void aac_sge_ieee1212_tole(struct aac_sge_ieee1212 *ptr);
103 void aac_sg_entryraw_tole(struct aac_sg_entryraw *ptr);
104 void aac_sg_entry_tole(struct aac_sg_entry *ptr);
105 void aac_sg_entry64_tole(struct aac_sg_entry64 *ptr);
106 void aac_blockread_tole(struct aac_blockread *ptr);
107 void aac_blockwrite_tole(struct aac_blockwrite *ptr);
108 void aac_blockread64_tole(struct aac_blockread64 *ptr);
109 void aac_blockwrite64_tole(struct aac_blockwrite64 *ptr);
110 
111 #endif
112 
113 #endif
114