1 From e665988be29ccea3584528967b432a5cfd801ca4 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Fri, 8 Feb 2019 07:42:30 +0100
4 Subject: [PATCH] brcmfmac: support monitor frames with the hardware/ucode
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 So far there were two monitor frame formats:
11 1) 802.11 frames (with frame (sub)type & all addresses)
12 2) 802.11 frames with the radiotap header
14 Testing the latest FullMAC firmwares for 4366b1/4366c0 resulted in
15 discovering a new format being used. It seems (almost?) identical to the
16 one known from ucode used in SoftMAC devices which is most likely the
19 While new firmwares will /announce/ radiotap header support using the
20 "rtap" fw capability string it seems no string was added for the new
24 1) We need new format support when dealing with a received frame
25 2) A new feature bit & mapping quirks have to be added manually
27 As for now only an empty radiotap is being created. Adding support for
28 extracting some info (band, channel, signal, etc.) is planned for the
31 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
32 Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
33 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
35 .../broadcom/brcm80211/brcmfmac/core.c | 55 +++++++++++++++++++
36 .../broadcom/brcm80211/brcmfmac/feature.c | 4 ++
37 .../broadcom/brcm80211/brcmfmac/feature.h | 4 +-
38 3 files changed, 62 insertions(+), 1 deletion(-)
40 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
41 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
44 #define BRCMF_BSSIDX_INVALID -1
46 +#define RXS_PBPRES BIT(2)
48 +#define D11_PHY_HDR_LEN 6
53 + __le16 PhyRxStatus_0;
54 + __le16 PhyRxStatus_1;
55 + __le16 PhyRxStatus_2;
56 + __le16 PhyRxStatus_3;
57 + __le16 PhyRxStatus_4;
58 + __le16 PhyRxStatus_5;
66 +struct wlc_d11rxhdr {
67 + struct d11rxhdr_le rxhdr;
76 char *brcmf_ifname(struct brcmf_if *ifp)
79 @@ -372,6 +402,35 @@ void brcmf_netif_mon_rx(struct brcmf_if
81 if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MONITOR_FMT_RADIOTAP)) {
83 + } else if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR)) {
84 + struct wlc_d11rxhdr *wlc_rxhdr = (struct wlc_d11rxhdr *)skb->data;
85 + struct ieee80211_radiotap_header *radiotap;
86 + unsigned int offset;
89 + RxStatus1 = le16_to_cpu(wlc_rxhdr->rxhdr.RxStatus1);
91 + offset = sizeof(struct wlc_d11rxhdr);
92 + /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU
95 + if (RxStatus1 & RXS_PBPRES)
97 + offset += D11_PHY_HDR_LEN;
99 + skb_pull(skb, offset);
101 + /* TODO: use RX header to fill some radiotap data */
102 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
103 + radiotap = skb_push(skb, sizeof(*radiotap));
105 + radiotap = (struct ieee80211_radiotap_header *)skb_push(skb, sizeof(*radiotap));
107 + memset(radiotap, 0, sizeof(*radiotap));
108 + radiotap->it_len = cpu_to_le16(sizeof(*radiotap));
110 + /* TODO: 4 bytes with receive status? */
113 struct ieee80211_radiotap_header *radiotap;
115 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
116 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
117 @@ -102,6 +102,10 @@ static const struct brcmf_feat_fwfeat br
118 { "01-6cb8e269", BIT(BRCMF_FEAT_MONITOR) },
119 /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 52442afee990 */
120 { "01-c47a91a4", BIT(BRCMF_FEAT_MONITOR) },
121 + /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 211de1679a68 */
122 + { "01-801fb449", BIT(BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR) },
123 + /* brcmfmac4366c-pcie.bin from linux-firmware.git commit 211de1679a68 */
124 + { "01-d2cbb8fd", BIT(BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR) },
127 static void brcmf_feat_firmware_overrides(struct brcmf_pub *drv)
128 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
129 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
131 * MFP: 802.11w Management Frame Protection.
132 * MONITOR: firmware can pass monitor packets to host.
133 * MONITOR_FMT_RADIOTAP: firmware provides monitor packets with radiotap header
134 + * MONITOR_FMT_HW_RX_HDR: firmware provides monitor packets with hw/ucode header
136 #define BRCMF_FEAT_LIST \
137 BRCMF_FEAT_DEF(MBSS) \
139 BRCMF_FEAT_DEF(WOWL_ARP_ND) \
140 BRCMF_FEAT_DEF(MFP) \
141 BRCMF_FEAT_DEF(MONITOR) \
142 - BRCMF_FEAT_DEF(MONITOR_FMT_RADIOTAP)
143 + BRCMF_FEAT_DEF(MONITOR_FMT_RADIOTAP) \
144 + BRCMF_FEAT_DEF(MONITOR_FMT_HW_RX_HDR)