Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2017-present Open Networking Foundation |
| 3 | ** |
| 4 | ** 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 |
| 7 | ** |
| 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ** |
| 10 | ** 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 | */ |
| 16 | |
| 17 | #ifndef DRIVERAPP_ASFVOLT16_DRIVER |
| 18 | #define DRIVERAPP_ASFVOLT16_DRIVER |
| 19 | |
| 20 | /* Includes related to proto buf */ |
| 21 | #include "bal_msg_type.grpc-c.h" |
| 22 | #include "bal_osmsg.grpc-c.h" |
| 23 | #include "bal_model_ids.grpc-c.h" |
| 24 | #include "bal_obj.grpc-c.h" |
| 25 | #include "bal_model_types.grpc-c.h" |
| 26 | #include "bal_errno.grpc-c.h" |
| 27 | #include "bal.grpc-c.h" |
| 28 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 29 | #include <syslog.h> |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 30 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 31 | #define ASFVOLT_ERROR (LOG_ERR) |
| 32 | #define ASFVOLT_INFO (LOG_INFO) |
| 33 | #define ASFVOLT_DEBUG (LOG_DEBUG) |
| 34 | #define ASFVOLT_SYSLOG_NAME "volthad" /* syslog service name */ |
| 35 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 36 | #define ASFVOLT_MAX_PKT_SIZE 500 |
| 37 | #define ASFVOLT_MAX_DEVICE_ID_SIZE 50 |
| 38 | #define MAX_CHAR_LENGTH 20 |
| 39 | #define MAX_OMCI_MSG_LENGTH 44 |
| 40 | |
| 41 | char voltha_device_id[ASFVOLT_MAX_DEVICE_ID_SIZE]; |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 42 | unsigned int is_reboot; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 43 | |
| 44 | typedef struct BalCoreIpInfo |
| 45 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 46 | char bal_core_arg1[4]; |
| 47 | char bal_core_ip_port[24]; |
| 48 | char bal_core_arg2[4]; |
| 49 | char bal_shared_lib_ip_port[24]; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 50 | }balCoreIpInfo; |
| 51 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 52 | #if 0 /* change to 1 to enable function/line to stdout w/syslog message*/ |
| 53 | #include <stdio.h> |
| 54 | |
| 55 | #define ASFVOLT_SYSLOG_MODE (LOG_CONS | LOG_PID | LOG_NDELAY) |
| 56 | #define DEBUG_LOG(format, args...) \ |
| 57 | printf(ASFVOLT_SYSLOG_NAME ": %s:%d: ", __FILE__, __LINE__); \ |
| 58 | printf(format, ## args); \ |
| 59 | putchar('\n'); |
| 60 | #else |
| 61 | #define ASFVOLT_SYSLOG_MODE ( LOG_PID | LOG_NDELAY) |
| 62 | #define DEBUG_LOG(format, args...) |
| 63 | #endif |
| 64 | |
Kim Kempf | b032b67 | 2017-09-11 18:40:34 -0700 | [diff] [blame] | 65 | #define ASFVOLT_LOG(log_type, format, args...) \ |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 66 | if(log_type) \ |
| 67 | {\ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 68 | syslog(log_type, "%s:%d: " format, __FILE__, __LINE__, ##args);\ |
| 69 | DEBUG_LOG(format, ## args);\ |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 70 | } |
| 71 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 72 | #define ASFVOLT_LOG_LOC(log_type, file, line, format, args...) \ |
| 73 | if(log_type) \ |
| 74 | {\ |
| 75 | syslog(log_type, "%s:%d: " format, file, line, ##args);\ |
| 76 | DEBUG_LOG(format, ## args);\ |
| 77 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 78 | |
| 79 | #define ASFVOLT_CFG_PROP_SET(cfg, obj, param, pram_prst, param_val) \ |
| 80 | if(pram_prst)\ |
| 81 | {\ |
| 82 | BCMBAL_CFG_PROP_SET(&cfg, obj, param, param_val);\ |
| 83 | } |
| 84 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 85 | #define ASFVOLT_HEX2LOG(prio, pFormat, pData, len) \ |
| 86 | asfvolt_hexlog2(prio, __FILE__, __LINE__, pFormat, pData, len) |
| 87 | |
| 88 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 89 | /*************************************************************** |
| 90 | * * |
| 91 | * Function Declarations * |
| 92 | * * |
| 93 | ****************************************************************/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 94 | extern void asfvolt_hexlog2(int prio, const char *_file_loc, int _file_line, const char *pFormat, void* pData, size_t len); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 95 | extern uint32_t asfvolt16_bal_init(BalInit *bal_init, balCoreIpInfo *coreInfo); |
| 96 | extern uint32_t asfvolt16_bal_finish(void); |
| 97 | extern uint32_t bal_register_indication_cbs(void); |
| 98 | extern uint32_t asfvolt16_bal_cfg_set(BalCfg *cfg); |
| 99 | extern uint32_t asfvolt16_bal_cfg_clear(BalKey *key); |
| 100 | extern uint32_t asfvolt16_bal_cfg_get(BalKey *key, BalCfg *cfg); |
| 101 | extern void asfvolt16_send_omci_msg(uint16_t olt_no, uint32_t onu_nu, char* packet_to_send); |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 102 | extern uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData, |
| 103 | BalInterfaceKey *statKey); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 104 | grpc_c_client_t *client; |
| 105 | |
| 106 | #endif /* DRIVERAPP_ASFVOLT16_DRIVER */ |