xref: /linux/net/mac80211/drop.h (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * mac80211 drop reason list
4  *
5  * Copyright (C) 2023-2024 Intel Corporation
6  */
7 
8 #ifndef MAC80211_DROP_H
9 #define MAC80211_DROP_H
10 #include <net/dropreason.h>
11 
12 typedef unsigned int __bitwise ieee80211_rx_result;
13 
14 #define MAC80211_DROP_REASONS_MONITOR(R)	\
15 	R(RX_DROP_M_UNEXPECTED_4ADDR_FRAME)	\
16 	R(RX_DROP_M_BAD_BCN_KEYIDX)		\
17 	R(RX_DROP_M_BAD_MGMT_KEYIDX)		\
18 /* this line for the trailing \ - add before this */
19 
20 #define MAC80211_DROP_REASONS_UNUSABLE(R)	\
21 	/* 0x00 == ___RX_DROP_UNUSABLE */	\
22 	R(RX_DROP_U_MIC_FAIL)			\
23 	R(RX_DROP_U_REPLAY)			\
24 	R(RX_DROP_U_BAD_MMIE)			\
25 	R(RX_DROP_U_DUP)			\
26 	R(RX_DROP_U_SPURIOUS)			\
27 	R(RX_DROP_U_DECRYPT_FAIL)		\
28 	R(RX_DROP_U_NO_KEY_ID)			\
29 	R(RX_DROP_U_BAD_CIPHER)			\
30 	R(RX_DROP_U_OOM)			\
31 	R(RX_DROP_U_NONSEQ_PN)			\
32 	R(RX_DROP_U_BAD_KEY_COLOR)		\
33 	R(RX_DROP_U_BAD_4ADDR)			\
34 	R(RX_DROP_U_BAD_AMSDU)			\
35 	R(RX_DROP_U_BAD_AMSDU_CIPHER)		\
36 	R(RX_DROP_U_INVALID_8023)		\
37 	/* 0x10 */				\
38 	R(RX_DROP_U_RUNT_ACTION)		\
39 	R(RX_DROP_U_UNPROT_ACTION)		\
40 	R(RX_DROP_U_UNPROT_DUAL)		\
41 	R(RX_DROP_U_UNPROT_UCAST_MGMT)		\
42 	R(RX_DROP_U_UNPROT_MCAST_MGMT)		\
43 	R(RX_DROP_U_UNPROT_BEACON)		\
44 	R(RX_DROP_U_UNPROT_UNICAST_PUB_ACTION)	\
45 	R(RX_DROP_U_UNPROT_ROBUST_ACTION)	\
46 	R(RX_DROP_U_ACTION_UNKNOWN_SRC)		\
47 	R(RX_DROP_U_REJECTED_ACTION_RESPONSE)	\
48 	R(RX_DROP_U_EXPECT_DEFRAG_PROT)		\
49 	R(RX_DROP_U_WEP_DEC_FAIL)		\
50 	R(RX_DROP_U_NO_IV)			\
51 	R(RX_DROP_U_NO_ICV)			\
52 	R(RX_DROP_U_AP_RX_GROUPCAST)		\
53 	R(RX_DROP_U_SHORT_MMIC)			\
54 	/* 0x20 */				\
55 	R(RX_DROP_U_MMIC_FAIL)			\
56 	R(RX_DROP_U_SHORT_TKIP)			\
57 	R(RX_DROP_U_TKIP_FAIL)			\
58 	R(RX_DROP_U_SHORT_CCMP)			\
59 	R(RX_DROP_U_SHORT_CCMP_MIC)		\
60 	R(RX_DROP_U_SHORT_GCMP)			\
61 	R(RX_DROP_U_SHORT_GCMP_MIC)		\
62 	R(RX_DROP_U_SHORT_CMAC)			\
63 	R(RX_DROP_U_SHORT_CMAC256)		\
64 	R(RX_DROP_U_SHORT_GMAC)			\
65 	R(RX_DROP_U_UNEXPECTED_VLAN_4ADDR)	\
66 	R(RX_DROP_U_UNEXPECTED_STA_4ADDR)	\
67 	R(RX_DROP_U_UNEXPECTED_VLAN_MCAST)	\
68 	R(RX_DROP_U_NOT_PORT_CONTROL)		\
69 	R(RX_DROP_U_UNKNOWN_ACTION_REJECTED)	\
70 /* this line for the trailing \ - add before this */
71 
72 /* having two enums allows for checking ieee80211_rx_result use with sparse */
73 enum ___mac80211_drop_reason {
74 /* if we get to the end of handlers with RX_CONTINUE this will be the reason */
75 	___RX_CONTINUE	= SKB_CONSUMED,
76 
77 /* this never gets used as an argument to kfree_skb_reason() */
78 	___RX_QUEUED	= SKB_NOT_DROPPED_YET,
79 
80 #define ENUM(x) ___ ## x,
81 	___RX_DROP_MONITOR = SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR <<
82 		SKB_DROP_REASON_SUBSYS_SHIFT,
83 	MAC80211_DROP_REASONS_MONITOR(ENUM)
84 
85 	___RX_DROP_UNUSABLE = SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE <<
86 		SKB_DROP_REASON_SUBSYS_SHIFT,
87 	MAC80211_DROP_REASONS_UNUSABLE(ENUM)
88 #undef ENUM
89 };
90 
91 enum mac80211_drop_reason {
92 	RX_CONTINUE	 = (__force ieee80211_rx_result)___RX_CONTINUE,
93 	RX_QUEUED	 = (__force ieee80211_rx_result)___RX_QUEUED,
94 	RX_DROP_MONITOR	 = (__force ieee80211_rx_result)___RX_DROP_MONITOR,
95 #define DEF(x) x = (__force ieee80211_rx_result)___ ## x,
96 	MAC80211_DROP_REASONS_MONITOR(DEF)
97 	MAC80211_DROP_REASONS_UNUSABLE(DEF)
98 #undef DEF
99 };
100 
101 #define RX_RES_IS_UNUSABLE(result)	\
102 	(((__force u32)(result) & SKB_DROP_REASON_SUBSYS_MASK) == ___RX_DROP_UNUSABLE)
103 
104 #endif /* MAC80211_DROP_H */
105