blob: 6d757b3979829fc25ce2edef72f457b3f9f1617a [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) {
34 // let always sleep for 1s irrespective of the value passed.
35 sleep (1);
36}
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 */
58bcmos_errno bcmolt_cfg_set(bcmolt_oltid olt, bcmolt_cfg *cfg)
59{
60 printf("-- entering :stubbed %s\n", __FUNCTION__);
61 return BCM_ERR_OK;
62}
63
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 */
74bcmos_errno bcmolt_cfg_clear(bcmolt_oltid olt, bcmolt_cfg *cfg)
75{
76 printf("-- entering :stubbed %s\n", __FUNCTION__);
77 return BCM_ERR_OK;
78}
79
80/* Get statistics */
81bcmos_errno bcmolt_stat_get(bcmolt_oltid olt, bcmolt_stat *stat, bcmolt_stat_flags flags)
82{
83 printf("-- entering :stubbed %s\n", __FUNCTION__);
84 return BCM_ERR_OK;
85}
86
87/* Get statistics configuration */
88bcmos_errno bcmolt_stat_cfg_get(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
89{
90 printf("-- entering :stubbed %s\n", __FUNCTION__);
91 return BCM_ERR_OK;
92}
93
94/* Set statistics configuration */
95bcmos_errno bcmolt_stat_cfg_set(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
96{
97 printf("-- entering :stubbed %s\n", __FUNCTION__);
98 return BCM_ERR_OK;
99}
100
101/* Register Autonomous Indication Message Handler */
102bcmos_errno bcmolt_ind_subscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
103{
104 printf("-- entering :stubbed %s\n", __FUNCTION__);
105 return BCM_ERR_OK;
106}
107
108/* Un-register Autonomous Indication Message Handler registered by bcmolt_ind_subscribe() */
109bcmos_errno bcmolt_ind_unsubscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
110{
111 printf("-- entering :stubbed %s\n", __FUNCTION__);
112 return BCM_ERR_OK;
113}
114
115/* Submit Operation */
116/*
117bcmos_errno bcmolt_oper_submit(bcmolt_oltid olt, bcmolt_oper *oper)
118{
119 printf("-- entering :stubbed %s\n", __FUNCTION__);
120 return BCM_ERR_OK;
121}
122*/
123
124/* Get configuration of multiple objects */
125bcmos_errno bcmolt_multi_cfg_get(
126 bcmolt_oltid olt,
127 bcmolt_multi_cfg *cfg,
128 bcmolt_filter_flags filter_flags)
129{
130 printf("-- entering :stubbed %s\n", __FUNCTION__);
131 return BCM_ERR_OK;
132}
133
134/* Get statistics of multiple objects */
135bcmos_errno bcmolt_multi_stat_get(
136 bcmolt_oltid olt,
137 bcmolt_multi_stat *stat,
138 bcmolt_stat_flags stat_flags,
139 bcmolt_filter_flags filter_flags)
140{
141 printf("-- entering :stubbed %s\n", __FUNCTION__);
142 return BCM_ERR_OK;
143}
144
145/* Map error code to error string */
146const char *bcmos_strerror(bcmos_errno err)
147{
148 static const char *errstr[] = {
149 [-BCM_ERR_OK] = "OK",
150 [-BCM_ERR_IN_PROGRESS] = "In progress",
151 [-BCM_ERR_PARM] = "Error in parameters",
152 [-BCM_ERR_NOMEM] = "No memory",
153 [-BCM_ERR_NORES] = "No resources",
154 [-BCM_ERR_INTERNAL] = "Internal error",
155 [-BCM_ERR_NOENT] = "Entry doesn't exist",
156 [-BCM_ERR_NODEV] = "Device doesn't exist",
157 [-BCM_ERR_ALREADY] = "Entry already exists/already in requested state",
158 [-BCM_ERR_RANGE] = "Out of range",
159 [-BCM_ERR_PERM] = "No permission to perform an operation",
160 [-BCM_ERR_NOT_SUPPORTED] = "Operation is not supported",
161 [-BCM_ERR_PARSE] = "Parsing error",
162 [-BCM_ERR_INVALID_OP] = "Invalid operation",
163 [-BCM_ERR_IO] = "I/O error",
164 [-BCM_ERR_STATE] = "Object is in bad state",
165 [-BCM_ERR_DELETED] = "Object is deleted",
166 [-BCM_ERR_TOO_MANY] = "Too many objects",
167 [-BCM_ERR_NO_MORE] = "No more entries",
168 [-BCM_ERR_OVERFLOW] = "Buffer overflow",
169 [-BCM_ERR_COMM_FAIL] = "Communication failure",
170 [-BCM_ERR_NOT_CONNECTED] = "No connection with the target system",
171 [-BCM_ERR_SYSCALL_ERR] = "System call returned error",
172 [-BCM_ERR_MSG_ERROR] = "Received message is insane",
173 [-BCM_ERR_TOO_MANY_REQS] = "Too many outstanding requests",
174 [-BCM_ERR_TIMEOUT] = "Operation timed out",
175 [-BCM_ERR_TOO_MANY_FRAGS] = "Too many fragments",
176 [-BCM_ERR_NULL] = "Got NULL pointer",
177 [-BCM_ERR_READ_ONLY] = "Attempt to set read-only parameter",
178 [-BCM_ERR_ONU_ERR_RESP] = "ONU returned an error response",
179 [-BCM_ERR_MANDATORY_PARM_IS_MISSING] = "Mandatory parameter is missing",
180 [-BCM_ERR_KEY_RANGE] = "Key field out of range",
181 [-BCM_ERR_QUEUE_EMPTY] = "Rx of PCIe empty",
182 [-BCM_ERR_QUEUE_FULL] = "Tx of PCIe full",
183 [-BCM_ERR_TOO_LONG] = "Processing is taking too long, but will finish eventually",
184 [-BCM_ERR_INSUFFICIENT_LIST_MEM] = "Insufficient list memory provided",
185 [-BCM_ERR_OUT_OF_SYNC] = "Sequence number or operation step was out of sync",
186 [-BCM_ERR_CHECKSUM] = "Checksum error",
187 [-BCM_ERR_IMAGE_TYPE] = "Unsupported file/image type",
188 [-BCM_ERR_INCOMPLETE_TERMINATION] = "Incomplete premature termination",
189 [-BCM_ERR_MISMATCH] = "Parameters mismatch",
190 };
191 static const char *unknown = "*unknown*";
192
193 if ((unsigned)(-err) >= sizeof(errstr)/sizeof(errstr[0]) || !errstr[-err])
194 return unknown;
195 return errstr[-err];
196}
197
198void bcmolt_msg_free(bcmolt_msg *msg)
199{
200 return;
201}
202
203void bcmolt_api_set_prop_present(bcmolt_msg *msg, const void *prop_ptr)
204{
205 return;
206}
207
208const bcmolt_enum_val bcmolt_obj_id_string_table[] = {"dummy string, never used"};
209const bcmolt_enum_val bcmolt_interface_state_string_table[] = {"dummy string, never used"};
210
211dev_log_id bcm_dev_log_id_register(const char *xi_name,
212 bcm_dev_log_level xi_default_log_level,
213 bcm_dev_log_id_type xi_default_log_type) {
214 return 0;
215}
216bool bcmcli_is_stopped(bcmcli_session *sess) {
217 printf("-- stub bcmcli_is_stopped called --\n");
218 return true;
219}
220
221bool bcmcli_parse(bcmcli_session *sess, char *s) {
222 printf("-- stub bcmcli_parse called --\n");
223 return true;
224}
225
226bool bcmcli_driver(bcmcli_session *sess) {
227 printf("-- stub bcmcli_driver called --\n");
228 return true;
229}
230void bcmcli_token_destroy(void *ptr) {
231 printf("-- stub bcmcli_token_destroy called --\n");
232 return;
233}
234
235void bcmcli_session_close( bcmcli_session*ptr) {
236 printf("-- stub bcmcli_session_close called --\n");
237 return;
238}
239
240bcmos_errno bcm_api_cli_set_commands(bcmcli_session *sess) {
241 printf("-- stub bcm_api_cli_set_commands called --\n");
242 return BCM_ERR_OK;
243}
244
245void bcmcli_stop(bcmcli_session *sess) {
246 printf("-- stub bcmcli_stop called --\n");
247 return;
248}
249
250void bcmcli_session_print(bcmcli_session *sess, const char *s) {
251 printf("-- stub bcmcli_session_print called --\n");
252 return;
253}
254
255bcmos_errno bcmcli_session_open(bcmcli_session_parm *mon_sess, bcmcli_session **curr_sess) {
256 printf("-- stub bcmcli_session_open called --\n");
257 return BCM_ERR_OK;
258}
259
260void bcm_dev_log_log(dev_log_id xi_id,
261 bcm_dev_log_level xi_log_level,
262 uint32_t xi_flags,
263 const char *fmt,
264 ...) {
265 memset(log_string, '\0', sizeof(log_string));
266 va_list args;
267 va_start(args, fmt);
268 vsnprintf(log_string, 490, fmt, args);
269 switch (xi_log_level) {
270 case DEV_LOG_LEVEL_FATAL:
271 printf("FATAL: %s\n", log_string);
272 // exit (0);
273 break;
274 case DEV_LOG_LEVEL_ERROR:
275 printf("ERROR : %s\n", log_string);
276 break;
277 case DEV_LOG_LEVEL_WARNING:
278 printf("WARNING : %s\n", log_string);
279 break;
280 case DEV_LOG_LEVEL_INFO:
281 printf("INFO : %s\n", log_string);
282 break;
283 case DEV_LOG_LEVEL_DEBUG:
284 printf("DEBUG : %s\n", log_string);
285 break;
286 default:
287 printf("%s\n", log_string);
288 }
289 va_end(args);
290}
291
292bcmos_errno bcmos_task_query(const bcmos_task *task, bcmos_task_parm *parm) {
293 printf (" -- stub bcmos_task_query called --\n");
294 return BCM_ERR_OK;
295}
296
297bcmos_errno bcmos_task_create(bcmos_task *task, const bcmos_task_parm *parm) {
298 printf (" -- stub bcmos_task_create called --\n");
299 return BCM_ERR_OK;
300}
301
302int bcmos_printf(const char *fmt, ...) {
303 memset(log_string, '\0', sizeof(log_string));
304 va_list args;
305 va_start(args, fmt);
306 vsnprintf(log_string, 490, fmt, args);
307 printf("%s\n", log_string);
308 va_end(args);
309
310}
311
312bcmos_bool bcmolt_api_conn_mgr_is_connected(bcmolt_goid olt) {
313 printf ("-- stub bcmolt_api_conn_mgr_is_connected called --\n");
314 return true;
315}
316}