FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
spp_platform_trace_log.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * spp_platform_trace_log.h
4  *
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:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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  *------------------------------------------------------------------
18  */
19 
20 #ifndef __SPP_PLATFORM_TRACE_LOG_H__
21 #define __SPP_PLATFORM_TRACE_LOG_H__
22 
23 #include <stdio.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>
29 
30 #include "spp_ctx.h"
31 #include "spp_timers.h"
32 
33 
34 typedef enum {
38 
39 typedef struct {
42 
43 typedef struct {
46  u32 arg[0];
48 
49 #define DUMP_PKT_IDX 61
50 #define OCTEON_SENSOR_READ 62
51 
52 typedef enum {
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 */
106  CNAT_FRAG_DB_ERROR, /* see spp_frag_db_error_sub_codes_t below */
107 
112 
113 typedef enum {
114 
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 */
120 
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 */
128 
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 */
131 
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 */
139 
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 */
143 
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*/
148 
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 */
152 
153  V6RD_INVALID_6RD_ID_ERROR = 90, /*1 param - id */
154  MAPE_INVALID_MAPE_ID_ERROR = 100 /* param - id */
156 
157 typedef enum {
165 
166 typedef enum {
170 
171 typedef enum {
175 
176 typedef enum {
180 
181 typedef enum {
185 
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
192 
193 extern spp_cnat_logger_tbl_t spp_cnat_logger_table[];
194 
195 /*
196  * This corresponds to the length of the IMETRO SHIM Header for RODDICK
197  * For non-roddick cases, introduce an Ethernet header as well
198  */
199 #if defined(RODDICK)
200 #define SPP_TRACE_LOG_SHIM_HDR_OFFSET 8
201 #define SPP_TRACE_LOG_ENCAPS_OFFSET 0
202 #else
203 #define SPP_TRACE_LOG_SHIM_HDR_OFFSET 0
204 #define SPP_TRACE_LOG_ENCAPS_OFFSET 16
205 #endif
206 
207 #define SPP_LOG_TRACE_HEADER_LENGTH \
208  (sizeof(spp_trace_log_hdr_t))
209 
210 
211 #define SPP_TRACE_LOG_IP_HDR_OFFSET \
212  (SPP_TRACE_LOG_ENCAPS_OFFSET + \
213  SPP_TRACE_LOG_SHIM_HDR_OFFSET)
214 
215 
216 #define SPP_TRACE_LOG_UDP_HDR_OFFSET \
217  (SPP_TRACE_LOG_IP_HDR_OFFSET + sizeof(ipv4_header))
218 
219 #define SPP_TRACE_LOG_HDR_OFFSET \
220  (SPP_TRACE_LOG_UDP_HDR_OFFSET + sizeof(udp_hdr_type_t))
221 
222 #define SPP_TRACE_LOG_RECORD_LENGTH 4
223 
224 /*
225  * Let us put the maximum length of the log data to be 1400
226  */
227 #define SPP_TRACE_LOG_MAX_PKT_LENGTH 800
228 
229 /* Structures and defines to store log info for MSC */
230 #define SPP_TRACE_LOG_INVALID_LOGGING_INDEX 0xffffffff
231 
232 /*
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
236  */
237 typedef struct {
238  /*
239  * This field determines the maximum size of the Netflow V9 information
240  * that can be stored in a logging packet
241  */
243 
244  u32 sequence_num; /* Sequence number of the logging packet */
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 */
251  /*
252  * current logging context
253  */
255 
256  /*
257  * Timestamp in UNIX seconds corresponding to when the current
258  * logging packet was created
259  */
261 
262  /*
263  * Queued logging context waiting to be sent to the l3 infra node
264  */
266 
267  /*
268  * Headers corresponding to various records in this
269  * current nfv9 logging context
270  */
274 
276 
277 typedef struct {
278  /*
279  * spp_ctx_alloc() call failed
280  */
282 
283  /*
284  * Cannot send the existing logging pkt, so cannot create
285  * any additional packets for logging purposes
286  */
288 
289  /*
290  * Cannot send the existing logging pkt due to cnat_rewrite_output
291  * superframe being full.
292  */
295 
296 
297 /*
298  * Global structure for SPP LOGS
299  */
300 typedef struct {
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.
305  */
307 
308  /*
309  * Node index corresponding to the infra L3 output node
310  * to which the nfv9 logging node will send the packet
311  */
313 
314  /*
315  * Whether we have initialized the NFv9 information
316  */
318 
319  /*
320  * pool index in global pool based on log type
321  */
322  u32 spp_log_pool_index[SPP_LOG_MAX];
323 
325 
326 
327 extern spp_timer_t sensor_timer;
330 
332 
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);
337 
338 /*
339  * The following 2 functions are temporary hacks until
340  * we have RTC support from the PD nodes
341  */
342 #if 0
343 inline
344 u32 spp_trace_log_get_sys_up_time_in_ms (void);
345 #endif
346 extern
348 
349 enum {
352 };
353 
354 extern int temperature_read_blocked;
355 
356 void read_octeon_sensors(u8 mode);
358 #endif /* __SPP_PLATFORM_TRACE_LOG_H__ */
spp_cmvx_error_sub_codes_t
void spp_trace_log_init(void)
spp_nfv9_error_sub_codes_t
Fixed length block allocator.
int temperature_read_blocked
spp_dummy_handler_sub_cdes_t
spp_config_error_sub_codes_t
spp_trace_log_t * log_record
spp_trace_log_info_t spp_default_trace_log_info
unsigned long u64
Definition: types.h:89
spp_trace_log_info_t * spp_trace_log_info_pool
spp_timer_t sensor_timer
u32 spp_trace_log_get_unix_time_in_seconds(void)
void init_trace_log_buf_pool(void)
struct spp_cnat_logger_tbl_t_ spp_cnat_logger_tbl_t
spp_trace_log_global_info_t spp_trace_log_global_info
spp_cli_error_sub_codes_t
void spp_trace_logger(u16 error_code, u16 num_args, u32 *arg)
spp_frag_db_error_sub_codes_t
unsigned int u32
Definition: types.h:88
Bitmaps built as vectors of machine words.
void Init_temperature_sensors()
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
void read_octeon_sensors(u8 mode)
struct _spp_ctx spp_ctx_t
spp_trace_log_hdr_t * log_header
void spp_printf(u16 error_code, u16 num_args, u32 *arg)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".