Skip to content

portal: add WIFI_CREATE op (portal-bridged cfg80211 wiphy)#93

Open
lacraig2 wants to merge 2 commits into
mainfrom
add-wifi-portal
Open

portal: add WIFI_CREATE op (portal-bridged cfg80211 wiphy)#93
lacraig2 wants to merge 2 commits into
mainfrom
add-wifi-portal

Conversation

@lacraig2

Copy link
Copy Markdown
Contributor

What

Adds a new portal device type: a portal-bridged virtual cfg80211 wiphy, mirroring how MTD is done (portal_mtd.c).

On a host WIFI_CREATE portal op, handle_op_wifi_create registers a real cfg80211 wiphy + netdev (station mode, 2.4 GHz band). Its .scan op schedules work that calls a host-provided callback, then reports the returned BSSes via cfg80211_inform_bss / cfg80211_scan_done.

Why

Lets a rehosted target perceive a scriptable Wi-Fi RF environment (neighbor APs, SSID/channel/signal) during emulation — the Wi-Fi analog of a host-modeled control plane — where the real radio driver can't load. Needs no mac80211_hwsim and no kernel rebuild: it links against cfg80211, which is already =y in the donor kernels, and ships entirely in the driver + a host plugin.

Changes

  • portal_op_list.h: X(wifi_create, WIFI_CREATE) — the X-macro auto-declares the handler prototype and auto-wires the dispatch table, so this one line is the whole op wiring.
  • portal_wifi.c (new; Makefile auto-globs portal/*.c): the create handler, request struct (ifname/mac + scan callback ptr), a packed on-wire BSS entry format, a minimal netdev, and the delayed-work .scan bridge.

Testing

Built for mipsel/6.13 (MODPOST clean — cfg80211 symbols resolve; module is GPL). On a live rehost the host plugin creates the wiphy at boot, and iw dev <if> scan / iwinfo <if> scan return the host-modeled BSSes.

Follow-ups

.dump_survey (channel noise/utilization) and AP-mode .get_station/.dump_station (connected-client RSSI).

lacraig2 added 2 commits July 23, 2026 15:21
Register a real cfg80211 wiphy + netdev on a host WIFI_CREATE portal op,
mirroring portal_mtd.c's create-with-callbacks pattern. Its .scan op calls
back to a host plugin that reports a modeled set of BSSes, so a rehosted
target can perceive a scriptable Wi-Fi RF environment during emulation with
no mac80211_hwsim and no kernel rebuild (links against cfg80211, already =y).

- portal_op_list.h: X(wifi_create, WIFI_CREATE) (auto-declares + dispatches)
- portal_wifi.c: handle_op_wifi_create + delayed-work .scan bridge that packs
  host-provided BSS entries via cfg80211_inform_bss / cfg80211_scan_done
Extend the portal-bridged wiphy with three more nl80211 ops so a host plugin can
model the channel picture and connected-client link stats, not just scan results:

- .dump_survey  → per-channel noise floor + active/busy time (SURVEY_INFO_*).
- .dump_station → per-peer signal, inactive/connected time, rx/tx bytes64+packets.
- .get_station  → resolve a MAC by walking the idx-based station callback.

Wiring mirrors the existing scan callback: portal_wifi_create_req gains
cb_survey_ptr + cb_station_ptr (host trampolines), and a small per-device scratch
buffer (PW_OP_BUF_SZ) backs the one-entry-per-call .dump_* iteration. No new portal
op — reuses WIFI_CREATE. New on-wire structs portal_wifi_survey / portal_wifi_station
(packed) carry the entries; the driver's DWARF-derived ISF exposes them so the host
resolves the layouts by name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant