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 @@ -409,6 +439,31 @@ 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 + radiotap = skb_push(skb, sizeof(*radiotap));
103 + memset(radiotap, 0, sizeof(*radiotap));
104 + radiotap->it_len = cpu_to_le16(sizeof(*radiotap));
106 + /* TODO: 4 bytes with receive status? */
109 struct ieee80211_radiotap_header *radiotap;
111 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
112 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
113 @@ -103,6 +103,10 @@ static const struct brcmf_feat_fwfeat br
114 { "01-6cb8e269", BIT(BRCMF_FEAT_MONITOR) },
115 /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 52442afee990 */
116 { "01-c47a91a4", BIT(BRCMF_FEAT_MONITOR) },
117 + /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 211de1679a68 */
118 + { "01-801fb449", BIT(BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR) },
119 + /* brcmfmac4366c-pcie.bin from linux-firmware.git commit 211de1679a68 */
120 + { "01-d2cbb8fd", BIT(BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR) },
123 static void brcmf_feat_firmware_overrides(struct brcmf_pub *drv)
124 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
125 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
127 * FWSUP: Firmware supplicant.
128 * MONITOR: firmware can pass monitor packets to host.
129 * MONITOR_FMT_RADIOTAP: firmware provides monitor packets with radiotap header
130 + * MONITOR_FMT_HW_RX_HDR: firmware provides monitor packets with hw/ucode header
132 #define BRCMF_FEAT_LIST \
133 BRCMF_FEAT_DEF(MBSS) \
135 BRCMF_FEAT_DEF(GSCAN) \
136 BRCMF_FEAT_DEF(FWSUP) \
137 BRCMF_FEAT_DEF(MONITOR) \
138 - BRCMF_FEAT_DEF(MONITOR_FMT_RADIOTAP)
139 + BRCMF_FEAT_DEF(MONITOR_FMT_RADIOTAP) \
140 + BRCMF_FEAT_DEF(MONITOR_FMT_HW_RX_HDR)