diff options
Diffstat (limited to 'net/tipc/dbg.c')
-rw-r--r-- | net/tipc/dbg.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c index 7ed60a1cfbb8..4f4beefa7830 100644 --- a/net/tipc/dbg.c +++ b/net/tipc/dbg.c | |||
@@ -44,10 +44,10 @@ static char print_string[MAX_STRING]; | |||
44 | static spinlock_t print_lock = SPIN_LOCK_UNLOCKED; | 44 | static spinlock_t print_lock = SPIN_LOCK_UNLOCKED; |
45 | 45 | ||
46 | static struct print_buf cons_buf = { NULL, 0, NULL, NULL }; | 46 | static struct print_buf cons_buf = { NULL, 0, NULL, NULL }; |
47 | struct print_buf *CONS = &cons_buf; | 47 | struct print_buf *TIPC_CONS = &cons_buf; |
48 | 48 | ||
49 | static struct print_buf log_buf = { NULL, 0, NULL, NULL }; | 49 | static struct print_buf log_buf = { NULL, 0, NULL, NULL }; |
50 | struct print_buf *LOG = &log_buf; | 50 | struct print_buf *TIPC_LOG = &log_buf; |
51 | 51 | ||
52 | 52 | ||
53 | #define FORMAT(PTR,LEN,FMT) \ | 53 | #define FORMAT(PTR,LEN,FMT) \ |
@@ -66,15 +66,15 @@ struct print_buf *LOG = &log_buf; | |||
66 | * simultaneous use of the print buffer(s) being manipulated. | 66 | * simultaneous use of the print buffer(s) being manipulated. |
67 | * 2) tipc_printf() uses 'print_lock' to prevent simultaneous use of | 67 | * 2) tipc_printf() uses 'print_lock' to prevent simultaneous use of |
68 | * 'print_string' and to protect its print buffer(s). | 68 | * 'print_string' and to protect its print buffer(s). |
69 | * 3) TEE() uses 'print_lock' to protect its print buffer(s). | 69 | * 3) TIPC_TEE() uses 'print_lock' to protect its print buffer(s). |
70 | * 4) Routines of the form log_XXX() uses 'print_lock' to protect LOG. | 70 | * 4) Routines of the form log_XXX() uses 'print_lock' to protect TIPC_LOG. |
71 | */ | 71 | */ |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * printbuf_init - initialize print buffer to empty | 74 | * tipc_printbuf_init - initialize print buffer to empty |
75 | */ | 75 | */ |
76 | 76 | ||
77 | void printbuf_init(struct print_buf *pb, char *raw, u32 sz) | 77 | void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 sz) |
78 | { | 78 | { |
79 | if (!pb || !raw || (sz < (MAX_STRING + 1))) | 79 | if (!pb || !raw || (sz < (MAX_STRING + 1))) |
80 | return; | 80 | return; |
@@ -87,26 +87,26 @@ void printbuf_init(struct print_buf *pb, char *raw, u32 sz) | |||
87 | } | 87 | } |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * printbuf_reset - reinitialize print buffer to empty state | 90 | * tipc_printbuf_reset - reinitialize print buffer to empty state |
91 | */ | 91 | */ |
92 | 92 | ||
93 | void printbuf_reset(struct print_buf *pb) | 93 | void tipc_printbuf_reset(struct print_buf *pb) |
94 | { | 94 | { |
95 | if (pb && pb->buf) | 95 | if (pb && pb->buf) |
96 | printbuf_init(pb, pb->buf, pb->size); | 96 | tipc_printbuf_init(pb, pb->buf, pb->size); |
97 | } | 97 | } |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * printbuf_empty - test if print buffer is in empty state | 100 | * tipc_printbuf_empty - test if print buffer is in empty state |
101 | */ | 101 | */ |
102 | 102 | ||
103 | int printbuf_empty(struct print_buf *pb) | 103 | int tipc_printbuf_empty(struct print_buf *pb) |
104 | { | 104 | { |
105 | return (!pb || !pb->buf || (pb->crs == pb->buf)); | 105 | return (!pb || !pb->buf || (pb->crs == pb->buf)); |
106 | } | 106 | } |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * printbuf_validate - check for print buffer overflow | 109 | * tipc_printbuf_validate - check for print buffer overflow |
110 | * | 110 | * |
111 | * Verifies that a print buffer has captured all data written to it. | 111 | * Verifies that a print buffer has captured all data written to it. |
112 | * If data has been lost, linearize buffer and prepend an error message | 112 | * If data has been lost, linearize buffer and prepend an error message |
@@ -114,7 +114,7 @@ int printbuf_empty(struct print_buf *pb) | |||
114 | * Returns length of print buffer data string (including trailing NULL) | 114 | * Returns length of print buffer data string (including trailing NULL) |
115 | */ | 115 | */ |
116 | 116 | ||
117 | int printbuf_validate(struct print_buf *pb) | 117 | int tipc_printbuf_validate(struct print_buf *pb) |
118 | { | 118 | { |
119 | char *err = " *** PRINT BUFFER WRAPPED AROUND ***\n"; | 119 | char *err = " *** PRINT BUFFER WRAPPED AROUND ***\n"; |
120 | char *cp_buf; | 120 | char *cp_buf; |
@@ -126,13 +126,13 @@ int printbuf_validate(struct print_buf *pb) | |||
126 | if (pb->buf[pb->size - 1] == '\0') { | 126 | if (pb->buf[pb->size - 1] == '\0') { |
127 | cp_buf = kmalloc(pb->size, GFP_ATOMIC); | 127 | cp_buf = kmalloc(pb->size, GFP_ATOMIC); |
128 | if (cp_buf != NULL){ | 128 | if (cp_buf != NULL){ |
129 | printbuf_init(&cb, cp_buf, pb->size); | 129 | tipc_printbuf_init(&cb, cp_buf, pb->size); |
130 | printbuf_move(&cb, pb); | 130 | tipc_printbuf_move(&cb, pb); |
131 | printbuf_move(pb, &cb); | 131 | tipc_printbuf_move(pb, &cb); |
132 | kfree(cp_buf); | 132 | kfree(cp_buf); |
133 | memcpy(pb->buf, err, strlen(err)); | 133 | memcpy(pb->buf, err, strlen(err)); |
134 | } else { | 134 | } else { |
135 | printbuf_reset(pb); | 135 | tipc_printbuf_reset(pb); |
136 | tipc_printf(pb, err); | 136 | tipc_printf(pb, err); |
137 | } | 137 | } |
138 | } | 138 | } |
@@ -140,13 +140,13 @@ int printbuf_validate(struct print_buf *pb) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * printbuf_move - move print buffer contents to another print buffer | 143 | * tipc_printbuf_move - move print buffer contents to another print buffer |
144 | * | 144 | * |
145 | * Current contents of destination print buffer (if any) are discarded. | 145 | * Current contents of destination print buffer (if any) are discarded. |
146 | * Source print buffer becomes empty if a successful move occurs. | 146 | * Source print buffer becomes empty if a successful move occurs. |
147 | */ | 147 | */ |
148 | 148 | ||
149 | void printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from) | 149 | void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from) |
150 | { | 150 | { |
151 | int len; | 151 | int len; |
152 | 152 | ||
@@ -156,12 +156,12 @@ void printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from) | |||
156 | return; | 156 | return; |
157 | 157 | ||
158 | if (!pb_from || !pb_from->buf) { | 158 | if (!pb_from || !pb_from->buf) { |
159 | printbuf_reset(pb_to); | 159 | tipc_printbuf_reset(pb_to); |
160 | return; | 160 | return; |
161 | } | 161 | } |
162 | 162 | ||
163 | if (pb_to->size < pb_from->size) { | 163 | if (pb_to->size < pb_from->size) { |
164 | printbuf_reset(pb_to); | 164 | tipc_printbuf_reset(pb_to); |
165 | tipc_printf(pb_to, "*** PRINT BUFFER OVERFLOW ***"); | 165 | tipc_printf(pb_to, "*** PRINT BUFFER OVERFLOW ***"); |
166 | return; | 166 | return; |
167 | } | 167 | } |
@@ -179,7 +179,7 @@ void printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from) | |||
179 | strcpy(pb_to->crs, pb_from->buf); | 179 | strcpy(pb_to->crs, pb_from->buf); |
180 | pb_to->crs += len; | 180 | pb_to->crs += len; |
181 | 181 | ||
182 | printbuf_reset(pb_from); | 182 | tipc_printbuf_reset(pb_from); |
183 | } | 183 | } |
184 | 184 | ||
185 | /** | 185 | /** |
@@ -199,7 +199,7 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...) | |||
199 | strcpy(print_string, "*** STRING TOO LONG ***"); | 199 | strcpy(print_string, "*** STRING TOO LONG ***"); |
200 | 200 | ||
201 | while (pb) { | 201 | while (pb) { |
202 | if (pb == CONS) | 202 | if (pb == TIPC_CONS) |
203 | printk(print_string); | 203 | printk(print_string); |
204 | else if (pb->buf) { | 204 | else if (pb->buf) { |
205 | chars_left = pb->buf + pb->size - pb->crs - 1; | 205 | chars_left = pb->buf + pb->size - pb->crs - 1; |
@@ -223,10 +223,10 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * TEE - perform next output operation on both print buffers | 226 | * TIPC_TEE - perform next output operation on both print buffers |
227 | */ | 227 | */ |
228 | 228 | ||
229 | struct print_buf *TEE(struct print_buf *b0, struct print_buf *b1) | 229 | struct print_buf *TIPC_TEE(struct print_buf *b0, struct print_buf *b1) |
230 | { | 230 | { |
231 | struct print_buf *pb = b0; | 231 | struct print_buf *pb = b0; |
232 | 232 | ||
@@ -294,96 +294,96 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...) | |||
294 | int len; | 294 | int len; |
295 | 295 | ||
296 | spin_lock_bh(&print_lock); | 296 | spin_lock_bh(&print_lock); |
297 | FORMAT(CONS->buf, len, fmt); | 297 | FORMAT(TIPC_CONS->buf, len, fmt); |
298 | printk(CONS->buf); | 298 | printk(TIPC_CONS->buf); |
299 | 299 | ||
300 | for (; pb; pb = pb->next) { | 300 | for (; pb; pb = pb->next) { |
301 | if (pb == CONS) | 301 | if (pb == TIPC_CONS) |
302 | continue; | 302 | continue; |
303 | printk("\n---- Start of dump,%s log ----\n\n", | 303 | printk("\n---- Start of dump,%s log ----\n\n", |
304 | (pb == LOG) ? "global" : "local"); | 304 | (pb == TIPC_LOG) ? "global" : "local"); |
305 | printbuf_dump(pb); | 305 | printbuf_dump(pb); |
306 | printbuf_reset(pb); | 306 | tipc_printbuf_reset(pb); |
307 | printk("\n-------- End of dump --------\n"); | 307 | printk("\n-------- End of dump --------\n"); |
308 | } | 308 | } |
309 | spin_unlock_bh(&print_lock); | 309 | spin_unlock_bh(&print_lock); |
310 | } | 310 | } |
311 | 311 | ||
312 | /** | 312 | /** |
313 | * log_stop - free up TIPC log print buffer | 313 | * tipc_log_stop - free up TIPC log print buffer |
314 | */ | 314 | */ |
315 | 315 | ||
316 | void log_stop(void) | 316 | void tipc_log_stop(void) |
317 | { | 317 | { |
318 | spin_lock_bh(&print_lock); | 318 | spin_lock_bh(&print_lock); |
319 | if (LOG->buf) { | 319 | if (TIPC_LOG->buf) { |
320 | kfree(LOG->buf); | 320 | kfree(TIPC_LOG->buf); |
321 | LOG->buf = NULL; | 321 | TIPC_LOG->buf = NULL; |
322 | } | 322 | } |
323 | spin_unlock_bh(&print_lock); | 323 | spin_unlock_bh(&print_lock); |
324 | } | 324 | } |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * log_reinit - set TIPC log print buffer to specified size | 327 | * tipc_log_reinit - set TIPC log print buffer to specified size |
328 | */ | 328 | */ |
329 | 329 | ||
330 | void log_reinit(int log_size) | 330 | void tipc_log_reinit(int log_size) |
331 | { | 331 | { |
332 | log_stop(); | 332 | tipc_log_stop(); |
333 | 333 | ||
334 | if (log_size) { | 334 | if (log_size) { |
335 | if (log_size <= MAX_STRING) | 335 | if (log_size <= MAX_STRING) |
336 | log_size = MAX_STRING + 1; | 336 | log_size = MAX_STRING + 1; |
337 | spin_lock_bh(&print_lock); | 337 | spin_lock_bh(&print_lock); |
338 | printbuf_init(LOG, kmalloc(log_size, GFP_ATOMIC), log_size); | 338 | tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC), log_size); |
339 | spin_unlock_bh(&print_lock); | 339 | spin_unlock_bh(&print_lock); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | /** | 343 | /** |
344 | * log_resize - reconfigure size of TIPC log buffer | 344 | * tipc_log_resize - reconfigure size of TIPC log buffer |
345 | */ | 345 | */ |
346 | 346 | ||
347 | struct sk_buff *log_resize(const void *req_tlv_area, int req_tlv_space) | 347 | struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space) |
348 | { | 348 | { |
349 | u32 value; | 349 | u32 value; |
350 | 350 | ||
351 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | 351 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) |
352 | return cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 352 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
353 | 353 | ||
354 | value = *(u32 *)TLV_DATA(req_tlv_area); | 354 | value = *(u32 *)TLV_DATA(req_tlv_area); |
355 | value = ntohl(value); | 355 | value = ntohl(value); |
356 | if (value != delimit(value, 0, 32768)) | 356 | if (value != delimit(value, 0, 32768)) |
357 | return cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 357 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
358 | " (log size must be 0-32768)"); | 358 | " (log size must be 0-32768)"); |
359 | log_reinit(value); | 359 | tipc_log_reinit(value); |
360 | return cfg_reply_none(); | 360 | return tipc_cfg_reply_none(); |
361 | } | 361 | } |
362 | 362 | ||
363 | /** | 363 | /** |
364 | * log_dump - capture TIPC log buffer contents in configuration message | 364 | * tipc_log_dump - capture TIPC log buffer contents in configuration message |
365 | */ | 365 | */ |
366 | 366 | ||
367 | struct sk_buff *log_dump(void) | 367 | struct sk_buff *tipc_log_dump(void) |
368 | { | 368 | { |
369 | struct sk_buff *reply; | 369 | struct sk_buff *reply; |
370 | 370 | ||
371 | spin_lock_bh(&print_lock); | 371 | spin_lock_bh(&print_lock); |
372 | if (!LOG->buf) | 372 | if (!TIPC_LOG->buf) |
373 | reply = cfg_reply_ultra_string("log not activated\n"); | 373 | reply = tipc_cfg_reply_ultra_string("log not activated\n"); |
374 | else if (printbuf_empty(LOG)) | 374 | else if (tipc_printbuf_empty(TIPC_LOG)) |
375 | reply = cfg_reply_ultra_string("log is empty\n"); | 375 | reply = tipc_cfg_reply_ultra_string("log is empty\n"); |
376 | else { | 376 | else { |
377 | struct tlv_desc *rep_tlv; | 377 | struct tlv_desc *rep_tlv; |
378 | struct print_buf pb; | 378 | struct print_buf pb; |
379 | int str_len; | 379 | int str_len; |
380 | 380 | ||
381 | str_len = min(LOG->size, 32768u); | 381 | str_len = min(TIPC_LOG->size, 32768u); |
382 | reply = cfg_reply_alloc(TLV_SPACE(str_len)); | 382 | reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len)); |
383 | if (reply) { | 383 | if (reply) { |
384 | rep_tlv = (struct tlv_desc *)reply->data; | 384 | rep_tlv = (struct tlv_desc *)reply->data; |
385 | printbuf_init(&pb, TLV_DATA(rep_tlv), str_len); | 385 | tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len); |
386 | printbuf_move(&pb, LOG); | 386 | tipc_printbuf_move(&pb, TIPC_LOG); |
387 | str_len = strlen(TLV_DATA(rep_tlv)) + 1; | 387 | str_len = strlen(TLV_DATA(rep_tlv)) + 1; |
388 | skb_put(reply, TLV_SPACE(str_len)); | 388 | skb_put(reply, TLV_SPACE(str_len)); |
389 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | 389 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); |