From 5f3bbbf007305576c41681dcf23c3e7dda6bc3a6 Mon Sep 17 00:00:00 2001 From: morrownr Date: Thu, 9 Feb 2023 09:11:23 -0600 Subject: [PATCH] various minor updates --- README.md | 4 - core/efuse/rtw_efuse.c | 10 +- core/monitor/rtw_radiotap.c | 2 + core/rtw_br_ext.c | 236 +++++++++++++++++++++++++++++- core/rtw_mlme_ext.c | 6 + hal/hal_hci/hal_usb.c | 6 +- hal/rtl8821c/usb/rtl8821cu_xmit.c | 7 +- install-driver.sh | 8 +- os_dep/linux/ioctl_cfg80211.c | 10 +- os_dep/linux/os_intfs.c | 6 +- os_dep/linux/usb_intf.c | 23 ++- 11 files changed, 279 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 57b3a9d..16df59a 100644 --- a/README.md +++ b/README.md @@ -165,10 +165,6 @@ Warning: If you decide to upgrade to a new version of kernel such as the newest available before installing the new kernel. Use the following commands in the driver directory: -``` -sudo ./remove-driver.sh -``` - ``` git pull ``` diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index 28cfb2a..5786c2a 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -940,11 +940,11 @@ void rtw_efuse_analyze(PADAPTER padapter, u8 Type, u8 Fake) for (i = 0; i < mapLen; i++) { if (i % 16 == 0) RTW_PRINT_SEL(RTW_DBGDUMP, "0x%03x: ", i); - _RTW_PRINT_SEL(RTW_DBGDUMP, "%02X%s" - , pEfuseHal->fakeEfuseInitMap[i] - , ((i + 1) % 16 == 0) ? "\n" : (((i + 1) % 8 == 0) ? " " : " ") - ); - } + _RTW_PRINT_SEL(RTW_DBGDUMP, "%02X%s" + , pEfuseHal->fakeEfuseInitMap[i] + , ((i + 1) % 16 == 0) ? "\n" : (((i + 1) % 8 == 0) ? " " : " ") + ); + } _RTW_PRINT_SEL(RTW_DBGDUMP, "\n"); out_free_buffer: diff --git a/core/monitor/rtw_radiotap.c b/core/monitor/rtw_radiotap.c index e9ebc7d..1f9fc49 100644 --- a/core/monitor/rtw_radiotap.c +++ b/core/monitor/rtw_radiotap.c @@ -402,8 +402,10 @@ sint rtw_fill_radiotap_hdr(_adapter *padapter, struct rx_pkt_attrib *a, u8 *buf) } if (a->ampdu_eof) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN); tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_EOF); +#endif } _rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2); diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index 1ccbd88..f8b8035 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -17,9 +17,10 @@ #ifdef __KERNEL__ #include #include -// #if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 14, 0)) -// #include -// #endif + #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + #include +#endif #include #include #include @@ -170,8 +171,8 @@ static void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, memcpy(networkAddr + 7, (unsigned char *)ipAddr, 4); } -/* The following 3 functions are no longer used +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) static void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) { @@ -203,8 +204,8 @@ static void __nat25_generate_apple_network_addr(unsigned char *networkAddr, memcpy(networkAddr + 1, (unsigned char *)network, 2); networkAddr[3] = *node; } +#endif -*/ static void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, unsigned char *ac_mac, unsigned short *sid) @@ -334,6 +335,7 @@ static int __nat25_network_hash(unsigned char *networkAddr) x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; return x & (NAT25_HASH_SIZE - 1); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) } else if (networkAddr[0] == NAT25_IPX) { unsigned long x; @@ -347,6 +349,7 @@ static int __nat25_network_hash(unsigned char *networkAddr) x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3]; return x & (NAT25_HASH_SIZE - 1); +#endif } else if (networkAddr[0] == NAT25_PPPOE) { unsigned long x; @@ -893,6 +896,229 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) } } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + /*---------------------------------------------------*/ + /* Handle IPX and Apple Talk frame */ + /*---------------------------------------------------*/ + else if ((protocol == __constant_htons(ETH_P_IPX)) || + (protocol == __constant_htons(ETH_P_ATALK)) || + (protocol == __constant_htons(ETH_P_AARP))) { + unsigned char ipx_header[2] = {0xFF, 0xFF}; + struct ipxhdr *ipx = NULL; + struct elapaarp *ea = NULL; + struct ddpehdr *ddp = NULL; + unsigned char *framePtr = skb->data + ETH_HLEN; + + if (protocol == __constant_htons(ETH_P_IPX)) { + RTW_INFO("NAT25: Protocol=IPX (Ethernet II)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { /* if(protocol <= __constant_htons(ETH_FRAME_LEN)) */ + if (!memcmp(ipx_header, framePtr, 2)) { + RTW_INFO("NAT25: Protocol=IPX (Ethernet 802.3)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { + unsigned char ipx_8022_type = 0xE0; + unsigned char snap_8022_type = 0xAA; + + if (*framePtr == snap_8022_type) { + unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */ + unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */ + unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */ + + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + RTW_INFO("NAT25: Protocol=IPX (Ethernet SNAP)\n"); + ipx = (struct ipxhdr *)framePtr; + } else if (!memcmp(aarp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ea = (struct elapaarp *)framePtr; + } else if (!memcmp(ddp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ddp = (struct ddpehdr *)framePtr; + } else { + DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], + framePtr[1], framePtr[2], framePtr[3], framePtr[4]); + return -1; + } + } else if (*framePtr == ipx_8022_type) { + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_header, framePtr, 2)) { + RTW_INFO("NAT25: Protocol=IPX (Ethernet 802.2)\n"); + ipx = (struct ipxhdr *)framePtr; + } else + return -1; + } + } + } + + /* IPX */ + if (ipx != NULL) { + switch (method) { + case NAT25_CHECK: + if (!memcmp(skb->data + ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { + RTW_INFO("NAT25: Check IPX skb_copy\n"); + return 0; + } + return -1; + + case NAT25_INSERT: { + RTW_INFO("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n", + ipx->ipx_dest.net, + ipx->ipx_dest.node[0], + ipx->ipx_dest.node[1], + ipx->ipx_dest.node[2], + ipx->ipx_dest.node[3], + ipx->ipx_dest.node[4], + ipx->ipx_dest.node[5], + ipx->ipx_dest.sock, + ipx->ipx_source.net, + ipx->ipx_source.node[0], + ipx->ipx_source.node[1], + ipx->ipx_source.node[2], + ipx->ipx_source.node[3], + ipx->ipx_source.node[4], + ipx->ipx_source.node[5], + ipx->ipx_source.sock); + + if (!memcmp(skb->data + ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { + RTW_INFO("NAT25: Use IPX Net, and Socket as network addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); + + /* change IPX source node addr to wlan STA address */ + memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); + } else + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); + + __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + } + return 0; + + case NAT25_LOOKUP: { + if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) { + RTW_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* replace IPX destination node addr with Lookup destination MAC addr */ + memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); + } else { + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + } + } + return 0; + + default: + return -1; + } + } + + /* AARP */ + else if (ea != NULL) { + /* Sanity check fields. */ + if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { + DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return 0; + + case NAT25_INSERT: { + /* change to AARP source mac address to wlan STA address */ + memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); + + RTW_INFO("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); + + __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + } + return 0; + + case NAT25_LOOKUP: { + RTW_INFO("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* change to AARP destination mac address to Lookup result */ + memcpy(ea->hw_dst, skb->data, ETH_ALEN); + } + return 0; + + default: + return -1; + } + } + + /* DDP */ + else if (ddp != NULL) { + switch (method) { + case NAT25_CHECK: + return -1; + + case NAT25_INSERT: { + RTW_INFO("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); + + __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + } + return 0; + + case NAT25_LOOKUP: { + RTW_INFO("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + } + return 0; + + default: + return -1; + } + } + + return -1; + } +#endif + /*---------------------------------------------------*/ /* Handle PPPoE frame */ /*---------------------------------------------------*/ diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index f961294..6bafdc4 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -16164,6 +16164,12 @@ u8 rtw_set_chbw_hdl(_adapter *padapter, u8 *pbuf) } LeaveAllPowerSaveModeDirect(padapter); + +#ifdef CONFIG_MONITOR_MODE_XMIT + pmlmeext->cur_channel = set_ch_parm->ch; + pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; + pmlmeext->cur_bwmode = set_ch_parm->bw; +#endif /* CONFIG_MONITOR_MODE_XMIT */ set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index c8a2c8e..e0e452c 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -26,7 +26,11 @@ int usb_init_recv_priv(_adapter *padapter, u16 ini_in_buf_sz) #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, - (void(*))usb_recv_tasklet, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)) + (void(*)(unsigned long))usb_recv_tasklet, +#else + (void *)usb_recv_tasklet, +#endif (unsigned long)padapter); #endif /* PLATFORM_LINUX */ diff --git a/hal/rtl8821c/usb/rtl8821cu_xmit.c b/hal/rtl8821c/usb/rtl8821cu_xmit.c index bdfbb40..de8bab7 100644 --- a/hal/rtl8821c/usb/rtl8821cu_xmit.c +++ b/hal/rtl8821c/usb/rtl8821cu_xmit.c @@ -931,7 +931,12 @@ s32 rtl8821cu_init_xmit_priv(PADAPTER padapter) HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); #ifdef PLATFORM_LINUX - tasklet_init(&pxmitpriv->xmit_tasklet, rtl8821cu_xmit_tasklet, + tasklet_init(&pxmitpriv->xmit_tasklet, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)) + (void(*)(unsigned long))rtl8821cu_xmit_tasklet, +#else + (void *)rtl8821cu_xmit_tasklet, +#endif (unsigned long)padapter); #endif #ifdef CONFIG_TX_EARLY_MODE diff --git a/install-driver.sh b/install-driver.sh index 2de7888..12534d2 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -121,10 +121,10 @@ for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi; do done # fail if no editor was found if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then - echo "No text editor found (default: ${DEFAULT_EDITOR})." - echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor." - echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\"" - exit 1 + echo "No text editor found (default: ${DEFAULT_EDITOR})." + echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor." + echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\"" + exit 1 fi echo ": ---------------------------" diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 81b60f2..cec7ef5 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -29,10 +29,10 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) #define STATION_INFO_INACTIVE_TIME BIT(NL80211_STA_INFO_INACTIVE_TIME) -#define STATION_INFO_LLID BIT(NL80211_STA_INFO_LLID) -#define STATION_INFO_PLID BIT(NL80211_STA_INFO_PLID) +#define STATION_INFO_LLID BIT(NL80211_STA_INFO_LLID) +#define STATION_INFO_PLID BIT(NL80211_STA_INFO_PLID) #define STATION_INFO_PLINK_STATE BIT(NL80211_STA_INFO_PLINK_STATE) -#define STATION_INFO_SIGNAL BIT(NL80211_STA_INFO_SIGNAL) +#define STATION_INFO_SIGNAL BIT(NL80211_STA_INFO_SIGNAL) #define STATION_INFO_TX_BITRATE BIT(NL80211_STA_INFO_TX_BITRATE) #define STATION_INFO_RX_PACKETS BIT(NL80211_STA_INFO_RX_PACKETS) #define STATION_INFO_TX_PACKETS BIT(NL80211_STA_INFO_TX_PACKETS) @@ -229,7 +229,7 @@ static u8 rtw_chbw_to_cfg80211_chan_def(struct wiphy *wiphy, struct cfg80211_cha if (!chan) goto exit; - if (bw == CHANNEL_WIDTH_20) + if (bw == CHANNEL_WIDTH_20) chdef->width = ht ? NL80211_CHAN_WIDTH_20 : NL80211_CHAN_WIDTH_20_NOHT; else if (bw == CHANNEL_WIDTH_40) chdef->width = NL80211_CHAN_WIDTH_40; @@ -5111,9 +5111,11 @@ void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint f ie_offset = _REASOCREQ_IE_OFFSET_; memset(&sinfo, 0, sizeof(sinfo)); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)) sinfo.filled = STATION_INFO_ASSOC_REQ_IES; sinfo.assoc_req_ies = pmgmt_frame + WLAN_HDR_A3_LEN + ie_offset; sinfo.assoc_req_ies_len = frame_len - WLAN_HDR_A3_LEN - ie_offset; +#endif cfg80211_new_sta(ndev, get_addr2_ptr(pmgmt_frame), &sinfo, GFP_ATOMIC); } #else /* defined(RTW_USE_CFG80211_STA_EVENT) */ diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index a3d50fc..4c8e21c 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -72,7 +72,7 @@ int rtw_scan_mode = 1;/* active, passive */ #else int rtw_wow_power_mgnt = PS_MODE_ACTIVE; int rtw_wow_lps_level = LPS_NORMAL; -#endif +#endif #endif /* CONFIG_WOWLAN */ #else /* !CONFIG_POWER_SAVING */ @@ -3915,7 +3915,7 @@ int _netdev_open(struct net_device *pnetdev) #ifdef CONFIG_IOCTL_CFG80211 rtw_cfg80211_init_wdev_data(padapter); #endif - rtw_netif_carrier_on(pnetdev); /* call this func when rtw_joinbss_event_callback return success */ + /* rtw_netif_carrier_on(pnetdev); */ /* call this func when rtw_joinbss_event_callback return success */ rtw_netif_wake_queue(pnetdev); #ifdef CONFIG_BR_EXT @@ -4036,7 +4036,7 @@ int _netdev_open(struct net_device *pnetdev) rtw_set_pwr_state_check_timer(pwrctrlpriv); #endif - rtw_netif_carrier_on(pnetdev); /* call this func when rtw_joinbss_event_callback return success */ + /* rtw_netif_carrier_on(pnetdev); */ /* call this func when rtw_joinbss_event_callback return success */ rtw_netif_wake_queue(pnetdev); #ifdef CONFIG_BR_EXT diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index bc214a3..fa2c048 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -86,18 +86,17 @@ static void rtw_dev_shutdown(struct device *dev) #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23)) /* Some useful macros to use to create struct usb_device_id */ -#define USB_DEVICE_ID_MATCH_VENDOR 0x0001 -#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002 -#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004 -#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008 -#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010 -#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 -#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 -#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080 -#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 -#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 -#define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400 - +#define USB_DEVICE_ID_MATCH_VENDOR 0x0001 +#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002 +#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004 +#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008 +#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010 +#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 +#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 +#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080 +#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 +#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 +#define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400 #define USB_DEVICE_ID_MATCH_INT_INFO \ (USB_DEVICE_ID_MATCH_INT_CLASS | \