mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-15 01:01:56 -04:00
Merge "qcacmn: Rate limit logs based on elapsed time"
This commit is contained in:
commit
16960ff67a
7 changed files with 103 additions and 32 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 ...) \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
58
qdf/inc/qdf_platform.h
Normal file
58
qdf/inc/qdf_platform.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 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
|
||||
* copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file was originally distributed by Qualcomm Atheros, Inc.
|
||||
* under proprietary terms before Copyright ownership was assigned
|
||||
* to the Linux Foundation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: qdf_platform.h
|
||||
* This file defines platform API abstractions.
|
||||
*/
|
||||
|
||||
#ifndef _QDF_PLATFORM_H
|
||||
#define _QDF_PLATFORM_H
|
||||
|
||||
/**
|
||||
* qdf_is_fw_down_callback - callback to query if fw is down
|
||||
*
|
||||
* Return: true if fw is down and false if fw is not down
|
||||
*/
|
||||
typedef bool (*qdf_is_fw_down_callback)(void);
|
||||
|
||||
/**
|
||||
* qdf_register_fw_down_callback() - API to register fw down callback
|
||||
* @is_fw_down: callback to query if fw is down or not
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
void qdf_register_fw_down_callback(qdf_is_fw_down_callback is_fw_down);
|
||||
|
||||
/**
|
||||
* qdf_is_fw_down() - API to check if fw is down or not
|
||||
*
|
||||
* Return: true: if fw is down
|
||||
* false: if fw is not down
|
||||
*/
|
||||
bool qdf_is_fw_down(void);
|
||||
#endif /*_QDF_PLATFORM_H*/
|
||||
|
|
@ -42,12 +42,6 @@
|
|||
#endif
|
||||
|
||||
typedef __qdf_wait_queue_head_t qdf_wait_queue_head_t;
|
||||
/**
|
||||
* qdf_is_fw_down_callback - callback to query if fw is down
|
||||
*
|
||||
* Return: true if fw is down and false if fw is not down
|
||||
*/
|
||||
typedef bool (*qdf_is_fw_down_callback)(void);
|
||||
|
||||
/**
|
||||
* qdf_unlikely - Compiler-dependent macro denoting code likely to execute
|
||||
|
|
@ -675,12 +669,4 @@ void qdf_get_random_bytes(void *buf, int nbytes)
|
|||
{
|
||||
return __qdf_get_random_bytes(buf, nbytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* qdf_register_fw_down_callback() - API to register fw down callback
|
||||
* @is_fw_down: callback to query if fw is down or not
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
void qdf_register_fw_down_callback(qdf_is_fw_down_callback is_fw_down);
|
||||
#endif /*_QDF_UTIL_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 ...)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
*/
|
||||
|
||||
#include "qdf_module.h"
|
||||
#include "qdf_util.h"
|
||||
#include "qdf_trace.h"
|
||||
#include "qdf_platform.h"
|
||||
|
||||
static qdf_is_fw_down_callback is_fw_down_cb;
|
||||
|
||||
|
|
@ -26,3 +27,15 @@ void qdf_register_fw_down_callback(qdf_is_fw_down_callback is_fw_down)
|
|||
is_fw_down_cb = is_fw_down;
|
||||
}
|
||||
qdf_export_symbol(qdf_register_fw_down_callback);
|
||||
|
||||
bool qdf_is_fw_down(void)
|
||||
{
|
||||
if (!is_fw_down_cb) {
|
||||
QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
||||
"fw down callback is not registered");
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_fw_down_cb();
|
||||
}
|
||||
qdf_export_symbol(qdf_is_fw_down);
|
||||
Loading…
Reference in a new issue