From c7b845d09aca326e5428644c5ff6ffd3181e6bf5 Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Wed, 12 Aug 2020 12:01:10 +0800 Subject: [PATCH] rtl88x2bu: build with mac80211 --- package/ctcgfw/rtl88x2bu/Makefile | 18 +++++++-- .../patches/001-use-kernel-byteorder.patch | 15 +++++++ .../rtl88x2bu/patches/020-remove-iwreq.patch | 33 ++++++++++++++++ .../rtl88x2bu/patches/030-wireless-5.8.patch | 39 +++++++++++++++++++ 4 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 package/ctcgfw/rtl88x2bu/patches/001-use-kernel-byteorder.patch create mode 100644 package/ctcgfw/rtl88x2bu/patches/020-remove-iwreq.patch create mode 100644 package/ctcgfw/rtl88x2bu/patches/030-wireless-5.8.patch diff --git a/package/ctcgfw/rtl88x2bu/Makefile b/package/ctcgfw/rtl88x2bu/Makefile index 17bbaf1179..37a377b3db 100644 --- a/package/ctcgfw/rtl88x2bu/Makefile +++ b/package/ctcgfw/rtl88x2bu/Makefile @@ -13,22 +13,33 @@ PKG_SOURCE_DATE:=2020-07-21 PKG_SOURCE_VERSION:=a2abcaf523dfab2afeda8cc2cdb5e3c9510fc5f3 PKG_MIRROR_HASH:=ba79fb9a823a38c5acf22999210645ba881da0b5498ee765383dc5eaa8234e62 -PKG_MAINTAINER:=ElonH +PKG_MAINTAINER:=[CTCGFW] Project OpenWrt PKG_BUILD_PARALLEL:=1 +STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h + include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/package.mk define KernelPackage/rtl88x2bu SUBMENU:=Wireless Drivers TITLE:=Realtek 8812BU/8822BU support - DEPENDS:=@BROKEN +@USB_SUPPORT +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT +kmod-mac80211 +kmod-usb-core + DEPENDS:=+kmod-cfg80211 +kmod-usb-core +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT FILES:=$(PKG_BUILD_DIR)/rtl88x2bu.ko AUTOLOAD:=$(call AutoProbe,rtl88x2bu) PROVIDES:=kmod-rtl88x2bu endef -EXTRA_CFLAGS=-DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -DCONFIG_RADIO_WORK -DCONFIG_CONCURRENT_MODE +NOSTDINC_FLAGS = \ + -I$(PKG_BUILD_DIR) \ + -I$(PKG_BUILD_DIR)/include \ + -I$(STAGING_DIR)/usr/include/mac80211-backport \ + -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \ + -I$(STAGING_DIR)/usr/include/mac80211 \ + -I$(STAGING_DIR)/usr/include/mac80211/uapi \ + -include backport/backport.h + +EXTRA_CFLAGS=-DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -DCONFIG_RADIO_WORK -DCONFIG_CONCURRENT_MODE -DBUILD_OPENWRT # CONFIG_IOCTL_CFG80211: If kernel version is after 2.6.35, we recommend user to use the new nl80211 API. # RTW_USE_CFG80211_STA_EVENT:It is used for driver to indicate new cfg80211 STA event, @@ -40,6 +51,7 @@ define Build/Compile +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ $(KERNEL_MAKE_FLAGS) \ M="$(PKG_BUILD_DIR)" \ + NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ USER_EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ CONFIG_RTL8822BU=m \ USER_MODULE_NAME=rtl88x2bu \ diff --git a/package/ctcgfw/rtl88x2bu/patches/001-use-kernel-byteorder.patch b/package/ctcgfw/rtl88x2bu/patches/001-use-kernel-byteorder.patch new file mode 100644 index 0000000000..e75a278339 --- /dev/null +++ b/package/ctcgfw/rtl88x2bu/patches/001-use-kernel-byteorder.patch @@ -0,0 +1,15 @@ +Fix compile problem when rtw_byteorder.h and asm/byteorder.h gets +included in addition for example indirectly, do not use realtek own copy +of the byteorder headers. + +--- a/include/drv_types.h ++++ b/include/drv_types.h +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include diff --git a/package/ctcgfw/rtl88x2bu/patches/020-remove-iwreq.patch b/package/ctcgfw/rtl88x2bu/patches/020-remove-iwreq.patch new file mode 100644 index 0000000000..ed184e6faf --- /dev/null +++ b/package/ctcgfw/rtl88x2bu/patches/020-remove-iwreq.patch @@ -0,0 +1,33 @@ +diff --git a/include/linux/wireless.h b/include/linux/wireless.h +index c7f4a6c..f7ef486 100644 +--- a/include/linux/wireless.h ++++ b/include/linux/wireless.h +@@ -18,10 +18,11 @@ + + /***************************** INCLUDES *****************************/ + +-#if 0 ++#if 1 + #include /* for __u* and __s* typedefs */ + #include /* for "struct sockaddr" et al */ + #include /* for IFNAMSIZ and co... */ ++ #include + #else + #define __user + /* typedef uint16_t __u16; */ +@@ -37,6 +38,8 @@ struct compat_iw_point { + __u16 flags; + }; + #endif ++ ++#if 0 + /* --------------------------- SUBTYPES --------------------------- */ + /* + * For all data larger than 16 octets, we need to use a +@@ -83,5 +86,6 @@ struct iwreq { + /* Data part (defined just above) */ + union iwreq_data u; + }; ++#endif + + #endif /* _LINUX_WIRELESS_H */ diff --git a/package/ctcgfw/rtl88x2bu/patches/030-wireless-5.8.patch b/package/ctcgfw/rtl88x2bu/patches/030-wireless-5.8.patch new file mode 100644 index 0000000000..686e5d5a09 --- /dev/null +++ b/package/ctcgfw/rtl88x2bu/patches/030-wireless-5.8.patch @@ -0,0 +1,39 @@ +diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c +index 2fd4e28..6fc93ea 100755 +--- a/os_dep/linux/ioctl_cfg80211.c ++++ b/os_dep/linux/ioctl_cfg80211.c +@@ -7325,6 +7325,14 @@ exit: + return ret; + } + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) || defined(BUILD_OPENWRT) ++static void cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy, ++ struct wireless_dev *wdev, ++ struct mgmt_frame_regs *upd) ++{ ++ ++} ++#else + static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) + struct wireless_dev *wdev, +@@ -7368,6 +7376,7 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, + exit: + return; + } ++#endif + + #if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)) + static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy, +@@ -9652,7 +9661,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = { + + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) + .mgmt_tx = cfg80211_rtw_mgmt_tx, ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) || defined(BUILD_OPENWRT) ++ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations, ++#else + .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, ++#endif + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) + .action = cfg80211_rtw_mgmt_tx, + #endif