blob: 5ab1b7956e83fe6afc77ffcf6d700b78839298cd [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
Girish Gowdrae538dfd2019-09-30 11:07:30 +0530147/* 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}