1818 LOG_ENTRY_NUM_ARGS_MAX)
1919#define MAX_HEADER_MISMATCH_TRACK 10
2020
21+
22+ struct header_mismatch {
23+ uint32_t prev ;
24+ uint32_t miss ;
25+ };
26+
2127static int formats_find (struct json_object * formats , uint32_t val , struct json_object * * format )
2228{
2329 char hex_header [STR_HEX32_SIZE ];
@@ -32,11 +38,13 @@ static uint32_t nlog_get_pos(const uint32_t *nlog, const uint32_t nlog_size, int
3238}
3339
3440static uint32_t nlog_get_events (const uint32_t * nlog , const uint32_t nlog_size , int start_offset ,
35- struct json_object * formats , struct json_object * events , uint32_t * tail_mismatches )
41+ struct json_object * formats , struct json_object * events ,
42+ struct header_mismatch * tail_mismatches )
3643{
3744 uint32_t event_count = 0 ;
3845 int last_bad_header_pos = nlog_size + 1 ; // invalid nlog offset
3946 uint32_t tail_count = 0 ;
47+ uint32_t prev_header = 0 ;
4048
4149 for (int i = nlog_size - start_offset - 1 ; i >= - start_offset ; i -- ) {
4250 struct json_object * format = NULL ;
@@ -48,8 +56,10 @@ static uint32_t nlog_get_events(const uint32_t *nlog, const uint32_t nlog_size,
4856 //check if found circular buffer tail
4957 if (i != (last_bad_header_pos - 1 )) {
5058 if (tail_mismatches &&
51- (tail_count < MAX_HEADER_MISMATCH_TRACK ))
52- tail_mismatches [tail_count ] = header ;
59+ (tail_count < MAX_HEADER_MISMATCH_TRACK )) {
60+ tail_mismatches [tail_count ].prev = prev_header ;
61+ tail_mismatches [tail_count ].miss = header ;
62+ }
5363 tail_count ++ ;
5464 }
5565 last_bad_header_pos = i ;
@@ -77,6 +87,7 @@ static uint32_t nlog_get_events(const uint32_t *nlog, const uint32_t nlog_size,
7787 }
7888 i -= 2 + num_data ;
7989 event_count ++ ;
90+ prev_header = header ;
8091 }
8192 return tail_count ;
8293}
@@ -86,14 +97,14 @@ int solidigm_nlog_parse(const char *buffer, uint64_t buff_size, struct json_obje
8697{
8798 uint32_t smaller_tail_count = UINT32_MAX ;
8899 int best_offset = 0 ;
89- uint32_t offset_tail_mismatches [LOG_ENTRY_MAX_SIZE ][MAX_HEADER_MISMATCH_TRACK ];
100+ struct header_mismatch tail_mismatches [LOG_ENTRY_MAX_SIZE ][MAX_HEADER_MISMATCH_TRACK ];
90101 struct json_object * events = json_object_new_array ();
91102 const uint32_t * nlog = (uint32_t * )buffer ;
92103 const uint32_t nlog_size = buff_size / sizeof (uint32_t );
93104
94105 for (int i = 0 ; i < LOG_ENTRY_MAX_SIZE ; i ++ ) {
95106 uint32_t tail_count = nlog_get_events (nlog , nlog_size , i , formats , NULL ,
96- offset_tail_mismatches [i ]);
107+ tail_mismatches [i ]);
97108 if (tail_count < smaller_tail_count ) {
98109 best_offset = i ;
99110 smaller_tail_count = tail_count ;
@@ -102,25 +113,27 @@ int solidigm_nlog_parse(const char *buffer, uint64_t buff_size, struct json_obje
102113 break ;
103114 }
104115 if (smaller_tail_count > 1 ) {
105- const char * name = "" ;
116+ int obj_id = -1 ;
106117 int media_bank = -1 ;
107- char str_mismatches [(STR_HEX32_SIZE + 1 ) * MAX_HEADER_MISMATCH_TRACK ];
118+ char str_mismatches [(STR_HEX32_SIZE + 1 ) * 2 * MAX_HEADER_MISMATCH_TRACK ];
108119 int pos = 0 ;
109120 int show_mismatch_num = smaller_tail_count < MAX_HEADER_MISMATCH_TRACK ?
110121 smaller_tail_count : MAX_HEADER_MISMATCH_TRACK ;
111122 struct json_object * jobj ;
112123
113- if (json_object_object_get_ex (metadata , "objName " , & jobj ))
114- name = json_object_get_string (jobj );
124+ if (json_object_object_get_ex (metadata , "objectId " , & jobj ))
125+ obj_id = json_object_get_int (jobj );
115126 if (json_object_object_get_ex (metadata , "mediaBankId" , & jobj ))
116127 media_bank = json_object_get_int (jobj );
117128
118129 for (int i = 0 ; i < show_mismatch_num ; i ++ )
119- pos += snprintf (& str_mismatches [pos ], STR_HEX32_SIZE + 1 , "0x%08X " ,
120- offset_tail_mismatches [best_offset ][i ]);
130+ pos += snprintf (& str_mismatches [pos ], (STR_HEX32_SIZE + 1 ) * 2 ,
131+ "0x%08X-0x%08X " ,
132+ tail_mismatches [best_offset ][i ].prev ,
133+ tail_mismatches [best_offset ][i ].miss );
121134
122- SOLIDIGM_LOG_WARNING ("%s:%d with %d header mismatches ( %s). Configuration file may be missing format headers ." ,
123- name , media_bank , smaller_tail_count , str_mismatches );
135+ SOLIDIGM_LOG_WARNING ("Warning: obj:%d-%d with %d header sequence mismatches ( %s)." ,
136+ obj_id , media_bank , smaller_tail_count , str_mismatches );
124137 }
125138 nlog_get_events (nlog , nlog_size , best_offset , formats , events , NULL );
126139
0 commit comments