From: Arne Fitzenreiter Date: Thu, 27 May 2021 16:36:01 +0000 (+0200) Subject: xradio: add external driver module for xradio sdio wlan X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4955d4fb6efc2fbab551cdd3b56edf0d5d319b5;p=people%2Fstevee%2Fipfire-2.x.git xradio: add external driver module for xradio sdio wlan this module is used on OrangePi Zero and NanoPi Duo Signed-off-by: Arne Fitzenreiter --- diff --git a/lfs/xradio b/lfs/xradio new file mode 100644 index 0000000000..b7bd40fffb --- /dev/null +++ b/lfs/xradio @@ -0,0 +1,101 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2021 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VERSUFIX = ipfire$(KCFG) +MODPATH = /lib/modules/$(KVER)-$(VERSUFIX)/extra/wlan/ + +VER = 354e8c32e7948d46a63796d0ca266b1f702999b0 + +THISAPP = xradio-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)-kmod-$(KVER)-$(VERSUFIX) + +SUP_ARCH = armv5tel + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = db59e90ca29523bfe59c527a3c2d91a0 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +dist: + $(PAK) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/xradio/disable_warnings.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/xradio/fix-transmit-of-tkip-encrypted-packets.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/xradio/fix-missing-wpa1-2-sequence-numbers-for-group.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/xradio/report-mic-fails-to-kernel-and-correct-iv-str.patch + + cd $(DIR_APP) && CONFIG_WLAN_VENDOR_XRADIO=m \ + make $(MAKETUNING) -C /lib/modules/$(KVER)-$(VERSUFIX)/build/ M=$(DIR_APP)/ modules + + # Install the built kernel modules. + mkdir -p $(MODPATH) + cd $(DIR_APP) && for f in $$(ls *.ko); do \ + /lib/modules/$$(uname -r)$(KCFG)/build/scripts/sign-file sha512 \ + /lib/modules/$$(uname -r)$(KCFG)/build/certs/signing_key.pem \ + /lib/modules/$$(uname -r)$(KCFG)/build/certs/signing_key.x509 \ + $$f; \ + xz $$f; \ + install -m 644 $$f.xz $(MODPATH); \ + done + + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index 553e706295..9518089530 100755 --- a/make.sh +++ b/make.sh @@ -1204,6 +1204,7 @@ buildipfire() { # arm multi platform (Panda, Wandboard ...) kernel build lfsmake2 linux KCFG="-multi" lfsmake2 rtl8189es KCFG="-multi" + lfsmake2 xradio KCFG="-multi" lfsmake2 xtables-addons KCFG="-multi" lfsmake2 linux-initrd KCFG="-multi" ;; diff --git a/src/patches/xradio/disable_warnings.patch b/src/patches/xradio/disable_warnings.patch new file mode 100644 index 0000000000..674e5dc387 --- /dev/null +++ b/src/patches/xradio/disable_warnings.patch @@ -0,0 +1,24 @@ +diff -Naur a/debug.h b/debug.h +--- a/debug.h 2020-05-02 17:17:06.000000000 +0000 ++++ b/debug.h 2021-05-26 06:42:41.347972240 +0000 +@@ -21,13 +21,13 @@ + #define XRADIO_DBG_DEV 0x40 /* current dev */ + + /* debug levels, default 0x07 */ +-#define XRADIO_DBG_LEV_AP 0x47 /* ap */ +-#define XRADIO_DBG_LEV_PM 0x47 /* pm */ +-#define XRADIO_DBG_LEV_SCAN 0x47 /* scan */ +-#define XRADIO_DBG_LEV_STA 0x47 /* sta, keys */ +-#define XRADIO_DBG_LEV_TXRX 0x47 /* tx, rx, ht, p2p, queue */ +-#define XRADIO_DBG_LEV_WSM 0x47 /* wsm */ +-#define XRADIO_DBG_LEV_XR 0x47 /* xradio, fwio, sdio, bh */ ++#define XRADIO_DBG_LEV_AP 0x03 /* ap */ ++#define XRADIO_DBG_LEV_PM 0x03 /* pm */ ++#define XRADIO_DBG_LEV_SCAN 0x03 /* scan */ ++#define XRADIO_DBG_LEV_STA 0x03 /* sta, keys */ ++#define XRADIO_DBG_LEV_TXRX 0x03 /* tx, rx, ht, p2p, queue */ ++#define XRADIO_DBG_LEV_WSM 0x03 /* wsm */ ++#define XRADIO_DBG_LEV_XR 0x03 /* xradio, fwio, sdio, bh */ + + #define ap_printk(level, ...) \ + do { \ diff --git a/src/patches/xradio/fix-missing-wpa1-2-sequence-numbers-for-group.patch b/src/patches/xradio/fix-missing-wpa1-2-sequence-numbers-for-group.patch new file mode 100644 index 0000000000..d27dca435a --- /dev/null +++ b/src/patches/xradio/fix-missing-wpa1-2-sequence-numbers-for-group.patch @@ -0,0 +1,76 @@ +From 70307b17ea3bd388d608bf77d0d0dd2058d05d3f Mon Sep 17 00:00:00 2001 +From: Arne Fitzenreiter +Date: Wed, 7 Mar 2018 23:23:39 +0100 +Subject: [PATCH 116/144] xradio: fix missing wpa1/2 sequence numbers for group + rekeying + +Signed-off-by: Arne Fitzenreiter +--- + drivers/net/wireless/xradio/keys.c | 26 ++++++++++++++++++++++---- + 1 file changed, 22 insertions(+), 4 deletions(-) + +diff --git a/keys.c b/keys.c +index 20050e1e75c2..1d95410932e1 100644 +--- a/keys.c ++++ b/keys.c +@@ -56,6 +56,7 @@ int xradio_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, + int ret = -EOPNOTSUPP; + struct xradio_common *hw_priv = dev->priv; + struct xradio_vif *priv = xrwl_get_vif_from_ieee80211(vif); ++ struct ieee80211_key_seq seq; + + wiphy_dbg(dev->wiphy, "vif %d: set_key cmd %d\n", priv->if_id, (int) cmd); + +@@ -103,6 +104,7 @@ int xradio_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, + } + break; + case WLAN_CIPHER_SUITE_TKIP: ++ ieee80211_get_key_rx_seq(key, 0, &seq); + if (pairwise) { + wsm_key->type = WSM_KEY_TYPE_TKIP_PAIRWISE; + memcpy(wsm_key->tkipPairwiseKey.peerAddress, peer_addr, ETH_ALEN); +@@ -115,12 +117,20 @@ int xradio_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, + memcpy(wsm_key->tkipGroupKey.tkipKeyData,&key->key[0], 16); + memcpy(wsm_key->tkipGroupKey.rxMicKey, &key->key[mic_offset], 8); + +- /* TODO: Where can I find TKIP SEQ? */ +- memset(wsm_key->tkipGroupKey.rxSeqCounter, 0, 8); ++ wsm_key->tkipGroupKey.rxSeqCounter[0] = seq.tkip.iv16 & 0xff; ++ wsm_key->tkipGroupKey.rxSeqCounter[1] = (seq.tkip.iv16>>8) & 0xff; ++ wsm_key->tkipGroupKey.rxSeqCounter[2] = seq.tkip.iv32 & 0xff; ++ wsm_key->tkipGroupKey.rxSeqCounter[3] = (seq.tkip.iv32>> 8) & 0xff; ++ wsm_key->tkipGroupKey.rxSeqCounter[4] = (seq.tkip.iv32>>16) & 0xff; ++ wsm_key->tkipGroupKey.rxSeqCounter[5] = (seq.tkip.iv32>>24) & 0xff; ++ wsm_key->tkipGroupKey.rxSeqCounter[6] = 0; ++ wsm_key->tkipGroupKey.rxSeqCounter[7] = 0; ++ + wsm_key->tkipGroupKey.keyId = key->keyidx; + } + break; + case WLAN_CIPHER_SUITE_CCMP: ++ ieee80211_get_key_rx_seq(key, 0, &seq); + if (pairwise) { + wsm_key->type = WSM_KEY_TYPE_AES_PAIRWISE; + memcpy(wsm_key->aesPairwiseKey.peerAddress, peer_addr, ETH_ALEN); +@@ -130,8 +140,16 @@ int xradio_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, + } else { + wsm_key->type = WSM_KEY_TYPE_AES_GROUP; + memcpy(wsm_key->aesGroupKey.aesKeyData, &key->key[0], 16); +- /* TODO: Where can I find AES SEQ? */ +- memset(wsm_key->aesGroupKey.rxSeqCounter, 0, 8); ++ ++ wsm_key->aesGroupKey.rxSeqCounter[0] = seq.ccmp.pn[5]; ++ wsm_key->aesGroupKey.rxSeqCounter[1] = seq.ccmp.pn[4]; ++ wsm_key->aesGroupKey.rxSeqCounter[2] = seq.ccmp.pn[3]; ++ wsm_key->aesGroupKey.rxSeqCounter[3] = seq.ccmp.pn[2]; ++ wsm_key->aesGroupKey.rxSeqCounter[4] = seq.ccmp.pn[1]; ++ wsm_key->aesGroupKey.rxSeqCounter[5] = seq.ccmp.pn[0]; ++ wsm_key->aesGroupKey.rxSeqCounter[6] = 0; ++ wsm_key->aesGroupKey.rxSeqCounter[7] = 0; ++ + wsm_key->aesGroupKey.keyId = key->keyidx; + } + break; +-- +2.31.0 + diff --git a/src/patches/xradio/fix-transmit-of-tkip-encrypted-packets.patch b/src/patches/xradio/fix-transmit-of-tkip-encrypted-packets.patch new file mode 100644 index 0000000000..a0ec0cfe08 --- /dev/null +++ b/src/patches/xradio/fix-transmit-of-tkip-encrypted-packets.patch @@ -0,0 +1,17 @@ +diff -Naur a/tx.c b/tx.c +--- a/tx.c 2020-05-02 19:17:06.000000000 +0200 ++++ b/tx.c 2021-05-26 12:33:36.117730336 +0200 +@@ -707,8 +707,11 @@ + memmove(p, &p[offset], t->skb->len - offset); + skb_trim(t->skb, t->skb->len - offset); + } +- /* ccmp pkt from umac to driver,it has iv room,,so ccmp pkt do not add iv room */ +- if (t->tx_info->control.hw_key->cipher != WLAN_CIPHER_SUITE_CCMP){ ++ ++ /* ccmp/tkip pkt from umac to driver,it has iv room,,so ccmp/tkip pkt do not add iv room */ ++ if ( (t->tx_info->control.hw_key->cipher != WLAN_CIPHER_SUITE_CCMP) && ++ (t->tx_info->control.hw_key->cipher != WLAN_CIPHER_SUITE_TKIP) ) ++ { + u8 *newhdr; + newhdr = skb_push(t->skb, iv_len); + memmove(newhdr, newhdr + iv_len, t->hdrlen); diff --git a/src/patches/xradio/report-mic-fails-to-kernel-and-correct-iv-str.patch b/src/patches/xradio/report-mic-fails-to-kernel-and-correct-iv-str.patch new file mode 100644 index 0000000000..ece413b413 --- /dev/null +++ b/src/patches/xradio/report-mic-fails-to-kernel-and-correct-iv-str.patch @@ -0,0 +1,41 @@ +From dd2f835ae8a634794c4bf6b7fce1f778ae925e25 Mon Sep 17 00:00:00 2001 +From: Arne Fitzenreiter +Date: Sun, 18 Mar 2018 10:55:00 +0100 +Subject: [PATCH 120/144] xradio: report mic fails to kernel and correct iv + stripping. + +Signed-off-by: Arne Fitzenreiter +--- + drivers/net/wireless/xradio/rx.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/rx.c b/rx.c +index 271632c96baa..5a2466edf534 100644 +--- a/rx.c ++++ b/rx.c +@@ -269,7 +269,8 @@ void xradio_rx_cb(struct xradio_vif *priv, + /* Firmware strips ICV in case of MIC failure. */ + if (arg->status == WSM_STATUS_MICFAILURE) { + icv_len = 0; +- hdr->flag |= RX_FLAG_IV_STRIPPED; ++ hdr->flag |= RX_FLAG_IV_STRIPPED | ++ RX_FLAG_MMIC_ERROR; + } + + if (skb->len < hdrlen + iv_len + icv_len) { +@@ -285,10 +286,8 @@ void xradio_rx_cb(struct xradio_vif *priv, + skb->data + skb->len-icv_len+8, 4); + skb_trim(skb, skb->len - 8); + hdr->flag |= RX_FLAG_MMIC_STRIPPED; +- } else if (unlikely(WSM_RX_STATUS_ENCRYPTION(arg->flags) == +- WSM_RX_STATUS_WAPI)) { +- /* Protocols not defined in mac80211 should be +- stripped/crypted in driver/firmware */ ++ } ++ if (hdr->flag & RX_FLAG_IV_STRIPPED) { + /* Remove IV, ICV and MIC */ + skb_trim(skb, skb->len - icv_len); + memmove(skb->data + iv_len, skb->data, hdrlen); +-- +2.31.0 +