rtl8821cu: build with mac80211

This commit is contained in:
AmadeusGhost 2020-08-12 12:02:02 +08:00
parent c7b845d09a
commit df7edc8ad3
5 changed files with 129 additions and 1 deletions

View File

@ -22,12 +22,15 @@ PKG_MIRROR_HASH:=0b0c12c69efa680481abc3a7703a1a224f7fcd6271f8eb3c038fbaef02945bf
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/rtl8821cu
SUBMENU:=Wireless Drivers
TITLE:=Realtek rtl8821cu 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)/rtl8821cu.ko
AUTOLOAD:=$(call AutoProbe,rtl8821cu)
PROVIDES:=kmod-rtl8821cu
@ -37,6 +40,15 @@ define KernelPackage/rtl8821cu/description
Kernel module for rtl8821cu wireless module.
endef
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_KCONFIG:=\
CONFIG_RTL8821CU=m \
USER_MODULE_NAME=rtl8821cu
@ -50,6 +62,7 @@ EXTRA_CFLAGS:= \
-DCONFIG_RADIO_WORK \
-DCONFIG_IOCTL_CFG80211 \
-DCONFIG_CONCURRENT_MODE \
-DBUILD_OPENWRT \
ifeq ($(ARCH),arm)
EXTRA_CFLAGS += -mfloat-abi=softfp
@ -62,6 +75,7 @@ endif
MAKE_OPTS:= \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)" \
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
USER_EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(EXTRA_KCONFIG)

View File

@ -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 <drv_conf.h>
#include <basic_types.h>
#include <osdep_service.h>
-#include <rtw_byteorder.h>
+#include <asm/byteorder.h>
#include <wlan_bssdef.h>
#include <wifi.h>
#include <ieee80211.h>

View File

@ -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 <linux/types.h> /* for __u* and __s* typedefs */
#include <linux/socket.h> /* for "struct sockaddr" et al */
#include <linux/if.h> /* for IFNAMSIZ and co... */
+ #include <uapi/linux/wireless.h>
#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 */

View File

@ -0,0 +1,66 @@
diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c
index c0df148..f74c426 100755
--- a/os_dep/linux/ioctl_cfg80211.c
+++ b/os_dep/linux/ioctl_cfg80211.c
@@ -7143,6 +7143,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,
@@ -7186,6 +7194,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,
@@ -9457,7 +9466,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
diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c
index c4b5157..cdb9388 100755
--- a/os_dep/linux/os_intfs.c
+++ b/os_dep/linux/os_intfs.c
@@ -1302,6 +1302,14 @@ unsigned int rtw_classify8021d(struct sk_buff *skb)
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
+static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb
+ , struct net_device *sb_dev
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0))
+ , select_queue_fallback_t fallback
+ #endif
+)
+#else
static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
, void *accel_priv
@@ -1310,6 +1318,7 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb
#endif
#endif
)
+#endif
{
_adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;