From 69a1c93dc2db2a74f7aa0c0c854b9c97778b3dfc Mon Sep 17 00:00:00 2001 From: Vivek Date: Mon, 18 Jan 2021 13:28:53 +0530 Subject: [PATCH] qcacmn: Rate limit prints to console from logging utility The prints from the driver are rate limited based on the configurations provided. Also the prints which are redirected to user space daemon and of certain log levels are also printed on the console. Add a rate limiting version of the API for the prints coming to console via the logging daemon. CRs-Fixed: 2853590 Change-Id: I9683172ac0665b46581bad13a1050c6d70d72b5c --- qdf/inc/qdf_trace.h | 18 +++++++++++++++++- qdf/linux/src/qdf_trace.c | 4 ++-- utils/logging/src/wlan_logging_sock_svc.c | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/qdf/inc/qdf_trace.h b/qdf/inc/qdf_trace.h index 7795abed07..ab493c7ec6 100644 --- a/qdf/inc/qdf_trace.h +++ b/qdf/inc/qdf_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -624,6 +624,20 @@ void qdf_rl_print_count_set(uint32_t rl_print_count); */ void qdf_rl_print_time_set(uint32_t rl_print_time); +/** + * qdf_rl_print_supressed_log() - print the supressed logs count + * + * Return: none + */ +void qdf_rl_print_supressed_log(void); + +/** + * qdf_rl_print_supressed_inc() - increment the supressed logs count + * + * Return: none + */ +void qdf_rl_print_supressed_inc(void); + #else /* WLAN_MAX_LOGS_PER_SEC */ static inline bool qdf_detected_excessive_logging(void) { @@ -631,6 +645,8 @@ static inline bool qdf_detected_excessive_logging(void) } static inline void qdf_rl_print_count_set(uint32_t rl_print_count) {} static inline void qdf_rl_print_time_set(uint32_t rl_print_time) {} +static inline void qdf_rl_print_supressed_log(void) {} +static inline void qdf_rl_print_supressed_inc(void) {} #endif /* WLAN_MAX_LOGS_PER_SEC */ #ifdef ENABLE_MTRACE_LOG diff --git a/qdf/linux/src/qdf_trace.c b/qdf/linux/src/qdf_trace.c index f75bf42bb1..0acc4a5a8a 100644 --- a/qdf/linux/src/qdf_trace.c +++ b/qdf/linux/src/qdf_trace.c @@ -3284,7 +3284,7 @@ void qdf_rl_print_time_set(uint32_t rl_print_time) qdf_export_symbol(qdf_rl_print_time_set); -static inline void qdf_rl_print_supressed_log(void) +void qdf_rl_print_supressed_log(void) { if (qdf_rl_print_supressed) { pr_err("QDF Ratelimiting: %d prints supressed", @@ -3293,7 +3293,7 @@ static inline void qdf_rl_print_supressed_log(void) } } -static inline void qdf_rl_print_supressed_inc(void) +void qdf_rl_print_supressed_inc(void) { qdf_rl_print_supressed++; } diff --git a/utils/logging/src/wlan_logging_sock_svc.c b/utils/logging/src/wlan_logging_sock_svc.c index 94565a5ec2..df64d3763f 100644 --- a/utils/logging/src/wlan_logging_sock_svc.c +++ b/utils/logging/src/wlan_logging_sock_svc.c @@ -318,6 +318,19 @@ static inline void wlan_panic_on_excessive_logging(void) static inline void wlan_panic_on_excessive_logging(void) {} #endif /* WLAN_MAX_LOGS_PER_SEC */ +#ifdef QDF_TRACE_PRINT_ENABLE +static inline void +log_to_console(QDF_TRACE_LEVEL level, const char *timestamp, const char *msg) +{ + if (qdf_detected_excessive_logging()) { + qdf_rl_print_supressed_inc(); + return; + } + + qdf_rl_print_supressed_log(); + pr_err("%s %s\n", timestamp, msg); +} +#else static inline void log_to_console(QDF_TRACE_LEVEL level, const char *timestamp, const char *msg) { @@ -347,6 +360,7 @@ log_to_console(QDF_TRACE_LEVEL level, const char *timestamp, const char *msg) break; } } +#endif int wlan_log_to_user(QDF_TRACE_LEVEL log_level, char *to_be_sent, int length) {