support kernel 6.1 plus some clean up

This commit is contained in:
morrownr 2022-10-19 16:15:30 -05:00
parent 6a2916db1a
commit 73a681a0db
7 changed files with 65 additions and 20 deletions

View File

@ -1,6 +1,6 @@
-----
#### Click [here](https://github.com/morrownr/USB-WiFi) for USB WiFi Adapter Information for Linux
#### [Go to Main Menu](https://github.com/morrownr/USB-WiFi)
-----
@ -61,7 +61,7 @@ sudo uname -mr; mokutil --sb-state; lsusb; rfkill list all; dkms status; iw dev;
### Compatible Kernels
- Kernels: 4.19 - 5.11 (Realtek)
- Kernels: 5.12 - 6.0 (community support)
- Kernels: 5.12 - 6.1 (community support)
### Tested Linux Distributions
@ -160,7 +160,6 @@ installing the new kernel. Use the following commands in the driver directory:
```
$ git pull
$ sudo ./remove-driver.sh
(install the new kernel)
$ sudo ./install-driver.sh
```
@ -411,7 +410,7 @@ the process each time a new kernel is installed in your distro.
### Driver Options ( edit-options.sh )
A file called `88x2bu.conf` will be installed in `/etc/modprobe.d` by
default if you use one of the scripts for installation.
default if you use the `./install-driver.sh` script.
Note: The installation script will prompt you to edit the options.

View File

@ -4,4 +4,3 @@ MAKE[0]="'make' -j$(nproc) KVER=${kernelver} KSRC=/lib/modules/${kernelver}/buil
CLEAN="'make' clean"
BUILT_MODULE_NAME[0]="88x2bu"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/wireless"
AUTOINSTALL="yes"

View File

@ -8,10 +8,6 @@ SCRIPT_NAME="install-driver.sh"
SCRIPT_VERSION="20221007"
OPTIONS_FILE="88x2bu.conf"
# Some distros have a non-mainlined, patched-in kernel driver
# that has to be deactivated.
BLACKLIST_FILE="rtw88_8822bu.conf"
MODULE_NAME="88x2bu"
KVER="$(uname -r)"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
@ -20,6 +16,10 @@ DRV_NAME="rtl88x2bu"
DRV_VERSION="5.13.1"
DRV_DIR="$(pwd)"
# Some distros have non-mainlined, patched-in kernel drivers
# that have to be deactivated.
BLACKLIST_FILE="rtw88_8822bu.conf"
# check to ensure sudo was used
if [[ $EUID -ne 0 ]]
then
@ -63,6 +63,7 @@ fi
uname -r
# architecture - for ARM: aarch64 = 64 bit, armv7l = 32 bit
uname -m
#getconf LONG_BIT (may be handy in the future)
echo "Starting installation..."
@ -122,6 +123,10 @@ else
dkms add -m ${DRV_NAME} -v ${DRV_VERSION}
RESULT=$?
# RESULT will be 3 if the DKMS tree already contains the same module/version
# combo. You cannot add the same module/version combo more than once.
# I need to add logic to handle this.
if [[ "$RESULT" != "0" ]]
then
echo "An error occurred. dkms add error = ${RESULT}"

View File

@ -446,7 +446,7 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset,
u8 ret = _SUCCESS;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
struct cfg80211_chan_def chdef;
struct cfg80211_chan_def chdef = {};
ret = rtw_chbw_to_cfg80211_chan_def(wiphy, &chdef, ch, bw, offset, ht);
if (ret != _SUCCESS)
@ -456,7 +456,7 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset,
if (started) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) || defined(RHEL8))
/* --- cfg80211_ch_switch_started_notify() ---
/* --- cfg80211_ch_switch_started_notfiy() ---
* A new parameter, bool quiet, is added from Linux kernel v5.11,
* to see if block-tx was requested by the AP. since currently,
* the API is used for station before connected in rtw_chk_start_clnt_join()
@ -464,7 +464,11 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset,
* called by others with block-tx.
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, 0, false);
#else
cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0, false);
#endif
#else
cfg80211_ch_switch_started_notify(adapter->pnetdev, &chdef, 0);
#endif
@ -1911,6 +1915,9 @@ exit:
}
static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
, int link_id
#endif
, u8 key_index
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
, bool pairwise
@ -2073,6 +2080,9 @@ addkey_end:
}
static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
, int link_id
#endif
, u8 keyid
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
, bool pairwise
@ -2261,6 +2271,9 @@ exit:
}
static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
int link_id,
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
u8 key_index, bool pairwise, const u8 *mac_addr)
#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) */
@ -2281,7 +2294,11 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
}
static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
struct net_device *ndev, u8 key_index
struct net_device *ndev,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
int link_id,
#endif
u8 key_index
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)) || defined(COMPAT_KERNEL_RELEASE)
, bool unicast, bool multicast
#endif
@ -2329,7 +2346,11 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30))
int cfg80211_rtw_set_default_mgmt_key(struct wiphy *wiphy,
struct net_device *ndev, u8 key_index)
struct net_device *ndev,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
int link_id,
#endif
u8 key_index)
{
#define SET_DEF_KEY_PARAM_FMT " key_index=%d"
#define SET_DEF_KEY_PARAM_ARG , key_index

View File

@ -2154,7 +2154,11 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name)
u8 rtnl_lock_needed = rtw_rtnl_lock_needed(dvobj);
#ifdef CONFIG_RTW_NAPI
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
netif_napi_add_weight(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT);
#else
netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT);
#endif
#endif /* CONFIG_RTW_NAPI */
#if defined(CONFIG_IOCTL_CFG80211)
@ -4539,7 +4543,9 @@ static int route_dump(u32 *gw_addr , int *gw_index)
struct msghdr msg;
struct iovec iov;
struct sockaddr_nl nladdr;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs;
#endif
char *pg;
int size = 0;
@ -4578,14 +4584,18 @@ static int route_dump(u32 *gw_addr , int *gw_index)
msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
err = sock_sendmsg(sock, &msg);
#else
err = sock_sendmsg(sock, &msg, sizeof(req));
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
if (err < 0)
goto out_sock;
@ -4610,14 +4620,18 @@ restart:
iov_iter_init(&msg.msg_iter, READ, &iov, 1, PAGE_SIZE);
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
err = sock_recvmsg(sock, &msg, MSG_DONTWAIT);
#else
err = sock_recvmsg(sock, &msg, PAGE_SIZE, MSG_DONTWAIT);
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
if (err < 0)
goto out_sock_pg;
@ -4688,14 +4702,18 @@ done:
msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
err = sock_sendmsg(sock, &msg);
#else
err = sock_sendmsg(sock, &msg, sizeof(req));
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
if (err > 0)
goto restart;

View File

@ -2914,7 +2914,9 @@ u64 rtw_division64(u64 x, u64 y)
inline u32 rtw_random32(void)
{
#ifdef PLATFORM_LINUX
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
return get_random_u32();
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
return prandom_u32();
#elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18))
u32 random_int;

View File

@ -6,18 +6,19 @@
SCRIPT_NAME="remove-driver.sh"
SCRIPT_VERSION="20221007"
OPTIONS_FILE="88x2bu.conf"
BLACKLIST_FILE="rtw88_8822bu.conf"
MODULE_NAME="88x2bu"
DRV_VERSION="5.13.1"
OPTIONS_FILE="${MODULE_NAME}.conf"
KVER="$(uname -r)"
KSRC="/lib/modules/${KVER}/build"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl88x2bu"
DRV_VERSION="5.13.1"
DRV_NAME="rtl${MODULE_NAME}"
DRV_DIR="$(pwd)"
BLACKLIST_FILE="rtw88_8822bu.conf"
# check to ensure sudo was used
if [[ $EUID -ne 0 ]]
then
@ -63,7 +64,7 @@ then
rm -f /etc/modprobe.d/${BLACKLIST_FILE}
echo "Deleting source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Removing a non-dkms installation."
# echo "Removing a non-dkms installation."
rm -f ${MODDESTDIR}${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
echo "The driver was removed successfully."