CDX: PLCR/KG miss fixup, per-CPU dist FQs, clean kldunload
- Miss action fixup: Ethernet/PPPoE tables → PLCR policer (rate-limits exception traffic), all other tables → KG scheme with CC_EN (re-enters CC tree). Replaces previous ENQ_FRAME-to-default-FQID approach. - Distribution FQRs now use per-CPU SW portal channels instead of pool channel, preventing TCP reordering on miss path. - BMan buffer refill: cdx_dist_fq_rx_callback now calls dtsec_rm_pool_rx_refill_bpid() and frees buffers via dtsec_rm_buf_free_external() (per-port UMA zone) instead of direct bman_put_buffer(). - Clean kldunload: cdx_destroy_port_fqs() retires all dist FQRs, qman_portal_quiesce() drains in-flight portal polls. FM_PORT_DeletePCD() called on all dtsec RX + OH ports before hash table deletion, preventing FMan PCD exceptions after unload.
This commit is contained in:
parent
2339ecc091
commit
1bc132cc48
69 changed files with 4808 additions and 215 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,6 +2,7 @@
|
|||
dist/*
|
||||
!dist/.keep
|
||||
_build/
|
||||
_vendor/
|
||||
|
||||
# Object files and libraries
|
||||
*.o
|
||||
|
|
|
|||
93
Makefile
93
Makefile
|
|
@ -22,6 +22,7 @@
|
|||
OPSDIR= ${.CURDIR}
|
||||
FASTPATH= ${OPSDIR}/fastpath
|
||||
DRIVERS= ${OPSDIR}/drivers
|
||||
VENDORDIR?= ${OPSDIR}/_vendor
|
||||
|
||||
# Cross-compilation settings (all ?= for easy override)
|
||||
SRCTOP?= /build
|
||||
|
|
@ -38,7 +39,8 @@ SETSDIR= /usr/local/opnsense/build/${OPS_SETTINGS}/aarch64/sets
|
|||
|
||||
# Common args for all kernel module builds
|
||||
# Host clang cross-compiles with explicit --target (bsd.kmod.mk does NOT add it)
|
||||
KMOD_ARGS= KERNBUILDDIR=${KERNBUILDDIR} \
|
||||
KMOD_ARGS= SYSDIR=${SRCDIR}/sys \
|
||||
KERNBUILDDIR=${KERNBUILDDIR} \
|
||||
MACHINE=arm64 MACHINE_ARCH=aarch64 \
|
||||
CC="cc --target=aarch64-unknown-freebsd14.3" LD=ld.lld
|
||||
|
||||
|
|
@ -85,6 +87,14 @@ KMOD_SFP= ${DRIVERS}/sfp-led
|
|||
KMOD_PCF= ${DRIVERS}/pcf2131
|
||||
KMOD_CAAM= ${DRIVERS}/caam
|
||||
KMOD_TMP= ${DRIVERS}/tmp431
|
||||
KMOD_MWIFI= ${DRIVERS}/mwifiex
|
||||
KMOD_DW= ${DRIVERS}/dpaa_wifi
|
||||
|
||||
# NXP vendor repositories (pinned commits for reproducible builds)
|
||||
MWIFIEX_REPO= https://github.com/nxp-imx/mwifiex.git
|
||||
MWIFIEX_COMMIT= 84ca65c9ff935d7f2999af100a82531c22c65234
|
||||
IMX_FW_REPO= https://github.com/nxp-imx/imx-firmware.git
|
||||
IMX_FW_COMMIT= 8c9b278016c97527b285f2fcbe53c2d428eb171d
|
||||
|
||||
build-cdx:
|
||||
${MAKE} -C ${KMOD_CDX} ${KMOD_ARGS}
|
||||
|
|
@ -119,9 +129,42 @@ build-caam:
|
|||
build-tmp431:
|
||||
${MAKE} -C ${KMOD_TMP} ${KMOD_ARGS}
|
||||
|
||||
fetch-vendor:
|
||||
@mkdir -p ${VENDORDIR}
|
||||
@if [ ! -d ${VENDORDIR}/mwifiex/.git ]; then \
|
||||
echo "==> Cloning nxp-imx/mwifiex"; \
|
||||
git clone --depth 1 ${MWIFIEX_REPO} ${VENDORDIR}/mwifiex; \
|
||||
cd ${VENDORDIR}/mwifiex && git fetch --depth 1 origin ${MWIFIEX_COMMIT} && git checkout ${MWIFIEX_COMMIT}; \
|
||||
fi
|
||||
@if [ ! -d ${VENDORDIR}/imx-firmware/.git ]; then \
|
||||
echo "==> Cloning nxp-imx/imx-firmware"; \
|
||||
git clone --depth 1 ${IMX_FW_REPO} ${VENDORDIR}/imx-firmware; \
|
||||
cd ${VENDORDIR}/imx-firmware && git fetch --depth 1 origin ${IMX_FW_COMMIT} && git checkout ${IMX_FW_COMMIT}; \
|
||||
fi
|
||||
|
||||
build-mwifiex: fetch-vendor
|
||||
${MAKE} -C ${KMOD_MWIFI} ${KMOD_ARGS} VENDORDIR=${VENDORDIR}
|
||||
|
||||
build-dpaa_wifi: fetch-vendor
|
||||
${MAKE} -C ${KMOD_DW} ${KMOD_ARGS} VENDORDIR=${VENDORDIR}
|
||||
|
||||
modules: build-cdx build-fci build-auto_bridge build-pf_notify \
|
||||
build-emc2302 build-ina2xx build-lp5812 build-sfpled build-pcf2131 \
|
||||
build-caam build-tmp431
|
||||
build-caam build-tmp431 build-mwifiex build-dpaa_wifi
|
||||
@mkdir -p ${DISTDIR}
|
||||
cp ${KMOD_CDX}/cdx.ko ${DISTDIR}/
|
||||
cp ${KMOD_FCI}/fci.ko ${DISTDIR}/
|
||||
cp ${KMOD_AB}/auto_bridge.ko ${DISTDIR}/
|
||||
cp ${KMOD_PN}/pf_notify.ko ${DISTDIR}/
|
||||
cp ${KMOD_EMC}/emc2302.ko ${DISTDIR}/
|
||||
cp ${KMOD_INA}/ina2xx.ko ${DISTDIR}/
|
||||
cp ${KMOD_LP}/lp5812.ko ${DISTDIR}/
|
||||
cp ${KMOD_SFP}/sfpled.ko ${DISTDIR}/
|
||||
cp ${KMOD_PCF}/pcf2131.ko ${DISTDIR}/
|
||||
cp ${KMOD_CAAM}/caam.ko ${DISTDIR}/
|
||||
cp ${KMOD_TMP}/tmp431.ko ${DISTDIR}/
|
||||
cp ${KMOD_MWIFI}/mwifiex.ko ${DISTDIR}/
|
||||
cp ${KMOD_DW}/dpaa_wifi.ko ${DISTDIR}/
|
||||
|
||||
# ============================================================
|
||||
# Userspace components (dependency order: fmlib -> fmc -> dpa_app)
|
||||
|
|
@ -154,6 +197,12 @@ fand:
|
|||
cd ${BUILDDIR}/fand && ${MAKE} -f ${DRIVERS}/fand/Makefile all
|
||||
|
||||
userspace: fmlib fmc dpa_app cmm cmmctl fand
|
||||
@mkdir -p ${DISTDIR}
|
||||
cp ${BUILDDIR}/fmc/fmc ${DISTDIR}/
|
||||
cp ${BUILDDIR}/dpa_app/dpa_app ${DISTDIR}/
|
||||
cp ${BUILDDIR}/cmm/cmm ${DISTDIR}/
|
||||
cp ${BUILDDIR}/cmmctl/cmmctl ${DISTDIR}/
|
||||
cp ${BUILDDIR}/fand/fand ${DISTDIR}/
|
||||
|
||||
# ============================================================
|
||||
# Collect outputs into dist/
|
||||
|
|
@ -172,6 +221,8 @@ dist: modules userspace
|
|||
cp ${KMOD_PCF}/pcf2131.ko ${DISTDIR}/
|
||||
cp ${KMOD_CAAM}/caam.ko ${DISTDIR}/
|
||||
cp ${KMOD_TMP}/tmp431.ko ${DISTDIR}/
|
||||
cp ${KMOD_MWIFI}/mwifiex.ko ${DISTDIR}/
|
||||
cp ${KMOD_DW}/dpaa_wifi.ko ${DISTDIR}/
|
||||
cp ${BUILDDIR}/fmc/fmc ${DISTDIR}/
|
||||
cp ${BUILDDIR}/dpa_app/dpa_app ${DISTDIR}/
|
||||
cp ${BUILDDIR}/cmm/cmm ${DISTDIR}/
|
||||
|
|
@ -202,6 +253,8 @@ package: clean dist
|
|||
install -m 644 ${DISTDIR}/pcf2131.ko ${PKG_STAGEDIR}/boot/modules/
|
||||
install -m 644 ${DISTDIR}/caam.ko ${PKG_STAGEDIR}/boot/modules/
|
||||
install -m 644 ${DISTDIR}/tmp431.ko ${PKG_STAGEDIR}/boot/modules/
|
||||
install -m 644 ${DISTDIR}/mwifiex.ko ${PKG_STAGEDIR}/boot/modules/
|
||||
install -m 644 ${DISTDIR}/dpaa_wifi.ko ${PKG_STAGEDIR}/boot/modules/
|
||||
# Userspace binaries
|
||||
install -m 755 ${DISTDIR}/cmm ${PKG_STAGEDIR}/usr/local/sbin/
|
||||
install -m 755 ${DISTDIR}/cmmctl ${PKG_STAGEDIR}/usr/local/sbin/
|
||||
|
|
@ -240,31 +293,19 @@ _NCPU!= sysctl -n hw.ncpu 2>/dev/null || echo 4
|
|||
image:
|
||||
@rm -rf ${DISTDIR}/*
|
||||
@touch ${DISTDIR}/.keep
|
||||
@# --- Early check: bail if opnsense-src has uncommitted changes ---
|
||||
@if [ -d "${SRCDIR}/.git" ]; then \
|
||||
if ! git -C ${SRCDIR} diff --quiet HEAD 2>/dev/null || \
|
||||
! git -C ${SRCDIR} diff --cached --quiet HEAD 2>/dev/null; then \
|
||||
echo "ERROR: ${SRCDIR} has uncommitted changes."; \
|
||||
echo "Commit or stash before running 'make image'."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi
|
||||
@echo "==> Step 1: Checking repositories"
|
||||
@test -d ${SRCDIR}/.git || git clone https://github.com/opnsense/src.git ${SRCDIR}
|
||||
@test -d ${SRCDIR}/.git || git clone https://github.com/we-are-mono/opnsense-src.git ${SRCDIR}
|
||||
@test -d ${BUILDTOOL}/.git || git clone https://github.com/maurice-w/opnsense-vm-images.git ${BUILDTOOL}
|
||||
@cp -n ${OPSDIR}/config/GATEWAY.conf ${BUILDTOOL}/device/ 2>/dev/null || true
|
||||
@echo "==> Step 2: Applying kernel patches"
|
||||
cd ${SRCDIR} && git checkout ${OPS_BRANCH} && \
|
||||
git reset --hard origin/${OPS_BRANCH} && \
|
||||
git am ${OPSDIR}/patches/*.patch
|
||||
@echo "==> Step 3: Building kernel (clean)"
|
||||
cd ${SRCDIR} && git checkout ${OPS_BRANCH} && git pull
|
||||
@echo "==> Step 2: Building kernel (clean)"
|
||||
sudo rm -f ${SETSDIR}/kernel-*-GATEWAY.txz
|
||||
sudo chflags -R noschg /usr/obj${SRCDIR}/arm64.aarch64 2>/dev/null || true
|
||||
sudo rm -rf /usr/obj${SRCDIR}/arm64.aarch64
|
||||
sudo ${MAKE} -C ${BUILDTOOL} kernel \
|
||||
DEVICE=GATEWAY SETTINGS=${OPS_SETTINGS} \
|
||||
TOOLSDIR=${BUILDTOOL} SRCDIR=${SRCDIR}
|
||||
@echo "==> Step 3a: Populating sysroot from base set"
|
||||
@echo "==> Step 2a: Populating sysroot from base set"
|
||||
@_base=$$(ls ${SETSDIR}/base-*-aarch64-GATEWAY.txz 2>/dev/null | head -1); \
|
||||
if [ -z "$$_base" ]; then \
|
||||
echo "ERROR: no base set found in ${SETSDIR}"; exit 1; \
|
||||
|
|
@ -276,7 +317,7 @@ image:
|
|||
--include='./usr/lib/*.so' \
|
||||
--include='./usr/lib/*.o' \
|
||||
--include='./lib/*.so*'
|
||||
@echo "==> Step 3b: Installing libxml2 into sysroot"
|
||||
@echo "==> Step 2b: Installing libxml2 into sysroot"
|
||||
@if [ ! -f ${SYSROOT}/usr/local/lib/libxml2.so ]; then \
|
||||
sudo rm -f /tmp/libxml2.pkg; \
|
||||
fetch -qo /tmp/libxml2.pkg '${LIBXML2_URL}'; \
|
||||
|
|
@ -293,17 +334,17 @@ image:
|
|||
else \
|
||||
echo " libxml2 already in sysroot"; \
|
||||
fi
|
||||
@echo "==> Step 4: Building modules and userspace"
|
||||
@echo "==> Step 3: Building modules and userspace"
|
||||
${MAKE} -C ${OPSDIR} -j${_NCPU} all
|
||||
@echo "==> Step 5: Building package"
|
||||
@echo "==> Step 4: Building package"
|
||||
${MAKE} -C ${OPSDIR} package
|
||||
@echo "==> Step 6: Assembling image"
|
||||
@echo "==> Step 5: Assembling image"
|
||||
sudo rm -f ${IMAGESDIR}/OPNsense-*-GATEWAY.img \
|
||||
${IMAGESDIR}/OPNsense-*-GATEWAY.img.gz
|
||||
sudo ${MAKE} -C ${BUILDTOOL} arm-5G \
|
||||
DEVICE=GATEWAY SETTINGS=${OPS_SETTINGS} \
|
||||
TOOLSDIR=${BUILDTOOL} SRCDIR=${SRCDIR}
|
||||
@echo "==> Step 7: Compressing and copying to dist/"
|
||||
@echo "==> Step 6: Compressing and copying to dist/"
|
||||
@mkdir -p ${DISTDIR}
|
||||
sudo gzip -k ${IMAGESDIR}/OPNsense-*-GATEWAY.img
|
||||
cp ${IMAGESDIR}/OPNsense-*-GATEWAY.img.gz ${DISTDIR}/
|
||||
|
|
@ -326,10 +367,12 @@ clean:
|
|||
${MAKE} -C ${KMOD_PCF} ${KMOD_ARGS} clean
|
||||
${MAKE} -C ${KMOD_CAAM} ${KMOD_ARGS} clean
|
||||
${MAKE} -C ${KMOD_TMP} ${KMOD_ARGS} clean
|
||||
${MAKE} -C ${KMOD_MWIFI} ${KMOD_ARGS} clean
|
||||
${MAKE} -C ${KMOD_DW} ${KMOD_ARGS} clean
|
||||
rm -rf ${BUILDDIR}
|
||||
|
||||
.PHONY: all modules userspace dist package image clean \
|
||||
.PHONY: all modules userspace dist package image clean fetch-vendor \
|
||||
build-cdx build-fci build-auto_bridge build-pf_notify \
|
||||
build-emc2302 build-ina2xx build-lp5812 build-sfpled build-pcf2131 \
|
||||
build-caam build-tmp431 \
|
||||
build-caam build-tmp431 build-mwifiex build-dpaa_wifi \
|
||||
fmlib fmc dpa_app cmm cmmctl fand
|
||||
|
|
|
|||
95
README.md
95
README.md
|
|
@ -3,7 +3,8 @@
|
|||
Out-of-tree kernel modules, userspace daemons, and build tooling for the Mono
|
||||
Gateway OPNsense image. Contains the DPAA1 fast-path stack (CDX flow offload,
|
||||
FCI, CMM connection manager, PF notifier, auto-bridge), board-support drivers
|
||||
(LP5812 LED, EMC2302 fan, INA2xx power, SFP LED, PCF2131 RTC, CAAM crypto),
|
||||
(LP5812 LED, EMC2302 fan, INA2xx power, SFP LED, PCF2131 RTC, TMP431 thermal,
|
||||
CAAM crypto), WiFi support (NXP 88W9098 PCIe driver + DPAA OH port bridge),
|
||||
FMan toolchain (fmlib, fmc, dpa_app), and helper scripts for kernel image
|
||||
creation and deployment.
|
||||
|
||||
|
|
@ -11,20 +12,17 @@ creation and deployment.
|
|||
|
||||
```
|
||||
opnsense-deps/
|
||||
├── patches/ # kernel source patches (git format-patch)
|
||||
│ ├── 0001-arm64-platform-support-for-NXP-LS1046A.patch
|
||||
│ ├── 0002-ncsw-port-DPAA1-NCSW-layer-to-ARM64.patch
|
||||
│ ├── 0003-dpaa-drivers-and-board-peripherals-for-LS1046A.patch
|
||||
│ ├── 0004-net-bridge-and-pf-hooks-for-hardware-flow-offload.patch
|
||||
│ ├── 0005-dts-add-Mono-Gateway-Development-Kit-device-tree.patch
|
||||
│ └── 0006-build-GATEWAY-kernel-config-and-DPAA-build-rules.patch
|
||||
├── drivers/ # out-of-tree kernel modules
|
||||
│ ├── caam/ # NXP CAAM crypto accelerator (JR + QI)
|
||||
│ ├── pcf2131/ # NXP PCF2131 RTC
|
||||
│ ├── dpaa_wifi/ # WiFi ↔ FMan OH port data plane bridge
|
||||
│ ├── emc2302/ # SMSC EMC2302 fan controller
|
||||
│ ├── fand/ # Fan control daemon (userspace)
|
||||
│ ├── ina2xx/ # TI INA2xx power monitor
|
||||
│ ├── lp5812/ # TI LP5812 LED controller
|
||||
│ └── sfp-led/ # SFP+ link status LED
|
||||
│ ├── mwifiex/ # NXP 88W9098 PCIe WiFi driver + firmware
|
||||
│ ├── pcf2131/ # NXP PCF2131 RTC
|
||||
│ ├── sfp-led/ # SFP+ link status LED
|
||||
│ └── tmp431/ # TI TMP431 thermal sensor
|
||||
├── fastpath/ # DPAA1 fast-path modules + userspace
|
||||
│ ├── cdx/ # CDX flow offload kernel module
|
||||
│ ├── fci/ # Fast-path Control Interface module
|
||||
|
|
@ -36,8 +34,10 @@ opnsense-deps/
|
|||
│ ├── cmm/ # Connection Manager daemon
|
||||
│ └── cmmctl/ # CMM control utility
|
||||
├── config/ # FMC/CDX XML configuration files
|
||||
├── patches/ # historical kernel patches (reference only)
|
||||
├── rc.d/ # rc.d service scripts and syshook scripts
|
||||
├── pkg/ # FreeBSD package metadata
|
||||
├── _vendor/ # NXP vendor repos (cloned at build time, gitignored)
|
||||
└── Makefile # top-level build (modules + userspace + package)
|
||||
```
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ Both the local and NFS paths need the following repositories in `/build`:
|
|||
```
|
||||
cd /build
|
||||
git clone https://github.com/maurice-w/opnsense-vm-images.git opnsense-build
|
||||
git clone https://github.com/opnsense/src.git opnsense-src
|
||||
git clone https://github.com/we-are-mono/opnsense-src.git opnsense-src
|
||||
git clone https://github.com/we-are-mono/opnsense-deps
|
||||
|
||||
# Copy the GATEWAY device config into the build system
|
||||
|
|
@ -147,18 +147,7 @@ set exists in the sets directory, remove it before building the image. The xtool
|
|||
mechanism (`setup_xtools`/`setup_xbase`) is broken for cross-builds and will leave amd64 binaries
|
||||
in the image.
|
||||
|
||||
### 4. Apply kernel patches
|
||||
|
||||
The kernel source is patched from upstream OPNsense (`stable/26.1`) via a series
|
||||
of format-patch files in `patches/`. Apply them before building:
|
||||
|
||||
```
|
||||
cd /build/opnsense-src
|
||||
git checkout stable/26.1
|
||||
git am /build/opnsense-deps/patches/*.patch
|
||||
```
|
||||
|
||||
### 5. Build kernel
|
||||
### 4. Build kernel
|
||||
|
||||
```
|
||||
sudo make -C /build/opnsense-build kernel DEVICE=GATEWAY SETTINGS=26.1 TOOLSDIR=/build/opnsense-build SRCDIR=/build/opnsense-src
|
||||
|
|
@ -179,7 +168,7 @@ sudo rm -f /usr/local/opnsense/build/26.1/aarch64/sets/kernel-*-GATEWAY.txz
|
|||
sudo rm -rf /usr/obj/build/opnsense-src/arm64.aarch64/sys/GATEWAY
|
||||
```
|
||||
|
||||
### 6. Install libxml2 into cross-compilation sysroot
|
||||
### 5. Install libxml2 into cross-compilation sysroot
|
||||
|
||||
Required by opnsense-deps (fmc links against libxml2). Fetch the aarch64 package
|
||||
from the FreeBSD pkg mirror and extract its headers and libraries into the
|
||||
|
|
@ -204,13 +193,17 @@ If the package version has changed, override it in the Makefile:
|
|||
make -C /build/opnsense-deps image LIBXML2_PKG=libxml2-2.16.0.pkg
|
||||
```
|
||||
|
||||
### 7. Build custom modules and tools (everything in this repo)
|
||||
### 6. Build custom modules and tools (everything in this repo)
|
||||
|
||||
```
|
||||
make -C /build/opnsense-deps -j24 all
|
||||
```
|
||||
|
||||
### 8. Assemble eMMC image
|
||||
The first build automatically clones NXP vendor repositories (mwifiex driver
|
||||
source and imx-firmware) into `_vendor/` at pinned commits. Subsequent builds
|
||||
reuse the cached clones. To force a fresh clone, remove `_vendor/` and rebuild.
|
||||
|
||||
### 7. Assemble eMMC image
|
||||
|
||||
```
|
||||
sudo make -C /build/opnsense-build arm-5G DEVICE=GATEWAY SETTINGS=26.1 TOOLSDIR=/build/opnsense-build SRCDIR=/build/opnsense-src
|
||||
|
|
@ -226,50 +219,40 @@ sudo gzip /usr/local/opnsense/build/26.1/aarch64/images/OPNsense-*-GATEWAY.img
|
|||
|
||||
## Development workflow
|
||||
|
||||
### Kernel patches
|
||||
### Kernel source
|
||||
|
||||
The kernel source (`opnsense-src`) is maintained on the `mono-gateway` branch,
|
||||
based on `stable/26.1`. Changes are organized into 6 logical patches:
|
||||
|
||||
| # | Patch | Scope |
|
||||
|---|-------|-------|
|
||||
| 1 | arm64: platform support | pio.h, machdep.c, systm.h, random.h |
|
||||
| 2 | ncsw: DPAA1 NCSW ARM64 | NCSW vendor code ARM64 porting |
|
||||
| 3 | dpaa: drivers + peripherals | BMan/QMan/FMan, dtsec, GPY PHY, INA2xx, GPIO |
|
||||
| 4 | net: bridge + pf hooks | if_bridge.c, pf.c for hardware offload |
|
||||
| 5 | dts: board device tree | mono-gateway-dk.dts |
|
||||
| 6 | build: GATEWAY config | kernel config, DPAA build rules |
|
||||
|
||||
Applying the patches with `git am` creates real commits with full history — the
|
||||
patches *are* the commit history. This means the `--fixup`/`--autosquash`
|
||||
workflow works identically whether you originally authored the patches or applied
|
||||
them fresh from the repository.
|
||||
The kernel source (`opnsense-src`) is a fork of OPNsense/FreeBSD at
|
||||
[we-are-mono/opnsense-src](https://github.com/we-are-mono/opnsense-src),
|
||||
branched from `stable/26.1`. All Mono Gateway changes live as commits on this
|
||||
branch.
|
||||
|
||||
**Making a change:**
|
||||
|
||||
```bash
|
||||
cd /build/opnsense-src
|
||||
|
||||
# See the 6 commits created by git am
|
||||
git log --oneline stable/26.1..mono-gateway
|
||||
# See Mono Gateway commits on top of upstream
|
||||
git log --oneline origin/stable/26.1..HEAD
|
||||
|
||||
# 1. Edit the file
|
||||
vim sys/contrib/device-tree/src/arm64/freescale/mono-gateway-dk.dts
|
||||
|
||||
# 2. Stage and create a fixup commit targeting the right patch
|
||||
# 2. Stage and commit
|
||||
git add sys/contrib/device-tree/src/arm64/freescale/mono-gateway-dk.dts
|
||||
git commit --fixup <hash-of-patch-5>
|
||||
git commit -m "dts: add PCIe WiFi reset GPIO"
|
||||
|
||||
# 3. Autosquash into the correct patch
|
||||
git rebase --autosquash stable/26.1
|
||||
|
||||
# 4. Regenerate all patches
|
||||
rm /build/opnsense-deps/patches/*.patch
|
||||
git format-patch -o /build/opnsense-deps/patches/ stable/26.1..mono-gateway
|
||||
# 3. Push
|
||||
git push
|
||||
```
|
||||
|
||||
For a change that doesn't fit an existing patch, just add a new commit at the
|
||||
end of `mono-gateway` — it becomes patch 7.
|
||||
To rebase on a newer upstream OPNsense release:
|
||||
|
||||
```bash
|
||||
git remote add upstream https://github.com/opnsense/src.git
|
||||
git fetch upstream
|
||||
git rebase upstream/stable/26.7 # or whatever the new branch is
|
||||
git push --force-with-lease
|
||||
```
|
||||
|
||||
### Out-of-tree modules
|
||||
|
||||
|
|
@ -365,4 +348,4 @@ After `saveenv` and `reset`, the board will automatically boot into OPNsense on
|
|||
every subsequent power-on.
|
||||
|
||||
> ## Disclaimer
|
||||
> Many of the files in this repository, including the kernel patches, were ported from Linux sources provided by NXP (originally targeting Linux kernel 5.4). Due to the sheer scope of the porting effort, Claude Opus 4.6 was used to assist with the adaptation of this code to FreeBSD. As such, this project should be considered **highly experimental** and is **not fit for production use** until thorough reviews and testing have been performed by the wider community.
|
||||
> Many of the files in this repository, and in the [kernel fork](https://github.com/we-are-mono/opnsense-src), were ported from Linux sources provided by NXP (originally targeting Linux kernel 5.4). Due to the sheer scope of the porting effort, Claude Opus 4.6 was used to assist with the adaptation of this code to FreeBSD. As such, this project should be considered **highly experimental** and is **not fit for production use** until thorough reviews and testing have been performed by the wider community.
|
||||
|
|
|
|||
57
WIFI-OFFLOAD-AUDIT.md
Normal file
57
WIFI-OFFLOAD-AUDIT.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# WiFi Offload Audit — CDX devman gaps vs Linux vendor code
|
||||
|
||||
## Context
|
||||
|
||||
The FreeBSD `cdx_devman_freebsd.c` was written from scratch for Ethernet
|
||||
offload. WiFi (`IF_TYPE_WLAN`) support is being added incrementally as
|
||||
errors surface. The Linux vendor code (`vendor/cdx/dpa_wifi.c`, ~3000 lines)
|
||||
has a complete WiFi TX/RX path. We need to audit all devman functions that
|
||||
walk interface hierarchies or resolve interface properties, and ensure they
|
||||
handle `IF_TYPE_WLAN` correctly.
|
||||
|
||||
## What was already fixed
|
||||
|
||||
1. **`dpa_get_fm_port_index()`** — added `IF_TYPE_WLAN` check to return
|
||||
`wlan_info.fman_idx/port_idx/portid` instead of walking to eth parent.
|
||||
|
||||
2. **`dpa_get_tx_info_by_itf()`** — added `IF_TYPE_WLAN` case in the
|
||||
interface hierarchy walk to get TX FQID from OH port and MAC from
|
||||
`wlan_info.mac_addr`.
|
||||
|
||||
3. **`cdx_ioc_set_dpa_params()`** — added OH port registration loop
|
||||
(step 7d) that was present in Linux `dpa_cfg.c` but missing from
|
||||
the FreeBSD port.
|
||||
|
||||
## Prompt for Claude
|
||||
|
||||
Audit ALL functions in `cdx_devman_freebsd.c` that use `devman_find_eth_parent()`,
|
||||
`IF_TYPE_ETHERNET`, or walk interface hierarchies (VLAN→PPPoE→Ethernet chains).
|
||||
For each one, determine if it needs `IF_TYPE_WLAN` handling.
|
||||
|
||||
Cross-reference with the Linux vendor code:
|
||||
- `vendor/cdx/dpa_wifi.c` — full WiFi TX/RX/VAP management
|
||||
- `vendor/cdx/dpa_wifi.h` — WiFi data structures and FD helpers
|
||||
- `vendor/cdx/devman.c` — Linux devman (compare interface walking)
|
||||
- `vendor/cdx/devoh.c` — Linux OH port management
|
||||
|
||||
Specifically check these functions in `cdx_devman_freebsd.c`:
|
||||
- `dpa_get_tx_l2info_by_itf()` — uses `devman_find_eth_parent()` for L2 bridge flows
|
||||
- `add_incoming_iface_info()` — resolves ingress interface info for hash insertion
|
||||
- `dpa_get_phys_iface()` — returns physical parent interface
|
||||
- Any function that reads `eth_info.*` fields
|
||||
|
||||
Also check `cdx_ehash.c` for WiFi-specific paths:
|
||||
- `fill_actions()` — builds opcode chain for header modification
|
||||
- `insert_entry_in_classif_table()` — already fixed fmindex, but check
|
||||
other assumptions (e.g., L2 header construction, ethertype handling)
|
||||
- `fill_sobject()` / `fill_dobject()` — source/dest object fill
|
||||
|
||||
And check `cdx_devoh_freebsd.c`:
|
||||
- `cdxdrv_create_of_fqs()` — creates QMan FQs for OH ports
|
||||
- Does it create distribution FQs that WiFi needs?
|
||||
|
||||
The goal is to find ALL remaining `IF_TYPE_WLAN` gaps before they surface
|
||||
as runtime errors, rather than fixing them one-by-one.
|
||||
|
||||
Do NOT write code — just research and report findings. List each function,
|
||||
whether it needs a fix, and what the fix would be.
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= caam
|
||||
SRCS= caam.c caam_jr.c caam_crypto.c caam_alg.c caam_hash.c caam_rng.c
|
||||
|
|
|
|||
36
drivers/dpaa_wifi/Makefile
Normal file
36
drivers/dpaa_wifi/Makefile
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# dpaa_wifi — WiFi ↔ FMan OH port data plane bridge
|
||||
#
|
||||
# Bridges mwifiex PCIe WiFi with DPAA1 FMan OH port for CDX offload.
|
||||
#
|
||||
# Build:
|
||||
# make -C /build/opnsense-deps/drivers/dpaa_wifi \
|
||||
# KERNBUILDDIR=/usr/obj/build/opnsense-src/arm64.aarch64/sys/GATEWAY \
|
||||
# MACHINE=arm64 MACHINE_ARCH=aarch64 CC=cc LD=ld.lld
|
||||
#
|
||||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
|
||||
KMOD= dpaa_wifi
|
||||
SRCS= dpaa_wifi.c
|
||||
SRCS+= opt_platform.h device_if.h bus_if.h ofw_bus_if.h
|
||||
|
||||
# mwifiex driver headers + mlan for moal_freebsd.h → mlan_decl.h
|
||||
VENDORDIR?= ${.CURDIR}/../../_vendor
|
||||
MLANDIR= ${VENDORDIR}/mwifiex/mlan
|
||||
CFLAGS+= -I${.CURDIR}/../mwifiex -I${MLANDIR}
|
||||
CFLAGS+= -DPCIE -DSTA_SUPPORT -DUAP_SUPPORT -DMLAN_64BIT -DPCIE9098
|
||||
|
||||
# NCSW headers + required defines
|
||||
CFLAGS+= -DNCSW_FREEBSD -DNCSW_ARM_CORE -DENDIAN_LITTLE
|
||||
CFLAGS+= -DCORE_CACHELINE_SIZE=64
|
||||
CFLAGS+= -DDEBUG_ERRORS=1 -DREPORT_EVENTS=1
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/inc
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/inc/etc
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/inc/flib
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/inc/cores
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/inc/Peripherals
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/inc/integrations
|
||||
CFLAGS+= -I${SYSDIR}/contrib/ncsw/Peripherals/FM/inc
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
761
drivers/dpaa_wifi/dpaa_wifi.c
Normal file
761
drivers/dpaa_wifi/dpaa_wifi.c
Normal file
|
|
@ -0,0 +1,761 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
*
|
||||
* dpaa_wifi — WiFi ↔ FMan OH port data plane bridge.
|
||||
*
|
||||
* Bridges mwifiex PCIe WiFi driver with DPAA1 FMan Offline/Header
|
||||
* Manipulation port so CDX can hardware-offload WiFi traffic.
|
||||
*
|
||||
* Two data paths:
|
||||
*
|
||||
* CDX→WiFi (download): CDX enqueues to OH port FQID → PCD miss →
|
||||
* default FQ callback → mbuf → if_transmit(uapN) → mwifiex → air.
|
||||
*
|
||||
* WiFi→CDX (upload): mwifiex RX → dpaa_wifi_inject() → BMan buffer →
|
||||
* OH port → PCD hit → CDX offload → dtsec TX → wire.
|
||||
* PCD miss → default FQ → if_input(uapN) → stack.
|
||||
*
|
||||
* Supports multiple VAPs (uap0, uap1, wlan0, etc.) via IFNET event-driven
|
||||
* lifecycle. VAP interfaces are automatically hooked on arrival and
|
||||
* unhooked on departure.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <contrib/ncsw/inc/Peripherals/dpaa_ext.h>
|
||||
#include <contrib/ncsw/inc/Peripherals/qm_ext.h>
|
||||
#include <contrib/ncsw/inc/Peripherals/fm_ext.h>
|
||||
#include <contrib/ncsw/inc/Peripherals/fm_port_ext.h>
|
||||
#include <contrib/ncsw/inc/ncsw_ext.h>
|
||||
|
||||
#include <dev/dpaa/dpaa_oh.h>
|
||||
#include <dev/dpaa/if_dtsec.h>
|
||||
#include <dev/dpaa/bman.h>
|
||||
#include <dev/dpaa/qman.h>
|
||||
|
||||
#include "moal_freebsd.h"
|
||||
#include "dpaa_wifi.h"
|
||||
|
||||
/* WiFi OH port: cell-index 4 in DTS (dpa-fman0-oh@3, portid 9) */
|
||||
#define WIFI_OH_CELL_INDEX 4
|
||||
|
||||
/* BMan pool for WiFi injection (WiFi→OH) */
|
||||
#define WIFI_POOL_SIZE 512
|
||||
#define WIFI_POOL_REFILL_THRESH 128
|
||||
#define WIFI_POOL_REFILL_COUNT 64
|
||||
#define WIFI_BUF_SIZE (9600 + 64) /* matches FM_PORT_BUFFER_SIZE */
|
||||
|
||||
/* Multi-VAP support: 88W9098 creates up to 2 BSS; 4 gives headroom */
|
||||
#define DPAA_WIFI_MAX_VAPS 4
|
||||
|
||||
/*
|
||||
* privData layout in WiFi injection buffers (16 bytes total):
|
||||
* [0..7] KVA stash (uintptr_t) — for UMA free after BMan/FMan round-trip
|
||||
* [8] VAP index (uint8_t) — for miss-path RX callback to identify VAP
|
||||
* [9..15] reserved
|
||||
*/
|
||||
#define PRIVDATA_KVA_OFF 0
|
||||
#define PRIVDATA_VAP_OFF sizeof(uintptr_t)
|
||||
|
||||
struct dpaa_wifi_vap {
|
||||
if_t ifp;
|
||||
uint8_t mac[ETHER_ADDR_LEN];
|
||||
uint8_t active;
|
||||
volatile uint64_t inject_count;
|
||||
volatile uint64_t rx_to_stack;
|
||||
volatile uint64_t rx_to_mwifiex;
|
||||
};
|
||||
|
||||
static device_t wifi_oh_dev;
|
||||
static uint32_t wifi_data_offset; /* buffer prefix size */
|
||||
static uint8_t wifi_bpid; /* our BMan pool ID */
|
||||
static t_Handle wifi_pool; /* BMan pool handle */
|
||||
static uma_zone_t wifi_zone; /* UMA zone for pool buffers */
|
||||
static volatile uint32_t wifi_buf_total; /* in-flight buffer count */
|
||||
|
||||
/* VAP table */
|
||||
static struct dpaa_wifi_vap wifi_vaps[DPAA_WIFI_MAX_VAPS];
|
||||
static volatile int wifi_nvaps;
|
||||
static struct mtx wifi_vap_mtx;
|
||||
|
||||
/* IFNET event handlers */
|
||||
static eventhandler_tag wifi_arrival_tag;
|
||||
static eventhandler_tag wifi_departure_tag;
|
||||
|
||||
/* Module-wide statistics */
|
||||
static volatile uint64_t wifi_inject_nobuf;
|
||||
static volatile uint64_t wifi_rx_drop;
|
||||
|
||||
/* Forward declarations */
|
||||
static int dpaa_wifi_inject(if_t ifp, struct mbuf *m);
|
||||
|
||||
/*
|
||||
* Return true if the interface name is a WiFi VAP we should hook.
|
||||
*/
|
||||
static bool
|
||||
dpaa_wifi_is_wifi_ifname(const char *name)
|
||||
{
|
||||
|
||||
return (strncmp(name, "uap", 3) == 0 ||
|
||||
strncmp(name, "wlan", 4) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a VAP table index by interface pointer.
|
||||
* Returns -1 if not found. Lock not required (read-only scan).
|
||||
*/
|
||||
static int
|
||||
dpaa_wifi_find_vap_idx(if_t ifp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active && wifi_vaps[i].ifp == ifp)
|
||||
return (i);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find target VAP for CDX→WiFi (download) frames.
|
||||
*
|
||||
* The Ethernet destination MAC is a WiFi client MAC, not the AP MAC.
|
||||
* Try to match against VAP MACs (handles AP-destined frames: ARP,
|
||||
* management). Fall back to first active VAP for client-destined
|
||||
* unicast — with one radio, all clients are on the same UAP.
|
||||
*/
|
||||
static struct dpaa_wifi_vap *
|
||||
dpaa_wifi_find_vap_for_rx(const void *frame_data)
|
||||
{
|
||||
const struct ether_header *eh;
|
||||
int i;
|
||||
|
||||
eh = (const struct ether_header *)frame_data;
|
||||
|
||||
/* Try exact MAC match (AP-addressed frames) */
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active &&
|
||||
memcmp(wifi_vaps[i].mac, eh->ether_dhost,
|
||||
ETHER_ADDR_LEN) == 0)
|
||||
return (&wifi_vaps[i]);
|
||||
}
|
||||
|
||||
/* Fallback: first active VAP (client-destined unicast) */
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active)
|
||||
return (&wifi_vaps[i]);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hook a WiFi VAP — set the RX bridge function pointer.
|
||||
* Caller must hold wifi_vap_mtx.
|
||||
*/
|
||||
static int
|
||||
dpaa_wifi_add_vap(if_t ifp)
|
||||
{
|
||||
struct mwifiex_priv *priv;
|
||||
int i, slot;
|
||||
|
||||
/* Already hooked? */
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active && wifi_vaps[i].ifp == ifp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Find a free slot */
|
||||
slot = -1;
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (!wifi_vaps[i].active) {
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slot < 0) {
|
||||
printf("dpaa_wifi: VAP table full (%d max)\n",
|
||||
DPAA_WIFI_MAX_VAPS);
|
||||
return (ENOSPC);
|
||||
}
|
||||
|
||||
priv = if_getsoftc(ifp);
|
||||
if (priv == NULL) {
|
||||
printf("dpaa_wifi: %s has no softc\n", if_name(ifp));
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
memcpy(wifi_vaps[slot].mac, priv->mac_addr, ETHER_ADDR_LEN);
|
||||
wifi_vaps[slot].inject_count = 0;
|
||||
wifi_vaps[slot].rx_to_stack = 0;
|
||||
wifi_vaps[slot].rx_to_mwifiex = 0;
|
||||
wifi_vaps[slot].ifp = ifp;
|
||||
|
||||
/* Publish the hook — must be last (readers are lock-free) */
|
||||
atomic_thread_fence_rel();
|
||||
wifi_vaps[slot].active = 1;
|
||||
atomic_add_int(&wifi_nvaps, 1);
|
||||
|
||||
priv->wifi_bridge_fn = dpaa_wifi_inject;
|
||||
|
||||
printf("dpaa_wifi: hooked %s (slot %d, mac %02x:%02x:%02x:%02x:%02x:%02x)\n",
|
||||
if_name(ifp), slot,
|
||||
wifi_vaps[slot].mac[0], wifi_vaps[slot].mac[1],
|
||||
wifi_vaps[slot].mac[2], wifi_vaps[slot].mac[3],
|
||||
wifi_vaps[slot].mac[4], wifi_vaps[slot].mac[5]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unhook a WiFi VAP — clear the RX bridge function pointer.
|
||||
* Caller must hold wifi_vap_mtx.
|
||||
*/
|
||||
static void
|
||||
dpaa_wifi_remove_vap(if_t ifp)
|
||||
{
|
||||
struct mwifiex_priv *priv;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active && wifi_vaps[i].ifp == ifp) {
|
||||
priv = if_getsoftc(ifp);
|
||||
if (priv != NULL)
|
||||
priv->wifi_bridge_fn = NULL;
|
||||
|
||||
printf("dpaa_wifi: unhooked %s (slot %d, "
|
||||
"inject=%ju rx_stack=%ju rx_wifi=%ju)\n",
|
||||
if_name(ifp), i,
|
||||
(uintmax_t)wifi_vaps[i].inject_count,
|
||||
(uintmax_t)wifi_vaps[i].rx_to_stack,
|
||||
(uintmax_t)wifi_vaps[i].rx_to_mwifiex);
|
||||
|
||||
wifi_vaps[i].active = 0;
|
||||
atomic_thread_fence_rel();
|
||||
wifi_vaps[i].ifp = NULL;
|
||||
atomic_subtract_int(&wifi_nvaps, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IFNET arrival event — auto-hook WiFi VAPs as they appear.
|
||||
*/
|
||||
static void
|
||||
dpaa_wifi_ifnet_arrival(void *arg __unused, if_t ifp)
|
||||
{
|
||||
|
||||
if (!dpaa_wifi_is_wifi_ifname(if_name(ifp)))
|
||||
return;
|
||||
|
||||
mtx_lock(&wifi_vap_mtx);
|
||||
dpaa_wifi_add_vap(ifp);
|
||||
mtx_unlock(&wifi_vap_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* IFNET departure event — auto-unhook WiFi VAPs as they disappear.
|
||||
*/
|
||||
static void
|
||||
dpaa_wifi_ifnet_departure(void *arg __unused, if_t ifp)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Quick check without lock */
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active && wifi_vaps[i].ifp == ifp)
|
||||
break;
|
||||
}
|
||||
if (i == DPAA_WIFI_MAX_VAPS)
|
||||
return;
|
||||
|
||||
mtx_lock(&wifi_vap_mtx);
|
||||
dpaa_wifi_remove_vap(ifp);
|
||||
mtx_unlock(&wifi_vap_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan for already-existing WiFi interfaces at module load time.
|
||||
* Handles the case where mwifiex loaded before dpaa_wifi.
|
||||
*/
|
||||
static void
|
||||
dpaa_wifi_scan_existing(void)
|
||||
{
|
||||
static const char *names[] = {
|
||||
"uap0", "uap1", "wlan0", "wlan1"
|
||||
};
|
||||
if_t ifp;
|
||||
int i;
|
||||
|
||||
mtx_lock(&wifi_vap_mtx);
|
||||
for (i = 0; i < (int)nitems(names); i++) {
|
||||
ifp = ifunit(names[i]);
|
||||
if (ifp != NULL)
|
||||
dpaa_wifi_add_vap(ifp);
|
||||
}
|
||||
mtx_unlock(&wifi_vap_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* BMan pool callbacks for WiFi injection buffers.
|
||||
*/
|
||||
static uint8_t *
|
||||
wifi_pool_get_buffer(t_Handle h_pool, t_Handle *context)
|
||||
{
|
||||
uint8_t *buf;
|
||||
|
||||
buf = uma_zalloc(wifi_zone, M_NOWAIT);
|
||||
if (buf != NULL)
|
||||
*(uintptr_t *)(buf + PRIVDATA_KVA_OFF) = (uintptr_t)buf;
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static t_Error
|
||||
wifi_pool_put_buffer(t_Handle h_pool, uint8_t *buffer, t_Handle context)
|
||||
{
|
||||
|
||||
uma_zfree(wifi_zone,
|
||||
(void *)(*(uintptr_t *)(buffer + PRIVDATA_KVA_OFF)));
|
||||
return (E_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* ext_free for mbufs backed by WiFi pool buffers (WiFi→CDX miss path).
|
||||
* The frame was injected by us, PCD didn't match, came back on default FQ.
|
||||
*/
|
||||
static void
|
||||
dpaa_wifi_ext_free_wifi(struct mbuf *m)
|
||||
{
|
||||
void *buf;
|
||||
|
||||
buf = m->m_ext.ext_arg1;
|
||||
uma_zfree(wifi_zone,
|
||||
(void *)(*(uintptr_t *)((char *)buf + PRIVDATA_KVA_OFF)));
|
||||
atomic_subtract_32(&wifi_buf_total, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* ext_free for mbufs backed by dtsec pool buffers (CDX→WiFi path).
|
||||
* The frame came from a dtsec RX BMan pool via CDX offload.
|
||||
*/
|
||||
static void
|
||||
dpaa_wifi_ext_free_dtsec(struct mbuf *m)
|
||||
{
|
||||
void *buf;
|
||||
uint8_t bpid;
|
||||
|
||||
buf = m->m_ext.ext_arg1;
|
||||
bpid = (uint8_t)(uintptr_t)m->m_ext.ext_arg2;
|
||||
dtsec_rm_buf_free_external(bpid, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Refill WiFi BMan pool if running low.
|
||||
*/
|
||||
static void
|
||||
wifi_pool_refill(void)
|
||||
{
|
||||
uint8_t *buf;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < WIFI_POOL_REFILL_COUNT; i++) {
|
||||
buf = uma_zalloc(wifi_zone, M_NOWAIT);
|
||||
if (buf == NULL)
|
||||
break;
|
||||
*(uintptr_t *)(buf + PRIVDATA_KVA_OFF) = (uintptr_t)buf;
|
||||
if (bman_put_buffer(wifi_pool, buf) != 0) {
|
||||
uma_zfree(wifi_zone, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
atomic_add_32(&wifi_buf_total, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Deliver a WiFi injection buffer to the stack.
|
||||
*
|
||||
* Shared helper for the OH default FQ callback (PCD miss) and the
|
||||
* CDX distribution FQ callback (PCD hit dispatched by BPID).
|
||||
* Both cases have a WiFi pool buffer with VAP index in privData.
|
||||
*
|
||||
* Runs inside QM_PORTAL_Poll with NCSW_PLOCK held — delivers via
|
||||
* qman_rx_defer for deferred if_input after lock release.
|
||||
*/
|
||||
static e_RxStoreResponse
|
||||
dpaa_wifi_deliver_to_stack(void *buf, t_DpaaFD *frame)
|
||||
{
|
||||
struct mbuf *m;
|
||||
struct dpaa_wifi_vap *vap;
|
||||
uint8_t vap_idx;
|
||||
|
||||
vap_idx = *(uint8_t *)((char *)buf + PRIVDATA_VAP_OFF);
|
||||
if (__predict_false(vap_idx >= DPAA_WIFI_MAX_VAPS ||
|
||||
!wifi_vaps[vap_idx].active)) {
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
bman_put_buffer(wifi_pool, buf);
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
vap = &wifi_vaps[vap_idx];
|
||||
|
||||
m = m_gethdr(M_NOWAIT, MT_DATA);
|
||||
if (__predict_false(m == NULL)) {
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
bman_put_buffer(wifi_pool, buf);
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
|
||||
m_extadd(m, buf, WIFI_BUF_SIZE,
|
||||
dpaa_wifi_ext_free_wifi, buf, NULL, 0, EXT_NET_DRV);
|
||||
m->m_pkthdr.rcvif = vap->ifp;
|
||||
m->m_data = (char *)buf + DPAA_FD_GET_OFFSET(frame);
|
||||
m->m_len = DPAA_FD_GET_LENGTH(frame);
|
||||
m->m_pkthdr.len = m->m_len;
|
||||
|
||||
if (__predict_false(bman_count(wifi_pool) < WIFI_POOL_REFILL_THRESH))
|
||||
wifi_pool_refill();
|
||||
|
||||
qman_rx_defer(m);
|
||||
atomic_add_64(&vap->rx_to_stack, 1);
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Distribution FQ callback — WiFi frames that matched PCD KeyGen.
|
||||
*
|
||||
* Registered via dpaa_oh_register_dist_cb() so CDX can dispatch
|
||||
* WiFi frames from distribution FQs instead of dropping them.
|
||||
* Same delivery logic as the default FQ's WiFi→stack path.
|
||||
*/
|
||||
static e_RxStoreResponse
|
||||
dpaa_wifi_dist_rx_cb(t_Handle app __unused, t_Handle qm_fqr,
|
||||
t_Handle qm_portal __unused, uint32_t fqid_offset,
|
||||
t_DpaaFD *frame)
|
||||
{
|
||||
void *buf;
|
||||
uint32_t fd_status;
|
||||
|
||||
buf = DPAA_FD_GET_ADDR(frame);
|
||||
if (__predict_false(buf == NULL))
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
|
||||
fd_status = DPAA_FD_GET_STATUS(frame);
|
||||
if (__predict_false((fd_status & 0x07FE0000) || wifi_nvaps == 0)) {
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
bman_put_buffer(wifi_pool, buf);
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
|
||||
return (dpaa_wifi_deliver_to_stack(buf, frame));
|
||||
}
|
||||
|
||||
/*
|
||||
* OH port default FQ callback — frames that PCD did not classify.
|
||||
*
|
||||
* Two cases, distinguished by BPID:
|
||||
* 1. BPID = wifi_bpid: WiFi→CDX miss (our injection, PCD no match).
|
||||
* Recover VAP index from privData, deliver to stack via if_input.
|
||||
* 2. BPID = other: CDX→WiFi (CDX offloaded frame for WiFi client).
|
||||
* Find target VAP by destination MAC, deliver via if_transmit.
|
||||
*
|
||||
* Runs inside QM_PORTAL_Poll with NCSW_PLOCK held — cannot call
|
||||
* if_input/if_transmit directly. Use qman_rx_defer with M_PROTO1
|
||||
* tag to distinguish TX-bound frames in the drain loop.
|
||||
*/
|
||||
static e_RxStoreResponse
|
||||
dpaa_wifi_rx_cb(t_Handle app, t_Handle fqr, t_Handle portal,
|
||||
uint32_t fqid_off, t_DpaaFD *frame)
|
||||
{
|
||||
void *buf;
|
||||
struct mbuf *m;
|
||||
struct dpaa_wifi_vap *vap;
|
||||
uint8_t bpid;
|
||||
uint32_t fd_status;
|
||||
|
||||
buf = DPAA_FD_GET_ADDR(frame);
|
||||
if (__predict_false(buf == NULL))
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
|
||||
bpid = frame->bpid;
|
||||
|
||||
/* Check for FMan errors */
|
||||
fd_status = DPAA_FD_GET_STATUS(frame);
|
||||
if (__predict_false(fd_status & 0x07FE0000)) { /* RX error mask */
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
if (__predict_false(wifi_nvaps == 0)) {
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
if (bpid == wifi_bpid) {
|
||||
/*
|
||||
* WiFi→CDX miss: frame from our injection that PCD
|
||||
* didn't match. Return to stack for normal processing.
|
||||
*/
|
||||
return (dpaa_wifi_deliver_to_stack(buf, frame));
|
||||
}
|
||||
|
||||
/*
|
||||
* CDX→WiFi: frame from CDX offload destined for a
|
||||
* WiFi client. Find the target VAP by destination
|
||||
* MAC match or first-active fallback, then deliver
|
||||
* to mwifiex via if_transmit.
|
||||
*
|
||||
* Tag with M_PROTO1 so the drain loop uses if_transmit
|
||||
* instead of if_input.
|
||||
*/
|
||||
m = m_gethdr(M_NOWAIT, MT_DATA);
|
||||
if (__predict_false(m == NULL)) {
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
vap = dpaa_wifi_find_vap_for_rx(
|
||||
(char *)buf + DPAA_FD_GET_OFFSET(frame));
|
||||
if (__predict_false(vap == NULL)) {
|
||||
m_free(m);
|
||||
atomic_add_64(&wifi_rx_drop, 1);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
m_extadd(m, buf, WIFI_BUF_SIZE,
|
||||
dpaa_wifi_ext_free_dtsec, buf,
|
||||
(void *)(uintptr_t)bpid, 0, EXT_NET_DRV);
|
||||
m->m_pkthdr.rcvif = vap->ifp;
|
||||
m->m_data = (char *)buf + DPAA_FD_GET_OFFSET(frame);
|
||||
m->m_len = DPAA_FD_GET_LENGTH(frame);
|
||||
m->m_pkthdr.len = m->m_len;
|
||||
m->m_flags |= M_PROTO1;
|
||||
|
||||
qman_rx_defer(m);
|
||||
atomic_add_64(&vap->rx_to_mwifiex, 1);
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
|
||||
drop:
|
||||
if (bpid == wifi_bpid)
|
||||
bman_put_buffer(wifi_pool, buf);
|
||||
else
|
||||
dtsec_rm_buf_free_external(bpid, buf);
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Inject a WiFi RX frame into the FMan OH port for PCD classification.
|
||||
*
|
||||
* Called from moal_recv_packet() instead of if_input() when the WiFi
|
||||
* bridge is active. Allocates a BMan buffer, copies frame data with
|
||||
* proper prefix headroom, builds an FD, and enqueues to the OH port.
|
||||
*
|
||||
* Returns 0 on success (mbuf consumed), ENOBUFS on pool exhaustion.
|
||||
*/
|
||||
static int
|
||||
dpaa_wifi_inject(if_t ifp, struct mbuf *m)
|
||||
{
|
||||
void *buf;
|
||||
t_DpaaFD fd;
|
||||
int vap_idx, error;
|
||||
|
||||
vap_idx = dpaa_wifi_find_vap_idx(ifp);
|
||||
if (__predict_false(vap_idx < 0)) {
|
||||
m_freem(m);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
buf = bman_get_buffer(wifi_pool);
|
||||
if (__predict_false(buf == NULL)) {
|
||||
/* Pool exhausted — try a quick refill */
|
||||
wifi_pool_refill();
|
||||
buf = bman_get_buffer(wifi_pool);
|
||||
if (buf == NULL) {
|
||||
atomic_add_64(&wifi_inject_nobuf, 1);
|
||||
m_freem(m);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
}
|
||||
|
||||
/* Stash KVA pointer and VAP index in privData */
|
||||
*(uintptr_t *)((char *)buf + PRIVDATA_KVA_OFF) = (uintptr_t)buf;
|
||||
*(uint8_t *)((char *)buf + PRIVDATA_VAP_OFF) = (uint8_t)vap_idx;
|
||||
|
||||
/* Copy frame data after the prefix area */
|
||||
m_copydata(m, 0, m->m_pkthdr.len,
|
||||
(char *)buf + wifi_data_offset);
|
||||
|
||||
/* Build contiguous Frame Descriptor */
|
||||
memset(&fd, 0, sizeof(fd));
|
||||
DPAA_FD_SET_ADDR(&fd, buf);
|
||||
DPAA_FD_SET_FORMAT(&fd, e_DPAA_FD_FORMAT_TYPE_SHORT_SBSF);
|
||||
DPAA_FD_SET_OFFSET(&fd, wifi_data_offset);
|
||||
DPAA_FD_SET_LENGTH(&fd, m->m_pkthdr.len);
|
||||
fd.bpid = wifi_bpid;
|
||||
|
||||
error = dpaa_oh_enqueue(wifi_oh_dev, &fd);
|
||||
if (__predict_false(error != 0)) {
|
||||
/* Enqueue failed — return buffer to pool */
|
||||
bman_put_buffer(wifi_pool, buf);
|
||||
m_freem(m);
|
||||
return (error);
|
||||
}
|
||||
|
||||
m_freem(m);
|
||||
atomic_add_64(&wifi_vaps[vap_idx].inject_count, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dpaa_wifi_load(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
/* Find WiFi OH port */
|
||||
wifi_oh_dev = dpaa_oh_find_port(WIFI_OH_CELL_INDEX);
|
||||
if (wifi_oh_dev == NULL) {
|
||||
printf("dpaa_wifi: OH port cell-index %d not found\n",
|
||||
WIFI_OH_CELL_INDEX);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
wifi_data_offset = dpaa_oh_get_data_offset(wifi_oh_dev);
|
||||
printf("dpaa_wifi: OH port found, data_offset=%u, dflt_fqid=%u\n",
|
||||
wifi_data_offset, dpaa_oh_get_default_fqid(wifi_oh_dev));
|
||||
|
||||
/* Register callback on OH default FQ */
|
||||
error = dpaa_oh_register_cb(wifi_oh_dev, dpaa_wifi_rx_cb, NULL);
|
||||
if (error != 0) {
|
||||
printf("dpaa_wifi: failed to register OH callback: %d\n",
|
||||
error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* Create BMan pool for WiFi injection buffers */
|
||||
wifi_zone = uma_zcreate("dpaa_wifi: Buffers", WIFI_BUF_SIZE,
|
||||
NULL, NULL, NULL, NULL, 255, 0);
|
||||
if (wifi_zone == NULL) {
|
||||
printf("dpaa_wifi: failed to create UMA zone\n");
|
||||
goto fail_cb;
|
||||
}
|
||||
|
||||
wifi_pool = bman_pool_create(&wifi_bpid, WIFI_BUF_SIZE,
|
||||
0, 0, WIFI_POOL_SIZE,
|
||||
wifi_pool_get_buffer, wifi_pool_put_buffer,
|
||||
WIFI_POOL_REFILL_THRESH, WIFI_POOL_SIZE,
|
||||
0, 0, NULL, (t_Handle)wifi_zone, NULL, NULL);
|
||||
if (wifi_pool == NULL) {
|
||||
printf("dpaa_wifi: failed to create BMan pool\n");
|
||||
goto fail_zone;
|
||||
}
|
||||
wifi_buf_total = WIFI_POOL_SIZE;
|
||||
|
||||
printf("dpaa_wifi: BMan pool created, bpid=%u, %u buffers\n",
|
||||
wifi_bpid, WIFI_POOL_SIZE);
|
||||
|
||||
/* Register dist FQ callback so CDX dispatches WiFi frames */
|
||||
dpaa_oh_register_dist_cb(wifi_bpid, dpaa_wifi_dist_rx_cb, NULL);
|
||||
|
||||
/* Initialize VAP table and IFNET event handlers */
|
||||
mtx_init(&wifi_vap_mtx, "dpaa_wifi_vap", NULL, MTX_DEF);
|
||||
|
||||
wifi_arrival_tag = EVENTHANDLER_REGISTER(ifnet_arrival_event,
|
||||
dpaa_wifi_ifnet_arrival, NULL, EVENTHANDLER_PRI_ANY);
|
||||
wifi_departure_tag = EVENTHANDLER_REGISTER(ifnet_departure_event,
|
||||
dpaa_wifi_ifnet_departure, NULL, EVENTHANDLER_PRI_ANY);
|
||||
|
||||
/* Scan for already-existing WiFi interfaces */
|
||||
dpaa_wifi_scan_existing();
|
||||
|
||||
printf("dpaa_wifi: loaded (%d VAPs hooked, callback=active)\n",
|
||||
wifi_nvaps);
|
||||
return (0);
|
||||
|
||||
fail_zone:
|
||||
uma_zdestroy(wifi_zone);
|
||||
wifi_zone = NULL;
|
||||
fail_cb:
|
||||
dpaa_oh_register_cb(wifi_oh_dev, NULL, NULL);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
static void
|
||||
dpaa_wifi_unload(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Deregister event handlers first (no new VAPs) */
|
||||
if (wifi_arrival_tag != NULL)
|
||||
EVENTHANDLER_DEREGISTER(ifnet_arrival_event,
|
||||
wifi_arrival_tag);
|
||||
if (wifi_departure_tag != NULL)
|
||||
EVENTHANDLER_DEREGISTER(ifnet_departure_event,
|
||||
wifi_departure_tag);
|
||||
|
||||
/* Unhook all active VAPs */
|
||||
mtx_lock(&wifi_vap_mtx);
|
||||
for (i = 0; i < DPAA_WIFI_MAX_VAPS; i++) {
|
||||
if (wifi_vaps[i].active)
|
||||
dpaa_wifi_remove_vap(wifi_vaps[i].ifp);
|
||||
}
|
||||
mtx_unlock(&wifi_vap_mtx);
|
||||
mtx_destroy(&wifi_vap_mtx);
|
||||
|
||||
/* Unregister dist FQ callback + default FQ callback */
|
||||
dpaa_oh_unregister_dist_cb(wifi_bpid);
|
||||
dpaa_oh_register_cb(wifi_oh_dev, NULL, NULL);
|
||||
|
||||
/* Destroy BMan pool and UMA zone */
|
||||
if (wifi_pool != NULL) {
|
||||
bman_pool_destroy(wifi_pool);
|
||||
wifi_pool = NULL;
|
||||
}
|
||||
if (wifi_zone != NULL) {
|
||||
uma_zdestroy(wifi_zone);
|
||||
wifi_zone = NULL;
|
||||
}
|
||||
|
||||
printf("dpaa_wifi: unloaded (nobuf=%ju drop=%ju)\n",
|
||||
(uintmax_t)wifi_inject_nobuf,
|
||||
(uintmax_t)wifi_rx_drop);
|
||||
}
|
||||
|
||||
static int
|
||||
dpaa_wifi_modevent(module_t mod, int type, void *unused)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
return (dpaa_wifi_load());
|
||||
case MOD_UNLOAD:
|
||||
dpaa_wifi_unload();
|
||||
return (0);
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
}
|
||||
|
||||
static moduledata_t dpaa_wifi_mod = {
|
||||
"dpaa_wifi",
|
||||
dpaa_wifi_modevent,
|
||||
NULL,
|
||||
};
|
||||
|
||||
DECLARE_MODULE(dpaa_wifi, dpaa_wifi_mod, SI_SUB_DRIVERS, SI_ORDER_ANY);
|
||||
MODULE_DEPEND(dpaa_wifi, dpaa_oh, 1, 1, 1);
|
||||
MODULE_DEPEND(dpaa_wifi, mwifiex, 1, 1, 1);
|
||||
MODULE_VERSION(dpaa_wifi, 1);
|
||||
26
drivers/dpaa_wifi/dpaa_wifi.h
Normal file
26
drivers/dpaa_wifi/dpaa_wifi.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
*
|
||||
* dpaa_wifi — WiFi ↔ FMan OH port data plane bridge.
|
||||
*
|
||||
* Bridges mwifiex PCIe WiFi driver with DPAA1 FMan OH port so CDX
|
||||
* can hardware-offload WiFi traffic.
|
||||
*/
|
||||
|
||||
#ifndef DPAA_WIFI_H_
|
||||
#define DPAA_WIFI_H_
|
||||
|
||||
/*
|
||||
* RX bridge hook for mwifiex.
|
||||
*
|
||||
* When set in mwifiex_priv.wifi_bridge_fn, moal_recv_packet() calls
|
||||
* this instead of if_input(). The function injects the frame into
|
||||
* the FMan WiFi OH port for PCD classification / CDX offload.
|
||||
*
|
||||
* Returns 0 on success (mbuf consumed), errno on failure (caller frees).
|
||||
*/
|
||||
typedef int (*dpaa_wifi_bridge_fn_t)(if_t ifp, struct mbuf *m);
|
||||
|
||||
#endif /* DPAA_WIFI_H_ */
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= emc2302
|
||||
SRCS= emc2302.c
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= ina2xx
|
||||
SRCS= ina2xx.c
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= lp5812
|
||||
SRCS= lp5812.c
|
||||
|
|
|
|||
92
drivers/mwifiex/Makefile
Normal file
92
drivers/mwifiex/Makefile
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# NXP 88W9098 PCIe WiFi driver for FreeBSD
|
||||
#
|
||||
# Compiles the OS-independent mlan layer + FreeBSD OS abstraction (moal),
|
||||
# and embeds the PCIe+UART combo firmware via firmware(9).
|
||||
#
|
||||
# Vendor source (mlan + firmware) is cloned at build time by the top-level
|
||||
# Makefile's fetch-vendor target into _vendor/.
|
||||
#
|
||||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
VENDORDIR?= ${.CURDIR}/../../_vendor
|
||||
MLANDIR= ${VENDORDIR}/mwifiex/mlan
|
||||
FWDIR= ${VENDORDIR}/imx-firmware/FwImage_9098_PCIE
|
||||
|
||||
KMOD= mwifiex
|
||||
|
||||
# Embed PCIe+UART combo firmware via firmware(9)
|
||||
FIRMWS= pcieuart9098_combo_v1.bin:mwifiex_9098_pcie_fw:1
|
||||
|
||||
# FreeBSD driver (moal layer)
|
||||
SRCS= mwifiex_pci.c moal_shim_freebsd.c
|
||||
|
||||
# mlan core (OS-independent)
|
||||
SRCS+= mlan_shim.c mlan_init.c mlan_txrx.c mlan_cmdevt.c mlan_misc.c
|
||||
SRCS+= mlan_cfp.c mlan_wmm.c mlan_pcie.c
|
||||
SRCS+= mlan_11n.c mlan_11n_aggr.c mlan_11n_rxreorder.c
|
||||
SRCS+= mlan_11ac.c mlan_11ax.c mlan_11d.c mlan_11h.c
|
||||
SRCS+= mlan_scan.c mlan_join.c mlan_meas.c
|
||||
SRCS+= mlan_sta_ioctl.c mlan_sta_cmd.c mlan_sta_cmdresp.c mlan_sta_event.c
|
||||
SRCS+= mlan_sta_tx.c mlan_sta_rx.c
|
||||
SRCS+= mlan_uap_ioctl.c mlan_uap_cmdevent.c mlan_uap_txrx.c
|
||||
# Skip: mlan_module.c (Linux EXPORT_SYMBOL), mlan_sdio.c, mlan_usb.c
|
||||
|
||||
# Required kernel interface headers
|
||||
SRCS+= device_if.h bus_if.h pci_if.h
|
||||
|
||||
# mlan include path + preprocessor defines
|
||||
MLAN_CFLAGS= -I${MLANDIR} \
|
||||
-DPCIE \
|
||||
-DSTA_SUPPORT \
|
||||
-DUAP_SUPPORT \
|
||||
-DMLAN_64BIT \
|
||||
-DPCIE9098 \
|
||||
-DDEBUG_LEVEL1
|
||||
|
||||
# mlan is NXP vendor code — suppress warnings that -Werror would reject
|
||||
MLAN_NOWARN= -Wno-error=unused-variable \
|
||||
-Wno-error=unused-label \
|
||||
-Wno-error=unused-but-set-variable \
|
||||
-Wno-error=missing-prototypes \
|
||||
-Wno-error=strict-prototypes \
|
||||
-Wno-error=cast-qual \
|
||||
-Wno-error=undef \
|
||||
-fgnu89-inline
|
||||
|
||||
# Apply mlan flags to all mlan source files
|
||||
.for _f in mlan_shim.c mlan_init.c mlan_txrx.c mlan_cmdevt.c mlan_misc.c \
|
||||
mlan_cfp.c mlan_wmm.c mlan_pcie.c \
|
||||
mlan_11n.c mlan_11n_aggr.c mlan_11n_rxreorder.c \
|
||||
mlan_11ac.c mlan_11ax.c mlan_11d.c mlan_11h.c \
|
||||
mlan_scan.c mlan_join.c mlan_meas.c \
|
||||
mlan_sta_ioctl.c mlan_sta_cmd.c mlan_sta_cmdresp.c mlan_sta_event.c \
|
||||
mlan_sta_tx.c mlan_sta_rx.c \
|
||||
mlan_uap_ioctl.c mlan_uap_cmdevent.c mlan_uap_txrx.c
|
||||
CFLAGS.${_f}+= ${MLAN_CFLAGS} ${MLAN_NOWARN}
|
||||
.endfor
|
||||
|
||||
# FreeBSD moal files also need mlan include path + defines
|
||||
CFLAGS.mwifiex_pci.c+= ${MLAN_CFLAGS}
|
||||
CFLAGS.moal_shim_freebsd.c+= ${MLAN_CFLAGS}
|
||||
|
||||
# Create symlinks from mlan source directory so kmod.mk can find them
|
||||
.for _f in mlan_shim.c mlan_init.c mlan_txrx.c mlan_cmdevt.c mlan_misc.c \
|
||||
mlan_cfp.c mlan_wmm.c mlan_pcie.c \
|
||||
mlan_11n.c mlan_11n_aggr.c mlan_11n_rxreorder.c \
|
||||
mlan_11ac.c mlan_11ax.c mlan_11d.c mlan_11h.c \
|
||||
mlan_scan.c mlan_join.c mlan_meas.c \
|
||||
mlan_sta_ioctl.c mlan_sta_cmd.c mlan_sta_cmdresp.c mlan_sta_event.c \
|
||||
mlan_sta_tx.c mlan_sta_rx.c \
|
||||
mlan_uap_ioctl.c mlan_uap_cmdevent.c mlan_uap_txrx.c
|
||||
${_f}: ${MLANDIR}/${_f}
|
||||
ln -sf ${MLANDIR}/${_f} ${.TARGET}
|
||||
CLEANFILES+= ${_f}
|
||||
.endfor
|
||||
|
||||
# Firmware binary symlink (bsd.kmod.mk looks for it in .CURDIR)
|
||||
pcieuart9098_combo_v1.bin: ${FWDIR}/pcieuart9098_combo_v1.bin
|
||||
ln -sf ${FWDIR}/pcieuart9098_combo_v1.bin ${.TARGET}
|
||||
CLEANFILES+= pcieuart9098_combo_v1.bin
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
1
drivers/mwifiex/mlan_11ac.c
Symbolic link
1
drivers/mwifiex/mlan_11ac.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11ac.c
|
||||
1
drivers/mwifiex/mlan_11ax.c
Symbolic link
1
drivers/mwifiex/mlan_11ax.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11ax.c
|
||||
1
drivers/mwifiex/mlan_11d.c
Symbolic link
1
drivers/mwifiex/mlan_11d.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11d.c
|
||||
1
drivers/mwifiex/mlan_11h.c
Symbolic link
1
drivers/mwifiex/mlan_11h.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11h.c
|
||||
1
drivers/mwifiex/mlan_11n.c
Symbolic link
1
drivers/mwifiex/mlan_11n.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11n.c
|
||||
1
drivers/mwifiex/mlan_11n_aggr.c
Symbolic link
1
drivers/mwifiex/mlan_11n_aggr.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11n_aggr.c
|
||||
1
drivers/mwifiex/mlan_11n_rxreorder.c
Symbolic link
1
drivers/mwifiex/mlan_11n_rxreorder.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_11n_rxreorder.c
|
||||
1
drivers/mwifiex/mlan_cfp.c
Symbolic link
1
drivers/mwifiex/mlan_cfp.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_cfp.c
|
||||
1
drivers/mwifiex/mlan_cmdevt.c
Symbolic link
1
drivers/mwifiex/mlan_cmdevt.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_cmdevt.c
|
||||
1
drivers/mwifiex/mlan_init.c
Symbolic link
1
drivers/mwifiex/mlan_init.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_init.c
|
||||
1
drivers/mwifiex/mlan_join.c
Symbolic link
1
drivers/mwifiex/mlan_join.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_join.c
|
||||
1
drivers/mwifiex/mlan_meas.c
Symbolic link
1
drivers/mwifiex/mlan_meas.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_meas.c
|
||||
1
drivers/mwifiex/mlan_misc.c
Symbolic link
1
drivers/mwifiex/mlan_misc.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_misc.c
|
||||
1
drivers/mwifiex/mlan_pcie.c
Symbolic link
1
drivers/mwifiex/mlan_pcie.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_pcie.c
|
||||
1
drivers/mwifiex/mlan_scan.c
Symbolic link
1
drivers/mwifiex/mlan_scan.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_scan.c
|
||||
1
drivers/mwifiex/mlan_shim.c
Symbolic link
1
drivers/mwifiex/mlan_shim.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_shim.c
|
||||
1
drivers/mwifiex/mlan_sta_cmd.c
Symbolic link
1
drivers/mwifiex/mlan_sta_cmd.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_sta_cmd.c
|
||||
1
drivers/mwifiex/mlan_sta_cmdresp.c
Symbolic link
1
drivers/mwifiex/mlan_sta_cmdresp.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_sta_cmdresp.c
|
||||
1
drivers/mwifiex/mlan_sta_event.c
Symbolic link
1
drivers/mwifiex/mlan_sta_event.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_sta_event.c
|
||||
1
drivers/mwifiex/mlan_sta_ioctl.c
Symbolic link
1
drivers/mwifiex/mlan_sta_ioctl.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_sta_ioctl.c
|
||||
1
drivers/mwifiex/mlan_sta_rx.c
Symbolic link
1
drivers/mwifiex/mlan_sta_rx.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_sta_rx.c
|
||||
1
drivers/mwifiex/mlan_sta_tx.c
Symbolic link
1
drivers/mwifiex/mlan_sta_tx.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_sta_tx.c
|
||||
1
drivers/mwifiex/mlan_txrx.c
Symbolic link
1
drivers/mwifiex/mlan_txrx.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_txrx.c
|
||||
1
drivers/mwifiex/mlan_uap_cmdevent.c
Symbolic link
1
drivers/mwifiex/mlan_uap_cmdevent.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_uap_cmdevent.c
|
||||
1
drivers/mwifiex/mlan_uap_ioctl.c
Symbolic link
1
drivers/mwifiex/mlan_uap_ioctl.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_uap_ioctl.c
|
||||
1
drivers/mwifiex/mlan_uap_txrx.c
Symbolic link
1
drivers/mwifiex/mlan_uap_txrx.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_uap_txrx.c
|
||||
1
drivers/mwifiex/mlan_wmm.c
Symbolic link
1
drivers/mwifiex/mlan_wmm.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/mwifiex/mlan/mlan_wmm.c
|
||||
173
drivers/mwifiex/moal_freebsd.h
Normal file
173
drivers/mwifiex/moal_freebsd.h
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
*
|
||||
* NXP 88W9098 PCIe WiFi driver — FreeBSD OS abstraction header.
|
||||
* This replaces mlinux/moal_main.h for the FreeBSD port.
|
||||
*/
|
||||
|
||||
#ifndef _MOAL_FREEBSD_H_
|
||||
#define _MOAL_FREEBSD_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/taskqueue.h>
|
||||
#include <sys/firmware.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
/* mlan types and declarations */
|
||||
#include "mlan_decl.h"
|
||||
#include "mlan_ioctl.h"
|
||||
|
||||
#include "mwifiex_pci.h"
|
||||
|
||||
MALLOC_DECLARE(M_MWIFIEX);
|
||||
|
||||
/*
|
||||
* Lock wrapper — mlan stores a t_void* and passes it back to
|
||||
* moal_spin_lock/unlock. We wrap a FreeBSD mutex.
|
||||
*/
|
||||
struct mwifiex_lock {
|
||||
struct mtx mtx;
|
||||
};
|
||||
|
||||
/*
|
||||
* Timer wrapper — mlan stores a t_void* and passes it back to
|
||||
* moal_start_timer/stop_timer.
|
||||
*/
|
||||
struct mwifiex_timer {
|
||||
struct callout callout;
|
||||
void (*callback)(void *);
|
||||
void *context;
|
||||
t_u8 periodic;
|
||||
t_u32 msec;
|
||||
};
|
||||
|
||||
/*
|
||||
* DMA allocation tracker — we need to track bus_dma resources for
|
||||
* each consistent allocation so we can free them properly.
|
||||
*/
|
||||
struct mwifiex_dma_alloc {
|
||||
bus_dma_tag_t tag;
|
||||
bus_dmamap_t map;
|
||||
bus_addr_t paddr;
|
||||
void *vaddr;
|
||||
bus_size_t size;
|
||||
SLIST_ENTRY(mwifiex_dma_alloc) link;
|
||||
};
|
||||
|
||||
/*
|
||||
* Per-BSS private — one per interface (STA + UAP).
|
||||
* Analogous to Linux moal_private.
|
||||
*/
|
||||
struct mwifiex_priv {
|
||||
struct mwifiex_handle *handle;
|
||||
if_t ifp;
|
||||
uint8_t bss_index; /* 0=STA, 1=UAP */
|
||||
uint8_t bss_type; /* MLAN_BSS_TYPE_STA/UAP */
|
||||
uint8_t bss_role; /* MLAN_BSS_ROLE_STA/UAP */
|
||||
uint8_t mac_addr[ETHER_ADDR_LEN];
|
||||
volatile int running; /* IFF_DRV_RUNNING set */
|
||||
|
||||
/* TX pending count */
|
||||
volatile int tx_pending;
|
||||
|
||||
/* Statistics */
|
||||
uint64_t tx_packets;
|
||||
uint64_t tx_bytes;
|
||||
uint64_t tx_errors;
|
||||
uint64_t rx_packets;
|
||||
uint64_t rx_bytes;
|
||||
uint64_t rx_errors;
|
||||
|
||||
/* dpaa_wifi bridge hook — set by dpaa_wifi.ko to divert RX
|
||||
* frames to the FMan OH port for CDX offload. NULL = disabled. */
|
||||
int (*wifi_bridge_fn)(if_t ifp, struct mbuf *m);
|
||||
};
|
||||
|
||||
/*
|
||||
* FreeBSD MOAL handle — our equivalent of Linux moal_handle.
|
||||
* This is passed as pmoal_handle to all moal_* callbacks.
|
||||
*/
|
||||
struct mwifiex_handle {
|
||||
struct mwifiex_softc *sc; /* back-pointer to softc */
|
||||
|
||||
/* MLAN adapter — returned by mlan_register() */
|
||||
t_void *pmlan_adapter;
|
||||
|
||||
/* Firmware image (from firmware(9)) */
|
||||
const struct firmware *fw_image;
|
||||
t_u32 fw_len;
|
||||
|
||||
/* DMA tag for consistent allocations */
|
||||
bus_dma_tag_t dma_tag;
|
||||
|
||||
/* Track all DMA allocations for cleanup */
|
||||
SLIST_HEAD(, mwifiex_dma_alloc) dma_allocs;
|
||||
struct mtx dma_list_mtx;
|
||||
|
||||
/* Deferred processing tasks (scheduled from interrupt context) */
|
||||
struct task main_task; /* DEFER_HANDLING */
|
||||
struct task cmdresp_task; /* DEFER_CMDRESP */
|
||||
struct task rx_task; /* DEFER_RX_DATA */
|
||||
struct task txcmpl_task; /* DEFER_TX_COMPLTE */
|
||||
|
||||
/* Per-BSS interfaces (STA=0, UAP=1) */
|
||||
struct mwifiex_priv *priv[MLAN_MAX_BSS_NUM];
|
||||
int priv_num;
|
||||
|
||||
/* Synchronous IOCTL completion */
|
||||
volatile int ioctl_wait_done;
|
||||
mlan_status ioctl_status;
|
||||
|
||||
/* Status */
|
||||
volatile int fw_ready;
|
||||
volatile int surprise_removed;
|
||||
|
||||
/* Card type info */
|
||||
t_u16 card_type;
|
||||
|
||||
/* UAP configuration (set via sysctl) */
|
||||
char uap_ssid[33]; /* max 32 chars + NUL */
|
||||
char uap_passphrase[65]; /* max 64 chars + NUL */
|
||||
int uap_channel; /* 0=auto, 1-14=2.4G */
|
||||
int uap_max_sta; /* max stations */
|
||||
int uap_bandwidth; /* 20, 40, or 80 MHz */
|
||||
char uap_security[16]; /* open/wpa2/wpa3/wpa2wpa3 */
|
||||
int uap_hidden; /* 0=broadcast, 1=hidden */
|
||||
volatile int uap_started; /* BSS is running */
|
||||
};
|
||||
|
||||
/* Callback table setup (moal_shim_freebsd.c) */
|
||||
void mwifiex_fill_callbacks(mlan_callbacks *cb);
|
||||
|
||||
#endif /* _MOAL_FREEBSD_H_ */
|
||||
1004
drivers/mwifiex/moal_shim_freebsd.c
Normal file
1004
drivers/mwifiex/moal_shim_freebsd.c
Normal file
File diff suppressed because it is too large
Load diff
24
drivers/mwifiex/mwifiex.c
Normal file
24
drivers/mwifiex/mwifiex.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* * Automatically @generated */
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/linker.h>
|
||||
#include <sys/firmware.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
extern char _binary_pcieuart9098_combo_v1_bin_start[], _binary_pcieuart9098_combo_v1_bin_end[];
|
||||
|
||||
static int
|
||||
mwifiex_fw_modevent(module_t mod, int type, void *unused){ const struct firmware *fp;
|
||||
int error; switch (type) { case MOD_LOAD:
|
||||
|
||||
fp = firmware_register("mwifiex_9098_pcie_fw", _binary_pcieuart9098_combo_v1_bin_start , (size_t)(_binary_pcieuart9098_combo_v1_bin_end - _binary_pcieuart9098_combo_v1_bin_start), 1, NULL);
|
||||
if (fp == NULL)
|
||||
goto fail_0;
|
||||
return (0);
|
||||
fail_0:
|
||||
return (ENXIO);
|
||||
case MOD_UNLOAD:
|
||||
error = firmware_unregister("mwifiex_9098_pcie_fw");
|
||||
return (error); } return (EINVAL);}static moduledata_t mwifiex_fw_mod = { "mwifiex_fw", mwifiex_fw_modevent, 0};DECLARE_MODULE(mwifiex_fw, mwifiex_fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);MODULE_VERSION(mwifiex_fw, 1);MODULE_DEPEND(mwifiex_fw, firmware, 1, 1, 1);
|
||||
1421
drivers/mwifiex/mwifiex_pci.c
Normal file
1421
drivers/mwifiex/mwifiex_pci.c
Normal file
File diff suppressed because it is too large
Load diff
119
drivers/mwifiex/mwifiex_pci.h
Normal file
119
drivers/mwifiex/mwifiex_pci.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
*
|
||||
* NXP 88W9098 PCIe WiFi driver — register definitions and softc.
|
||||
*/
|
||||
|
||||
#ifndef _MWIFIEX_PCI_H_
|
||||
#define _MWIFIEX_PCI_H_
|
||||
|
||||
/* PCI vendor/device IDs */
|
||||
#define MWIFIEX_VENDOR_ID 0x1b4b
|
||||
#define MWIFIEX_9098_FN0 0x2b43 /* WiFi */
|
||||
#define MWIFIEX_9098_FN1 0x2b44 /* Bluetooth */
|
||||
|
||||
/* Chip revision IDs (from REV_ID_REG & 0xff) */
|
||||
#define MWIFIEX_REV_Z1Z2 0x00
|
||||
#define MWIFIEX_REV_A0 0x01
|
||||
#define MWIFIEX_REV_A1 0x02
|
||||
#define MWIFIEX_REV_A2 0x03
|
||||
|
||||
/* Control/status registers (BAR 0) */
|
||||
#define PCIE9098_DEV_ID_REG 0x0000
|
||||
#define PCIE9098_REV_ID_REG 0x0008
|
||||
#define PCIE9098_IP_REV_REG 0x1000
|
||||
|
||||
/* CPU interrupt registers */
|
||||
#define PCIE9098_CPU_INT_EVENT 0x1C20
|
||||
#define PCIE9098_CPU_INT_STATUS 0x1C24
|
||||
|
||||
/* Host interrupt registers */
|
||||
#define PCIE9098_HOST_INT_STATUS 0x1C44
|
||||
#define PCIE9098_HOST_INT_MASK 0x1C48
|
||||
#define PCIE9098_HOST_INT_CLR_SEL 0x1C4C
|
||||
#define PCIE9098_HOST_INT_STATUS_MASK 0x1C50
|
||||
#define PCIE9098_HOST_INT_SEL 0x1C58
|
||||
|
||||
/* Scratch registers */
|
||||
#define PCIE9098_SCRATCH_0_REG 0x1C60
|
||||
#define PCIE9098_SCRATCH_2_REG 0x1C68
|
||||
#define PCIE9098_SCRATCH_6_REG 0x1C78
|
||||
#define PCIE9098_SCRATCH_7_REG 0x1C7C
|
||||
#define PCIE9098_HOST_STRAP_REG 0x1C70
|
||||
#define PCIE9098_MAGIC_REG 0x1C74
|
||||
#define PCIE9098_DRV_READY 0x1C90
|
||||
#define PCIE9098_FW_RESET_REG 0x1C94
|
||||
#define PCIE9098_FW_STUCK_CODE_REG 0x1C98
|
||||
|
||||
/* Magic value in MAGIC_REG indicating valid chip info */
|
||||
#define CHIP_MAGIC_VALUE 0x24
|
||||
|
||||
/* Host strap values (secondary interface type) */
|
||||
#define CARD_TYPE_PCIE_PCIE 2
|
||||
#define CARD_TYPE_PCIE_UART 3
|
||||
#define CARD_TYPE_PCIE_USB 7
|
||||
|
||||
/* FW reset value */
|
||||
#define PCIE9098_FW_RESET_VAL 0x98
|
||||
|
||||
/* Host interrupt bits */
|
||||
#define HOST_INTR_DNLD_DONE (1 << 0) /* TX data done */
|
||||
#define HOST_INTR_CMD_DNLD (1 << 7) /* CMD download done */
|
||||
#define HOST_INTR_UPLD_RDY (1 << 16) /* RX data ready */
|
||||
#define HOST_INTR_EVENT_RDY (1 << 17) /* Event ready */
|
||||
#define HOST_INTR_CMD_DONE (1 << 25) /* CMD response done */
|
||||
|
||||
#define HOST_INTR_MASK \
|
||||
(HOST_INTR_DNLD_DONE | HOST_INTR_UPLD_RDY | \
|
||||
HOST_INTR_CMD_DONE | HOST_INTR_CMD_DNLD | \
|
||||
HOST_INTR_EVENT_RDY)
|
||||
|
||||
/* ADMA channel base addresses */
|
||||
#define ADMA_CHAN0_Q0 0x10000 /* TX data */
|
||||
#define ADMA_CHAN1_Q0 0x10800 /* RX data */
|
||||
#define ADMA_CHAN1_Q1 0x10880 /* RX event */
|
||||
#define ADMA_CHAN2_Q0 0x11000 /* TX command */
|
||||
#define ADMA_CHAN2_Q1 0x11080 /* CMD response */
|
||||
|
||||
/* Forward declaration */
|
||||
struct mwifiex_handle;
|
||||
|
||||
/* Driver softc */
|
||||
struct mwifiex_softc {
|
||||
device_t sc_dev;
|
||||
|
||||
/* PCI resources */
|
||||
struct resource *sc_bar0; /* BAR 0 memory */
|
||||
int sc_bar0_rid;
|
||||
bus_space_tag_t sc_bar0_bt;
|
||||
bus_space_handle_t sc_bar0_bh;
|
||||
|
||||
struct resource *sc_bar2; /* BAR 2 memory */
|
||||
int sc_bar2_rid;
|
||||
bus_space_tag_t sc_bar2_bt;
|
||||
bus_space_handle_t sc_bar2_bh;
|
||||
|
||||
struct resource *sc_irq; /* MSI interrupt */
|
||||
int sc_irq_rid;
|
||||
void *sc_irq_cookie;
|
||||
|
||||
/* Chip info */
|
||||
uint16_t sc_device_id;
|
||||
uint8_t sc_revision;
|
||||
uint8_t sc_strap;
|
||||
uint8_t sc_magic;
|
||||
int sc_is_fn0; /* WiFi (1) vs BT (0) */
|
||||
|
||||
/* MOAL handle (FN0 only) */
|
||||
struct mwifiex_handle *sc_handle;
|
||||
};
|
||||
|
||||
/* Register access macros — control/status registers are on BAR 2 */
|
||||
#define MWIFIEX_READ_4(sc, off) \
|
||||
bus_space_read_4((sc)->sc_bar2_bt, (sc)->sc_bar2_bh, (off))
|
||||
#define MWIFIEX_WRITE_4(sc, off, val) \
|
||||
bus_space_write_4((sc)->sc_bar2_bt, (sc)->sc_bar2_bh, (off), (val))
|
||||
|
||||
#endif /* _MWIFIEX_PCI_H_ */
|
||||
1
drivers/mwifiex/pcieuart9098_combo_v1.bin
Symbolic link
1
drivers/mwifiex/pcieuart9098_combo_v1.bin
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/build/opnsense-deps/_vendor/imx-firmware/FwImage_9098_PCIE/pcieuart9098_combo_v1.bin
|
||||
BIN
drivers/mwifiex/pcieuart9098_combo_v1.bin.fwo
Normal file
BIN
drivers/mwifiex/pcieuart9098_combo_v1.bin.fwo
Normal file
Binary file not shown.
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= pcf2131
|
||||
SRCS= pcf2131.c
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= sfpled
|
||||
SRCS= sfp_led.c
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= tmp431
|
||||
SRCS= tmp431.c
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
FASTPATH_ROOT= ${.CURDIR}/..
|
||||
SYSDIR?= ${FASTPATH_ROOT}/../../opnsense-src/sys
|
||||
|
||||
CFLAGS+= -I${FASTPATH_ROOT}/include
|
||||
CFLAGS+= -DENDIAN_LITTLE -DGCC_TOOLCHAIN
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= auto_bridge
|
||||
SRCS= auto_bridge.c
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ CFLAGS+= -DENABLE_EGRESS_QOS
|
|||
CFLAGS+= -DDPAA_FAST_PATH
|
||||
CFLAGS+= -DENABLE_FLOW_TIME_STAMPS
|
||||
CFLAGS+= -DDPA_IPSEC_OFFLOAD
|
||||
CFLAGS+= -DWIFI_ENABLE
|
||||
|
||||
# NCSW build environment defines (replicate dflags_arm64.h without its
|
||||
# Linux-specific includes like <asm/byteorder.h> and <linux/delay.h>)
|
||||
|
|
|
|||
|
|
@ -155,6 +155,9 @@ CMD_DECLARE(statistics)
|
|||
#ifdef DPA_IPSEC_OFFLOAD
|
||||
CMD_DECLARE(ipsec)
|
||||
#endif
|
||||
#ifdef WIFI_ENABLE
|
||||
CMD_DECLARE(wifi)
|
||||
#endif
|
||||
CMD_DECLARE(mc4)
|
||||
CMD_DECLARE(mc6)
|
||||
CMD_DECLARE(rtp_relay)
|
||||
|
|
@ -179,6 +182,9 @@ cdx_cmdhandler_init(void)
|
|||
CMD_INIT(statistics);
|
||||
#ifdef DPA_IPSEC_OFFLOAD
|
||||
CMD_INIT(ipsec);
|
||||
#endif
|
||||
#ifdef WIFI_ENABLE
|
||||
CMD_INIT(wifi);
|
||||
#endif
|
||||
CMD_INIT(mc4);
|
||||
CMD_INIT(mc6);
|
||||
|
|
@ -201,6 +207,9 @@ cdx_cmdhandler_exit(void)
|
|||
CMD_EXIT(mc4);
|
||||
#ifdef DPA_IPSEC_OFFLOAD
|
||||
CMD_EXIT(ipsec);
|
||||
#endif
|
||||
#ifdef WIFI_ENABLE
|
||||
CMD_EXIT(wifi);
|
||||
#endif
|
||||
CMD_EXIT(statistics);
|
||||
CMD_EXIT(qm);
|
||||
|
|
|
|||
|
|
@ -387,9 +387,9 @@ dpa_get_ifinfo_by_name(char *name)
|
|||
}
|
||||
|
||||
/*
|
||||
* Walk the interface hierarchy to find the physical ethernet parent.
|
||||
* Walk the interface hierarchy to find the physical parent.
|
||||
* Traverses VLAN → parent and PPPoE → parent until an ethernet
|
||||
* interface (IF_TYPE_ETHERNET) is found.
|
||||
* or WiFi interface is found.
|
||||
*
|
||||
* Returns the dpa_iface_info of the physical port, or NULL.
|
||||
*/
|
||||
|
|
@ -399,7 +399,7 @@ devman_find_eth_parent(struct dpa_iface_info *iface)
|
|||
int depth = 0;
|
||||
|
||||
while (iface != NULL && depth < 8) {
|
||||
if (iface->if_flags & IF_TYPE_ETHERNET)
|
||||
if (iface->if_flags & (IF_TYPE_ETHERNET | IF_TYPE_WLAN))
|
||||
return (iface);
|
||||
if (iface->if_flags & IF_TYPE_VLAN)
|
||||
iface = iface->vlan_info.parent;
|
||||
|
|
@ -562,6 +562,15 @@ dpa_get_fm_port_index(uint32_t itf_index, uint32_t underlying_iif_index,
|
|||
return (-1);
|
||||
}
|
||||
|
||||
/* WiFi interfaces store FMan info from the OH port */
|
||||
if (iface->if_flags & IF_TYPE_WLAN) {
|
||||
*fm_index = iface->wlan_info.fman_idx;
|
||||
*port_index = iface->wlan_info.port_idx;
|
||||
*portid = iface->wlan_info.portid;
|
||||
spin_unlock(&dpa_devlist_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
eth_iface = devman_find_eth_parent(iface);
|
||||
if (eth_iface == NULL) {
|
||||
spin_unlock(&dpa_devlist_lock);
|
||||
|
|
@ -629,6 +638,21 @@ dpa_get_tx_info_by_itf(PRouteEntry rt_entry,
|
|||
l2_info->pppoe_present = 1;
|
||||
l2_info->pppoe_sess_id = cur->pppoe_info.session_id;
|
||||
cur = cur->pppoe_info.parent;
|
||||
} else if (cur->if_flags & IF_TYPE_WLAN) {
|
||||
/* WiFi VAP — TX goes to the OH port */
|
||||
struct wlan_iface_info *wlan = &cur->wlan_info;
|
||||
struct dpa_iface_info *oh;
|
||||
|
||||
memcpy(l2_info->l2hdr, rt_entry->dstmac, 6);
|
||||
memcpy(l2_info->l2hdr + 6, wlan->mac_addr, 6);
|
||||
l2_info->mtu = cur->mtu;
|
||||
l2_info->is_wlan_iface = 1;
|
||||
|
||||
oh = dpa_get_ohifinfo_by_portid(wlan->portid);
|
||||
if (oh != NULL)
|
||||
l2_info->fqid =
|
||||
oh->oh_info.fqinfo[RX_DEFA_FQ].fq_base;
|
||||
break;
|
||||
} else if (cur->if_flags & IF_TYPE_ETHERNET) {
|
||||
/* Reached physical port — extract TX info */
|
||||
struct eth_iface_info *eth = &cur->eth_info;
|
||||
|
|
@ -692,16 +716,32 @@ dpa_get_tx_l2info_by_itf(struct dpa_l2hdr_info *l2_info,
|
|||
|
||||
eth_parent = devman_find_eth_parent(iface);
|
||||
if (eth_parent != NULL) {
|
||||
struct eth_iface_info *eth = ð_parent->eth_info;
|
||||
if (eth_parent->if_flags & IF_TYPE_WLAN) {
|
||||
struct wlan_iface_info *wlan =
|
||||
ð_parent->wlan_info;
|
||||
struct dpa_iface_info *oh;
|
||||
|
||||
memcpy(l2_info->l2hdr + 6, eth->mac_addr, 6);
|
||||
l2_info->mtu = eth_parent->mtu;
|
||||
l2_info->fqid = eth->fwd_tx_fqinfo[
|
||||
hash % DPAA_FWD_TX_QUEUES].fqid;
|
||||
memcpy(l2_info->l2hdr + 6, wlan->mac_addr, 6);
|
||||
l2_info->mtu = eth_parent->mtu;
|
||||
l2_info->is_wlan_iface = 1;
|
||||
|
||||
oh = dpa_get_ohifinfo_by_portid(wlan->portid);
|
||||
if (oh != NULL)
|
||||
l2_info->fqid =
|
||||
oh->oh_info.fqinfo[RX_DEFA_FQ].fq_base;
|
||||
} else {
|
||||
struct eth_iface_info *eth =
|
||||
ð_parent->eth_info;
|
||||
|
||||
memcpy(l2_info->l2hdr + 6, eth->mac_addr, 6);
|
||||
l2_info->mtu = eth_parent->mtu;
|
||||
l2_info->fqid = eth->fwd_tx_fqinfo[
|
||||
hash % DPAA_FWD_TX_QUEUES].fqid;
|
||||
#ifdef INCLUDE_ETHER_IFSTATS
|
||||
l2_info->ether_stats_offset =
|
||||
eth_parent->txstats_index;
|
||||
l2_info->ether_stats_offset =
|
||||
eth_parent->txstats_index;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock(&dpa_devlist_lock);
|
||||
|
|
@ -799,8 +839,19 @@ dpa_get_tx_fqid_by_name(char *name, uint32_t *fqid,
|
|||
return (-1);
|
||||
}
|
||||
|
||||
*fqid = eth_parent->eth_info.fwd_tx_fqinfo[
|
||||
hash % DPAA_FWD_TX_QUEUES].fqid;
|
||||
if (eth_parent->if_flags & IF_TYPE_WLAN) {
|
||||
struct dpa_iface_info *oh;
|
||||
|
||||
oh = dpa_get_ohifinfo_by_portid(
|
||||
eth_parent->wlan_info.portid);
|
||||
if (oh != NULL)
|
||||
*fqid = oh->oh_info.fqinfo[RX_DEFA_FQ].fq_base;
|
||||
else
|
||||
*fqid = 0;
|
||||
} else {
|
||||
*fqid = eth_parent->eth_info.fwd_tx_fqinfo[
|
||||
hash % DPAA_FWD_TX_QUEUES].fqid;
|
||||
}
|
||||
if (is_dscp_fq_map)
|
||||
*is_dscp_fq_map = 0;
|
||||
|
||||
|
|
@ -1314,20 +1365,99 @@ cdx_check_rx_iface_type_vlan(struct _itf *input_itf)
|
|||
}
|
||||
|
||||
/* ================================================================
|
||||
* Remaining stubs — WiFi/bridge not in scope for this platform
|
||||
* WiFi VAP interface management
|
||||
* ================================================================ */
|
||||
|
||||
/*
|
||||
* dpa_add_wlan_if — Register a WiFi VAP interface.
|
||||
*
|
||||
* Called from control_wifi.c:wifi_vap_entry() on WIFI_ADD_VAP.
|
||||
* Populates wlan_iface_info with the WiFi OH port's fman/port
|
||||
* indices so that cdx_ehash.c can route flows to/from WiFi.
|
||||
*
|
||||
* Data-path delivery of CDX-offloaded WiFi frames is handled by
|
||||
* the dpaa_wifi kernel module (dpaa_wifi.ko), which registers its
|
||||
* own callback on the OH port's default FQ.
|
||||
*/
|
||||
int
|
||||
dpa_add_wlan_if(char *name, struct _itf *itf, uint32_t vap_id,
|
||||
unsigned char *mac)
|
||||
{
|
||||
return (-1);
|
||||
struct dpa_iface_info *iface, *oh;
|
||||
|
||||
/*
|
||||
* Find the WiFi OH port — portid 9 from cdx_cfg.xml
|
||||
* (OFFLINE port 2, "dpa-fman0-oh@3").
|
||||
*/
|
||||
oh = dpa_get_ohifinfo_by_portid(9);
|
||||
if (oh == NULL) {
|
||||
DPA_ERROR("cdx: dpa_add_wlan_if: WiFi OH port "
|
||||
"(portid=9) not found\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
iface = kzalloc(sizeof(*iface), GFP_KERNEL);
|
||||
if (iface == NULL)
|
||||
return (-1);
|
||||
|
||||
strlcpy((char *)iface->name, name, IF_NAME_SIZE);
|
||||
iface->itf_id = itf->index;
|
||||
iface->if_flags = itf->type;
|
||||
iface->mtu = 1500;
|
||||
|
||||
/* Populate wlan_info from OH port */
|
||||
iface->wlan_info.vap_id = vap_id;
|
||||
memcpy(iface->wlan_info.mac_addr, mac, 6);
|
||||
iface->wlan_info.fman_idx = oh->oh_info.fman_idx;
|
||||
iface->wlan_info.port_idx = oh->oh_info.port_idx;
|
||||
iface->wlan_info.portid = oh->oh_info.portid;
|
||||
|
||||
dpa_add_port_to_list(iface);
|
||||
|
||||
DPA_INFO("cdx: devman: registered WiFi %s — itf_id=%u vap=%u "
|
||||
"portid=%u fman=%u port=%u\n", name, iface->itf_id, vap_id,
|
||||
iface->wlan_info.portid, iface->wlan_info.fman_idx,
|
||||
iface->wlan_info.port_idx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
dpa_update_wlan_if(struct _itf *itf, unsigned char *mac)
|
||||
{
|
||||
return (-1);
|
||||
struct dpa_iface_info *iface;
|
||||
|
||||
spin_lock(&dpa_devlist_lock);
|
||||
iface = devman_find_by_itfid(itf->index);
|
||||
if (iface == NULL) {
|
||||
spin_unlock(&dpa_devlist_lock);
|
||||
DPA_ERROR("cdx: dpa_update_wlan_if: itf_id=%u not found\n",
|
||||
itf->index);
|
||||
return (-1);
|
||||
}
|
||||
memcpy(iface->wlan_info.mac_addr, mac, 6);
|
||||
spin_unlock(&dpa_devlist_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* dpaa_get_vap_fwd_fq — Get the TX FQID for WiFi-bound offloaded frames.
|
||||
*
|
||||
* CDX calls this to determine where to enqueue frames destined for a
|
||||
* WiFi VAP. Returns the WiFi OH port's default RX FQID — frames
|
||||
* enqueued there are processed by the OH port and forwarded to WiFi.
|
||||
*/
|
||||
int
|
||||
dpaa_get_vap_fwd_fq(uint16_t vap_id, uint32_t *fqid, uint32_t hash)
|
||||
{
|
||||
struct dpa_iface_info *oh;
|
||||
|
||||
oh = dpa_get_ohifinfo_by_portid(9); /* WiFi OH port */
|
||||
if (oh == NULL)
|
||||
return (-1);
|
||||
|
||||
*fqid = oh->oh_info.fqinfo[RX_DEFA_FQ].fq_base;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#include <sys/bus.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <vm/uma.h>
|
||||
#include <machine/atomic.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
|
|
@ -32,6 +34,7 @@
|
|||
#include <contrib/ncsw/inc/Peripherals/fm_port_ext.h>
|
||||
#include <contrib/ncsw/inc/Peripherals/qm_ext.h>
|
||||
#include <dev/dpaa/fman.h>
|
||||
#include <dev/dpaa/bman.h>
|
||||
#include <dev/dpaa/if_dtsec.h>
|
||||
#include <dev/dpaa/dpaa_oh.h>
|
||||
|
||||
|
|
@ -218,6 +221,7 @@ cdx_dpa_bridge_init(void)
|
|||
|
||||
/* SDK external hash table API (fm_ehash_freebsd.c) */
|
||||
extern void ExternalHashTableDelete(t_Handle h_HashTbl);
|
||||
extern void cdx_destroy_port_fqs(void);
|
||||
|
||||
void
|
||||
cdx_dpa_bridge_destroy(void)
|
||||
|
|
@ -225,11 +229,60 @@ cdx_dpa_bridge_destroy(void)
|
|||
struct cdx_fman_info *fi = &cdx_fman_info_data;
|
||||
uint32_t i;
|
||||
|
||||
/* Clear globals first to prevent concurrent access */
|
||||
/*
|
||||
* Step 1: Delete PCD on all ports FIRST.
|
||||
* This stops FMan from classifying frames through CDX hash
|
||||
* tables and KG schemes. Without this, FMan continues to
|
||||
* reference MURAM objects we're about to free → exceptions.
|
||||
*/
|
||||
{
|
||||
devclass_t dc;
|
||||
device_t dev;
|
||||
struct dtsec_softc *sc;
|
||||
int unit;
|
||||
|
||||
dc = devclass_find("dtsec");
|
||||
if (dc != NULL) {
|
||||
for (unit = 0; unit < devclass_get_maxunit(dc);
|
||||
unit++) {
|
||||
dev = devclass_get_device(dc, unit);
|
||||
if (dev == NULL)
|
||||
continue;
|
||||
sc = device_get_softc(dev);
|
||||
if (sc == NULL || sc->sc_rxph == NULL)
|
||||
continue;
|
||||
FM_PORT_DeletePCD(sc->sc_rxph);
|
||||
device_printf(dev, "PCD deleted for CDX "
|
||||
"unload\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* OH ports */
|
||||
for (i = 0; i < CDX_MAX_OH_PORTS; i++) {
|
||||
t_Handle ohp;
|
||||
if (cdx_oh_devs[i] == NULL)
|
||||
continue;
|
||||
ohp = dpaa_oh_get_fm_port(cdx_oh_devs[i]);
|
||||
if (ohp != NULL) {
|
||||
FM_PORT_DeletePCD(ohp);
|
||||
printf("cdx: OH port %u PCD deleted\n",
|
||||
i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear globals to prevent concurrent access */
|
||||
fman_info = NULL;
|
||||
cdx_num_fmans = 0;
|
||||
cdx_fman_dev = NULL;
|
||||
|
||||
/*
|
||||
* Step 2: Free distribution FQRs.
|
||||
* PCD is already deleted, so no new frames will be enqueued.
|
||||
* Retire existing FQs and quiesce portal poll tasks.
|
||||
*/
|
||||
cdx_destroy_port_fqs();
|
||||
|
||||
/*
|
||||
* Delete all hash tables tracked in tbl_info.
|
||||
* Handles both standalone (from cdx_dpa_init) and bound
|
||||
|
|
@ -418,6 +471,25 @@ cdx_dpa_bridge_find_dtsec(const char *ifname)
|
|||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* cdx_dpa_bridge_find_ifnet — Find the ifnet for a dtsec by name.
|
||||
*
|
||||
* Thin wrapper around cdx_dpa_bridge_find_dtsec that returns just
|
||||
* the ifnet pointer. Used by cdx_dpa_takeover.c to avoid including
|
||||
* if_dtsec.h in the CDX module.
|
||||
*/
|
||||
if_t
|
||||
cdx_dpa_bridge_find_ifnet(const char *ifname)
|
||||
{
|
||||
struct dtsec_softc *sc;
|
||||
|
||||
sc = cdx_dpa_bridge_find_dtsec(ifname);
|
||||
if (sc == NULL)
|
||||
return (NULL);
|
||||
|
||||
return (sc->sc_ifnet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a dtsec device by FMan port index (eth_id). Used by devman
|
||||
* to look up dtsec devices by port number rather than name.
|
||||
|
|
@ -527,6 +599,76 @@ cdx_dpa_bridge_get_rx_pool(void)
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* cdx_dpa_bridge_get_rx_sc — Return an opaque dtsec_softc pointer.
|
||||
*
|
||||
* Used by cdx_dpa_takeover.c to cache the softc pointer for passing
|
||||
* as ext_arg2 in m_extadd. The CDX module doesn't include if_dtsec.h
|
||||
* directly, so the pointer is opaque (void *) from its perspective.
|
||||
*/
|
||||
void *
|
||||
cdx_dpa_bridge_get_rx_sc(void)
|
||||
{
|
||||
|
||||
return (cdx_dpa_bridge_find_dtsec_by_ethid(0));
|
||||
}
|
||||
|
||||
/*
|
||||
* cdx_dpa_bridge_rx_buf_free — Consumption model buffer free.
|
||||
*
|
||||
* Recovers the original KVA pointer stashed at offset 0 of the buffer
|
||||
* by the dtsec driver's BMan refill code, frees to UMA, and decrements
|
||||
* sc_rx_buf_total. The dtsec refill mechanism will notice the BMan
|
||||
* pool count is low and replenish it with fresh allocations.
|
||||
*
|
||||
* This matches dtsec_rm_fqr_mext_free() in if_dtsec_rm.c.
|
||||
*/
|
||||
void
|
||||
cdx_dpa_bridge_rx_buf_free(void *sc_opaque, void *buf)
|
||||
{
|
||||
struct dtsec_softc *sc = sc_opaque;
|
||||
|
||||
uma_zfree(sc->sc_rx_zone, (void *)(*(uintptr_t *)buf));
|
||||
atomic_subtract_32(&sc->sc_rx_buf_total, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* cdx_dpa_bridge_rx_pool_refill — Refill BMan pool from UMA.
|
||||
*
|
||||
* Allocates buffers from the dtsec UMA zone, stashes the KVA pointer
|
||||
* at offset 0 (matching dtsec_rm_buf_stash_ptr), and puts them into
|
||||
* BMan. Increments sc_rx_buf_total for each buffer added.
|
||||
*
|
||||
* Must be called when BMan pool count is low. This is the CDX
|
||||
* equivalent of the refill at the top of dtsec_rm_fqr_rx_callback().
|
||||
* When CDX replaces the dtsec PCD, dtsec RX callbacks no longer fire,
|
||||
* so CDX must handle refill itself.
|
||||
*
|
||||
* Returns the number of buffers actually added to BMan.
|
||||
*/
|
||||
unsigned int
|
||||
cdx_dpa_bridge_rx_pool_refill(void *sc_opaque, unsigned int count)
|
||||
{
|
||||
struct dtsec_softc *sc = sc_opaque;
|
||||
unsigned int i;
|
||||
uint8_t *buf;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
buf = uma_zalloc(sc->sc_rx_zone, M_NOWAIT);
|
||||
if (buf == NULL)
|
||||
break;
|
||||
/* Stash KVA pointer at offset 0 for recovery after
|
||||
* BMan/FMan round-trip (matches dtsec_rm_buf_stash_ptr) */
|
||||
*(uintptr_t *)buf = (uintptr_t)buf;
|
||||
if (bman_put_buffer(sc->sc_rx_pool, buf) != 0) {
|
||||
uma_zfree(sc->sc_rx_zone, buf);
|
||||
break;
|
||||
}
|
||||
atomic_add_32(&sc->sc_rx_buf_total, 1);
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* QoS helpers — port handle and PCD accessors for cdx_qos_freebsd.c
|
||||
* ---------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <contrib/ncsw/inc/ncsw_ext.h>
|
||||
|
||||
struct dtsec_softc;
|
||||
struct ifnet;
|
||||
|
||||
int cdx_dpa_bridge_init(void);
|
||||
void cdx_dpa_bridge_destroy(void);
|
||||
|
|
@ -18,10 +19,15 @@ void cdx_dpa_bridge_print_dtsec(void);
|
|||
|
||||
/* dtsec lookup helpers for devman */
|
||||
struct dtsec_softc *cdx_dpa_bridge_find_dtsec(const char *ifname);
|
||||
struct ifnet *cdx_dpa_bridge_find_ifnet(const char *ifname);
|
||||
struct dtsec_softc *cdx_dpa_bridge_find_dtsec_by_ethid(uint8_t eth_id);
|
||||
const char *cdx_dpa_bridge_find_ifname_by_fman_params(uint32_t fm_index,
|
||||
uint32_t port_idx, uint32_t type);
|
||||
t_Handle cdx_dpa_bridge_get_rx_pool(void);
|
||||
void *cdx_dpa_bridge_get_rx_sc(void);
|
||||
void cdx_dpa_bridge_rx_buf_free(void *sc_opaque, void *buf);
|
||||
unsigned int cdx_dpa_bridge_rx_pool_refill(void *sc_opaque,
|
||||
unsigned int count);
|
||||
|
||||
/* OH port discovery and lookup (CDX port number is 1-based) */
|
||||
void cdx_dpa_bridge_discover_oh_ports(void);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
|
||||
#include "cdx_ioctl.h"
|
||||
#include "cdx_dpa_bridge.h"
|
||||
|
|
@ -32,6 +36,11 @@
|
|||
#include <dev/dpaa/fman.h>
|
||||
#include <dev/dpaa/fman_chardev.h>
|
||||
#include <dev/dpaa/bman.h>
|
||||
#include <dev/dpaa/dpaa_oh.h>
|
||||
|
||||
/* From if_dtsec.h — forward declare to avoid pulling in NCSW port types */
|
||||
void dtsec_rm_buf_free_external(uint8_t bpid, void *buf);
|
||||
void dtsec_rm_pool_rx_refill_bpid(uint8_t bpid);
|
||||
|
||||
/* NCSW types (t_Handle) */
|
||||
#include <contrib/ncsw/inc/ncsw_ext.h>
|
||||
|
|
@ -46,6 +55,15 @@
|
|||
extern t_Error ExternalHashTableModifyMissNextEngine(t_Handle h_HashTbl,
|
||||
t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
|
||||
|
||||
/* Deferred RX delivery — kernel symbol from qman_portals.c */
|
||||
extern void qman_rx_defer(struct mbuf *m);
|
||||
|
||||
/* DPAA FD accessors — from dpaa_ext.h */
|
||||
#include <contrib/ncsw/inc/Peripherals/dpaa_ext.h>
|
||||
|
||||
/* FM_PORT_BUFFER_SIZE — from dtsec_rm.c */
|
||||
#define CDX_RX_BUFFER_SIZE 9600
|
||||
|
||||
/* FreeBSD QMan API — kernel symbol resolution */
|
||||
extern t_Handle qman_fqr_create(uint32_t fqids_num,
|
||||
e_QmFQChannel channel, uint8_t wq, bool force_fqid,
|
||||
|
|
@ -55,6 +73,7 @@ extern t_Handle qman_fqr_create(uint32_t fqids_num,
|
|||
extern t_Error qman_fqr_register_cb(t_Handle fqr,
|
||||
t_QmReceivedFrameCallback *callback, t_Handle app);
|
||||
extern t_Error qman_fqr_free(t_Handle fqr);
|
||||
extern void qman_portal_quiesce(void);
|
||||
extern void dtsec_release_rss_fqrs(void);
|
||||
|
||||
/* Global fman_info pointer (declared in cdx_dpa_stub.c) */
|
||||
|
|
@ -77,6 +96,7 @@ extern int cdx_qos_init_ingress_profiles(void);
|
|||
#endif
|
||||
|
||||
#define PORTID_SHIFT_VAL 8
|
||||
#define CDX_NUM_RX_CPUS 4 /* LS1046A quad-core */
|
||||
|
||||
/*
|
||||
* Distribution FQR tracking for cleanup.
|
||||
|
|
@ -85,39 +105,114 @@ extern int cdx_qos_init_ingress_profiles(void);
|
|||
static t_Handle cdx_dist_fqrs[CDX_MAX_DIST_FQRS];
|
||||
static int cdx_num_dist_fqrs;
|
||||
|
||||
/* Global BMan pool handle for releasing buffers in CDX dist FQ callback */
|
||||
static t_Handle cdx_rx_pool;
|
||||
/* Global BMan pool handle for releasing buffers in dist FQ callback */
|
||||
/* cdx_rx_pool removed — buffers now freed via dtsec_rm_buf_free_external */
|
||||
|
||||
/*
|
||||
* cdx_dist_mext_free — mbuf external storage free for dist FQ frames.
|
||||
*
|
||||
* Uses the dtsec driver's dtsec_rm_buf_free_external() to properly:
|
||||
* 1. Map BPID → dtsec_softc (correct per-port UMA zone)
|
||||
* 2. Recover stashed KVA pointer from buffer privData
|
||||
* 3. Free to UMA zone (driver's refill path replenishes BMan)
|
||||
* 4. Decrement sc_rx_buf_total (prevents refill stall)
|
||||
*
|
||||
* ext_arg1 = buffer DMAP address (from FD).
|
||||
* ext_arg2 = (void *)(uintptr_t)bpid.
|
||||
*/
|
||||
static void
|
||||
cdx_dist_mext_free(struct mbuf *m)
|
||||
{
|
||||
void *buf;
|
||||
uint8_t bpid;
|
||||
|
||||
buf = m->m_ext.ext_arg1;
|
||||
bpid = (uint8_t)(uintptr_t)m->m_ext.ext_arg2;
|
||||
if (buf != NULL)
|
||||
dtsec_rm_buf_free_external(bpid, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* cdx_dist_fq_rx_callback — Callback for CDX distribution FQs.
|
||||
*
|
||||
* Frames arriving here matched a KG distribution scheme but didn't
|
||||
* match any hash table entry (and weren't caught by the miss action).
|
||||
* This shouldn't normally happen with correct PCD config, but if it
|
||||
* does we must release the BMan buffer to avoid pool exhaustion.
|
||||
* Frames arriving here are miss frames from CDX enhanced hash tables:
|
||||
* they matched a KG distribution scheme but no CDX flow entry.
|
||||
*
|
||||
* For dtsec ports: build an mbuf and deliver to the FreeBSD network
|
||||
* stack via qman_rx_defer (deferred delivery avoids nested portal
|
||||
* locks). This matches Linux where distribution FQs use the same
|
||||
* rx_default_dqrr callback as regular driver RX FQs.
|
||||
*
|
||||
* For OH ports (WiFi, IPsec): dispatch to registered handler via BPID.
|
||||
*
|
||||
* The app parameter carries the dtsec ifnet pointer (set during FQ
|
||||
* creation in cdx_create_port_fqs). NULL means no dtsec mapping.
|
||||
*/
|
||||
static volatile uint64_t cdx_dist_fq_rx_count;
|
||||
|
||||
static e_RxStoreResponse
|
||||
cdx_dist_fq_rx_callback(t_Handle app __unused, t_Handle qm_fqr,
|
||||
cdx_dist_fq_rx_callback(t_Handle app, t_Handle qm_fqr,
|
||||
t_Handle qm_portal __unused, uint32_t fqid_offset,
|
||||
t_DpaaFD *frame)
|
||||
{
|
||||
dpaa_oh_dist_cb_t fn;
|
||||
t_Handle fn_app;
|
||||
void *frame_va;
|
||||
|
||||
/* Check for registered OH port handler (WiFi, IPsec, etc.) */
|
||||
fn = dpaa_oh_lookup_dist_cb(frame->bpid, &fn_app);
|
||||
if (fn != NULL)
|
||||
return (fn(fn_app, qm_fqr, qm_portal, fqid_offset, frame));
|
||||
|
||||
frame_va = DPAA_FD_GET_ADDR(frame);
|
||||
if (frame_va == NULL)
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
|
||||
/*
|
||||
* Dtsec miss frames: build mbuf and deliver to stack.
|
||||
* app is the ifnet pointer set by cdx_create_port_fqs.
|
||||
*/
|
||||
if (app != NULL) {
|
||||
if_t ifp = (if_t)app;
|
||||
struct mbuf *m;
|
||||
|
||||
m = m_gethdr(M_NOWAIT, MT_HEADER);
|
||||
if (m == NULL)
|
||||
goto drop;
|
||||
|
||||
m_extadd(m, frame_va, CDX_RX_BUFFER_SIZE,
|
||||
cdx_dist_mext_free, frame_va,
|
||||
(void *)(uintptr_t)frame->bpid, 0,
|
||||
EXT_NET_DRV);
|
||||
|
||||
m->m_pkthdr.rcvif = ifp;
|
||||
m->m_data = (char *)frame_va + DPAA_FD_GET_OFFSET(frame);
|
||||
m->m_len = DPAA_FD_GET_LENGTH(frame);
|
||||
m->m_pkthdr.len = m->m_len;
|
||||
|
||||
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
|
||||
if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);
|
||||
|
||||
qman_rx_defer(m);
|
||||
dtsec_rm_pool_rx_refill_bpid(frame->bpid);
|
||||
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
|
||||
drop:
|
||||
/* No dtsec mapping — log and return buffer via driver path */
|
||||
atomic_fetchadd_64(&cdx_dist_fq_rx_count, 1);
|
||||
if (cdx_dist_fq_rx_count <= 5 ||
|
||||
(cdx_dist_fq_rx_count % 100000) == 0) {
|
||||
uint32_t base_fqid = QM_FQR_GetFqid(qm_fqr);
|
||||
printf("cdx: dist_fq_rx_callback: count=%ju "
|
||||
"fqid=0x%x (base=0x%x+%u)\n",
|
||||
"fqid=0x%x (base=0x%x+%u) DROPPED\n",
|
||||
(uintmax_t)cdx_dist_fq_rx_count,
|
||||
base_fqid + fqid_offset, base_fqid, fqid_offset);
|
||||
}
|
||||
|
||||
frame_va = DPAA_FD_GET_ADDR(frame);
|
||||
if (frame_va != NULL && cdx_rx_pool != NULL)
|
||||
bman_put_buffer(cdx_rx_pool, frame_va);
|
||||
if (frame_va != NULL)
|
||||
dtsec_rm_buf_free_external(frame->bpid, frame_va);
|
||||
|
||||
return (e_RX_STORE_RESPONSE_CONTINUE);
|
||||
}
|
||||
|
|
@ -145,19 +240,28 @@ cdx_create_port_fqs(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* Grab BMan pool handle from first dtsec for buffer release in
|
||||
* dist FQ callback. All dtsec interfaces share the same pool. */
|
||||
if (cdx_rx_pool == NULL)
|
||||
cdx_rx_pool = cdx_dpa_bridge_get_rx_pool();
|
||||
/* Buffer free now uses dtsec_rm_buf_free_external(bpid, buf)
|
||||
* which maps BPID → per-port UMA zone. No pool handle needed. */
|
||||
|
||||
for (i = 0; i < fi->max_ports; i++) {
|
||||
struct cdx_port_info *pi = &fi->portinfo[i];
|
||||
struct cdx_dist_info *di = pi->dist_info;
|
||||
uint32_t portid = pi->portid;
|
||||
if_t ifp;
|
||||
|
||||
if (di == NULL || pi->max_dist == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Look up the dtsec ifnet for this port.
|
||||
* pi->name was resolved to kernel name (e.g. "dtsec3")
|
||||
* in Step 1 of set_dpa_params. OH ports have type==0
|
||||
* and won't match — ifp will be NULL, and the callback
|
||||
* will fall through to the OH/drop path.
|
||||
*/
|
||||
ifp = (pi->type != 0) ?
|
||||
cdx_dpa_bridge_find_ifnet(pi->name) : NULL;
|
||||
|
||||
for (j = 0; j < pi->max_dist; j++) {
|
||||
uint32_t fqid;
|
||||
uint32_t count;
|
||||
|
|
@ -171,7 +275,8 @@ cdx_create_port_fqs(void)
|
|||
(portid << PORTID_SHIFT_VAL);
|
||||
|
||||
fqr = qman_fqr_create(count,
|
||||
e_QM_FQ_CHANNEL_POOL1, /* pool channel */
|
||||
(e_QmFQChannel)(e_QM_FQ_CHANNEL_SWPORTAL0 +
|
||||
(fqid % CDX_NUM_RX_CPUS)),
|
||||
1, /* wq */
|
||||
true, /* force_fqid */
|
||||
fqid, /* specific FQID */
|
||||
|
|
@ -190,7 +295,7 @@ cdx_create_port_fqs(void)
|
|||
}
|
||||
|
||||
qman_fqr_register_cb(fqr,
|
||||
cdx_dist_fq_rx_callback, NULL);
|
||||
cdx_dist_fq_rx_callback, ifp);
|
||||
|
||||
if (nfqr < CDX_MAX_DIST_FQRS)
|
||||
cdx_dist_fqrs[nfqr] = fqr;
|
||||
|
|
@ -204,6 +309,69 @@ cdx_create_port_fqs(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* Forward declaration for cdx_dpa_bridge.c */
|
||||
void cdx_destroy_port_fqs(void);
|
||||
|
||||
/*
|
||||
* cdx_destroy_port_fqs — Free all CDX distribution FQRs.
|
||||
*
|
||||
* Called from cdx_dpa_bridge_destroy() during module unload, BEFORE
|
||||
* hash table deletion. Retires each FQ via QMan hardware (RETIRE →
|
||||
* OOS → destroy), then quiesces all portal poll tasks to ensure no
|
||||
* in-flight QM_PORTAL_Poll() call references the about-to-be-freed
|
||||
* CDX callback function.
|
||||
*/
|
||||
void
|
||||
cdx_destroy_port_fqs(void)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
n = cdx_num_dist_fqrs;
|
||||
if (n > CDX_MAX_DIST_FQRS)
|
||||
n = CDX_MAX_DIST_FQRS;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (cdx_dist_fqrs[i] != NULL) {
|
||||
qman_fqr_free(cdx_dist_fqrs[i]);
|
||||
cdx_dist_fqrs[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* After retiring all FQs, drain all per-CPU portal taskqueues.
|
||||
* A portal poll task on another CPU may be mid-iteration with a
|
||||
* DQRR entry already fetched before the retire took effect.
|
||||
* taskqueue_drain() waits for any in-flight poll to complete.
|
||||
*/
|
||||
qman_portal_quiesce();
|
||||
|
||||
printf("cdx: destroy_port_fqs: %d FQRs freed\n", n);
|
||||
cdx_num_dist_fqrs = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the Ethernet distribution KG scheme handle from portinfo.
|
||||
* Scans all ports' dist_info for type == ETHERNET_DIST.
|
||||
* Returns the resolved NCSW scheme handle, or NULL if not found.
|
||||
*
|
||||
* Based on Linux vendor get_ethdist_info_by_fman_params()
|
||||
* (dpa_cfg.c:214) with the dist++ loop bug fixed.
|
||||
*/
|
||||
static t_Handle
|
||||
get_ethdist_scheme_handle(struct cdx_port_info *pinfo, uint32_t nports)
|
||||
{
|
||||
uint32_t i, j;
|
||||
|
||||
for (i = 0; i < nports; i++) {
|
||||
struct cdx_dist_info *d = pinfo[i].dist_info;
|
||||
for (j = 0; j < pinfo[i].max_dist; j++, d++) {
|
||||
if (d->type == ETHERNET_DIST)
|
||||
return (d->handle);
|
||||
}
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* cdx_ioc_set_dpa_params — Handle CDX_CTRL_DPA_SET_PARAMS ioctl.
|
||||
*
|
||||
|
|
@ -213,10 +381,10 @@ cdx_create_port_fqs(void)
|
|||
*
|
||||
* Flow:
|
||||
* 1. copyin fman_info, table_info, port_info, dist_info from userspace
|
||||
* 2. Resolve chardev handle IDs to NCSW hash table handles
|
||||
* 3. Bind each NCSW hash table to CDX (ExternalHashTableBindNCSW)
|
||||
* 4. Tear down old standalone hash tables
|
||||
* 5. Install new metadata into global fman_info
|
||||
* 2. Resolve chardev handle IDs (hash tables + KG scheme handles)
|
||||
* 3. Install new metadata into global fman_info
|
||||
* 4. Create policer profiles, then patch miss actions (KG + PLCR)
|
||||
* 5. Create distribution FQs, register OH ports
|
||||
*/
|
||||
int
|
||||
cdx_ioc_set_dpa_params(unsigned long args)
|
||||
|
|
@ -230,7 +398,7 @@ cdx_ioc_set_dpa_params(unsigned long args)
|
|||
device_t fmdev;
|
||||
struct fmcd_softc *fmcd;
|
||||
t_Handle pcd_handle, fm_handle, muram_handle;
|
||||
uint32_t i, num_tables, max_ports, total_dists;
|
||||
uint32_t i, j, num_tables, max_ports, total_dists;
|
||||
int error;
|
||||
|
||||
params = (struct cdx_ctrl_set_dpa_params *)args;
|
||||
|
|
@ -425,6 +593,36 @@ cdx_ioc_set_dpa_params(unsigned long args)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 3.5: Resolve dist_info scheme handles.
|
||||
*
|
||||
* dpa_app stores chardev device IDs in dist_info[].handle
|
||||
* (from FM_PCD_Get_Sch_handle via fmlib). Translate to
|
||||
* kernel NCSW KG scheme pointers for use in miss fixup.
|
||||
*/
|
||||
if (k_pinfo != NULL) {
|
||||
for (i = 0; i < max_ports; i++) {
|
||||
struct cdx_dist_info *d = k_pinfo[i].dist_info;
|
||||
for (j = 0; j < k_pinfo[i].max_dist; j++, d++) {
|
||||
if (d->handle != NULL) {
|
||||
t_Handle resolved =
|
||||
fmcd_handle_resolve(fmcd,
|
||||
(uint64_t)(uintptr_t)d->handle,
|
||||
FMCD_HDL_KG_SCHEME);
|
||||
if (resolved == NULL) {
|
||||
printf("cdx: set_dpa_params: "
|
||||
"port %u dist %u: bad "
|
||||
"scheme handle 0x%lx\n",
|
||||
i, j,
|
||||
(unsigned long)(uintptr_t)
|
||||
d->handle);
|
||||
}
|
||||
d->handle = resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 4: copyin ipr_info (optional).
|
||||
*/
|
||||
|
|
@ -440,75 +638,6 @@ cdx_ioc_set_dpa_params(unsigned long args)
|
|||
/* Store in global for cdx_init_ip_reassembly() */
|
||||
ipr_info = k_ipr;
|
||||
|
||||
/*
|
||||
* Step 5: Patch miss actions on CDX enhanced hash tables.
|
||||
*
|
||||
* With USE_ENHANCED_EHASH, FM_PCD_HashTableSet creates CDX
|
||||
* enhanced hash tables directly (via ExternalHashTableSet).
|
||||
* k_tinfo[].id was resolved from chardev handle IDs to
|
||||
* en_exthash_info* kernel pointers in step 2.5 above.
|
||||
*
|
||||
* Patch each table's miss action to enqueue unmatched frames
|
||||
* to the dtsec driver's RX default FQID (so misses reach the
|
||||
* FreeBSD network stack).
|
||||
*
|
||||
* port_idx is a bitmask: bit N set = table belongs to portid N.
|
||||
* CDX portids 0-7 map to fmlib RX indexes (fmcd rx_port_fqids[]).
|
||||
*/
|
||||
{
|
||||
uint32_t patched = 0, skipped = 0;
|
||||
|
||||
for (i = 0; i < num_tables; i++) {
|
||||
uint32_t port_bits, bit;
|
||||
uint32_t rx_fqid;
|
||||
|
||||
if (k_tinfo[i].id == NULL ||
|
||||
(uintptr_t)k_tinfo[i].id < VM_MIN_KERNEL_ADDRESS ||
|
||||
k_tinfo[i].dpa_type != DPA_CLS_TBL_EXTERNAL_HASH) {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Find the first physical port and its RX FQID */
|
||||
port_bits = k_tinfo[i].port_idx;
|
||||
rx_fqid = 0;
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
if (port_bits & (1U << bit)) {
|
||||
rx_fqid = fmcd_get_rx_dflt_fqid(
|
||||
fmcd, bit);
|
||||
if (rx_fqid != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_fqid != 0) {
|
||||
t_FmPcdCcNextEngineParams miss_params;
|
||||
|
||||
memset(&miss_params, 0, sizeof(miss_params));
|
||||
miss_params.nextEngine = e_FM_PCD_DONE;
|
||||
miss_params.params.enqueueParams.action =
|
||||
e_FM_PCD_ENQ_FRAME;
|
||||
miss_params.params.enqueueParams.overrideFqid =
|
||||
TRUE;
|
||||
miss_params.params.enqueueParams.newFqid =
|
||||
rx_fqid;
|
||||
|
||||
ExternalHashTableModifyMissNextEngine(
|
||||
k_tinfo[i].id, &miss_params);
|
||||
}
|
||||
patched++;
|
||||
if (patched <= 3 || (patched % 20) == 0) {
|
||||
printf("cdx: set_dpa_params: table %u '%s' "
|
||||
"miss -> FQID %u\n",
|
||||
i, k_tinfo[i].name, rx_fqid);
|
||||
}
|
||||
}
|
||||
|
||||
printf("cdx: set_dpa_params: miss fixup complete — "
|
||||
"%u patched, %u skipped (of %u tables)\n",
|
||||
patched, skipped, num_tables);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 7: Install new state into global fman_info.
|
||||
*
|
||||
|
|
@ -556,7 +685,124 @@ cdx_ioc_set_dpa_params(unsigned long args)
|
|||
printf("cdx: set_dpa_params: expt policer init failed\n");
|
||||
|
||||
/*
|
||||
* Step 7c: Create ingress QoS policer profiles.
|
||||
* Step 7c: Patch miss actions on CDX enhanced hash tables.
|
||||
*
|
||||
* Match Linux vendor cdxdrv_set_miss_action() (dpa_cfg.c:416):
|
||||
* - ETHERNET / PPPOE tables → PLCR policer (rate-limits
|
||||
* exception traffic, breaks CC re-entry loop)
|
||||
* - All other tables → KG scheme with CC_EN (re-enters
|
||||
* CC tree, eventually hits Ethernet table's PLCR miss)
|
||||
*/
|
||||
{
|
||||
t_Handle eth_scheme;
|
||||
uint32_t patched = 0, skipped = 0;
|
||||
|
||||
eth_scheme = get_ethdist_scheme_handle(k_pinfo,
|
||||
max_ports);
|
||||
if (eth_scheme == NULL)
|
||||
printf("cdx: set_dpa_params: WARNING: no "
|
||||
"Ethernet distribution scheme found\n");
|
||||
else
|
||||
printf("cdx: set_dpa_params: eth dist scheme "
|
||||
"%p\n", eth_scheme);
|
||||
|
||||
for (i = 0; i < num_tables; i++) {
|
||||
t_FmPcdCcNextEngineParams miss_params;
|
||||
|
||||
if (k_tinfo[i].id == NULL ||
|
||||
(uintptr_t)k_tinfo[i].id <
|
||||
VM_MIN_KERNEL_ADDRESS ||
|
||||
k_tinfo[i].dpa_type !=
|
||||
DPA_CLS_TBL_EXTERNAL_HASH) {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&miss_params, 0, sizeof(miss_params));
|
||||
|
||||
if (k_tinfo[i].type != ETHERNET_TABLE &&
|
||||
k_tinfo[i].type != PPPOE_RELAY_TABLE) {
|
||||
/*
|
||||
* Non-Ethernet tables: KG scheme miss.
|
||||
* KG re-enters CC tree (CC_EN), frame
|
||||
* eventually reaches Ethernet table
|
||||
* whose PLCR miss breaks the loop.
|
||||
*/
|
||||
if (eth_scheme == NULL) {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
miss_params.nextEngine = e_FM_PCD_KG;
|
||||
miss_params.params.kgParams
|
||||
.h_DirectScheme = eth_scheme;
|
||||
} else {
|
||||
/*
|
||||
* Ethernet / PPPoE tables: PLCR miss.
|
||||
* Rate-limits exception traffic and
|
||||
* enqueues to default FQID (set by KG
|
||||
* on initial classification).
|
||||
*/
|
||||
miss_params.nextEngine = e_FM_PCD_PLCR;
|
||||
miss_params.params.plcrParams
|
||||
.sharedProfile = 1;
|
||||
miss_params.params.plcrParams
|
||||
.newRelativeProfileId =
|
||||
CDX_EXPT_ETH_RATELIMIT;
|
||||
}
|
||||
|
||||
if (ExternalHashTableModifyMissNextEngine(
|
||||
k_tinfo[i].id, &miss_params) != E_OK) {
|
||||
printf("cdx: set_dpa_params: "
|
||||
"miss fixup FAILED table %u '%s'\n",
|
||||
i, k_tinfo[i].name);
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
patched++;
|
||||
|
||||
printf("cdx: set_dpa_params: table %u '%s' "
|
||||
"type %u miss -> %s\n",
|
||||
i, k_tinfo[i].name, k_tinfo[i].type,
|
||||
(miss_params.nextEngine == e_FM_PCD_PLCR) ?
|
||||
"PLCR" : "KG");
|
||||
}
|
||||
|
||||
/*
|
||||
* Sync FMan PCD Host Command channel after all
|
||||
* miss action modifications. Flushes any FMan
|
||||
* internal caches so the microcode sees the
|
||||
* updated MURAM AD values.
|
||||
*/
|
||||
if (patched > 0) {
|
||||
int sync_err = 0;
|
||||
for (i = 0; i < num_tables; i++) {
|
||||
if (k_tinfo[i].id == NULL ||
|
||||
(uintptr_t)k_tinfo[i].id <
|
||||
VM_MIN_KERNEL_ADDRESS ||
|
||||
k_tinfo[i].dpa_type !=
|
||||
DPA_CLS_TBL_EXTERNAL_HASH)
|
||||
continue;
|
||||
if (ExternalHashTableFmPcdHcSync(
|
||||
k_tinfo[i].id) != 0) {
|
||||
printf("cdx: set_dpa_params: "
|
||||
"HcSync failed table %u\n",
|
||||
i);
|
||||
sync_err++;
|
||||
}
|
||||
}
|
||||
if (sync_err == 0)
|
||||
printf("cdx: set_dpa_params: "
|
||||
"HcSync OK (%u tables)\n",
|
||||
patched);
|
||||
}
|
||||
|
||||
printf("cdx: set_dpa_params: miss fixup complete — "
|
||||
"%u patched, %u skipped (of %u tables)\n",
|
||||
patched, skipped, num_tables);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 7d: Create ingress QoS policer profiles.
|
||||
* Per-queue rate limiting for offloaded flows.
|
||||
*/
|
||||
#ifdef ENABLE_INGRESS_QOS
|
||||
|
|
@ -564,6 +810,24 @@ cdx_ioc_set_dpa_params(unsigned long args)
|
|||
printf("cdx: set_dpa_params: ingress policer init failed\n");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Step 7e: Register OH ports in devman interface list.
|
||||
*
|
||||
* The Linux dpa_cfg.c iterates portinfo and calls
|
||||
* cdx_add_oh_iface() for each OH port (type==0). We must
|
||||
* do the same here — fman_info->portinfo is now set, so
|
||||
* get_dpa_oh_iface_info() can resolve portids from the XML.
|
||||
*/
|
||||
for (i = 0; i < max_ports; i++) {
|
||||
if (k_pinfo[i].type == 0) {
|
||||
if (cdx_add_oh_iface(k_pinfo[i].name) != 0) {
|
||||
printf("cdx: set_dpa_params: "
|
||||
"OH port %s add failed\n",
|
||||
k_pinfo[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 8: Create QMan FQs for CDX distribution FQIDs.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@ SRCS= cmm.c \
|
|||
cmm_vlan.c \
|
||||
cmm_ipsec.c \
|
||||
cmm_tunnel.c \
|
||||
cmm_ctrl.c
|
||||
cmm_ctrl.c \
|
||||
cmm_wifi.c
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../fci_lib
|
||||
CFLAGS+= -I${.CURDIR}/../fci
|
||||
CFLAGS+= -I${.CURDIR}/../include
|
||||
CFLAGS+= -DLS1043
|
||||
CFLAGS+= -DWIFI_ENABLE
|
||||
CFLAGS+= -Wall -Wextra -Wno-unused-parameter
|
||||
|
||||
# libfci
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ FCI_HDR= ${SRCDIR}/fci
|
|||
CMM_SRCS= cmm.c cmm_conn.c cmm_route.c cmm_neigh.c \
|
||||
cmm_itf.c cmm_rtsock.c cmm_fe.c cmm_offload.c \
|
||||
cmm_vlan.c cmm_ipsec.c cmm_tunnel.c cmm_deny.c \
|
||||
cmm_socket.c cmm_bridge.c cmm_ctrl.c cmm_l2tp.c
|
||||
cmm_socket.c cmm_bridge.c cmm_ctrl.c cmm_l2tp.c \
|
||||
cmm_wifi.c
|
||||
CMM_OBJS= ${CMM_SRCS:.c=.o}
|
||||
|
||||
PROG= cmm
|
||||
|
|
@ -32,6 +33,7 @@ CFLAGS+= --sysroot=${SYSROOT} ${TARGET}
|
|||
CFLAGS+= -I${FCI_DIR} -I${FCI_HDR} -I${SRCDIR}/include -I${CMM_DIR} \
|
||||
-I${SRCDIR}/auto_bridge -I${SRCDIR}/pf_notify
|
||||
CFLAGS+= -DLS1043
|
||||
CFLAGS+= -DWIFI_ENABLE
|
||||
|
||||
LDFLAGS= ${TARGET} --sysroot=${SYSROOT}
|
||||
LIBS=
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "cmm_deny.h"
|
||||
#include "cmm_socket.h"
|
||||
#include "cmm_bridge.h"
|
||||
#include "cmm_wifi.h"
|
||||
#include "cmm_ctrl.h"
|
||||
#include "pf_notify.h"
|
||||
#include "libfci.h"
|
||||
|
|
@ -258,6 +259,7 @@ main(int argc, char *argv[])
|
|||
cmm_l2tp_init(g);
|
||||
cmm_socket_init();
|
||||
cmm_bridge_init(g);
|
||||
cmm_wifi_init(g);
|
||||
|
||||
if (cmm_ipsec_init() < 0)
|
||||
goto out;
|
||||
|
|
@ -433,6 +435,7 @@ out:
|
|||
cmm_ctrl_fini(g);
|
||||
cmm_sa_flush_all(g);
|
||||
cmm_conn_deregister_all(g);
|
||||
cmm_wifi_fini(g);
|
||||
cmm_bridge_fini(g);
|
||||
cmm_socket_fini(g);
|
||||
cmm_l2tp_fini(g);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ cmm_fe_route_register(struct cmm_global *g, struct cmm_route *rt)
|
|||
if (itf == NULL)
|
||||
return (-1);
|
||||
|
||||
/* Skip loopback — CDX can't offload local delivery routes */
|
||||
if (strncmp(itf->ifname, "lo", 2) == 0)
|
||||
return (-1);
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.action = FPP_ACTION_REGISTER;
|
||||
cmd.mtu = rt->mtu;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "cmm_vlan.h"
|
||||
#include "cmm_tunnel.h"
|
||||
#include "cmm_bridge.h"
|
||||
#include "cmm_wifi.h"
|
||||
|
||||
static struct list_head itf_hash[ITF_HASH_SIZE];
|
||||
|
||||
|
|
@ -146,6 +147,21 @@ mask_to_prefixlen(sa_family_t af, const void *mask)
|
|||
* Probe an interface for 802.1Q VLAN membership using SIOCGETVLAN.
|
||||
* If successful, populates vlan_id, parent_ifindex, and sets ITF_F_VLAN.
|
||||
*/
|
||||
/*
|
||||
* Detect WiFi VAP interfaces by name prefix.
|
||||
* mwifiex creates "uap0", "uap1", etc.
|
||||
*/
|
||||
static void
|
||||
itf_detect_wifi(struct cmm_interface *itf)
|
||||
{
|
||||
if (strncmp(itf->ifname, "uap", 3) == 0 ||
|
||||
strncmp(itf->ifname, "wlan", 4) == 0) {
|
||||
itf->itf_flags |= ITF_F_WIFI;
|
||||
cmm_print(CMM_LOG_INFO,
|
||||
"itf: %s is WiFi VAP", itf->ifname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
itf_detect_vlan(struct cmm_interface *itf, int sd)
|
||||
{
|
||||
|
|
@ -235,16 +251,18 @@ cmm_itf_init(void)
|
|||
itf_detect_tunnel(itf, sd);
|
||||
close(sd);
|
||||
}
|
||||
itf_detect_wifi(itf);
|
||||
}
|
||||
|
||||
cmm_print(CMM_LOG_INFO,
|
||||
"itf: %s idx=%d mac=%02x:%02x:%02x:%02x:%02x:%02x "
|
||||
"mtu=%u flags=0x%x",
|
||||
"mtu=%u flags=0x%x%s",
|
||||
itf->ifname, itf->ifindex,
|
||||
itf->macaddr[0], itf->macaddr[1],
|
||||
itf->macaddr[2], itf->macaddr[3],
|
||||
itf->macaddr[4], itf->macaddr[5],
|
||||
itf->mtu, itf->flags);
|
||||
itf->mtu, itf->flags,
|
||||
(itf->itf_flags & ITF_F_WIFI) ? " WIFI" : "");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +364,18 @@ cmm_itf_handle_ifinfo(struct cmm_global *g, void *msg, int msglen)
|
|||
if (ifm->ifm_data.ifi_type == IFT_BRIDGE)
|
||||
itf->itf_flags |= ITF_F_BRIDGE;
|
||||
|
||||
/* Populate MTU, MAC, and detect VLAN via ioctl */
|
||||
/* Extract MAC from RTM_IFINFO sockaddr_dl */
|
||||
if (ifm->ifm_addrs & RTA_IFP) {
|
||||
struct sockaddr_dl *sdl;
|
||||
|
||||
sdl = (struct sockaddr_dl *)(ifm + 1);
|
||||
if (sdl->sdl_family == AF_LINK &&
|
||||
sdl->sdl_alen == ETHER_ADDR_LEN)
|
||||
memcpy(itf->macaddr, LLADDR(sdl),
|
||||
ETHER_ADDR_LEN);
|
||||
}
|
||||
|
||||
/* Populate MTU and detect VLAN/tunnel/WiFi */
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int sd;
|
||||
|
|
@ -362,11 +391,18 @@ cmm_itf_handle_ifinfo(struct cmm_global *g, void *msg, int msglen)
|
|||
itf_detect_tunnel(itf, sd);
|
||||
close(sd);
|
||||
}
|
||||
itf_detect_wifi(itf);
|
||||
}
|
||||
|
||||
cmm_print(CMM_LOG_INFO,
|
||||
"itf: new %s idx=%d mtu=%u",
|
||||
itf->ifname, itf->ifindex, itf->mtu);
|
||||
"itf: new %s idx=%d mac=%02x:%02x:%02x:%02x:%02x:%02x "
|
||||
"mtu=%u flags=0x%x%s",
|
||||
itf->ifname, itf->ifindex,
|
||||
itf->macaddr[0], itf->macaddr[1],
|
||||
itf->macaddr[2], itf->macaddr[3],
|
||||
itf->macaddr[4], itf->macaddr[5],
|
||||
itf->mtu, ifm->ifm_flags,
|
||||
(itf->itf_flags & ITF_F_WIFI) ? " WIFI" : "");
|
||||
}
|
||||
|
||||
if (itf->flags != (uint32_t)ifm->ifm_flags) {
|
||||
|
|
@ -385,9 +421,10 @@ cmm_itf_handle_ifinfo(struct cmm_global *g, void *msg, int msglen)
|
|||
itf->mtu = ifm->ifm_data.ifi_mtu;
|
||||
}
|
||||
|
||||
/* Notify VLAN, tunnel, and bridge modules of flag changes */
|
||||
/* Notify VLAN, tunnel, WiFi, and bridge modules of flag changes */
|
||||
cmm_vlan_notify(g, itf);
|
||||
cmm_tunnel_notify(g, itf);
|
||||
cmm_wifi_notify(g, itf);
|
||||
|
||||
/* If this is a bridge or a potential bridge member, rescan */
|
||||
if ((itf->itf_flags & ITF_F_BRIDGE) ||
|
||||
|
|
@ -593,3 +630,21 @@ cmm_itf_foreach_l2tp(struct cmm_global *g, cmm_itf_l2tp_fn fn)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cmm_itf_foreach_wifi(struct cmm_global *g, cmm_itf_wifi_fn fn)
|
||||
{
|
||||
struct list_head *bucket, *pos;
|
||||
struct cmm_interface *itf;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ITF_HASH_SIZE; i++) {
|
||||
bucket = &itf_hash[i];
|
||||
for (pos = list_first(bucket); pos != bucket;
|
||||
pos = list_next(pos)) {
|
||||
itf = container_of(pos, struct cmm_interface, entry);
|
||||
if (itf->itf_flags & ITF_F_WIFI)
|
||||
fn(g, itf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ struct cmm_ifaddr {
|
|||
#define ITF_F_BRIDGE (1 << 4) /* Bridge interface */
|
||||
#define ITF_F_L2TP (1 << 5) /* L2TP tunnel interface */
|
||||
#define ITF_F_FPP_L2TP (1 << 6) /* L2TP registered in CDX */
|
||||
#define ITF_F_WIFI (1 << 7) /* WiFi VAP interface */
|
||||
#define ITF_F_FPP_WIFI (1 << 8) /* WiFi VAP registered in CDX */
|
||||
|
||||
struct cmm_route;
|
||||
|
||||
|
|
@ -89,6 +91,10 @@ void cmm_itf_foreach_tunnel(struct cmm_global *g, cmm_itf_tunnel_fn fn);
|
|||
typedef int (*cmm_itf_l2tp_fn)(struct cmm_global *, struct cmm_interface *);
|
||||
void cmm_itf_foreach_l2tp(struct cmm_global *g, cmm_itf_l2tp_fn fn);
|
||||
|
||||
/* Iterate all WiFi interfaces, calling fn for each with ITF_F_WIFI set */
|
||||
typedef int (*cmm_itf_wifi_fn)(struct cmm_global *, struct cmm_interface *);
|
||||
void cmm_itf_foreach_wifi(struct cmm_global *g, cmm_itf_wifi_fn fn);
|
||||
|
||||
/* Probe interface for tunnel endpoints (gif/gre) */
|
||||
void itf_detect_tunnel(struct cmm_interface *itf, int sd);
|
||||
|
||||
|
|
|
|||
170
fastpath/cmm/cmm_wifi.c
Normal file
170
fastpath/cmm/cmm_wifi.c
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* cmm_wifi.c — WiFi VAP offload
|
||||
*
|
||||
* Detects WiFi VAP interfaces (uap0, uap1, ...) and registers them
|
||||
* with CDX via FPP_CMD_WIFI_VAP_ENTRY so the hardware flow offload
|
||||
* engine recognizes WiFi as a valid egress/ingress interface.
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <net/if.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cmm.h"
|
||||
#include "cmm_wifi.h"
|
||||
#include "cmm_itf.h"
|
||||
|
||||
/*
|
||||
* Parse VAP ID from interface name: "uap0" → 0, "uap1" → 1, etc.
|
||||
* Returns -1 if the name doesn't match a WiFi VAP pattern.
|
||||
*/
|
||||
/*
|
||||
* Parse VAP ID from interface name.
|
||||
* uap interfaces use vapid 0..15, wlan interfaces use 16..31.
|
||||
* This avoids collisions since both "uap0" and "wlan0" would
|
||||
* otherwise both map to vapid 0.
|
||||
*/
|
||||
#define CMM_WLAN_VAPID_BASE 16
|
||||
|
||||
static int
|
||||
cmm_wifi_parse_vapid(const char *ifname)
|
||||
{
|
||||
const char *p;
|
||||
int base;
|
||||
|
||||
if (strncmp(ifname, "uap", 3) == 0) {
|
||||
p = ifname + 3;
|
||||
base = 0;
|
||||
} else if (strncmp(ifname, "wlan", 4) == 0) {
|
||||
p = ifname + 4;
|
||||
base = CMM_WLAN_VAPID_BASE;
|
||||
} else {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (*p < '0' || *p > '9')
|
||||
return (-1);
|
||||
return (base + (int)strtol(p, NULL, 10));
|
||||
}
|
||||
|
||||
static int
|
||||
cmm_wifi_register(struct cmm_global *g, struct cmm_interface *itf)
|
||||
{
|
||||
fpp_wifi_cmd_t cmd;
|
||||
int vap_id, rc;
|
||||
|
||||
if (!(itf->itf_flags & ITF_F_WIFI))
|
||||
return (0);
|
||||
if (itf->itf_flags & ITF_F_FPP_WIFI)
|
||||
return (0); /* already registered */
|
||||
|
||||
vap_id = cmm_wifi_parse_vapid(itf->ifname);
|
||||
if (vap_id < 0) {
|
||||
cmm_print(CMM_LOG_WARN,
|
||||
"wifi: %s: cannot parse VAP ID", itf->ifname);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.action = FPP_VWD_VAP_ADD;
|
||||
cmd.vap_id = vap_id;
|
||||
strlcpy(cmd.ifname, itf->ifname, sizeof(cmd.ifname));
|
||||
memcpy(cmd.mac_addr, itf->macaddr, 6);
|
||||
|
||||
cmm_print(CMM_LOG_INFO,
|
||||
"wifi: sending FPP_CMD_WIFI_VAP_ENTRY (0x%x) for %s "
|
||||
"vapid=%d len=%zu",
|
||||
FPP_CMD_WIFI_VAP_ENTRY, itf->ifname, vap_id,
|
||||
sizeof(cmd));
|
||||
|
||||
rc = fci_write(g->fci_handle, FPP_CMD_WIFI_VAP_ENTRY,
|
||||
sizeof(cmd), (unsigned short *)&cmd);
|
||||
if (rc != 0) {
|
||||
cmm_print(CMM_LOG_WARN,
|
||||
"wifi: register %s failed: %d", itf->ifname, rc);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
itf->itf_flags |= ITF_F_FPP_WIFI;
|
||||
cmm_print(CMM_LOG_INFO,
|
||||
"wifi: registered %s (vapid=%d mac=%02x:%02x:%02x:%02x:%02x:%02x)",
|
||||
itf->ifname, vap_id,
|
||||
itf->macaddr[0], itf->macaddr[1], itf->macaddr[2],
|
||||
itf->macaddr[3], itf->macaddr[4], itf->macaddr[5]);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cmm_wifi_deregister(struct cmm_global *g, struct cmm_interface *itf)
|
||||
{
|
||||
fpp_wifi_cmd_t cmd;
|
||||
int vap_id;
|
||||
|
||||
if (!(itf->itf_flags & ITF_F_FPP_WIFI))
|
||||
return (0);
|
||||
|
||||
vap_id = cmm_wifi_parse_vapid(itf->ifname);
|
||||
if (vap_id < 0)
|
||||
return (-1);
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.action = FPP_VWD_VAP_REMOVE;
|
||||
cmd.vap_id = vap_id;
|
||||
strlcpy(cmd.ifname, itf->ifname, sizeof(cmd.ifname));
|
||||
|
||||
fci_write(g->fci_handle, FPP_CMD_WIFI_VAP_ENTRY,
|
||||
sizeof(cmd), (unsigned short *)&cmd);
|
||||
|
||||
itf->itf_flags &= ~ITF_F_FPP_WIFI;
|
||||
cmm_print(CMM_LOG_INFO, "wifi: deregistered %s", itf->ifname);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
cmm_wifi_init(struct cmm_global *g)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Reset all WiFi VAP entries in CDX */
|
||||
rc = fci_write(g->fci_handle, FPP_CMD_WIFI_VAP_RESET, 0, NULL);
|
||||
if (rc != 0)
|
||||
cmm_print(CMM_LOG_WARN, "wifi: reset failed: %d", rc);
|
||||
|
||||
/* Register all existing UP WiFi interfaces */
|
||||
cmm_itf_foreach_wifi(g, cmm_wifi_register);
|
||||
|
||||
cmm_print(CMM_LOG_INFO, "wifi: initialized");
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
cmm_wifi_fini(struct cmm_global *g)
|
||||
{
|
||||
|
||||
cmm_itf_foreach_wifi(g, cmm_wifi_deregister);
|
||||
}
|
||||
|
||||
void
|
||||
cmm_wifi_notify(struct cmm_global *g, struct cmm_interface *itf)
|
||||
{
|
||||
|
||||
if (!(itf->itf_flags & ITF_F_WIFI))
|
||||
return;
|
||||
|
||||
cmm_print(CMM_LOG_INFO,
|
||||
"wifi: notify %s flags=0x%x itf_flags=0x%x%s%s",
|
||||
itf->ifname, itf->flags, itf->itf_flags,
|
||||
(itf->flags & IFF_UP) ? " UP" : " DOWN",
|
||||
(itf->itf_flags & ITF_F_FPP_WIFI) ? " REGISTERED" : "");
|
||||
|
||||
if ((itf->flags & IFF_UP) && !(itf->itf_flags & ITF_F_FPP_WIFI))
|
||||
cmm_wifi_register(g, itf);
|
||||
else if (!(itf->flags & IFF_UP) && (itf->itf_flags & ITF_F_FPP_WIFI))
|
||||
cmm_wifi_deregister(g, itf);
|
||||
}
|
||||
24
fastpath/cmm/cmm_wifi.h
Normal file
24
fastpath/cmm/cmm_wifi.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* cmm_wifi.h — WiFi VAP offload
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#ifndef CMM_WIFI_H
|
||||
#define CMM_WIFI_H
|
||||
|
||||
#include "cmm.h"
|
||||
|
||||
struct cmm_interface;
|
||||
|
||||
/* Reset CDX WiFi state and register all existing UP WiFi VAPs */
|
||||
int cmm_wifi_init(struct cmm_global *g);
|
||||
|
||||
/* Deregister all WiFi VAPs from CDX */
|
||||
void cmm_wifi_fini(struct cmm_global *g);
|
||||
|
||||
/* Called when interface flags change — register/deregister as needed */
|
||||
void cmm_wifi_notify(struct cmm_global *g, struct cmm_interface *itf);
|
||||
|
||||
#endif /* CMM_WIFI_H */
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The original is deeply Linux-coupled (linux/cdev.h, struct net_device,
|
||||
* struct qman_fq, etc.). CDX uses it only for the is_wlan_iface check
|
||||
* in cdx_ehash.c. Provide minimal stubs.
|
||||
* in cdx_ehash.c and for dpaa_get_vap_fwd_fq() in the TX path.
|
||||
*
|
||||
* Copyright 2026 Mono Technologies Inc.
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
|
@ -11,12 +11,14 @@
|
|||
#ifndef _DPAA_HOST_GENERIC_H_
|
||||
#define _DPAA_HOST_GENERIC_H_
|
||||
|
||||
/* Stub: WiFi VAP forwarding — always fails (no WiFi offload on FreeBSD) */
|
||||
static inline int
|
||||
dpaa_get_vap_fwd_fq(uint16_t vap_id, uint32_t *fqid, uint32_t hash)
|
||||
{
|
||||
|
||||
return (-1);
|
||||
}
|
||||
/*
|
||||
* dpaa_get_vap_fwd_fq — Get the TX FQID for a WiFi VAP.
|
||||
*
|
||||
* On the Linux ASK platform, this returns VWD's wlan_fq_to_fman FQID.
|
||||
* On FreeBSD, we return the WiFi OH port's default RX FQID.
|
||||
*
|
||||
* Returns 0 on success, -1 if the WiFi OH port is not configured.
|
||||
*/
|
||||
int dpaa_get_vap_fwd_fq(uint16_t vap_id, uint32_t *fqid, uint32_t hash);
|
||||
|
||||
#endif /* _DPAA_HOST_GENERIC_H_ */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Copyright 2026 Mono Technologies Inc.
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
SYSDIR?= ${.CURDIR}/../../../opnsense-src/sys
|
||||
|
||||
KMOD= pf_notify
|
||||
SRCS= pf_notify.c
|
||||
|
|
|
|||
13
fastpath/vendor/cdx/control_wifi.c
vendored
13
fastpath/vendor/cdx/control_wifi.c
vendored
|
|
@ -37,6 +37,12 @@ static int wifi_vap_entry( U16 *ptr, U16 len )
|
|||
|
||||
memcpy( &cmd, ptr, sizeof(struct wifiCmd));
|
||||
|
||||
printk(KERN_INFO "cdx: wifi_vap_entry: action=%u vapid=%u "
|
||||
"ifname='%s' mac=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
cmd.action, cmd.VAPID, cmd.ifname,
|
||||
cmd.mac_addr[0], cmd.mac_addr[1], cmd.mac_addr[2],
|
||||
cmd.mac_addr[3], cmd.mac_addr[4], cmd.mac_addr[5]);
|
||||
|
||||
if( cmd.VAPID >= MAX_WIFI_VAPS )
|
||||
return ERR_UNKNOWN_ACTION;
|
||||
|
||||
|
|
@ -72,10 +78,14 @@ static int wifi_vap_entry( U16 *ptr, U16 len )
|
|||
|
||||
if(!add_onif(cmd.ifname, &port->itf, NULL, IF_TYPE_WLAN | IF_TYPE_PHYSICAL))
|
||||
{
|
||||
printk(KERN_ERR "cdx: wifi_vap_entry: "
|
||||
"add_onif('%s') FAILED\n", cmd.ifname);
|
||||
return CMD_ERR;
|
||||
}
|
||||
|
||||
if (dpa_add_wlan_if(cmd.ifname, &port->itf, cmd.VAPID, cmd.mac_addr)) {
|
||||
printk(KERN_ERR "cdx: wifi_vap_entry: "
|
||||
"dpa_add_wlan_if('%s') FAILED\n", cmd.ifname);
|
||||
remove_onif_by_index(port->itf.index);
|
||||
wifiDesc[cmd.VAPID].VAPID = 0xFFFF;
|
||||
return CMD_ERR;
|
||||
|
|
@ -89,6 +99,9 @@ static int wifi_vap_entry( U16 *ptr, U16 len )
|
|||
if ( rxc->users < MAX_WIFI_VAPS )
|
||||
rxc->users++;
|
||||
|
||||
printk(KERN_INFO "cdx: wifi_vap_entry: registered "
|
||||
"'%s' vapid=%u portid=%d users=%u\n",
|
||||
cmd.ifname, cmd.VAPID, portid, rxc->users);
|
||||
break;
|
||||
/* Removed UPDATE_VAP as it is updating bridge mac address with vap's mac address
|
||||
This is handled using seperate command for all interfaces */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
/boot/modules/pcf2131.ko
|
||||
/boot/modules/caam.ko
|
||||
/boot/modules/tmp431.ko
|
||||
/boot/modules/mwifiex.ko
|
||||
/boot/modules/dpaa_wifi.ko
|
||||
/usr/local/sbin/cmm
|
||||
/usr/local/sbin/cmmctl
|
||||
/usr/local/sbin/dpa_app
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue