Wireless Fidelity with bwfm(4) Patrick Wildt September 22, 2019 - - PowerPoint PPT Presentation

wireless fidelity with bwfm 4
SMART_READER_LITE
LIVE PREVIEW

Wireless Fidelity with bwfm(4) Patrick Wildt September 22, 2019 - - PowerPoint PPT Presentation

Why? How? What now? Wireless Fidelity with bwfm(4) Patrick Wildt September 22, 2019 Patrick Wildt Wireless Fidelity with bwfm(4) Why? Personally How? Hardware What now? Milestones Who am I? OpenBSD developer ARM64-subtree maintainer


slide-1
SLIDE 1

Why? How? What now?

Wireless Fidelity with bwfm(4)

Patrick Wildt September 22, 2019

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-2
SLIDE 2

Why? How? What now? Personally Hardware Milestones

Who am I?

OpenBSD developer ARM64-subtree maintainer LLVM-subtree updater SBC hoarder

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-3
SLIDE 3

Why? How? What now? Personally Hardware Milestones

Collection of devices

Cubox-i Macbook Raspberry Pi 3 Z83 Mini-PC

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-4
SLIDE 4

Why? How? What now? Personally Hardware Milestones

Milestones

Skeleton Driver May 2016 USB Firmware Upload June 2016 September 2017 WiFi Scan October 2017 OpenBSD commit PCIe backend December 2017 SDIO backend February 2018 ??? ??? January 2018 Host AP Mode

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-5
SLIDE 5

Why? How? What now? Start Details Tricky bits

Study

1 Find documentation

Search the web for datasheets (by chip name) git grep in various OS (chip name, vendor/product ID) Neither code nor datasheet? Quit now. Alternative: reverse engineering

2 Study code and/or documentation to grasp concepts

Attention: license concerns!

3 Realize it’s going to be a long project Patrick Wildt Wireless Fidelity with bwfm(4)

slide-6
SLIDE 6

Why? How? What now? Start Details Tricky bits

Full vs Soft (simplified)

Configuration Layer mac80211 cfg80211 MAC Layer Hardware SoftMAC FullMAC nl80211 Network Layer

Linux OpenBSD

net80211 SoftMAC

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-7
SLIDE 7

Why? How? What now? Start Details Tricky bits

brcm80211

ISC-licensed brcm80211 drivers (Linux): brcmfmac brcmsmac FullMAC SoftMAC 35 496 LoC 75 177 LoC brcmsmac/phy/phy_n.c: 28 624 Lines Of Magic

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-8
SLIDE 8

Why? How? What now? Start Details Tricky bits

Jobs

What do we not have to do? No beacons No frequency changes No MCS handling What do we have to do? Initiate scan Configure SSID Configure keys Handle events Handle network packets

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-9
SLIDE 9

Why? How? What now? Start Details Tricky bits

Skeleton

bwfm(4) BCDC Msgbuf USB SDIO PCI

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-10
SLIDE 10

Why? How? What now? Start Details Tricky bits

Dongle

1 Started with SDIO

But realized testing kernels will take too long Unsure if SDIO layer actually worked

2 Bought a USB device 3 Started with the lower layers 4 Added PCIe/SDIO backend later Patrick Wildt Wireless Fidelity with bwfm(4)

slide-11
SLIDE 11

Why? How? What now? Start Details Tricky bits

Write code that compiles

1 Skeleton-driver 2 Initialize bus access 3 Try to figure out whether the device is alive

read chip id read MAC address receive an interrupt

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-12
SLIDE 12

Why? How? What now? Start Details Tricky bits

USB

Configuration Data Data+Events

Control Pipe Data Pipe Data Pipe

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-13
SLIDE 13

Why? How? What now? Start Details Tricky bits

Configuration

Initiate Scan:

struct bwfm_escan_params *params; [...] bwfm_fwvar_var_set_data(sc , "escan", params , params_size );

Connect to SSID:

struct bwfm_ext_join_params *params; [...] bwfm_fwvar_var_set_data(sc , "join", params , sizeof (* params ));

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-14
SLIDE 14

Why? How? What now? Start Details Tricky bits

Connect to SSID

j

  • i

n 3 B S D ... SSID Len SSID join variable + params status flags len cmd Patrick Wildt Wireless Fidelity with bwfm(4)

slide-15
SLIDE 15

Why? How? What now? Start Details Tricky bits

BCDC Packets

Data Events

flags prio flags2 data

  • ffset

firmware signals Ethernet Destination Mac flags prio flags2 data

  • ffset

firmware signals Ethernet Destination Mac Ethernet Source Mac Ethertype Ethernet Source Mac Ethertype 0x886c Data Payload Event ... type status reason ... event-specific payload

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-16
SLIDE 16

Why? How? What now? Start Details Tricky bits

SDIO

Configuration

FIFO

Data Data Events Patrick Wildt Wireless Fidelity with bwfm(4)

slide-17
SLIDE 17

Why? How? What now? Start Details Tricky bits

SDIO Interrupt

Shared pin: DAT[1]/IRQ Sampled as IRQ during Interrupt Period Some host controllers have troubles Workaround: externally routed GPIO

1 2 3 4 5 6 7 8 Chip

INT

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-18
SLIDE 18

Why? How? What now? Start Details Tricky bits

PCIe

Packet-based Multiple Ringbuffers

TX Control Ring TX RX-Post Ring (Control, TX, RX) Complete Rings n Flowrings

1010101 1010101 1010101 1010101

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-19
SLIDE 19

Why? How? What now? Start Details Tricky bits

Package

Read/write access to backplane Write Firmware & NVRAM Turn on/off ARM core Read dmesg

RAM 2.4/5 GHz Radio 802.11 PHY DOT11MAC B U S ARM SDIO PCIE OTP

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-20
SLIDE 20

Why? How? What now? Start Details Tricky bits

dmesg

hndarm_armr addr : 0 x18002000 , cr4_idx : 000000.001 RTE (SDIO− MSG_BUF) 7 . 3 5 . 1 8 0 . 1 1 9 ( r594535 )

  • n BCM4350

r8 @ 3 7 . 4 / 2 4 0 . 8 / 2 4 0 . 8MHz 000000.001 a l l o c a t i n g a max

  • f

255 r x c p l i d b u f f e r s 000000.002 pciemsgbuf0 : Broadcom PCIE MSGBUF d r i v e r 000000.003 r e c l a i m s e c t i o n 0 : Returned 59036 b y t e s to the heap 000000.131 e n a b l e 1 : q0 frmcnt 0 , wrdcnt 0 , q1 frmcnt 0 , wrdcnt 000000.131 e n a b l e 1 : q0 frmcnt 0 , wrdcnt 0 , q1 frmcnt 0 , wrdcnt 000000.175 wl0 : Broadcom BCM4350 802.11 W i r e l e s s C o n t r o l l e r 7 . 3 5 . 1 8 0 . 1 1 9 ( r594535 ) 000000.175 TCAM: 256 used : 255 exceed : 0 000000.176 r e c l a i m s e c t i o n 1 : Returned 147512 b y t e s to the heap 000005.375 wl0 : wlc_enable_probe_req : s t a t e down , d e f e r r i n g s e t t i n g

  • f

h os t f l a g s 000005.413 wlc_bmac_switch_macfreq : 4350 need f i x f o r 37.4Mhz 000005.421 wl0 : wlc_enable_probe_req : s t a t e down , d e f e r r i n g s e t t i n g

  • f

h os t f l a g s 000005.421 e n a b l e 1 : q0 frmcnt 0 , wrdcnt 0 , q1 frmcnt 0 , wrdcnt Patrick Wildt Wireless Fidelity with bwfm(4)

slide-21
SLIDE 21

Why? How? What now? Start Details Tricky bits

Firmware Features

4356a2-roml/pcie-ag-msgbuf-splitrx-p2p-pno-aoe-pktfilter- keepalive-sr-mchan-pktctx-proptxstatus-ampduhostreorder-lpc- pwropt-txbf-wl11u-mfp-tdls-amsdutx-sarctrl-proxd-hs20sta-rcc- wepso-ndoe-linkstat-gscan-hchk-logtrace-roamexp-rmon Version: 7.35.101.6 (r702795) CRC: 4f3f65c5 Date: Sun 2017-06-04 16:51:38 PDT Ucode Ver: 963.316 FWID: 01-5e8eb735

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-22
SLIDE 22

Why? How? What now? Start Details Tricky bits

Tricky bits

Flow-control Asynchronous control messages Asynchronous creation of flowrings net80211 Integration

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-23
SLIDE 23

Why? How? What now? Issues Status Future

Firmware

Remote Control Message Injection (CVE-2016-0801): Updated firmware in November 2017 KRACK (October 2017): Updated firmware in June 2018 (based on linux-firmware.git)

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-24
SLIDE 24

Why? How? What now? Issues Status Future

KRACK

/* * The firmware supplicant can handle the WPA * handshake for us , but we honestly want to * do this ourselves , so disable the firmware * supplicant and let our stack handle it. */ bwfm_fwvar_var_set_int(sc , "sup_wpa", 0);

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-25
SLIDE 25

Why? How? What now? Issues Status Future

NVRAM

Purpose: Provides configuration for the specific package Sets up antenna configuration, max dB, etc. Needed on: PCIe (sometimes) SDIO (always) USB (not yet?) Provided by: Hardware designer (in their git repo) EFI BIOS (in an EFI variable)

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-26
SLIDE 26

Why? How? What now? Issues Status Future

Current Status

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-27
SLIDE 27

Why? How? What now? Issues Status Future

Current Status

Works as client Properly fast 802.11ac (Wi-Fi 5) Implemented on recent Macbooks Implemented on raspberry Pis Available as official raspberry Pi USB Dongle (while supplies last) Works as access point often enough

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-28
SLIDE 28

Why? How? What now? Issues Status Future

Future

Better AP support Multi-AP support Suspend/Resume Firmware Signals Support for more devices

Patrick Wildt Wireless Fidelity with bwfm(4)

slide-29
SLIDE 29

Why? How? What now? Issues Status Future

Questions?

Patrick Wildt Wireless Fidelity with bwfm(4)