Commit e5f1cc98 authored by Johannes Berg's avatar Johannes Berg Committed by Luca Coelho

iwlwifi: allow rate-limited error messages

Sometimes we might want to have an error message for something
related to TX/RX, but if that somehow happens frequently it'll
overwhelm the logs. Add IWL_ERR_LIMIT() to alleviate that by
rate-limiting those messages.

To do this, rework __iwl_err() a bit to have a mode argument
instead of passing yet another (bool) argument to it.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211017162352.2cb1e6b75672.Iec5b1c1bcc6ebc87c586921a6c5c2a937f49e83c@changeidSigned-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 6b1259d1
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/* /*
* Copyright (C) 2005-2014 Intel Corporation * Copyright (C) 2005-2014, 2021 Intel Corporation
*/ */
#ifndef __iwl_agn_h__ #ifndef __iwl_agn_h__
#define __iwl_agn_h__ #define __iwl_agn_h__
...@@ -398,8 +398,10 @@ do { \ ...@@ -398,8 +398,10 @@ do { \
if (!iwl_is_rfkill((m))) \ if (!iwl_is_rfkill((m))) \
IWL_ERR(m, fmt, ##args); \ IWL_ERR(m, fmt, ##args); \
else \ else \
__iwl_err((m)->dev, true, \ __iwl_err((m)->dev, \
!iwl_have_debug_level(IWL_DL_RADIO), \ iwl_have_debug_level(IWL_DL_RADIO) ? \
IWL_ERR_MODE_RFKILL : \
IWL_ERR_MODE_TRACE_ONLY, \
fmt, ##args); \ fmt, ##args); \
} while (0) } while (0)
#else #else
...@@ -408,7 +410,8 @@ do { \ ...@@ -408,7 +410,8 @@ do { \
if (!iwl_is_rfkill((m))) \ if (!iwl_is_rfkill((m))) \
IWL_ERR(m, fmt, ##args); \ IWL_ERR(m, fmt, ##args); \
else \ else \
__iwl_err((m)->dev, true, true, fmt, ##args); \ __iwl_err((m)->dev, IWL_ERR_MODE_TRACE_ONLY, \
fmt, ##args); \
} while (0) } while (0)
#endif /* CONFIG_IWLWIFI_DEBUG */ #endif /* CONFIG_IWLWIFI_DEBUG */
......
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/* /*
* Copyright (C) 2005-2011 Intel Corporation * Copyright (C) 2005-2011, 2021 Intel Corporation
*/ */
#include <linux/device.h> #include <linux/device.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -31,21 +31,31 @@ IWL_EXPORT_SYMBOL(__iwl_info); ...@@ -31,21 +31,31 @@ IWL_EXPORT_SYMBOL(__iwl_info);
__iwl_fn(crit) __iwl_fn(crit)
IWL_EXPORT_SYMBOL(__iwl_crit); IWL_EXPORT_SYMBOL(__iwl_crit);
void __iwl_err(struct device *dev, bool rfkill_prefix, bool trace_only, void __iwl_err(struct device *dev, enum iwl_err_mode mode, const char *fmt, ...)
const char *fmt, ...)
{ {
struct va_format vaf = { struct va_format vaf = {
.fmt = fmt, .fmt = fmt,
}; };
va_list args; va_list args, args2;
va_start(args, fmt); va_start(args, fmt);
vaf.va = &args; switch (mode) {
if (!trace_only) { case IWL_ERR_MODE_RATELIMIT:
if (rfkill_prefix) if (net_ratelimit())
break;
fallthrough;
case IWL_ERR_MODE_REGULAR:
case IWL_ERR_MODE_RFKILL:
va_copy(args2, args);
vaf.va = &args2;
if (mode == IWL_ERR_MODE_RFKILL)
dev_err(dev, "(RFKILL) %pV", &vaf); dev_err(dev, "(RFKILL) %pV", &vaf);
else else
dev_err(dev, "%pV", &vaf); dev_err(dev, "%pV", &vaf);
va_end(args2);
break;
default:
break;
} }
trace_iwlwifi_err(&vaf); trace_iwlwifi_err(&vaf);
va_end(args); va_end(args);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2018 - 2020 Intel Corporation * Copyright(c) 2018 - 2021 Intel Corporation
* *
* Portions of this file are derived from the ipw3945 project. * Portions of this file are derived from the ipw3945 project.
*****************************************************************************/ *****************************************************************************/
...@@ -22,9 +22,16 @@ static inline bool iwl_have_debug_level(u32 level) ...@@ -22,9 +22,16 @@ static inline bool iwl_have_debug_level(u32 level)
#endif #endif
} }
enum iwl_err_mode {
IWL_ERR_MODE_REGULAR,
IWL_ERR_MODE_RFKILL,
IWL_ERR_MODE_TRACE_ONLY,
IWL_ERR_MODE_RATELIMIT,
};
struct device; struct device;
void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace, void __iwl_err(struct device *dev, enum iwl_err_mode mode, const char *fmt, ...)
const char *fmt, ...) __printf(4, 5); __printf(3, 4);
void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3); void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3); void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3); void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);
...@@ -33,13 +40,17 @@ void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3); ...@@ -33,13 +40,17 @@ void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);
#define CHECK_FOR_NEWLINE(f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n') #define CHECK_FOR_NEWLINE(f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n')
/* No matter what is m (priv, bus, trans), this will work */ /* No matter what is m (priv, bus, trans), this will work */
#define IWL_ERR_DEV(d, f, a...) \ #define __IWL_ERR_DEV(d, mode, f, a...) \
do { \ do { \
CHECK_FOR_NEWLINE(f); \ CHECK_FOR_NEWLINE(f); \
__iwl_err((d), false, false, f, ## a); \ __iwl_err((d), mode, f, ## a); \
} while (0) } while (0)
#define IWL_ERR_DEV(d, f, a...) \
__IWL_ERR_DEV(d, IWL_ERR_MODE_REGULAR, f, ## a)
#define IWL_ERR(m, f, a...) \ #define IWL_ERR(m, f, a...) \
IWL_ERR_DEV((m)->dev, f, ## a) IWL_ERR_DEV((m)->dev, f, ## a)
#define IWL_ERR_LIMIT(m, f, a...) \
__IWL_ERR_DEV((m)->dev, IWL_ERR_MODE_RATELIMIT, f, ## a)
#define IWL_WARN(m, f, a...) \ #define IWL_WARN(m, f, a...) \
do { \ do { \
CHECK_FOR_NEWLINE(f); \ CHECK_FOR_NEWLINE(f); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment