Page MenuHomeFreeBSD

net80211 drivers without struct ifnet
AbandonedPublic

Authored by glebius on May 26 2015, 3:35 PM.

Details

Reviewers
None
Group Reviewers
network
Summary

This is part of larger project for new interface driver KPI, and
it will cut away usage of superfluous struct ifnet from WiFi
drivers.

All WiFi drivers create a device(9), and an ifnet(9). Then interface
cloning operation creates another ifnet(9) of wlan(4), which acts
as actual interface. All userland applications issue ioctls, read
statistics and run packet capture on the wlan(4), not on the
underlying parent.

The patch cuts down the ifnet(9) from drivers. Right now only iwn(4)
is converted. I will seek for testers and convert other drivers.
But before I'd like to get reviewed the base concept.

Changes to the stack:

o Struct ieee80211com is the single gateway between stack and driver:

  • packets are sent via new ic_transmit method, which is very much like the previous if_transmit.
  • bringing parent up/down is done via new ic_parent method
  • device specific ioctls (if any) are received on new ic_ioctl method
  • struct ieee80211com lives in the driver softc

o ieee80211_ifattach() registers an ieee80211com on global list
o wlan cloner seeks for specified parent on the global list
o VAP interface mac address isn't a copy, but a pointer. It points either to original mac address in ieee80211com, or if wlanX address is changed, then to IF_LLADDR of own interface.
o Handling of promisc and allmulti is done by accounting number of VAPs in given state.

Changes to a driver (iwn(4) provided as tested example):
o Don't create interface: if_alloc, if_attach, if_free.
o Convert IFF_DRV_RUNNING into internal flag in softc. Use it under driver lock always.
o Convert SIOCSIFFLAGS code into ic_parent method.
o Leave if_ioctl method to ic_ioctl if there are any driver specific ioctls, otherwise delete it.
o Convert interface start/transmit method to ic_transmit method.

  • As option use mbufq.

o Go through all functions and change initialization of struct ieee80211com pointer. It used to be ifp->if_l2com, now it lives in softc.
o Statistics.

  • Properly update vap packets/errors statistics if vap is known.
  • If vap is unknown, increase ic_ierrors/ic_oerrors.
  • TX stats are done on TX completion, in ieee80211_tx_complete()

Changes to /etc:
o Although the startup sequence didn't change: ifconfig wlan0 wlandev iwn0, wpa_supplicant, etc..., the rc.d needs extra care. The problem is that rc.d explicitly checked presence of the parent in 'ifconfig -l'. XXX: The rc.d diff needs extra polishing.

Test Plan

Test each driver :(

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

glebius updated this revision to Diff 5707.May 26 2015, 3:35 PM
glebius retitled this revision from to net80211 drivers without struct ifnet.
glebius updated this object.
glebius edited the test plan for this revision. (Show Details)
glebius added a reviewer: network.
glebius updated this object.May 26 2015, 3:39 PM
glebius updated this object.
glebius updated this object.
s3erios_gmail.com added inline comments.
sys/net80211/ieee80211_ioctl.c
2533

Without this check net80211 enters SCAN state even when device is not initialized (for example, issue wlandebug scan+state and then turn device off with RF switch)

glebius added inline comments.May 27 2015, 9:06 PM
sys/net80211/ieee80211_ioctl.c
2533

The device should check its internal RUNNING flag in the handler.

glebius updated this revision to Diff 5770.May 29 2015, 6:20 AM
glebius updated this object.

Add converted bwi(4).

glebius updated this revision to Diff 5865.Jun 1 2015, 3:27 PM

Convert ath(4). Not tested.

op added a subscriber: op.Jun 1 2015, 5:36 PM
op added inline comments.Jun 1 2015, 7:05 PM
sys/dev/ath/if_ath_rx.c
1208

Style(9) issue here: please use tabulator instead of space after #undef.

op added a comment.Jun 1 2015, 8:08 PM

I running into compile error, and this patch should fix them:

op@opn src> git diff
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 53763a6..b719ed4 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -5729,8 +5729,7 @@ ath_scan_end(struct ieee80211com *ic)
 static void
 ath_update_chw(struct ieee80211com *ic)
 {
-       struct ifnet *ifp = ic->ic_ifp;
-       struct ath_softc *sc = ifp->if_softc;
+       struct ath_softc *sc = ic->ic_softc;
 
        DPRINTF(sc, ATH_DEBUG_STATE, "%s: called\n", __func__);
        ath_set_channel(ic);
diff --git a/sys/dev/ath/if_ath_tdma.c b/sys/dev/ath/if_ath_tdma.c
index fd23db1..d4c9ccd 100644
--- a/sys/dev/ath/if_ath_tdma.c
+++ b/sys/dev/ath/if_ath_tdma.c
@@ -359,7 +359,7 @@ ath_tdma_update(struct ieee80211_node *ni,
 #define        TU_TO_TSF(_tu)  (((u_int64_t)(_tu)) << 10)
        struct ieee80211vap *vap = ni->ni_vap;
        struct ieee80211com *ic = ni->ni_ic;
-       struct ath_softc *sc = ic->ic_ifp->if_softc;
+       struct ath_softc *sc = ic->ic_softc;
        struct ath_hal *ah = sc->sc_ah;
        const HAL_RATE_TABLE *rt = sc->sc_currates;
        u_int64_t tsf, rstamp, nextslot, nexttbtt, nexttbtt_full;
glebius updated this revision to Diff 5881.Jun 2 2015, 4:05 PM

Convert iwi(4).

glebius updated this revision to Diff 5882.Jun 2 2015, 4:23 PM

Address Oliver's comments on ath(4).

glebius updated this revision to Diff 5891.Jun 2 2015, 10:47 PM

Update to fresh head, where bug in iwi(4) is fixed.

glebius updated this revision to Diff 5892.Jun 2 2015, 10:57 PM

Address new LOR reported by Oliver.

glebius updated this revision to Diff 5940.Jun 4 2015, 11:12 AM

Convert ral(4).

glebius updated this revision to Diff 5941.Jun 4 2015, 12:50 PM

Convert urtwn(4).

glebius updated this revision to Diff 5946.Jun 4 2015, 6:20 PM
  • Fix to iwi(4) and probably others, to clean up ni/m pointers in the TX ring after call to ieee80211_tx_complete()
  • Use ieee80211_tx_complete() in bwi(4).
  • Merge with latest head.
glebius updated this revision to Diff 5968.Jun 5 2015, 3:45 PM

Convert ural(4).

Promiscuous flag does nothing - it looks like the prefix increment is more suitable for ic_promisc / ic_allmulti variables.

glebius updated this revision to Diff 6074.Jun 10 2015, 3:20 PM

Convert rum(4).

glebius updated this revision to Diff 6085.Jun 10 2015, 8:34 PM

Couple of KASSERT fixes in ral(4).

Submitted by: kevlo

glebius updated this revision to Diff 6087.Jun 10 2015, 8:45 PM

Convert wpi(4).

Submitted by: Andriy Voskoboinyk <s3erios gmail.com>

sys/net80211/ieee80211.c
677

here

682

here

699

here

704

and here

glebius updated this revision to Diff 6088.Jun 10 2015, 9:05 PM

Use proper increments in promisc/allmulti handlers. We are interested in
the resulting values, not in the previous ones.

Submitted by: Andriy Voskoboinyk

glebius marked 4 inline comments as done.Jun 10 2015, 9:06 PM
glebius added inline comments.
sys/net80211/ieee80211.c
677

Yep, good catch. Thanks!

glebius updated this revision to Diff 6163.Jun 13 2015, 2:27 PM
glebius marked an inline comment as done.

Convert run(4).

glebius updated this revision to Diff 6199.Jun 15 2015, 6:25 AM

Fix statistics in run(4).

glebius updated this revision to Diff 6240.Jun 16 2015, 4:33 PM

Convert zyd(4).

glebius updated this revision to Diff 6261.Jun 17 2015, 8:25 AM

Convert urtw(4).

glebius updated this revision to Diff 6286.Jun 18 2015, 10:40 AM

Fix lock leak in urtw_parent().

glebius updated this revision to Diff 6374.Jun 22 2015, 10:21 AM
  • Converted rsu(4).
  • Merged iwn(4).
glebius updated this revision to Diff 7428.Jul 28 2015, 11:25 AM
glebius removed rS FreeBSD src repository as the repository for this revision.
  • Merge head (affected: ath, iwn).
  • Convert malo(4).
glebius updated this revision to Diff 7461.Jul 29 2015, 8:42 AM
  • Add missing locking to malo(4).

Reported by: kevlo

glebius updated this revision to Diff 7650.Aug 4 2015, 2:13 PM
  • Convert if_ndis(4)
glebius updated this revision to Diff 7708.Aug 6 2015, 2:11 PM

Convert rest of drivers: mwl, ipw, bwn, wi and wtap.

glebius updated this revision to Diff 7712.Aug 6 2015, 2:52 PM
  • Provide net.wlan.devices sysctl.

Convert rest of drivers: mwl, ipw, bwn, wi and wtap.

​Hi,
I've just tried the latest revision of D2655 on an i386 kernel (with "device mwl" and "device mwlfw" in the kernel configuration file).

cc  -c -O -pipe  -g -nostdinc  -I. -I/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys -I/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h  -mno-mmx -mno-sse -msoft-float -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__  -Wmissing-include-dirs -fdiagnostics-show-option  -Wno-unknown-pragmas  -Wno-error-tautological-compare -Wno-error-empty-body  -Wno-error-parentheses-equality -Wno-error-unused-function  -Wno-error-pointer-sign  -mno-aes -mno-avx  -std=iso9899:1999 -Werror  /usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:1519:20: error: unused variable 'sc' [-Werror,-Wunused-variable]
        struct mwl_softc *sc = vap->iv_ic->ic_softc;
                          ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:1547:20: error: unused variable 'sc' [-Werror,-Wunused-variable]
        struct mwl_softc *sc = vap->iv_ic->ic_softc;
                          ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:1614:20: error: unused variable 'sc' [-Werror,-Wunused-variable]
        struct mwl_softc *sc = vap->iv_ic->ic_softc;
                          ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:2258:20: error: unused variable 'sc' [-Werror,-Wunused-variable]
        struct mwl_softc *sc = ic->ic_softc;
                          ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:2813:7: error: expected expression
                if (IFF_DUMPPKTS_RECV(sc, wh)) {
                    ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:248:35: note: expanded from macro 'IFF_DUMPPKTS_RECV'
#define IFF_DUMPPKTS_RECV(sc, wh)       do {} while (0)
                                        ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:3320:6: error: expected expression
        if (IFF_DUMPPKTS_XMIT(sc))
            ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:249:32: note: expanded from macro 'IFF_DUMPPKTS_XMIT'
#define IFF_DUMPPKTS_XMIT(sc)           do {} while (0)
                                        ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:3880:20: error: unused variable 'sc' [-Werror,-Wunused-variable]
        struct mwl_softc *sc = ic->ic_softc;
                          ^
/usr/local/BSDRP/GLEBWIFI/FreeBSD/src/sys/dev/mwl/if_mwl.c:3888:20: error: unused variable 'sc' [-Werror,-Wunused-variable]
        struct mwl_softc *sc = ic->ic_softc;
                          ^
8 errors generated.
*** Error code 1
glebius abandoned this revision.Aug 7 2015, 11:53 AM

Close it since it is committed.