18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright IBM Corp. 2008
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Author: Jan Glauber (jang@linux.vnet.ibm.com)
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef QDIO_DEBUG_H
88c2ecf20Sopenharmony_ci#define QDIO_DEBUG_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <asm/debug.h>
118c2ecf20Sopenharmony_ci#include <asm/qdio.h>
128c2ecf20Sopenharmony_ci#include "qdio.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* that gives us 15 characters in the text event views */
158c2ecf20Sopenharmony_ci#define QDIO_DBF_LEN	32
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciextern debug_info_t *qdio_dbf_setup;
188c2ecf20Sopenharmony_ciextern debug_info_t *qdio_dbf_error;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define DBF_ERR		3	/* error conditions	*/
218c2ecf20Sopenharmony_ci#define DBF_WARN	4	/* warning conditions	*/
228c2ecf20Sopenharmony_ci#define DBF_INFO	6	/* informational	*/
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#undef DBF_EVENT
258c2ecf20Sopenharmony_ci#undef DBF_ERROR
268c2ecf20Sopenharmony_ci#undef DBF_DEV_EVENT
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define DBF_EVENT(text...) \
298c2ecf20Sopenharmony_ci	do { \
308c2ecf20Sopenharmony_ci		char debug_buffer[QDIO_DBF_LEN]; \
318c2ecf20Sopenharmony_ci		snprintf(debug_buffer, QDIO_DBF_LEN, text); \
328c2ecf20Sopenharmony_ci		debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \
338c2ecf20Sopenharmony_ci	} while (0)
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic inline void DBF_HEX(void *addr, int len)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	debug_event(qdio_dbf_setup, DBF_ERR, addr, len);
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define DBF_ERROR(text...) \
418c2ecf20Sopenharmony_ci	do { \
428c2ecf20Sopenharmony_ci		char debug_buffer[QDIO_DBF_LEN]; \
438c2ecf20Sopenharmony_ci		snprintf(debug_buffer, QDIO_DBF_LEN, text); \
448c2ecf20Sopenharmony_ci		debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \
458c2ecf20Sopenharmony_ci	} while (0)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic inline void DBF_ERROR_HEX(void *addr, int len)
488c2ecf20Sopenharmony_ci{
498c2ecf20Sopenharmony_ci	debug_event(qdio_dbf_error, DBF_ERR, addr, len);
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define DBF_DEV_EVENT(level, device, text...) \
538c2ecf20Sopenharmony_ci	do { \
548c2ecf20Sopenharmony_ci		char debug_buffer[QDIO_DBF_LEN]; \
558c2ecf20Sopenharmony_ci		if (debug_level_enabled(device->debug_area, level)) { \
568c2ecf20Sopenharmony_ci			snprintf(debug_buffer, QDIO_DBF_LEN, text); \
578c2ecf20Sopenharmony_ci			debug_text_event(device->debug_area, level, debug_buffer); \
588c2ecf20Sopenharmony_ci		} \
598c2ecf20Sopenharmony_ci	} while (0)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr,
628c2ecf20Sopenharmony_ci			       int len, int level)
638c2ecf20Sopenharmony_ci{
648c2ecf20Sopenharmony_ci	debug_event(dev->debug_area, level, addr, len);
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ciint qdio_allocate_dbf(struct qdio_irq *irq_ptr);
688c2ecf20Sopenharmony_civoid qdio_setup_debug_entries(struct qdio_irq *irq_ptr);
698c2ecf20Sopenharmony_civoid qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr);
708c2ecf20Sopenharmony_ciint qdio_debug_init(void);
718c2ecf20Sopenharmony_civoid qdio_debug_exit(void);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#endif
74