From owner-freebsd-wireless@freebsd.org Thu Jun 28 00:37:32 2018 Return-Path: Delivered-To: freebsd-wireless@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 940231020B80 for ; Thu, 28 Jun 2018 00:37:32 +0000 (UTC) (envelope-from ajcsweb@gmail.com) Received: from mail-ua0-x233.google.com (mail-ua0-x233.google.com [IPv6:2607:f8b0:400c:c08::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1ED1C7C082 for ; Thu, 28 Jun 2018 00:37:32 +0000 (UTC) (envelope-from ajcsweb@gmail.com) Received: by mail-ua0-x233.google.com with SMTP id x18-v6so2442258uaj.9 for ; Wed, 27 Jun 2018 17:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=2rB4qfapZlFrgyTFKq+4v7NdAd/L0HVVFkjSos/oJ8g=; b=arXTG0siYva0dBjX4rdBtIlVbC5AgobDRkaURDLaK+lb/s/FQWzFUz6w5Oc8RRkQzi DljuIEGP3Aq9vJJFHST6CFxXaA1gtY1KD5TplylrRfVEVIQFoXqmtW6d+eI12OLRzPSM ln1Ca8nGyetZdppB1ooQGXw72rwZLpx0Za41MquyGZAjAJp3Vzobx25lmOvH2o0Z6KML 2MuN4WOIYo0FQDi8fUBZqWNqjoGCdZ8ZH12/zYSB5X2mJ2y7HEFeGKm3dQlfnYmVe0l3 o9iJLhniQlQqbk2fMt6P/vvgyGWwvOdx7/QfXYZ1vG5czqr3yN+fECgJr+L6n12gZ2RP ASxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=2rB4qfapZlFrgyTFKq+4v7NdAd/L0HVVFkjSos/oJ8g=; b=hVWfwGXrBMk13GsDzYafLMI6mjWaHTtBuYvbKbM37Z5NkoZuNfIG0vEmiTl1ztCL5x yDjJc8YBj66YL7+jxKwqgE5ZpVblmv/GVvssgvHEVH8Ki7SnhSpycUdja2+l/xmTLqrz Nje5TtPZNU7P3w5slxCDH5CLx9aLuQH7U5YfNqv0DqekGzKpj8mpKBqL2dMHMw6fDxpQ PLD+1CgHHUvmS97IO2T/chAqOUbJc88YMeg09FtnguEqe4x/ClW12fk+uST545L8sKmh nXU/2TWOPIP7FIMxrnn2beGOQ92NmWuWg1PRKm0TTavIydGiUcq3c8Tay9YppzmMe6C9 s1BA== X-Gm-Message-State: APt69E3NSxaC0be28wXOFBP2eqfcVF12wdFoJ5VVP8iMGxdcln5g2OM7 dhzwTwaLXlGJPLv4JhQfZhkNy/H4Q6n4FbwS0zS0EmtN X-Google-Smtp-Source: AAOMgpcfjvVE/ZvszF1+xKYYDmrfEQI5TFnx6nblhtaQcs2lS9kg78grfQPHKgdmI8hUw14W+EbAz1mNaVH9f7KTdlc= X-Received: by 2002:a9f:2e07:: with SMTP id t7-v6mr5142488uaj.54.1530146251059; Wed, 27 Jun 2018 17:37:31 -0700 (PDT) MIME-Version: 1.0 From: waddlesplash Date: Wed, 27 Jun 2018 20:37:22 -0400 Message-ID: Subject: Haiku's usage of the FreeBSD net80211 stack and drivers To: freebsd-wireless@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 00:37:32 -0000 Hi, I'm one of the developers of the Haiku operating system [1]. For those who are unfamiliar, it's a free and open-source reimplementation & continuation of BeOS. We have our own kernel and driver stack, initially (~2003) forked from the NewOS kernel, but now very substantially diverged in both structure and essence from it. Most of our network stack (buffers, TCP, UDP, etc.) is a work of our own creation. However, we are still a pretty small team, so for network drivers we have (since 2010) a compatibility layer for FreeBSD network drivers. This layer essentially implements all of the FreeBSD KPIs (ifnet, busdma, mbuf, etc.) that network drivers use. We've fallen behind a bit; until earlier this year we were still using said drivers from FreeBSD 9, but we're finally rectifying that now. To make a (very) long story short, I have indeed managed to sync FreeBSD 11.1's net80211 code as well as the iwn driver and make them work on Haiku, with many thanks to the assistance of various people from EFnet#freebsd-wifi. Upon hearing that we had Haiku-specific patches to said code, Adrian suggested he'd like to look at them, mentioning that he'd also potentially like to de-FreeBSDify net80211, and directed me to this mailing list. The specific changes which might be candidates for merging into FreeBSD are as follows: 1. no *SYSINIT() -- our runtime loader doesn't support it, and we have no plans / otherwise need for it, so instead we call all functions that SYSINIT would manually in the appropriate location. 2. ieee80211req_scan_result now contains a complete ieee80211_channel, not just the freq and flags (we use this in userland) 3. NULL checks on dst in ieee80211_output(), as we pass in NULL from our hooks code in some places 4. casts so the header files can compile as C++ (ieee80211_haiku is a .cpp not a .c so we can use Haiku kernel routines which are C++) 5. calling ieee80211_vap_xmitpkt instead of iv_output in ieee80211_output(), as our iv_output is pretty much ethernet/IFQ_DRV queue-only. 6. Behavioral change to ieee80211_check_scan: default to IEEE80211_SCAN_NOJOIN if we are not explicitly looking for a SSID 7. Behavioral change to ieee80211_ioctl_setmlme relating to wpa_supplicant behavior (see lengthy comment in the diff) The complete diff (minus ieee80211_haiku) can be found here: [2] (Disregard the stuff blacking out counter(9) usage -- the manpage for it said that it was non-atomic and had some specific behavior re. interrupts so I deferred looking into it, but it looks like that's an implementation detail; I'll probably implement it on our end as an atomic.) The patchset isn't too large, so even if none of these get merged, it's not really a huge burden on our end. The harder part is always the KPI changes that get made, as our compatibility layer makes a lot of assumptions about net80211 and driver behavior (e.g. the ieee80211com / IFQ_DRV removal took me quite a while and a good amount of assistance to figure out.) Anyway, thanks for the help so far, and thanks for a (mostly) portable net80211 stack! -waddlesplash [1]: https://www.haiku-os.org/ [2]: https://git.haiku-os.org/haiku/commit/?id=af8988cdb6664339b2958b32863554c70d2fe76f