Add Freescale Nexus decoder implementation
[babeltrace.git] / converter / nexus / FManDebugLog.h
1 /*
2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
21 */
22
23 #ifndef FMANDEBUGLOG_H
24 #define FMANDEBUGLOG_H
25
26 #include <inttypes.h>
27 #include <vector>
28 #include <string>
29
30 using std::vector;
31 using std::string;
32
33 class FManModuleDebugLog;
34
35 // Frame Manager Debug Log collects the context data from
36 // a related series of Nexus FMAN ICT messages before parsing
37 // the context data into the internal FMan module specific logs.
38 //
39 class FManDebugLog
40 {
41 public:
42
43 FManDebugLog() :
44 fmanID_(0), context_complete_(false),
45 log_parse_error_(LOG_PARSE_NO_ERROR),
46 log_complete_(false)
47 {
48 }
49
50 ~FManDebugLog()
51 {
52 reset();
53 }
54
55 // Reset the log to the initial state.
56 void reset();
57
58 // Add context data to the log.
59 bool addContextData(uint32_t context_data);
60
61 // Set last context data to close the log.
62 void setLastContextData()
63 {
64 context_complete_ = true;
65 }
66
67 // Evaluate of the context data and return true
68 // if the log contains valid data.
69 bool parseContextData();
70
71 // Output log as a string.
72 string asString() const;
73
74 // Set the Fman ID.
75 void setFManID(uint32_t fmanID)
76 {
77 fmanID_ = fmanID;
78 }
79
80 // Return true if the log contains valid data.
81 bool logComplete() const
82 {
83 return log_complete_;
84 }
85
86 protected:
87
88 // Constants to access NIA data fields
89 static const uint32_t NIA_SIZE_MASK = 0x3f;
90 static const uint32_t NIA_SIZE_SHIFT = 24;
91 static const uint32_t NIA_ENG_MASK = 0x1f;
92 static const uint32_t NIA_ENG_SHIFT = 18;
93
94 private:
95 // Fman instance ID
96 uint32_t fmanID_;
97
98 // context data
99 vector<uint32_t> context_data_;
100
101 // context data complete
102 bool context_complete_;
103
104 // maintain a list of module logs
105 vector<FManModuleDebugLog*> logs_;
106
107 // log parse error
108 enum log_parse_error {
109 LOG_PARSE_NO_ERROR = 0,
110 LOG_PARSE_DATA_LENGTH_ERROR,
111 LOG_PARSE_UNDEFINED_ENG_ERROR
112 } log_parse_error_;
113
114 // log complete
115 bool log_complete_;
116 };
117
118 // Base class for all module specific log types
119 class FManModuleDebugLog
120 {
121 public:
122
123 FManModuleDebugLog() :
124 verbosity_level_(0), order_restoration_required_(false),
125 action_code_(0), has_timestamp_(false), timestamp_(0)
126 {
127 }
128 virtual ~FManModuleDebugLog()
129 {
130 }
131
132 // parse the context data
133 bool parseContextData(vector<uint32_t> &context_data);
134
135 // output derived log name as string
136 virtual string nameAsString() const = 0;
137
138 // output logs as a string
139 string asString() const;
140
141 protected:
142
143 // constants to access context data fields
144 static const uint32_t NIA_VL_MASK = 0x3;
145 static const uint32_t NIA_VL_SHIFT = 30;
146 static const uint32_t NIA_ORR_MASK = 0x1;
147 static const uint32_t NIA_ORR_SHIFT = 23;
148 static const uint32_t NIA_AC_MASK = 0x3ffff;
149 static const uint32_t NIA_AC_SHIFT = 0;
150
151 // generic model Verbosity Levels
152 enum verbosity_level
153 {
154 FMAN_TRACE_DISABLED = 0,
155 FMAN_TRACE_MINIMUM = 1,
156 FMAN_TRACE_VERBOSE = 2,
157 FMAN_TRACE_VERY_VERBOSE = 3
158 };
159
160 // parse header info
161 virtual bool parseContextData_(vector<uint32_t> &context_data) = 0;
162
163 // output logs as a string
164 virtual string asString_() const = 0;
165
166 // output a port ID string
167 string portIDasString_( uint32_t port_id) const;
168
169 // from NIA
170 uint32_t verbosity_level_;
171 bool order_restoration_required_;
172
173 // common data
174 uint32_t action_code_;
175
176 bool has_timestamp_;
177 uint32_t timestamp_;
178
179 private:
180
181 };
182
183 class FManControllerDebugLog: public FManModuleDebugLog
184 {
185 public:
186
187 FManControllerDebugLog()
188 {
189 }
190 virtual ~FManControllerDebugLog()
191 {
192 }
193
194 // output log name as string
195 virtual string nameAsString() const
196 {
197 return "FMan Controller";
198 }
199
200 protected:
201
202 enum action_code
203 {
204 CTRL_CLASSIF_CMD = 0x6,
205 CTRL_INDEP_TX_CMD = 0x8,
206 CTRL_INDEP_RX_CMD = 0xa,
207 CTRL_HOST_CMD = 0xc
208 };
209
210 // parse the context data
211 virtual bool parseContextData_(vector<uint32_t> &context_data);
212
213 // output log as a string
214 virtual string asString_() const;
215
216 private:
217
218 };
219
220 class FManParserDebugLog: public FManModuleDebugLog
221 {
222 public:
223 FManParserDebugLog() :
224 hxs_id_(0), parse_start_point_(0)
225 {
226 for (uint32_t i = 0; i < MAX_NUM_PROG_CTRS; i++) {
227 program_counter_[i] = 0;
228 }
229 }
230 virtual ~FManParserDebugLog()
231 {
232 }
233
234 // output log name as string
235 virtual string nameAsString() const
236 {
237 return "FMan Parser Engine";
238 }
239
240 protected:
241
242 static const uint32_t MAX_NUM_PROG_CTRS = 16;
243
244 static const uint32_t NIA_AC_HXS_ID_MASK = 0x3ff;
245 static const uint32_t NIA_AC_HXS_ID_SHIFT = 0;
246
247 enum hxs_id
248 {
249 PARSER_ETH_CMD = 0x00,
250 PARSER_LLC_SNAP_CMD = 0x01,
251 PARSER_VLAN_CMD = 0x02,
252 PARSER_PPP_CMD = 0x03,
253 PARSER_MPLS_CMD = 0x04,
254 PARSER_IPV4_CMD = 0x05,
255 PARSER_IPV6_CMD = 0x06,
256 PARSER_GRE_CMD = 0x07,
257 PARSER_MINENCAP_CMD = 0x08,
258 PARSER_OTHER_L3_CMD = 0x09,
259 PARSER_TCP_CMD = 0x0a,
260 PARSER_UDP_CMD = 0x0b,
261 PARSER_IPSEC_CMD = 0x0c,
262 PARSER_SCTP_CMD = 0x0d,
263 PARSER_DCCP_CMD = 0x0e,
264 PARSER_OTHER_L4_CMD = 0x0f,
265 PARSER_NULL_CMD = 0x3ff
266 };
267 // parse the context data
268 virtual bool parseContextData_(vector<uint32_t> &context_data);
269
270 // output log as a string
271 virtual string asString_() const;
272
273 private:
274
275 uint32_t hxs_id_;
276 uint32_t parse_start_point_;
277 uint32_t program_counter_[MAX_NUM_PROG_CTRS];
278 };
279
280 class FManKeyGenDebugLog: public FManModuleDebugLog
281 {
282 public:
283
284 FManKeyGenDebugLog() :
285 ccen_(0), ss_(0), scheme_(0),
286 selected_scheme_(0), int_frame_ptr_(0)
287 {
288 }
289 virtual ~FManKeyGenDebugLog()
290 {
291 }
292
293 protected:
294
295 static const uint32_t NIA_AC_CCEN_MASK = 0x1;
296 static const uint32_t NIA_AC_CCEN_SHIFT = 9;
297 static const uint32_t NIA_AC_SS_MASK = 0x1;
298 static const uint32_t NIA_AC_SS_SHIFT = 8;
299 static const uint32_t NIA_AC_SCHEME_MASK = 0x1f;
300 static const uint32_t NIA_AC_SCHEME_SHIFT = 0;
301
302 static const uint32_t FMKG_SS_MASK = 0xff;
303 static const uint32_t FMKG_SS_SHIFT = 24;
304 static const uint32_t FMKG_IFP_MASK = 0xff;
305 static const uint32_t FMKG_IFP_SHIFT = 16;
306
307 // parse the context data
308 virtual bool parseContextData_(vector<uint32_t> &context_data);
309
310 // output log as a string
311 virtual string asString_() const;
312
313 // output log name as string
314 virtual string nameAsString() const
315 {
316 return "FMan Key Generator Engine";
317 }
318
319 private:
320
321 uint32_t ccen_;
322 uint32_t ss_;
323 uint32_t scheme_;
324
325 uint32_t selected_scheme_;
326 uint32_t int_frame_ptr_;
327
328 };
329
330 class FManPolicerDebugLog: public FManModuleDebugLog
331 {
332 public:
333
334 FManPolicerDebugLog() :
335 pmo_(0),
336 pnum_(0),
337 fcs_action_(0),
338 port_id_(0),
339 pi_(0),
340 cblnd_(0),
341 alg_(0),
342 fls_(0),
343 pkt_(0),
344 rbfls_(0),
345 flsres_(0),
346 fpp_(0),
347 flm_(0),
348 fatm_(0),
349 fbtm_(0),
350 fctm_(0),
351 abs_pnum_(0),
352 pcc_(0),
353 pc_(0),
354 pkt_length_(0),
355 profile_cbs_(0),
356 profile_cts_(0),
357 profile_pbs_ebs_(0),
358 profile_ets_(0)
359 {
360 }
361 virtual ~FManPolicerDebugLog()
362 {
363 }
364
365 protected:
366
367 static const uint32_t NIA_AC_PMO_MASK = 0x1;
368 static const uint32_t NIA_AC_PMO_SHIFT = 15;
369 static const uint32_t NIA_AC_PNUM_MASK = 0xff;
370 static const uint32_t NIA_AC_PNUM_SHIFT = 0;
371
372 // verbose word 0
373 static const uint32_t POLICE_FCS_MASK = 0x3;
374 static const uint32_t POLICE_FCS_SHIFT = 30;
375 static const uint32_t POLICE_PORTID_MASK = 0x3f;
376 static const uint32_t POLICE_PORTID_SHIFT = 24;
377 static const uint32_t POLICE_FLM_MASK = 0x1;
378 static const uint32_t POLICE_FLM_SHIFT = 23;
379 static const uint32_t POLICE_FATM_MASK = 0x1;
380 static const uint32_t POLICE_FATM_SHIFT = 22;
381 static const uint32_t POLICE_FBTM_MASK = 0x1;
382 static const uint32_t POLICE_FBTM_SHIFT = 21;
383 static const uint32_t POLICE_FCTM_MASK = 0x1;
384 static const uint32_t POLICE_FCTM_SHIFT = 20;
385 static const uint32_t POLICE_PNUM_MASK = 0xff;
386 static const uint32_t POLICE_PNUM_SHIFT = 8;
387 static const uint32_t POLICE_PPC_MASK = 0x3;
388 static const uint32_t POLICE_PPC_SHIFT = 6;
389 static const uint32_t POLICE_PC_MASK = 0x3;
390 static const uint32_t POLICE_PC_SHIFT = 4;
391 static const uint32_t POLICE_PKTLEN_MSB_MASK = 0xf;
392 static const uint32_t POLICE_PKTLEN_MSB_SHIFT = 0;
393
394 // verbose word 1
395 static const uint32_t POLICE_PKTLEN_LSB_MASK = 0xffff;
396 static const uint32_t POLICE_PKTLEN_LSB_SHIFT = 16;
397 static const uint32_t POLICE_PROF_INI_MASK = 0x1;
398 static const uint32_t POLICE_PROF_INI_SHIFT = 15;
399 static const uint32_t POLICE_CBLND_MASK = 0x1;
400 static const uint32_t POLICE_CBLND_SHIFT = 14;
401 static const uint32_t POLICE_ALG_MASK = 0x3;
402 static const uint32_t POLICE_ALG_SHIFT = 12;
403 static const uint32_t POLICE_FLS_MASK = 0xf;
404 static const uint32_t POLICE_FLS_SHIFT = 8;
405 static const uint32_t POLICE_PKT_MASK = 0x1;
406 static const uint32_t POLICE_PKT_SHIFT = 7;
407 static const uint32_t POLICE_RBFLS_MASK = 0x1;
408 static const uint32_t POLICE_RBFLS_SHIFT = 6;
409 static const uint32_t POLICE_FLSRES_MASK = 0x1;
410 static const uint32_t POLICE_FLSRES_SHIFT = 5;
411 static const uint32_t POLICE_FPP_MASK = 0xf;
412 static const uint32_t POLICE_FPP_SHIFT = 0;
413
414 // parse the context data
415 virtual bool parseContextData_(vector<uint32_t> &context_data);
416
417 // output log as a string
418 virtual string asString_() const;
419
420 // output log name as string
421 virtual string nameAsString() const
422 {
423 return "FMan Policer Engine";
424 }
425
426 private:
427
428 // from NIA
429 uint8_t pmo_;
430 uint8_t pnum_;
431
432 // FCS action
433 uint8_t fcs_action_;
434 uint8_t port_id_;
435
436 // Debug flags and PNUM
437 uint8_t pi_;
438 uint8_t cblnd_;
439 uint8_t alg_;
440 uint8_t fls_;
441 uint8_t pkt_;
442 uint8_t rbfls_;
443 uint8_t flsres_;
444 uint8_t fpp_;
445
446 uint8_t flm_;
447 uint8_t fatm_;
448 uint8_t fbtm_;
449 uint8_t fctm_;
450 uint8_t abs_pnum_;
451 uint8_t pcc_;
452 uint8_t pc_;
453
454 // derived from multiple fields
455 uint32_t pkt_length_;
456
457 // very verbose profile info
458 uint32_t profile_cbs_;
459 uint32_t profile_cts_;
460 uint32_t profile_pbs_ebs_;
461 uint32_t profile_ets_;
462 };
463
464 class FManBMIDebugLog: public FManModuleDebugLog
465 {
466 public:
467
468 FManBMIDebugLog() :
469 port_id_(0),
470 debug_trap_state_(0)
471 {
472 fd_[0] = 0;
473 fd_[1] = 0;
474 fd_[2] = 0;
475 fd_[3] = 0;
476 }
477 virtual ~FManBMIDebugLog()
478 {
479 }
480
481 // output log name as string
482 virtual string nameAsString() const
483 {
484 return "FMan Buffer Manager Interface (BMI)";
485 }
486
487 protected:
488
489 enum action_codes
490 {
491 BMI_INI_CMD = 0x000,
492 BMI_REL_INT_BUF_TNUM_TERM_CMD = 0x0C0,
493 BMI_REL_INT_IC_BUF_TNUM_TERM_CMD = 0x2C0,
494 BMI_TX_FR_REL_BUF_OR_ENQ_CMD = 0x274,
495 BMI_TX_FR_NO_DMA_CMD = 0x010,
496 BMI_TX_FR_NO_DMA_REL_INT_BUF_CMD = 0x050,
497 BMI_TX_FR_NO_DMA_REL_INT_BUF_TERM_CMD = 0x0D0,
498 BMI_ENQ_FR_CMD = 0x002,
499 BMI_DISC_FR_TERM_CMD = 0x0C1,
500 BMI_FETCH_FR_EXE_CMD = 0x20C,
501 BMI_FETCH_FR_HDR_EXE_CMD = 0x208
502 };
503
504 // parse the context data
505 virtual bool parseContextData_(vector<uint32_t> &context_data);
506
507 // output log as a string
508 virtual string asString_() const;
509
510 private:
511
512 uint32_t port_id_;
513 uint32_t debug_trap_state_;
514 uint32_t fd_[4];
515 };
516
517 // Base QMI class for the QMI Enqueue/Dequeue subclasses
518 class FManQMIDebugLog: public FManModuleDebugLog
519 {
520 public:
521
522 FManQMIDebugLog() :
523 cfg_port_pri_(0),
524 cfg_deq_opt_(0),
525 cfg_port_en_(0),
526 cfg_pref_opt_(0),
527 cfg_frm_cnt_(0),
528 cfg_sub_port_(0),
529 cfg_byte_cnt_(0),
530 fd_cmd_(0),
531 res_sp_(0),
532 res_fqid_src_(0),
533 res_byte_cnt_(0),
534 res_frm_cnt_(0),
535 res_tag_(0)
536 {
537 }
538 virtual ~FManQMIDebugLog()
539 {
540 }
541
542 protected:
543
544 static const uint32_t QMI_CFG_PORTPRI_MASK = 0x1;
545 static const uint32_t QMI_CFG_PORTPRI_SHIFT = 31;
546 static const uint32_t QMI_CFG_DEQOPT_MASK = 0x7;
547 static const uint32_t QMI_CFG_DEQOPT_SHIFT = 28;
548 static const uint32_t QMI_CFG_PORTEN_MASK = 0x1;
549 static const uint32_t QMI_CFG_PORTEN_SHIFT = 27;
550 static const uint32_t QMI_CFG_PREFOPT_MASK = 0x1;
551 static const uint32_t QMI_CFG_PREFOPT_SHIFT = 25;
552 static const uint32_t QMI_CFG_FRMCNT_MASK = 0x1;
553 static const uint32_t QMI_CFG_FRMCNT_SHIFT = 24;
554 static const uint32_t QMI_CFG_SUBPORT_MASK = 0xf;
555 static const uint32_t QMI_CFG_SUBPORT_SHIFT = 20;
556 static const uint32_t QMI_CFG_BYTECNT_MASK = 0xffff;
557 static const uint32_t QMI_CFG_BYTECNT_SHIFT = 0;
558
559 static const uint32_t QMI_RES_SP_MASK = 0xf;
560 static const uint32_t QMI_RES_SP_SHIFT = 28;
561 static const uint32_t QMI_RES_FQIDSRC_MASK = 0x3;
562 static const uint32_t QMI_RES_FQIDSRC_SHIFT = 26;
563 static const uint32_t QMI_RES_BYTECNT_MASK = 0xffff;
564 static const uint32_t QMI_RES_BYTECNT_SHIFT = 10;
565 static const uint32_t QMI_RES_FRMCNT_MASK = 0x3;
566 static const uint32_t QMI_RES_FRMCNT_SHIFT = 8;
567 static const uint32_t QMI_RES_TAG_MASK = 0xff;
568 static const uint32_t QMI_RES_TAG_SHIFT = 0;
569
570 // parse the context data
571 virtual bool parseContextData_(vector<uint32_t> &context_data);
572
573 // output log as a string
574 virtual string asString_() const;
575
576 private:
577
578 uint8_t cfg_port_pri_;
579 uint8_t cfg_deq_opt_;
580 uint8_t cfg_port_en_;
581 uint8_t cfg_pref_opt_;
582 uint8_t cfg_frm_cnt_;
583 uint8_t cfg_sub_port_;
584 uint32_t cfg_byte_cnt_;
585
586 uint32_t fd_cmd_;
587
588 uint8_t res_sp_;
589 uint8_t res_fqid_src_;
590 uint32_t res_byte_cnt_;
591 uint8_t res_frm_cnt_;
592 uint8_t res_tag_;
593 };
594
595 class FManQMIEnqueueDebugLog: public FManQMIDebugLog
596 {
597 public:
598
599 FManQMIEnqueueDebugLog()
600 {
601 }
602 virtual ~FManQMIEnqueueDebugLog()
603 {
604 }
605
606 // output log name as string
607 virtual string nameAsString() const
608 {
609 return "FMan Enqueue Queue Manager Interface (QMI)";
610 }
611 };
612
613 class FManQMIDequeueDebugLog: public FManQMIDebugLog
614 {
615 public:
616
617 FManQMIDequeueDebugLog()
618 {
619 }
620 virtual ~FManQMIDequeueDebugLog()
621 {
622 }
623
624 // output log name as string
625 virtual string nameAsString() const
626 {
627 return "FMan Enqueue Queue Manager Interface (QMI)";
628 }
629 };
630
631 #endif // FMANDEBUGLOG_H
This page took 0.043099 seconds and 4 git commands to generate.