162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * mac80211 drop reason list
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2023 Intel Corporation
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef MAC80211_DROP_H
962306a36Sopenharmony_ci#define MAC80211_DROP_H
1062306a36Sopenharmony_ci#include <net/dropreason.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_citypedef unsigned int __bitwise ieee80211_rx_result;
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define MAC80211_DROP_REASONS_MONITOR(R)	\
1562306a36Sopenharmony_ci	R(RX_DROP_M_UNEXPECTED_4ADDR_FRAME)	\
1662306a36Sopenharmony_ci	R(RX_DROP_M_BAD_BCN_KEYIDX)		\
1762306a36Sopenharmony_ci	R(RX_DROP_M_BAD_MGMT_KEYIDX)		\
1862306a36Sopenharmony_ci/* this line for the trailing \ - add before this */
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define MAC80211_DROP_REASONS_UNUSABLE(R)	\
2162306a36Sopenharmony_ci	R(RX_DROP_U_MIC_FAIL)			\
2262306a36Sopenharmony_ci	R(RX_DROP_U_REPLAY)			\
2362306a36Sopenharmony_ci	R(RX_DROP_U_BAD_MMIE)			\
2462306a36Sopenharmony_ci/* this line for the trailing \ - add before this */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* having two enums allows for checking ieee80211_rx_result use with sparse */
2762306a36Sopenharmony_cienum ___mac80211_drop_reason {
2862306a36Sopenharmony_ci/* if we get to the end of handlers with RX_CONTINUE this will be the reason */
2962306a36Sopenharmony_ci	___RX_CONTINUE	= SKB_CONSUMED,
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/* this never gets used as an argument to kfree_skb_reason() */
3262306a36Sopenharmony_ci	___RX_QUEUED	= SKB_NOT_DROPPED_YET,
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#define ENUM(x) ___ ## x,
3562306a36Sopenharmony_ci	___RX_DROP_MONITOR = SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR <<
3662306a36Sopenharmony_ci		SKB_DROP_REASON_SUBSYS_SHIFT,
3762306a36Sopenharmony_ci	MAC80211_DROP_REASONS_MONITOR(ENUM)
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci	___RX_DROP_UNUSABLE = SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE <<
4062306a36Sopenharmony_ci		SKB_DROP_REASON_SUBSYS_SHIFT,
4162306a36Sopenharmony_ci	MAC80211_DROP_REASONS_UNUSABLE(ENUM)
4262306a36Sopenharmony_ci#undef ENUM
4362306a36Sopenharmony_ci};
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_cienum mac80211_drop_reason {
4662306a36Sopenharmony_ci	RX_CONTINUE	 = (__force ieee80211_rx_result)___RX_CONTINUE,
4762306a36Sopenharmony_ci	RX_QUEUED	 = (__force ieee80211_rx_result)___RX_QUEUED,
4862306a36Sopenharmony_ci	RX_DROP_MONITOR	 = (__force ieee80211_rx_result)___RX_DROP_MONITOR,
4962306a36Sopenharmony_ci	RX_DROP_UNUSABLE = (__force ieee80211_rx_result)___RX_DROP_UNUSABLE,
5062306a36Sopenharmony_ci#define DEF(x) x = (__force ieee80211_rx_result)___ ## x,
5162306a36Sopenharmony_ci	MAC80211_DROP_REASONS_MONITOR(DEF)
5262306a36Sopenharmony_ci	MAC80211_DROP_REASONS_UNUSABLE(DEF)
5362306a36Sopenharmony_ci#undef DEF
5462306a36Sopenharmony_ci};
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#define RX_RES_IS_UNUSABLE(result)	\
5762306a36Sopenharmony_ci	(((__force u32)(result) & SKB_DROP_REASON_SUBSYS_MASK) == ___RX_DROP_UNUSABLE)
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#endif /* MAC80211_DROP_H */
60