2 *------------------------------------------------------------------
3 * spp_platform_trace_log.h
5 * Copyright (c) 2009-2013 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #ifndef __SPP_PLATFORM_TRACE_LOG_H__
21 #define __SPP_PLATFORM_TRACE_LOG_H__
24 #include <vppinfra/vec.h>
25 #include <vppinfra/bitmap.h>
26 #include <vppinfra/hash.h>
27 #include <vppinfra/pool.h>
28 #include <vppinfra/clib.h>
31 #include "spp_timers.h"
41 } spp_trace_log_hdr_t;
49 #define DUMP_PKT_IDX 61
50 #define OCTEON_SENSOR_READ 62
55 CNAT_NO_VRF_RUN_ERROR,
56 CNAT_NO_POOL_FOR_ANY_ERROR,
57 CNAT_NO_PORT_FOR_ANY_ERROR,
58 CNAT_BAD_INUSE_ANY_ERROR,
59 CNAT_NOT_FOUND_ANY_ERROR,
60 CNAT_INV_PORT_FOR_DIRECT_ERROR,
61 CNAT_BAD_INUSE_DIRECT_ERROR,
62 CNAT_NOT_FOUND_DIRECT_ERROR,
63 CNAT_OUT_OF_PORT_LIMIT_ERROR,
64 CNAT_MAIN_DB_CREATE_ERROR,
66 CNAT_INDEX_MISMATCH_ERROR,
67 CNAT_PACKET_DROP_ERROR,
68 CNAT_INV_UNUSED_USR_INDEX,
69 CNAT_INVALID_VRFMAP_INDEX,
70 CNAT_USER_OUT_OF_PORTS,
71 CNAT_EXT_PORT_THRESH_EXCEEDED,
72 CNAT_EXT_PORT_THRESH_NORMAL,
73 CNAT_NO_EXT_PORT_AVAILABLE,
74 CNAT_SESSION_THRESH_EXCEEDED,
75 CNAT_SESSION_THRESH_NORMAL,
78 SYSMGR_PD_KEY_CREATION_ERROR,
79 SYSMGR_PD_SHMEM_ID_ERROR,
80 SYSMGR_PD_SHMEM_ATTACH_ERROR,
85 SPP_MAX_DISPATCH_REACHED,
88 HA_INVALID_SEQ_OR_CONFIG_OR_TYPE,
90 CNAT_CLI_INVALID_INPUT, /* new adds as part of CSCto04510, see sub codes below */
91 CNAT_DUMMY_HANDLER_HIT, /* Has sub codes , see spp_dummy_handler_sub_cdes_t */
92 CNAT_CONFIG_ERROR, /* has subcodes-see spp_config_error_sub_codes_t below */
93 CNAT_NFV9_ERROR, /* Has sub codes see spp_nfv9_error_sub_codes_t below */
94 CNAT_CMVX_TWSI_READ_WRITE_FAIL, /* Hassub codes see spp_cmvx_error_sub_codes_t */
95 CNAT_TEMP_SENSOR_TIMEOUT,
96 CNAT_TEMP_SENSOR_DATA_MISMATCH,
97 CNAT_TEMP_SENSOR_CONFIG_FAILED,
98 HA_APP_NOT_RESPONDING,
99 HA_DATA_PATH_TEST_FAILED,
100 CNAT_WRONG_PORT_ALLOC_TYPE,
101 CNAT_NEW_PORT_ALLOC_ERROR,
102 CNAT_INVALID_INDEX_TO_FREE_PORT,
103 CNAT_DELETE_DB_ENTRY_NO_PORTMAP,
104 CNAT_MAIN_DB_LIMIT_ERROR,
105 CNAT_USER_DB_LIMIT_ERROR,
106 CNAT_FRAG_DB_ERROR, /* see spp_frag_db_error_sub_codes_t below */
109 CNAT_NAT64_SYSTEM_LIMIT_ERROR,
115 TCP_MSS_INVALID_IVRF = 10, /* 1 param - vrf id */
116 NFV9_LOG_INVALID_IP_OR_PORT = 20, /* 2 params - nfv9 server ip and port */
117 NFV9_LOG_INVALID_PARAMS_OTHERS, /* 3 params, ref rate, time out, path mtu */
118 NFV9_LOG_PATH_MTU_TOO_SMALL, /* 1 param, path mtu passed */
119 NFV9_LOG_CANNOT_ADD_VRF_NOT_FOUND, /* 1 param, in vrf id */
121 VRF_MAP_ADDR_POOL_START_ADDR_GT_END_ADDR = 30, /* 2 params, start and end addr */
122 VRF_MAP_ADDR_POOL_ADDR_POOL_TOO_LARGE, /* 2 params, start and end addr */
123 VRF_MAP_ADDR_POOL_INVALID_IN_OR_OUT_VRF, /* 2 params, in vrf and out vrf */
124 VRF_MAP_ADDR_POOL_TOO_LARGE_FOR_CORE, /* 2 params, pool size, core instance */
125 VRF_MAP_DEL_POOL_START_ADDR_GT_END_ADDR, /* 2 params, start and end addr */
126 VRF_MAP_DEL_POOL_ADDR_POOL_NOT_FOUND, /* 2 params, start and end addr */
127 VRF_MAP_DEL_POOL_VRF_MAP_EMPTY, /* 2 params, start and end addr */
129 ADD_SVI_ADDR_INVALID_VRF = 40, /* 2 params, vrf passed and ipv4 addr */
130 ADD_SVI_INDEX_INVALID_VRF, /* 2 params, vrf, uidb_index */
132 MAPPED_STAT_PORT_INVALID_OUTPUT_PARAMS = 50,
133 /* 3 params, out vrf, out ip, out port */
134 MAPPED_STAT_PORT_UDP_PORT_POLARITY_MISMATCH, /* 2 params, in port and out port */
135 MAPPED_STAT_PORT_IN_VRF_MAP_EMPTY, /* 1 param, in vrf id passed */
136 MAPPED_STAT_PORT_VRF_MAP_NOT_IN_S_RUN, /* 1 param, vrf map status */
137 MAPPED_STAT_PORT_INVALID_OUT_VRF_ID, /* 1 param, out vrf id passed */
138 MAPPED_STAT_PORT_FAILED_TO_ADD_STAT_PORT, /* 4 params, in vrf, in ip, in port, error code */
140 STAT_PORT_INVALID_IN_PARAMS = 60, /* 4 params, in vrf, in ip, in port, proto */
141 STAT_PORT_FAILED_TO_ADD_STAT_PORT, /* 4 params, in vrf, in ip, in port, error code */
142 STAT_PORT_CONFIG_IN_USE, /* 4 params, in vrf, in ip, in port, proto */
144 DEL_STAT_PORT_IN_VRF_MAP_EMPTY = 70, /* 1 param, in vrf id passed */
145 DEL_STAT_PORT_INVALID_IN_PARAMS, /* 4 params, in vrf, in ip, in port, proto */
146 DEL_STAT_PORT_CANNOT_DELETE_NO_ENTRY, /* 4 params, in vrf, in ip, in port, proto */
147 DEL_STAT_PORT_CANNOT_DELETE_NOT_STATIC_PORT, /* 4 params, in vrf, in ip, in port, proto*/
149 XLAT_SVI_CFG_INVALID_INDEX = 80, /* 1 param - uidb_index */
150 XLAT_WRONG_V6_PREFIX_MASK, /* 1 param - v6 prefix mask */
151 XLAT_INVALID_XLAT_ID_ERROR, /* 1 param - id */
153 V6RD_INVALID_6RD_ID_ERROR = 90, /*1 param - id */
154 MAPE_INVALID_MAPE_ID_ERROR = 100 /* param - id */
155 } spp_config_error_sub_codes_t;
164 } spp_dummy_handler_sub_cdes_t;
169 } spp_cmvx_error_sub_codes_t;
172 FRAG_DB_INVALID_BUCKET,
174 } spp_frag_db_error_sub_codes_t;
177 CLI_INVALID_PAYLOAD_SIZE,
179 } spp_cli_error_sub_codes_t;
182 NFV9_DOWNSTREAM_CONGESTION,
183 NFV9_FAILED_TO_CREATE_CONTEXT
184 } spp_nfv9_error_sub_codes_t;
186 typedef struct spp_cnat_logger_tbl_t_ {
187 u16 error_code; // The thread id stored by software
189 u16 rate_limit_time; // If we need to rate_limit logging
190 u8 param_name[7][32];// Parameter name for debug purposes
191 } spp_cnat_logger_tbl_t;
193 extern spp_cnat_logger_tbl_t spp_cnat_logger_table[];
196 * This corresponds to the length of the IMETRO SHIM Header for RODDICK
197 * For non-roddick cases, introduce an Ethernet header as well
200 #define SPP_TRACE_LOG_SHIM_HDR_OFFSET 8
201 #define SPP_TRACE_LOG_ENCAPS_OFFSET 0
203 #define SPP_TRACE_LOG_SHIM_HDR_OFFSET 0
204 #define SPP_TRACE_LOG_ENCAPS_OFFSET 16
207 #define SPP_LOG_TRACE_HEADER_LENGTH \
208 (sizeof(spp_trace_log_hdr_t))
211 #define SPP_TRACE_LOG_IP_HDR_OFFSET \
212 (SPP_TRACE_LOG_ENCAPS_OFFSET + \
213 SPP_TRACE_LOG_SHIM_HDR_OFFSET)
216 #define SPP_TRACE_LOG_UDP_HDR_OFFSET \
217 (SPP_TRACE_LOG_IP_HDR_OFFSET + sizeof(ipv4_header))
219 #define SPP_TRACE_LOG_HDR_OFFSET \
220 (SPP_TRACE_LOG_UDP_HDR_OFFSET + sizeof(udp_hdr_type_t))
222 #define SPP_TRACE_LOG_RECORD_LENGTH 4
225 * Let us put the maximum length of the log data to be 1400
227 #define SPP_TRACE_LOG_MAX_PKT_LENGTH 800
229 /* Structures and defines to store log info for MSC */
230 #define SPP_TRACE_LOG_INVALID_LOGGING_INDEX 0xffffffff
233 * This structure stores the Logging information on per LOG TYPE
234 * basis. This structure is allocated from a pool and index
235 * to this structure based on log type
239 * This field determines the maximum size of the Netflow V9 information
240 * that can be stored in a logging packet
242 u16 max_length_minus_max_record_size;
244 u32 sequence_num; /* Sequence number of the logging packet */
245 u32 last_pkt_sent_count;
246 u16 pkt_length; /* Length of the currently NFv9 information */
247 u16 log_record_length; /* Length of add record */
248 u16 total_record_length; /* number of trace records */
249 u16 total_record_count;
250 spp_log_type_t log_type;
252 * current logging context
254 spp_ctx_t *current_logging_context;
257 * Timestamp in UNIX seconds corresponding to when the current
258 * logging packet was created
260 u32 current_logging_context_timestamp;
263 * Queued logging context waiting to be sent to the l3 infra node
265 spp_ctx_t *queued_logging_context;
268 * Headers corresponding to various records in this
269 * current nfv9 logging context
271 spp_trace_log_t *log_record;
272 spp_trace_log_hdr_t *log_header;
275 } spp_trace_log_info_t;
279 * spp_ctx_alloc() call failed
281 u64 spp_trace_log_context_creation_fail_count;
284 * Cannot send the existing logging pkt, so cannot create
285 * any additional packets for logging purposes
287 u64 spp_trace_log_context_creation_deferred_count;
290 * Cannot send the existing logging pkt due to cnat_rewrite_output
291 * superframe being full.
293 u64 spp_trace_log_downstream_constipation_count;
294 } spp_global_counters_t;
298 * Global structure for SPP LOGS
301 /* A timer structure to periodically send log packets
302 * that have been waiting to be full for a long time. This will
303 * ensure event/error logs don't get delayed too much before they
304 * are sent to the MSC.
306 spp_timer_t log_timer;
309 * Node index corresponding to the infra L3 output node
310 * to which the nfv9 logging node will send the packet
312 u16 spp_trace_log_disp_node_index;
315 * Whether we have initialized the NFv9 information
317 u8 spp_trace_log_init_done;
320 * pool index in global pool based on log type
322 u32 spp_log_pool_index[SPP_LOG_MAX];
324 } spp_trace_log_global_info_t;
327 extern spp_timer_t sensor_timer;
328 extern spp_trace_log_info_t spp_default_trace_log_info;
329 extern spp_trace_log_info_t *spp_trace_log_info_pool;
331 extern spp_trace_log_global_info_t spp_trace_log_global_info;
333 void spp_trace_logger(u16 error_code, u16 num_args, u32 *arg);
334 void spp_trace_log_init(void);
335 void init_trace_log_buf_pool(void);
336 void spp_printf(u16 error_code, u16 num_args, u32 *arg);
339 * The following 2 functions are temporary hacks until
340 * we have RTC support from the PD nodes
343 u32 spp_trace_log_get_sys_up_time_in_ms (void);
346 u32 spp_trace_log_get_unix_time_in_seconds (void);
349 TEMPERATURE_SENSOR_TEST_MODE,
350 TEMPERATURE_SENSOR_QUIET_MODE,
353 extern int temperature_read_blocked;
355 void read_octeon_sensors(u8 mode);
356 void Init_temperature_sensors();
357 #endif /* __SPP_PLATFORM_TRACE_LOG_H__ */