RDK Documentation (Open Sourced RDK Components)
rmh_type.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef RDK_MOCA_HAL_TYPES_H
21 #define RDK_MOCA_HAL_TYPES_H
22 
23 #include <stdint.h>
24 #include <stdbool.h>
25 #include <stdlib.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define RMH_MAX_NUM_APIS 1024
32 #define RMH_MAX_NUM_TAGS 32
33 #define RMH_MAX_MOCA_NODES 16
34 typedef struct RMH* RMH_Handle;
35 typedef uint8_t RMH_MacAddress_t[6];
36 
37 #define AS(x,y) x=(y),
38 #define ENUM_RMH_Result \
39  AS(RMH_SUCCESS, 0) \
40  AS(RMH_FAILURE, 1) \
41  AS(RMH_INVALID_PARAM, 2) \
42  AS(RMH_INVALID_NETWORK_STATE, 3) \
43  AS(RMH_INVALID_INTERNAL_STATE, 4) \
44  AS(RMH_INVALID_ID, 5) \
45  AS(RMH_INVALID_MOCA_VERSION, 6) \
46  AS(RMH_TIMEOUT, 7) \
47  AS(RMH_INSUFFICIENT_SPACE, 8) \
48  AS(RMH_NOT_SUPPORTED, 9) \
49  AS(RMH_UNIMPLEMENTED, 10)
50 typedef enum RMH_Result { ENUM_RMH_Result } RMH_Result;
51 
52 #define ENUM_RMH_PowerMode \
53  AS(RMH_POWER_MODE_M0_ACTIVE, 1u << 0) \
54  AS(RMH_POWER_MODE_M1_IDLE, 1u << 1) \
55  AS(RMH_POWER_MODE_M2_STANDBY, 1u << 2) \
56  AS(RMH_POWER_MODE_M3_SLEEP, 1u << 3)
57 typedef enum RMH_PowerMode { ENUM_RMH_PowerMode } RMH_PowerMode;
58 
59 #define ENUM_RMH_PERMode \
60  AS(RMH_PER_MODE_LEGACY, 0) \
61  AS(RMH_PER_MODE_NOMINAL, 1) \
62  AS(RMH_PER_MODE_VERY_LOW, 2)
63 typedef enum RMH_PERMode { ENUM_RMH_PERMode } RMH_PERMode;
64 
65 #define ENUM_RMH_LinkStatus \
66  AS(RMH_LINK_STATUS_DISABLED, 0) \
67  AS(RMH_LINK_STATUS_NO_LINK, 1) \
68  AS(RMH_LINK_STATUS_INTERFACE_DOWN, 2) \
69  AS(RMH_LINK_STATUS_UP, 3)
70 typedef enum RMH_LinkStatus { ENUM_RMH_LinkStatus } RMH_LinkStatus;
71 
72 #define ENUM_RMH_AdmissionStatus \
73  AS(RMH_ADMISSION_STATUS_UNKNOWN, 0) \
74  AS(RMH_ADMISSION_STATUS_STARTED, 1) \
75  AS(RMH_ADMISSION_STATUS_SUCCEEDED, 2) \
76  AS(RMH_ADMISSION_STATUS_FAILED, 3) \
77  AS(RMH_ADMISSION_STATUS_CHANNEL_UNUSABLE, 4) \
78  AS(RMH_ADMISSION_STATUS_TIMEOUT, 5)
79 typedef enum RMH_AdmissionStatus { ENUM_RMH_AdmissionStatus } RMH_AdmissionStatus;
80 
81 #define ENUM_RMH_MoCAResetReason \
82  AS(RMH_MOCA_RESET_REASON_NO_RESET_OCCURRED, 0) \
83  AS(RMH_MOCA_RESET_REASON_REMOTE_NODE_REQUEST, 1) \
84  AS(RMH_MOCA_RESET_REASON_UNKNOWN, 2)
85 typedef enum RMH_MoCAResetReason { ENUM_RMH_MoCAResetReason } RMH_MoCAResetReason;
86 
87 #define ENUM_RMH_SubcarrierProfile \
88  AS(RMH_MOCA_SUBCARRIER_PROFILE_NOT_USABLE, 0x00) \
89  AS(RMH_MOCA_SUBCARRIER_PROFILE_BPSK, 0x01) \
90  AS(RMH_MOCA_SUBCARRIER_PROFILE_QPSK, 0x02) \
91  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_8, 0x03) \
92  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_16, 0x04) \
93  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_32, 0x05) \
94  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_64, 0x06) \
95  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_128, 0x07) \
96  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_256, 0x08) \
97  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_512, 0x09) \
98  AS(RMH_MOCA_SUBCARRIER_PROFILE_QAM_1024, 0x0A)
99 typedef enum RMH_SubcarrierProfile { ENUM_RMH_SubcarrierProfile } RMH_SubcarrierProfile;
100 
101 #define ENUM_RMH_MoCAVersion \
102  AS(RMH_MOCA_VERSION_UNKNOWN, 0) \
103  AS(RMH_MOCA_VERSION_10, 0x10) \
104  AS(RMH_MOCA_VERSION_11, 0x11) \
105  AS(RMH_MOCA_VERSION_20, 0x20)
106 typedef enum RMH_MoCAVersion { ENUM_RMH_MoCAVersion } RMH_MoCAVersion;
107 
108 #define RMH_LOG_NONE 0
109 #define RMH_LOG_DEFAULT (RMH_LOG_ERROR | RMH_LOG_WARNING | RMH_LOG_MESSAGE)
110 
111 #define ENUM_RMH_LogLevel \
112  AS(RMH_LOG_ERROR, 1u << 0) \
113  AS(RMH_LOG_WARNING, 1u << 1) \
114  AS(RMH_LOG_MESSAGE, 1u << 2) \
115  AS(RMH_LOG_DEBUG, 1u << 3) \
116  AS(RMH_LOG_TRACE, 1u << 4)
117 typedef enum RMH_LogLevel { ENUM_RMH_LogLevel } RMH_LogLevel;
118 
119 #define ENUM_RMH_Event \
120  AS(RMH_EVENT_LINK_STATUS_CHANGED, 1u << 0) \
121  AS(RMH_EVENT_MOCA_VERSION_CHANGED, 1u << 1) \
122  AS(RMH_EVENT_LOW_BANDWIDTH, 1u << 2) \
123  AS(RMH_EVENT_NODE_JOINED, 1u << 4) \
124  AS(RMH_EVENT_NODE_DROPPED, 1u << 5) \
125  AS(RMH_EVENT_ADMISSION_STATUS_CHANGED, 1u << 6) \
126  AS(RMH_EVENT_NC_ID_CHANGED, 1u << 7) \
127  AS(RMH_EVENT_API_PRINT, 1u << 8) \
128  AS(RMH_EVENT_DRIVER_PRINT, 1u << 9) \
129  AS(RMH_EVENT_MOCA_RESET, 1u << 10)
130 typedef enum RMH_Event { ENUM_RMH_Event } RMH_Event;
131 
132 #define ENUM_RMH_Band \
133  AS(RMH_BAND_C4, 0) \
134  AS(RMH_BAND_D, 1) \
135  AS(RMH_BAND_D_LOW, 2) \
136  AS(RMH_BAND_D_HIGH, 3) \
137  AS(RMH_BAND_D_EX, 4) \
138  AS(RMH_BAND_E, 5) \
139  AS(RMH_BAND_F, 6) \
140  AS(RMH_BAND_H, 8)
141 typedef enum RMH_Band { ENUM_RMH_Band } RMH_Band;
142 
143 #define ENUM_RMH_ACAType \
144  AS(RMH_ACA_TYPE_EVM, 0) \
145  AS(RMH_ACA_TYPE_QUIET, 1)
146 typedef enum RMH_ACAType { ENUM_RMH_ACAType } RMH_ACAType;
147 
148 #define ENUM_RMH_ACAStatus \
149  AS(RMH_ACA_STATUS_NOT_REQUESTED, 0) \
150  AS(RMH_ACA_STATUS_SUCCESS, 1) \
151  AS(RMH_ACA_STATUS_IN_PROGRESS, 2) \
152  AS(RMH_ACA_STATUS_FAILURE_GENERIC, 3) \
153  AS(RMH_ACA_STATUS_FAILURE_BAD_CHANNEL, 4) \
154  AS(RMH_ACA_STATUS_FAILURE_NO_EVM_PROBE, 5)
155 typedef enum RMH_ACAStatus { ENUM_RMH_ACAStatus } RMH_ACAStatus;
156 
157 typedef struct RMH_EventData {
158  union {
159  struct {
160  RMH_LinkStatus status;
161  } RMH_EVENT_LINK_STATUS_CHANGED;
162  struct {
163  RMH_AdmissionStatus status;
164  } RMH_EVENT_ADMISSION_STATUS_CHANGED;
165  struct {
166  RMH_MoCAResetReason reason;
167  } RMH_EVENT_MOCA_RESET;
168  struct {
169  RMH_MoCAVersion version;
170  } RMH_EVENT_MOCA_VERSION_CHANGED;
171  struct {
172  } RMH_EVENT_LOW_BANDWIDTH;
173  struct {
174  bool ncValid;
175  uint32_t ncNodeId;
176  } RMH_EVENT_NC_ID_CHANGED;
177  struct {
178  uint32_t nodeId;
179  } RMH_EVENT_NODE_JOINED;
180  struct {
181  uint32_t nodeId;
182  } RMH_EVENT_NODE_DROPPED;
183  struct {
184  RMH_LogLevel logLevel;
185  const char *logMsg;
186  } RMH_EVENT_API_PRINT;
187  struct {
188  RMH_LogLevel logLevel;
189  const char *logMsg;
190  } RMH_EVENT_DRIVER_PRINT;
191  };
192 } RMH_EventData;
193 typedef void (*RMH_EventCallback)(const enum RMH_Event event, const struct RMH_EventData *eventData, void* userContext);
194 
195 typedef struct RMH_NodeList_Uint32_t {
196  bool nodePresent[RMH_MAX_MOCA_NODES];
197  uint32_t nodeValue[RMH_MAX_MOCA_NODES];
199 
200 typedef struct RMH_NodeList_Mac {
201  bool nodePresent[RMH_MAX_MOCA_NODES];
202  RMH_MacAddress_t nodeValue[RMH_MAX_MOCA_NODES];
204 
205 typedef struct RMH_NodeMesh_Uint32_t {
206  bool nodePresent[RMH_MAX_MOCA_NODES];
207  RMH_NodeList_Uint32_t nodeValue[RMH_MAX_MOCA_NODES];
209 
210 typedef enum RMH_APIParamDirection {
211  RMH_INPUT_PARAM,
212  RMH_OUTPUT_PARAM,
213 }RMH_APIParamDirection;
214 
215 typedef struct RMHGeneric_Param {
216  const RMH_APIParamDirection direction;
217  const char *name;
218  const char *type;
219  const char *desc;
221 
222 typedef struct RMH_API {
223  const char *apiName;
224  const bool socApiExpected;
225  const bool genericApiExpected;
226  const char *socApiName;
227  const char *apiDefinition;
228  const char *apiDescription;
229  const char *tags;
230  const uint32_t apiNumParams;
231  const RMHGeneric_Param* apiParams;
232 } RMH_API;
233 
234 typedef struct RMH_APIList {
235  char apiListName[32];
236  uint32_t apiListSize;
237  RMH_API *apiList[RMH_MAX_NUM_APIS];
238 } RMH_APIList;
239 
240 typedef struct RMH_APITagList {
241  uint32_t tagListSize;
242  RMH_APIList tagList[RMH_MAX_NUM_TAGS];
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif /*RDK_MOCA_HAL_TYPES_H*/
RMH_NodeList_Uint32_t
Definition: rmh_type.h:195
RMH_NodeList_Mac
Definition: rmh_type.h:200
RMH_APITagList
Definition: rmh_type.h:240
RMHGeneric_Param
Definition: rmh_type.h:215
RMH
Definition: librmh.h:57
RMH_EventData
Definition: rmh_type.h:157
RMH_APIList
Definition: rmh_type.h:234
RMH_NodeMesh_Uint32_t
Definition: rmh_type.h:205
RMH_API
Definition: rmh_type.h:222