1 /*
2  * Copyright (C) 2003-2015 FreeIPMI Core Team
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18 
19 #ifndef IPMI_CHANNEL_SPEC_H
20 #define IPMI_CHANNEL_SPEC_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define IPMI_CHANNEL_NUMBER_PRIMARY_IPMB                0x0
27 #define IPMI_CHANNEL_NUMBER_IMPLEMENTATION_SPECIFIC_MIN 0x01 /* 0x01 to 0x0B */
28 #define IPMI_CHANNEL_NUMBER_IMPLEMENTATION_SPECIFIC_MAX 0x0B /* 0x01 to 0x0B */
29 #define IPMI_CHANNEL_NUMBER_RESERVED_MIN                0x0C /* 0x0C to 0x0D */
30 #define IPMI_CHANNEL_NUMBER_RESERVED_MAX                0x0D /* 0x0C to 0x0D */
31 #define IPMI_CHANNEL_NUMBER_PRESENT_IF                  0xE
32 #define IPMI_CHANNEL_NUMBER_CURRENT_CHANNEL             IPMI_CHANNEL_NUMBER_PRESENT_IF
33 #define IPMI_CHANNEL_NUMBER_SYSTEM_INTERFACE            0xF
34 
35 #define IPMI_CHANNEL_NUMBERS_MAX                        16
36 
37 /* To avoid gcc warnings, add +1 in comparison */
38 #define IPMI_CHANNEL_NUMBER_VALID(__channel_number)                   \
39   ((((__channel_number + 1) >= (IPMI_CHANNEL_NUMBER_PRIMARY_IPMB + 1) \
40      && (__channel_number) < IPMI_CHANNEL_NUMBER_RESERVED_MIN)        \
41     || ((__channel_number) > IPMI_CHANNEL_NUMBER_RESERVED_MAX         \
42         && (__channel_number) <= IPMI_CHANNEL_NUMBER_SYSTEM_INTERFACE)) ? 1 : 0)
43 
44 #define IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED       0x0 /* 0x03, 0x0A to 0x1B */
45 #define IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_1     IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED
46 #define IPMI_CHANNEL_PROTOCOL_TYPE_IPMB           0x1
47 #define IPMI_CHANNEL_PROTOCOL_TYPE_ICMB_10        0x2
48 #define IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_2     0x0 /* 0x03, 0x0A to 0x1B */
49 #define IPMI_CHANNEL_PROTOCOL_TYPE_SMBUS_1X_2X    0x4
50 #define IPMI_CHANNEL_PROTOCOL_TYPE_KCS            0x5
51 #define IPMI_CHANNEL_PROTOCOL_TYPE_SMIC           0x6
52 #define IPMI_CHANNEL_PROTOCOL_TYPE_BT_10          0x7
53 #define IPMI_CHANNEL_PROTOCOL_TYPE_BT_15          0x8
54 #define IPMI_CHANNEL_PROTOCOL_TYPE_TMODE          0x9
55 #define IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_MIN   0x0A /* 0x03, 0x0A to 0x1B */
56 #define IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_MAX   0x1B /* 0x03, 0x0A to 0x1B */
57 #define IPMI_CHANNEL_PROTOCOL_TYPE_OEM_MIN        0x1C /* 0x1C to 0x1F */
58 #define IPMI_CHANNEL_PROTOCOL_TYPE_OEM_MAX        0x1F /* 0x1C to 0x1F */
59 
60 #define IPMI_CHANNEL_PROTOCOL_TYPE_IS_RESERVED(__val)      \
61   (((__val) == IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_1       \
62     || (__val) == IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_2    \
63     || ((__val) >= IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_MIN \
64         && (__val) <= IPMI_CHANNEL_PROTOCOL_TYPE_RESERVED_MAX)) ? 1 : 0)
65 
66 #define IPMI_CHANNEL_PROTOCOL_TYPE_IS_OEM(__val)  \
67   (((__val) >= IPMI_CHANNEL_PROTOCOL_TYPE_OEM_MIN \
68     && (__val) <= IPMI_CHANNEL_PROTOCOL_TYPE_OEM_MAX) ? 1 : 0)
69 
70 #define IPMI_CHANNEL_MEDIUM_TYPE_RESERVED          0x0 /* 0x0D to 0x5F */
71 #define IPMI_CHANNEL_MEDIUM_TYPE_IPMB              0x1
72 #define IPMI_CHANNEL_MEDIUM_TYPE_ICMB_10           0x2
73 #define IPMI_CHANNEL_MEDIUM_TYPE_ICMB_09           0x3
74 #define IPMI_CHANNEL_MEDIUM_TYPE_LAN_802_3         0x4
75 #define IPMI_CHANNEL_MEDIUM_TYPE_RS232             0x5
76 #define IPMI_CHANNEL_MEDIUM_TYPE_OTHER_LAN         0x6
77 #define IPMI_CHANNEL_MEDIUM_TYPE_PCI_SMBUS         0x7
78 #define IPMI_CHANNEL_MEDIUM_TYPE_SMBUS_10_11       0x8
79 #define IPMI_CHANNEL_MEDIUM_TYPE_SMBUS_20          0x9
80 #define IPMI_CHANNEL_MEDIUM_TYPE_USB_1X            0xA
81 #define IPMI_CHANNEL_MEDIUM_TYPE_USB_2X            0xB
82 #define IPMI_CHANNEL_MEDIUM_TYPE_SYSTEM_INTERFACE  0xC
83 #define IPMI_CHANNEL_MEDIUM_TYPE_RESERVED_MIN      0x0D /* 0x0D to 0x59 */
84 #define IPMI_CHANNEL_MEDIUM_TYPE_RESERVED_MAX      0x59 /* 0x0D to 0x59 */
85 #define IPMI_CHANNEL_MEDIUM_TYPE_OEM_MIN           0x60 /* 0x60 to 0x7F */
86 #define IPMI_CHANNEL_MEDIUM_TYPE_OEM_MAX           0x7F /* 0x60 to 0x7F */
87 
88 #define IPMI_CHANNEL_MEDIUM_TYPE_IS_RESERVED(__val)      \
89   (((__val) == IPMI_CHANNEL_MEDIUM_TYPE_RESERVED         \
90     || ((__val) >= IPMI_CHANNEL_MEDIUM_TYPE_RESERVED_MIN \
91         && (__val) <= IPMI_CHANNEL_MEDIUM_TYPE_RESERVED_MAX)) ? 1 : 0)
92 
93 #define IPMI_CHANNEL_MEDIUM_TYPE_IS_OEM(__val)  \
94   (((__val) >= IPMI_CHANNEL_MEDIUM_TYPE_OEM_MIN \
95     && (__val) <= IPMI_CHANNEL_MEDIUM_TYPE_OEM_MAX) ? 1 : 0)
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* IPMI_CHANNEL_SPEC_H */
102