diff --git a/hif/inc/hif.h b/hif/inc/hif.h index 3df076e4fe..4804549fae 100644 --- a/hif/inc/hif.h +++ b/hif/inc/hif.h @@ -52,8 +52,6 @@ extern "C" { typedef void __iomem *A_target_id_t; typedef void *hif_handle_t; -#define HIF_DBG_PRINT_RATE 1000 - #define HIF_TYPE_AR6002 2 #define HIF_TYPE_AR6003 3 #define HIF_TYPE_AR6004 5 diff --git a/hif/src/hif_debug.h b/hif/src/hif_debug.h index a51437bebf..8fa8508d11 100644 --- a/hif/src/hif_debug.h +++ b/hif/src/hif_debug.h @@ -1,9 +1,8 @@ /* - * Copyright (c) 2014, 2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2016, 2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * - * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all @@ -23,6 +22,15 @@ #define __HIF_DEBUG_H__ #include "qdf_trace.h" +#define __hif_log_rl(level, format, args...) \ + QDF_TRACE_RATE_LIMITED(QDF_MODULE_ID_HIF, level, FL(format), ## args) + +#define hif_alert_rl(params...) __hif_log_rl(QDF_TRACE_LEVEL_FATAL, params) +#define hif_err_rl(params...) __hif_log_rl(QDF_TRACE_LEVEL_ERROR, params) +#define hif_warn_rl(params...) __hif_log_rl(QDF_TRACE_LEVEL_WARN, params) +#define hif_info_rl(params...) __hif_log_rl(QDF_TRACE_LEVEL_INFO, params) +#define hif_debug_rl(params...) __hif_log_rl(QDF_TRACE_LEVEL_DEBUG, params) + #define HIF_ERROR(args ...) \ QDF_TRACE(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_ERROR, ## args) #define HIF_WARN(args ...) \ diff --git a/hif/src/sdio/hif_sdio_dev.c b/hif/src/sdio/hif_sdio_dev.c index a85a48a92a..8ad65dcf7e 100644 --- a/hif/src/sdio/hif_sdio_dev.c +++ b/hif/src/sdio/hif_sdio_dev.c @@ -1,9 +1,8 @@ /* - * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * - * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all @@ -190,10 +189,7 @@ HTC_PACKET *hif_dev_alloc_rx_buffer(struct hif_sdio_device *pdev) headsize = sizeof(HTC_PACKET); netbuf = qdf_nbuf_alloc(NULL, bufsize + headsize, 0, 4, false); if (netbuf == NULL) { - QDF_TRACE_RATE_LIMITED(HIF_DBG_PRINT_RATE, QDF_MODULE_ID_HIF, - QDF_TRACE_LEVEL_ERROR, - "(%s)Allocate netbuf failed\n", - __func__); + hif_err_rl("Allocate netbuf failed"); return NULL; } packet = (HTC_PACKET *) qdf_nbuf_data(netbuf); diff --git a/qdf/linux/src/i_qdf_trace.h b/qdf/linux/src/i_qdf_trace.h index aa3ac261ed..e1b27176c5 100644 --- a/qdf/linux/src/i_qdf_trace.h +++ b/qdf/linux/src/i_qdf_trace.h @@ -58,14 +58,26 @@ #define QDF_TRACE qdf_trace_msg #define QDF_VTRACE qdf_vtrace_msg #define QDF_TRACE_HEX_DUMP qdf_trace_hex_dump -#define QDF_TRACE_RATE_LIMITED(rate, module, level, format, ...)\ +#define QDF_MAX_LOGS_PER_SEC 2 +/** + * QDF_TRACE_RATE_LIMITED() - rate limited version of QDF_TRACE + * @params: parameters to pass through to QDF_TRACE + * + * This API prevents logging a message more than QDF_MAX_LOGS_PER_SEC times per + * second. This means any subsequent calls to this API from the same location + * within 1/QDF_MAX_LOGS_PER_SEC seconds will be dropped. + * + * Return: None + */ +#define QDF_TRACE_RATE_LIMITED(params...)\ do {\ - static int rate_limit;\ - rate_limit++;\ - if (rate)\ - if (0 == (rate_limit % rate))\ - qdf_trace_msg(module, level, format,\ - ##__VA_ARGS__);\ + static ulong __last_ticks;\ + ulong __ticks = jiffies;\ + if (time_after(__ticks,\ + __last_ticks + HZ / QDF_MAX_LOGS_PER_SEC)) {\ + QDF_TRACE(params);\ + __last_ticks = __ticks;\ + } \ } while (0) #else #define QDF_TRACE(arg ...)