blob: 3119827a06eb3969e63376daa8b4a45654a85405 [file] [log] [blame]
Girish Gowdrae538dfd2019-09-30 11:07:30 +05301/*
2 Copyright (C) 2018 Open Networking Foundation
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// This file stub definitions for some BAL APIs that are unavailable
20// in TEST_MODE
21//
22extern "C" {
23#include <test_stub.h>
24#include <stdio.h>
25#include <string.h>
26#include <stdarg.h>
27
28#include <bcmos_system.h>
29#include <bcmolt_msg.h>
30#include <bcmolt_host_api.h>
31
32char log_string[500];
33dev_log_id def_log_id=0;
34
35void bcmos_usleep(uint32_t us) {
36 // let always sleep for 1s irrespective of the value passed.
37 sleep (1);
38}
39
40void bcmos_fastlock_init(bcmos_fastlock *lock, uint32_t flags) {
41 pthread_mutex_init(&(lock->lock), NULL);
42}
43
44long bcmos_fastlock_lock(bcmos_fastlock *lock) {
45 pthread_mutex_lock(&(lock->lock));
46}
47
48void bcmos_fastlock_unlock(bcmos_fastlock *lock, long flags) {
49 pthread_mutex_unlock(&(lock->lock));
50}
51
52/* Initialize API layer */
53bcmos_errno bcmolt_api_init(void)
54{
55 printf("-- entering :stubbed %s\n", __FUNCTION__);
56 return BCM_ERR_OK;
57}
58
59/* Set configuration */
60bcmos_errno bcmolt_cfg_set(bcmolt_oltid olt, bcmolt_cfg *cfg)
61{
62 printf("-- entering :stubbed %s\n", __FUNCTION__);
63 return BCM_ERR_OK;
64}
65
66/* Get configuration */
67/*
68bcmos_errno bcmolt_cfg_get(bcmolt_oltid olt, bcmolt_cfg *cfg)
69{
70 printf("-- entering :stubbed %s\n", __FUNCTION__);
71 return BCM_ERR_OK;
72}
73*/
74
75/* Clear configuration */
76bcmos_errno bcmolt_cfg_clear(bcmolt_oltid olt, bcmolt_cfg *cfg)
77{
78 printf("-- entering :stubbed %s\n", __FUNCTION__);
79 return BCM_ERR_OK;
80}
81
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
147bcmos_errno bcmolt_host_init(const bcmolt_host_init_parms *init_parms)
148{
149 return BCM_ERR_OK;
150}
151
152/* Map error code to error string */
153const char *bcmos_strerror(bcmos_errno err)
154{
155 static const char *errstr[] = {
156 [-BCM_ERR_OK] = "OK",
157 [-BCM_ERR_IN_PROGRESS] = "In progress",
158 [-BCM_ERR_PARM] = "Error in parameters",
159 [-BCM_ERR_NOMEM] = "No memory",
160 [-BCM_ERR_NORES] = "No resources",
161 [-BCM_ERR_INTERNAL] = "Internal error",
162 [-BCM_ERR_NOENT] = "Entry doesn't exist",
163 [-BCM_ERR_NODEV] = "Device doesn't exist",
164 [-BCM_ERR_ALREADY] = "Entry already exists/already in requested state",
165 [-BCM_ERR_RANGE] = "Out of range",
166 [-BCM_ERR_PERM] = "No permission to perform an operation",
167 [-BCM_ERR_NOT_SUPPORTED] = "Operation is not supported",
168 [-BCM_ERR_PARSE] = "Parsing error",
169 [-BCM_ERR_INVALID_OP] = "Invalid operation",
170 [-BCM_ERR_IO] = "I/O error",
171 [-BCM_ERR_STATE] = "Object is in bad state",
172 [-BCM_ERR_DELETED] = "Object is deleted",
173 [-BCM_ERR_TOO_MANY] = "Too many objects",
174 [-BCM_ERR_NO_MORE] = "No more entries",
175 [-BCM_ERR_OVERFLOW] = "Buffer overflow",
176 [-BCM_ERR_COMM_FAIL] = "Communication failure",
177 [-BCM_ERR_NOT_CONNECTED] = "No connection with the target system",
178 [-BCM_ERR_SYSCALL_ERR] = "System call returned error",
179 [-BCM_ERR_MSG_ERROR] = "Received message is insane",
180 [-BCM_ERR_TOO_MANY_REQS] = "Too many outstanding requests",
181 [-BCM_ERR_TIMEOUT] = "Operation timed out",
182 [-BCM_ERR_TOO_MANY_FRAGS] = "Too many fragments",
183 [-BCM_ERR_NULL] = "Got NULL pointer",
184 [-BCM_ERR_READ_ONLY] = "Attempt to set read-only parameter",
185 [-BCM_ERR_ONU_ERR_RESP] = "ONU returned an error response",
186 [-BCM_ERR_MANDATORY_PARM_IS_MISSING] = "Mandatory parameter is missing",
187 [-BCM_ERR_KEY_RANGE] = "Key field out of range",
188 [-BCM_ERR_QUEUE_EMPTY] = "Rx of PCIe empty",
189 [-BCM_ERR_QUEUE_FULL] = "Tx of PCIe full",
190 [-BCM_ERR_TOO_LONG] = "Processing is taking too long, but will finish eventually",
191 [-BCM_ERR_INSUFFICIENT_LIST_MEM] = "Insufficient list memory provided",
192 [-BCM_ERR_OUT_OF_SYNC] = "Sequence number or operation step was out of sync",
193 [-BCM_ERR_CHECKSUM] = "Checksum error",
194 [-BCM_ERR_IMAGE_TYPE] = "Unsupported file/image type",
195 [-BCM_ERR_INCOMPLETE_TERMINATION] = "Incomplete premature termination",
196 [-BCM_ERR_MISMATCH] = "Parameters mismatch",
197 };
198 static const char *unknown = "*unknown*";
199
200 if ((unsigned)(-err) >= sizeof(errstr)/sizeof(errstr[0]) || !errstr[-err])
201 return unknown;
202 return errstr[-err];
203}
204
205void bcmolt_msg_free(bcmolt_msg *msg)
206{
207 return;
208}
209
210void bcmolt_api_set_prop_present(bcmolt_msg *msg, const void *prop_ptr)
211{
212 return;
213}
214
215const bcmolt_enum_val bcmolt_obj_id_string_table[] = {"dummy string, never used"};
216const bcmolt_enum_val bcmolt_interface_state_string_table[] = {"dummy string, never used"};
217
218dev_log_id bcm_dev_log_id_register(const char *xi_name,
219 bcm_dev_log_level xi_default_log_level,
220 bcm_dev_log_id_type xi_default_log_type) {
221 return 0;
222}
223bool bcmcli_is_stopped(bcmcli_session *sess) {
224 printf("-- stub bcmcli_is_stopped called --\n");
225 return true;
226}
227
228bool bcmcli_parse(bcmcli_session *sess, char *s) {
229 printf("-- stub bcmcli_parse called --\n");
230 return true;
231}
232
233bool bcmcli_driver(bcmcli_session *sess) {
234 printf("-- stub bcmcli_driver called --\n");
235 return true;
236}
237void bcmcli_token_destroy(void *ptr) {
238 printf("-- stub bcmcli_token_destroy called --\n");
239 return;
240}
241
242void bcmcli_session_close( bcmcli_session*ptr) {
243 printf("-- stub bcmcli_session_close called --\n");
244 return;
245}
246
247bcmos_errno bcm_api_cli_set_commands(bcmcli_session *sess) {
248 printf("-- stub bcm_api_cli_set_commands called --\n");
249 return BCM_ERR_OK;
250}
251
252void bcmcli_stop(bcmcli_session *sess) {
253 printf("-- stub bcmcli_stop called --\n");
254 return;
255}
256
257void bcmcli_session_print(bcmcli_session *sess, const char *s) {
258 printf("-- stub bcmcli_session_print called --\n");
259 return;
260}
261
262bcmos_errno bcmcli_session_open(bcmcli_session_parm *mon_sess, bcmcli_session **curr_sess) {
263 printf("-- stub bcmcli_session_open called --\n");
264 return BCM_ERR_OK;
265}
266
267void bcm_dev_log_log(dev_log_id xi_id,
268 bcm_dev_log_level xi_log_level,
269 uint32_t xi_flags,
270 const char *fmt,
271 ...) {
272 memset(log_string, '\0', sizeof(log_string));
273 va_list args;
274 va_start(args, fmt);
275 vsnprintf(log_string, 490, fmt, args);
276 switch (xi_log_level) {
277 case DEV_LOG_LEVEL_FATAL:
278 printf("FATAL: %s\n", log_string);
279 // exit (0);
280 break;
281 case DEV_LOG_LEVEL_ERROR:
282 printf("ERROR : %s\n", log_string);
283 break;
284 case DEV_LOG_LEVEL_WARNING:
285 printf("WARNING : %s\n", log_string);
286 break;
287 case DEV_LOG_LEVEL_INFO:
288 printf("INFO : %s\n", log_string);
289 break;
290 case DEV_LOG_LEVEL_DEBUG:
291 printf("DEBUG : %s\n", log_string);
292 break;
293 default:
294 printf("%s\n", log_string);
295 }
296 va_end(args);
297}
298
299bcmos_errno bcmos_task_query(const bcmos_task *task, bcmos_task_parm *parm) {
300 printf (" -- stub bcmos_task_query called --\n");
301 return BCM_ERR_OK;
302}
303
304bcmos_errno bcmos_task_create(bcmos_task *task, const bcmos_task_parm *parm) {
305 printf (" -- stub bcmos_task_create called --\n");
306 return BCM_ERR_OK;
307}
308
309int bcmos_printf(const char *fmt, ...) {
310 memset(log_string, '\0', sizeof(log_string));
311 va_list args;
312 va_start(args, fmt);
313 vsnprintf(log_string, 490, fmt, args);
314 printf("%s\n", log_string);
315 va_end(args);
316
317}
318
319bcmos_bool bcmolt_api_conn_mgr_is_connected(bcmolt_goid olt) {
320 printf ("-- stub bcmolt_api_conn_mgr_is_connected called --\n");
321 return true;
322}
323}