2021-09-28 18:12:17

by kernel test robot

[permalink] [raw]
Subject: drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get'

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 6fd3ec5c7af58d5d6b598fba22ac387645af33f4
commit: ca19ea63f739c7a4e5dad64951706fea789e1f1a mlxsw: core_acl_flex_actions: Add mirror sampler action
date: 7 months ago
config: mips-randconfig-r013-20210928 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ca19ea63f739c7a4e5dad64951706fea789e1f1a
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout ca19ea63f739c7a4e5dad64951706fea789e1f1a
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/net/ethernet/mellanox/mlxsw/ mm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:119:1: note: expanded from here
mlxsw_afa_polcnt_c_p_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1736:1: warning: unused function 'mlxsw_afa_polcnt_counter_set_type_get'
MLXSW_ITEM32(afa, polcnt, counter_set_type, 0x04, 24, 8);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:152:1: note: expanded from here
mlxsw_afa_polcnt_counter_set_type_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1741:1: warning: unused function 'mlxsw_afa_polcnt_counter_index_get'
MLXSW_ITEM32(afa, polcnt, counter_index, 0x04, 0, 24);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:185:1: note: expanded from here
mlxsw_afa_polcnt_counter_index_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1747:1: warning: unused function 'mlxsw_afa_polcnt_pid_get'
MLXSW_ITEM32(afa, polcnt, pid, 0x08, 0, 14);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:26:1: note: expanded from here
mlxsw_afa_polcnt_pid_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1859:1: warning: unused function 'mlxsw_afa_virfwd_fid_cmd_get'
MLXSW_ITEM32(afa, virfwd, fid_cmd, 0x08, 29, 3);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:113:1: note: expanded from here
mlxsw_afa_virfwd_fid_cmd_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1864:1: warning: unused function 'mlxsw_afa_virfwd_fid_get'
MLXSW_ITEM32(afa, virfwd, fid, 0x08, 0, 16);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:146:1: note: expanded from here
mlxsw_afa_virfwd_fid_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1905:1: warning: unused function 'mlxsw_afa_mcrouter_rpf_action_get'
MLXSW_ITEM32(afa, mcrouter, rpf_action, 0x00, 28, 3);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:33:1: note: expanded from here
mlxsw_afa_mcrouter_rpf_action_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1908:1: warning: unused function 'mlxsw_afa_mcrouter_expected_irif_get'
MLXSW_ITEM32(afa, mcrouter, expected_irif, 0x00, 0, 16);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:66:1: note: expanded from here
mlxsw_afa_mcrouter_expected_irif_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1911:1: warning: unused function 'mlxsw_afa_mcrouter_min_mtu_get'
MLXSW_ITEM32(afa, mcrouter, min_mtu, 0x08, 0, 16);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:99:1: note: expanded from here
mlxsw_afa_mcrouter_min_mtu_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1921:1: warning: unused function 'mlxsw_afa_mcrouter_vrmid_get'
MLXSW_ITEM32(afa, mcrouter, vrmid, 0x0C, 31, 1);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:132:1: note: expanded from here
mlxsw_afa_mcrouter_vrmid_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1929:1: warning: unused function 'mlxsw_afa_mcrouter_rigr_rmid_index_get'
MLXSW_ITEM32(afa, mcrouter, rigr_rmid_index, 0x0C, 0, 24);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:165:1: note: expanded from here
mlxsw_afa_mcrouter_rigr_rmid_index_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1979:1: warning: unused function 'mlxsw_afa_l4port_s_d_get'
MLXSW_ITEM32(afa, l4port, s_d, 0x00, 31, 1);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:30:1: note: expanded from here
mlxsw_afa_l4port_s_d_get
^
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:1984:1: warning: unused function 'mlxsw_afa_l4port_l4_port_get'
MLXSW_ITEM32(afa, l4port, l4_port, 0x08, 0, 16);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:63:1: note: expanded from here
mlxsw_afa_l4port_l4_port_get
^
>> drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get'
MLXSW_ITEM32(afa, sampler, mirror_agent, 0x04, 0, 3);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:112:1: note: expanded from here
mlxsw_afa_sampler_mirror_agent_get
^
>> drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2030:1: warning: unused function 'mlxsw_afa_sampler_mirror_probability_rate_get'
MLXSW_ITEM32(afa, sampler, mirror_probability_rate, 0x08, 0, 24);
^
drivers/net/ethernet/mellanox/mlxsw/item.h:355:19: note: expanded from macro 'MLXSW_ITEM32'
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
<scratch space>:145:1: note: expanded from here
mlxsw_afa_sampler_mirror_probability_rate_get
^
fatal error: error in backend: Nested variants found in inline asm string: ' .set push
.set mips64r2
.if ( 0x00 ) != -1)) 0x00 ) != -1)) : ($( static struct ftrace_branch_data __attribute__((__aligned__(4))) __attribute__((__section__("_ftrace_branch"))) __if_trace = $( .func = __func__, .file = "arch/mips/include/asm/atomic.h", .line = 153, $); 0x00 ) != -1)) : $))) ) && ( 0 ); .set push; .set mips64r2; .rept 1; sync 0x00; .endr; .set pop; .else; ; .endif
1: ll $1, $2 # atomic_fetch_add
addu $0, $1, $3
sc $0, $2
beqz $0, 1b
.set pop
move $0, $1
'
clang-14: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 14.0.0 (git://gitmirror/llvm_project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
Target: mipsel-unknown-linux
Thread model: posix
InstalledDir: /opt/cross/clang-dc6e8dfdfe/bin
clang-14: note: diagnostic msg:
Makefile arch drivers fs include kernel mm net nr_bisected scripts source usr


vim +/mlxsw_afa_sampler_mirror_agent_get +2022 drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c

2018
2019 /* afa_sampler_mirror_agent
2020 * Mirror (SPAN) agent.
2021 */
> 2022 MLXSW_ITEM32(afa, sampler, mirror_agent, 0x04, 0, 3);
2023
2024 #define MLXSW_AFA_SAMPLER_RATE_MAX (BIT(24) - 1)
2025
2026 /* afa_sampler_mirror_probability_rate
2027 * Mirroring probability.
2028 * Valid values are 1 to 2^24 - 1
2029 */
> 2030 MLXSW_ITEM32(afa, sampler, mirror_probability_rate, 0x08, 0, 24);
2031

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (9.53 kB)
.config.gz (30.42 kB)
Download all attachments

2021-09-29 09:45:36

by Ido Schimmel

[permalink] [raw]
Subject: Re: drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get'

On Tue, Sep 28, 2021 at 09:06:54PM +0300, kernel test robot wrote:
> All warnings (new ones prefixed by >>):
>
> static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
> <scratch space>:119:1: note: expanded from here
> mlxsw_afa_polcnt_c_p_get
> ^

Nathan,

I saw your reply to a similar issue here [1] and I got the impression
that you are leading the LLVM-related efforts, so I thought I will
consult with you regarding a possible solution.

The inline functions that clang is complaining about are generated by
macros that make it easy to set/get fields in the payloads of
configuration messages used to communicate with the device. It is
possible that sometime we only set a field, but never retrieve its value
such as in the warning above. This is very much intentional and not
indicative of a function we forgot to remove.

The patch below [2] adds the "__maybe_unused" keyword to these macros
and makes clang happy [3].

Is this acceptable or you suggest a different solution?

Thanks

[1] https://lists.01.org/hyperkitty/list/[email protected]/thread/TIUWC7KZVTHGJKIZ4M3LI3JJYVAAINJX/

[2]
diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h
index e92cadc98128..d2c8f436efb7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/item.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/item.h
@@ -290,13 +290,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u8 \
+static inline u8 __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
{ \
return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), \
index); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
u8 val) \
{ \
@@ -311,11 +311,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
+static inline u16 __maybe_unused \
+mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
{ \
return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
} \
-static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val)\
+static inline void __maybe_unused \
+mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val) \
{ \
__mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
}
@@ -331,13 +333,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u16 \
+static inline u16 __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
{ \
return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \
index); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
u16 val) \
{ \
@@ -352,11 +354,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
+static inline u32 __maybe_unused \
+mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
{ \
return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
} \
-static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val)\
+static inline void __maybe_unused \
+mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val) \
{ \
__mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
}
@@ -372,13 +376,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u32 \
+static inline u32 __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
{ \
return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \
index); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
u32 val) \
{ \
@@ -393,11 +397,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
+static inline u64 __maybe_unused \
+mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
{ \
return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
} \
-static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val)\
+static inline void __maybe_unused \
+mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val) \
{ \
__mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
}
@@ -413,13 +419,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bits = _sizebits,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u64 \
+static inline u64 __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
{ \
return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \
index); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
u64 val) \
{ \
@@ -433,19 +439,19 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bytes = _sizebytes,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \
{ \
__mlxsw_item_memcpy_from(buf, dst, \
&__ITEM_NAME(_type, _cname, _iname), 0); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, const char *src) \
{ \
__mlxsw_item_memcpy_to(buf, src, \
&__ITEM_NAME(_type, _cname, _iname), 0); \
} \
-static inline char * \
+static inline char * __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_data(char *buf) \
{ \
return __mlxsw_item_data(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
@@ -460,7 +466,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bytes = _sizebytes,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
unsigned short index, \
char *dst) \
@@ -468,7 +474,7 @@ mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
__mlxsw_item_memcpy_from(buf, dst, \
&__ITEM_NAME(_type, _cname, _iname), index); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
unsigned short index, \
const char *src) \
@@ -476,7 +482,7 @@ mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
__mlxsw_item_memcpy_to(buf, src, \
&__ITEM_NAME(_type, _cname, _iname), index); \
} \
-static inline char * \
+static inline char * __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_data(char *buf, unsigned short index) \
{ \
return __mlxsw_item_data(buf, \
@@ -491,14 +497,14 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
.size = {.bytes = _sizebytes,}, \
.name = #_type "_" #_cname "_" #_iname, \
}; \
-static inline u8 \
+static inline u8 __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \
{ \
return __mlxsw_item_bit_array_get(buf, \
&__ITEM_NAME(_type, _cname, _iname), \
index); \
} \
-static inline void \
+static inline void __maybe_unused \
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 index, u8 val) \
{ \
return __mlxsw_item_bit_array_set(buf, \

[3]
$ make -j8 CC=clang C=2 W=1 drivers/net/ethernet/mellanox/mlxsw/
DESCEND bpf/resolve_btfids
DESCEND objtool
CHECK scripts/mod/empty.c
CALL scripts/atomic/check-atomics.sh
CALL scripts/checksyscalls.sh
CHECK drivers/net/ethernet/mellanox/mlxsw/core.c
CHECK drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
CHECK drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
CHECK drivers/net/ethernet/mellanox/mlxsw/core_env.c
CHECK drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
CHECK drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
CHECK drivers/net/ethernet/mellanox/mlxsw/pci.c
CHECK drivers/net/ethernet/mellanox/mlxsw/i2c.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_router_xm.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_kvdl.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_kvdl.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_mr_tcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_policer.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
CHECK drivers/net/ethernet/mellanox/mlxsw/minimal.c

2021-09-29 16:41:28

by Nathan Chancellor

[permalink] [raw]
Subject: Re: drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get'

Hi Ido,

On Wed, Sep 29, 2021 at 12:44:16PM +0300, Ido Schimmel wrote:
> On Tue, Sep 28, 2021 at 09:06:54PM +0300, kernel test robot wrote:
> > All warnings (new ones prefixed by >>):
> >
> > static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^
> > <scratch space>:119:1: note: expanded from here
> > mlxsw_afa_polcnt_c_p_get
> > ^
>
> I saw your reply to a similar issue here [1] and I got the impression
> that you are leading the LLVM-related efforts, so I thought I will
> consult with you regarding a possible solution.
>
> The inline functions that clang is complaining about are generated by
> macros that make it easy to set/get fields in the payloads of
> configuration messages used to communicate with the device. It is
> possible that sometime we only set a field, but never retrieve its value
> such as in the warning above. This is very much intentional and not
> indicative of a function we forgot to remove.
>
> The patch below [2] adds the "__maybe_unused" keyword to these macros
> and makes clang happy [3].
>
> Is this acceptable or you suggest a different solution?

Yes, I would say this is a perfectly fine solution. The warning is there
to make you consider if you have forgotten to use or remove a function
depending on the context and if this is expected behavior, silencing the
compiler with the __maybe_unused attribute is the right thing to do. The
kernel does this for resume and suspend functions as CONFIG_PM might not
be set.

Cheers,
Nathan

> Thanks
>
> [1] https://lists.01.org/hyperkitty/list/[email protected]/thread/TIUWC7KZVTHGJKIZ4M3LI3JJYVAAINJX/
>
> [2]
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h
> index e92cadc98128..d2c8f436efb7 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/item.h
> +++ b/drivers/net/ethernet/mellanox/mlxsw/item.h
> @@ -290,13 +290,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u8 \
> +static inline u8 __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
> { \
> return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), \
> index); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
> u8 val) \
> { \
> @@ -311,11 +311,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
> +static inline u16 __maybe_unused \
> +mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
> { \
> return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
> } \
> -static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val)\
> +static inline void __maybe_unused \
> +mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val) \
> { \
> __mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
> }
> @@ -331,13 +333,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u16 \
> +static inline u16 __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
> { \
> return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \
> index); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
> u16 val) \
> { \
> @@ -352,11 +354,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
> +static inline u32 __maybe_unused \
> +mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
> { \
> return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
> } \
> -static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val)\
> +static inline void __maybe_unused \
> +mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val) \
> { \
> __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
> }
> @@ -372,13 +376,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u32 \
> +static inline u32 __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
> { \
> return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \
> index); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
> u32 val) \
> { \
> @@ -393,11 +397,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
> +static inline u64 __maybe_unused \
> +mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
> { \
> return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
> } \
> -static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val)\
> +static inline void __maybe_unused \
> +mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val) \
> { \
> __mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
> }
> @@ -413,13 +419,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bits = _sizebits,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u64 \
> +static inline u64 __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
> { \
> return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \
> index); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
> u64 val) \
> { \
> @@ -433,19 +439,19 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bytes = _sizebytes,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \
> { \
> __mlxsw_item_memcpy_from(buf, dst, \
> &__ITEM_NAME(_type, _cname, _iname), 0); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, const char *src) \
> { \
> __mlxsw_item_memcpy_to(buf, src, \
> &__ITEM_NAME(_type, _cname, _iname), 0); \
> } \
> -static inline char * \
> +static inline char * __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_data(char *buf) \
> { \
> return __mlxsw_item_data(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
> @@ -460,7 +466,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bytes = _sizebytes,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
> unsigned short index, \
> char *dst) \
> @@ -468,7 +474,7 @@ mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
> __mlxsw_item_memcpy_from(buf, dst, \
> &__ITEM_NAME(_type, _cname, _iname), index); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
> unsigned short index, \
> const char *src) \
> @@ -476,7 +482,7 @@ mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
> __mlxsw_item_memcpy_to(buf, src, \
> &__ITEM_NAME(_type, _cname, _iname), index); \
> } \
> -static inline char * \
> +static inline char * __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_data(char *buf, unsigned short index) \
> { \
> return __mlxsw_item_data(buf, \
> @@ -491,14 +497,14 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
> .size = {.bytes = _sizebytes,}, \
> .name = #_type "_" #_cname "_" #_iname, \
> }; \
> -static inline u8 \
> +static inline u8 __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \
> { \
> return __mlxsw_item_bit_array_get(buf, \
> &__ITEM_NAME(_type, _cname, _iname), \
> index); \
> } \
> -static inline void \
> +static inline void __maybe_unused \
> mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 index, u8 val) \
> { \
> return __mlxsw_item_bit_array_set(buf, \
>
> [3]
> $ make -j8 CC=clang C=2 W=1 drivers/net/ethernet/mellanox/mlxsw/
> DESCEND bpf/resolve_btfids
> DESCEND objtool
> CHECK scripts/mod/empty.c
> CALL scripts/atomic/check-atomics.sh
> CALL scripts/checksyscalls.sh
> CHECK drivers/net/ethernet/mellanox/mlxsw/core.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/core_env.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/pci.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/i2c.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_router_xm.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_kvdl.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_kvdl.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_mr_tcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_policer.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
> CHECK drivers/net/ethernet/mellanox/mlxsw/minimal.c

2021-09-30 06:46:15

by Ido Schimmel

[permalink] [raw]
Subject: Re: drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get'

On Wed, Sep 29, 2021 at 09:39:41AM -0700, Nathan Chancellor wrote:
> Yes, I would say this is a perfectly fine solution. The warning is there
> to make you consider if you have forgotten to use or remove a function
> depending on the context and if this is expected behavior, silencing the
> compiler with the __maybe_unused attribute is the right thing to do. The
> kernel does this for resume and suspend functions as CONFIG_PM might not
> be set.

Thanks, Nathan. Will send the patch to net-next (most likely next week)
and copy you.