blob: 1a82dff896ffffc8ab724c50eb2f78e708e15382 [file] [log] [blame]
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001/*
Girish Gowdraa707e7c2019-11-07 11:36:13 +05302 * Copyright 2018-present Open Networking Foundation
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00003
Girish Gowdraa707e7c2019-11-07 11:36:13 +05304 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00007
Girish Gowdraa707e7c2019-11-07 11:36:13 +05308 * http://www.apache.org/licenses/LICENSE-2.0
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00009
Girish Gowdraa707e7c2019-11-07 11:36:13 +053010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000016
17// This file stub definitions for some BAL APIs that are unavailable
18// in TEST_MODE
19//
20extern "C" {
21#include <test_stub.h>
22#include <stdio.h>
23#include <string.h>
24#include <stdarg.h>
25
26#include <bcmos_system.h>
27#include <bcmolt_msg.h>
28#include <bcmolt_host_api.h>
29
30char log_string[500];
31dev_log_id def_log_id=0;
32
33void bcmos_usleep(uint32_t us) {
Amit Ghoshfcad4d32019-11-13 10:24:55 +000034 // let always sleep for 10ms irrespective of the value passed.
35 usleep (10000);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000036}
37
38void bcmos_fastlock_init(bcmos_fastlock *lock, uint32_t flags) {
39 pthread_mutex_init(&(lock->lock), NULL);
40}
41
42long bcmos_fastlock_lock(bcmos_fastlock *lock) {
43 pthread_mutex_lock(&(lock->lock));
44}
45
46void bcmos_fastlock_unlock(bcmos_fastlock *lock, long flags) {
47 pthread_mutex_unlock(&(lock->lock));
48}
49
50/* Initialize API layer */
51bcmos_errno bcmolt_api_init(void)
52{
53 printf("-- entering :stubbed %s\n", __FUNCTION__);
54 return BCM_ERR_OK;
55}
56
57/* Set configuration */
Chaitrashree G S73e084d2019-11-20 16:18:59 -050058/*bcmos_errno bcmolt_cfg_set(bcmolt_oltid olt, bcmolt_cfg *cfg)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000059{
60 printf("-- entering :stubbed %s\n", __FUNCTION__);
61 return BCM_ERR_OK;
Chaitrashree G S73e084d2019-11-20 16:18:59 -050062}*/
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000063
64/* Get configuration */
65/*
66bcmos_errno bcmolt_cfg_get(bcmolt_oltid olt, bcmolt_cfg *cfg)
67{
68 printf("-- entering :stubbed %s\n", __FUNCTION__);
69 return BCM_ERR_OK;
70}
71*/
72
73/* Clear configuration */
Thiyagarajan Subramani6dc20052019-12-05 09:06:36 -050074/*
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000075bcmos_errno bcmolt_cfg_clear(bcmolt_oltid olt, bcmolt_cfg *cfg)
76{
77 printf("-- entering :stubbed %s\n", __FUNCTION__);
78 return BCM_ERR_OK;
79}
Thiyagarajan Subramani6dc20052019-12-05 09:06:36 -050080*/
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000081
82/* Get statistics */
83bcmos_errno bcmolt_stat_get(bcmolt_oltid olt, bcmolt_stat *stat, bcmolt_stat_flags flags)
84{
85 printf("-- entering :stubbed %s\n", __FUNCTION__);
86 return BCM_ERR_OK;
87}
88
89/* Get statistics configuration */
90bcmos_errno bcmolt_stat_cfg_get(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
91{
92 printf("-- entering :stubbed %s\n", __FUNCTION__);
93 return BCM_ERR_OK;
94}
95
96/* Set statistics configuration */
97bcmos_errno bcmolt_stat_cfg_set(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
98{
99 printf("-- entering :stubbed %s\n", __FUNCTION__);
100 return BCM_ERR_OK;
101}
102
103/* Register Autonomous Indication Message Handler */
104bcmos_errno bcmolt_ind_subscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
105{
106 printf("-- entering :stubbed %s\n", __FUNCTION__);
107 return BCM_ERR_OK;
108}
109
110/* Un-register Autonomous Indication Message Handler registered by bcmolt_ind_subscribe() */
111bcmos_errno bcmolt_ind_unsubscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
112{
113 printf("-- entering :stubbed %s\n", __FUNCTION__);
114 return BCM_ERR_OK;
115}
116
117/* Submit Operation */
118/*
119bcmos_errno bcmolt_oper_submit(bcmolt_oltid olt, bcmolt_oper *oper)
120{
121 printf("-- entering :stubbed %s\n", __FUNCTION__);
122 return BCM_ERR_OK;
123}
124*/
125
126/* Get configuration of multiple objects */
127bcmos_errno bcmolt_multi_cfg_get(
128 bcmolt_oltid olt,
129 bcmolt_multi_cfg *cfg,
130 bcmolt_filter_flags filter_flags)
131{
132 printf("-- entering :stubbed %s\n", __FUNCTION__);
133 return BCM_ERR_OK;
134}
135
136/* Get statistics of multiple objects */
137bcmos_errno bcmolt_multi_stat_get(
138 bcmolt_oltid olt,
139 bcmolt_multi_stat *stat,
140 bcmolt_stat_flags stat_flags,
141 bcmolt_filter_flags filter_flags)
142{
143 printf("-- entering :stubbed %s\n", __FUNCTION__);
144 return BCM_ERR_OK;
145}
146
147/* Map error code to error string */
148const char *bcmos_strerror(bcmos_errno err)
149{
150 static const char *errstr[] = {
151 [-BCM_ERR_OK] = "OK",
152 [-BCM_ERR_IN_PROGRESS] = "In progress",
153 [-BCM_ERR_PARM] = "Error in parameters",
154 [-BCM_ERR_NOMEM] = "No memory",
155 [-BCM_ERR_NORES] = "No resources",
156 [-BCM_ERR_INTERNAL] = "Internal error",
157 [-BCM_ERR_NOENT] = "Entry doesn't exist",
158 [-BCM_ERR_NODEV] = "Device doesn't exist",
159 [-BCM_ERR_ALREADY] = "Entry already exists/already in requested state",
160 [-BCM_ERR_RANGE] = "Out of range",
161 [-BCM_ERR_PERM] = "No permission to perform an operation",
162 [-BCM_ERR_NOT_SUPPORTED] = "Operation is not supported",
163 [-BCM_ERR_PARSE] = "Parsing error",
164 [-BCM_ERR_INVALID_OP] = "Invalid operation",
165 [-BCM_ERR_IO] = "I/O error",
166 [-BCM_ERR_STATE] = "Object is in bad state",
167 [-BCM_ERR_DELETED] = "Object is deleted",
168 [-BCM_ERR_TOO_MANY] = "Too many objects",
169 [-BCM_ERR_NO_MORE] = "No more entries",
170 [-BCM_ERR_OVERFLOW] = "Buffer overflow",
171 [-BCM_ERR_COMM_FAIL] = "Communication failure",
172 [-BCM_ERR_NOT_CONNECTED] = "No connection with the target system",
173 [-BCM_ERR_SYSCALL_ERR] = "System call returned error",
174 [-BCM_ERR_MSG_ERROR] = "Received message is insane",
175 [-BCM_ERR_TOO_MANY_REQS] = "Too many outstanding requests",
176 [-BCM_ERR_TIMEOUT] = "Operation timed out",
177 [-BCM_ERR_TOO_MANY_FRAGS] = "Too many fragments",
178 [-BCM_ERR_NULL] = "Got NULL pointer",
179 [-BCM_ERR_READ_ONLY] = "Attempt to set read-only parameter",
180 [-BCM_ERR_ONU_ERR_RESP] = "ONU returned an error response",
181 [-BCM_ERR_MANDATORY_PARM_IS_MISSING] = "Mandatory parameter is missing",
182 [-BCM_ERR_KEY_RANGE] = "Key field out of range",
183 [-BCM_ERR_QUEUE_EMPTY] = "Rx of PCIe empty",
184 [-BCM_ERR_QUEUE_FULL] = "Tx of PCIe full",
185 [-BCM_ERR_TOO_LONG] = "Processing is taking too long, but will finish eventually",
186 [-BCM_ERR_INSUFFICIENT_LIST_MEM] = "Insufficient list memory provided",
187 [-BCM_ERR_OUT_OF_SYNC] = "Sequence number or operation step was out of sync",
188 [-BCM_ERR_CHECKSUM] = "Checksum error",
189 [-BCM_ERR_IMAGE_TYPE] = "Unsupported file/image type",
190 [-BCM_ERR_INCOMPLETE_TERMINATION] = "Incomplete premature termination",
191 [-BCM_ERR_MISMATCH] = "Parameters mismatch",
192 };
193 static const char *unknown = "*unknown*";
194
195 if ((unsigned)(-err) >= sizeof(errstr)/sizeof(errstr[0]) || !errstr[-err])
196 return unknown;
197 return errstr[-err];
198}
199
200void bcmolt_msg_free(bcmolt_msg *msg)
201{
202 return;
203}
204
205void bcmolt_api_set_prop_present(bcmolt_msg *msg, const void *prop_ptr)
206{
207 return;
208}
209
210const bcmolt_enum_val bcmolt_obj_id_string_table[] = {"dummy string, never used"};
211const bcmolt_enum_val bcmolt_interface_state_string_table[] = {"dummy string, never used"};
212
213dev_log_id bcm_dev_log_id_register(const char *xi_name,
214 bcm_dev_log_level xi_default_log_level,
215 bcm_dev_log_id_type xi_default_log_type) {
216 return 0;
217}
218bool bcmcli_is_stopped(bcmcli_session *sess) {
219 printf("-- stub bcmcli_is_stopped called --\n");
220 return true;
221}
222
223bool bcmcli_parse(bcmcli_session *sess, char *s) {
224 printf("-- stub bcmcli_parse called --\n");
225 return true;
226}
227
228bool bcmcli_driver(bcmcli_session *sess) {
229 printf("-- stub bcmcli_driver called --\n");
230 return true;
231}
232void bcmcli_token_destroy(void *ptr) {
233 printf("-- stub bcmcli_token_destroy called --\n");
234 return;
235}
236
237void bcmcli_session_close( bcmcli_session*ptr) {
238 printf("-- stub bcmcli_session_close called --\n");
239 return;
240}
241
242bcmos_errno bcm_api_cli_set_commands(bcmcli_session *sess) {
243 printf("-- stub bcm_api_cli_set_commands called --\n");
244 return BCM_ERR_OK;
245}
246
247void bcmcli_stop(bcmcli_session *sess) {
248 printf("-- stub bcmcli_stop called --\n");
249 return;
250}
251
252void bcmcli_session_print(bcmcli_session *sess, const char *s) {
253 printf("-- stub bcmcli_session_print called --\n");
254 return;
255}
256
257bcmos_errno bcmcli_session_open(bcmcli_session_parm *mon_sess, bcmcli_session **curr_sess) {
258 printf("-- stub bcmcli_session_open called --\n");
259 return BCM_ERR_OK;
260}
261
262void bcm_dev_log_log(dev_log_id xi_id,
263 bcm_dev_log_level xi_log_level,
264 uint32_t xi_flags,
265 const char *fmt,
266 ...) {
267 memset(log_string, '\0', sizeof(log_string));
268 va_list args;
269 va_start(args, fmt);
270 vsnprintf(log_string, 490, fmt, args);
271 switch (xi_log_level) {
272 case DEV_LOG_LEVEL_FATAL:
273 printf("FATAL: %s\n", log_string);
274 // exit (0);
275 break;
276 case DEV_LOG_LEVEL_ERROR:
277 printf("ERROR : %s\n", log_string);
278 break;
279 case DEV_LOG_LEVEL_WARNING:
280 printf("WARNING : %s\n", log_string);
281 break;
282 case DEV_LOG_LEVEL_INFO:
283 printf("INFO : %s\n", log_string);
284 break;
285 case DEV_LOG_LEVEL_DEBUG:
286 printf("DEBUG : %s\n", log_string);
287 break;
288 default:
289 printf("%s\n", log_string);
290 }
291 va_end(args);
292}
293
294bcmos_errno bcmos_task_query(const bcmos_task *task, bcmos_task_parm *parm) {
295 printf (" -- stub bcmos_task_query called --\n");
296 return BCM_ERR_OK;
297}
298
299bcmos_errno bcmos_task_create(bcmos_task *task, const bcmos_task_parm *parm) {
300 printf (" -- stub bcmos_task_create called --\n");
301 return BCM_ERR_OK;
302}
303
304int bcmos_printf(const char *fmt, ...) {
305 memset(log_string, '\0', sizeof(log_string));
306 va_list args;
307 va_start(args, fmt);
308 vsnprintf(log_string, 490, fmt, args);
309 printf("%s\n", log_string);
310 va_end(args);
311
312}
313
314bcmos_bool bcmolt_api_conn_mgr_is_connected(bcmolt_goid olt) {
315 printf ("-- stub bcmolt_api_conn_mgr_is_connected called --\n");
316 return true;
317}
318}