From e66e31d229d4f835929917910b81e6ec983143a5 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:04:29 +0200 Subject: [PATCH 01/14] test --- Makefile | 2 +- hal/phydm/phydm_pre_define.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e5eeaf08..dda39c99 100755 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ CONFIG_USB2_EXTERNAL_POWER = y CONFIG_RTW_DEBUG = y # default log level is _DRV_INFO_ = 4, # please refer to "How_to_set_driver_debug_log_level.doc" to set the available level. -CONFIG_RTW_LOG_LEVEL = 3 #Consti10 3==DRV_WARNING +CONFIG_RTW_LOG_LEVEL = 7 #Consti10 3==DRV_WARNING ######################## Wake On Lan ########################## CONFIG_WOWLAN = n CONFIG_WAKEUP_TYPE = 0x7 #bit2: deauth, bit1: unicast, bit0: magic pkt. diff --git a/hal/phydm/phydm_pre_define.h b/hal/phydm/phydm_pre_define.h index f9e4ad12..6b488331 100644 --- a/hal/phydm/phydm_pre_define.h +++ b/hal/phydm/phydm_pre_define.h @@ -594,8 +594,8 @@ enum odm_board_type_e { ODM_BOARD_EXT_PA = BIT(3), /* 0 = no 2G ext-PA, 1 = existing 2G ext-PA */ ODM_BOARD_EXT_LNA = BIT(4), /* 0 = no 2G ext-LNA, 1 = existing 2G ext-LNA */ ODM_BOARD_EXT_TRSW = BIT(5), /* 0 = no ext-TRSW, 1 = existing ext-TRSW */ - ODM_BOARD_EXT_PA_5G = BIT(6), /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */ - ODM_BOARD_EXT_LNA_5G = BIT(7), /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */ + ODM_BOARD_EXT_PA_5G = 1, /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */ + ODM_BOARD_EXT_LNA_5G = 1, /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */ }; enum odm_package_type_e { From 7d3df105f08b088f42caabfe29073879c2d40c31 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:12:52 +0200 Subject: [PATCH 02/14] Update phydm_pre_define.h --- hal/phydm/phydm_pre_define.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/phydm/phydm_pre_define.h b/hal/phydm/phydm_pre_define.h index 6b488331..f9e4ad12 100644 --- a/hal/phydm/phydm_pre_define.h +++ b/hal/phydm/phydm_pre_define.h @@ -594,8 +594,8 @@ enum odm_board_type_e { ODM_BOARD_EXT_PA = BIT(3), /* 0 = no 2G ext-PA, 1 = existing 2G ext-PA */ ODM_BOARD_EXT_LNA = BIT(4), /* 0 = no 2G ext-LNA, 1 = existing 2G ext-LNA */ ODM_BOARD_EXT_TRSW = BIT(5), /* 0 = no ext-TRSW, 1 = existing ext-TRSW */ - ODM_BOARD_EXT_PA_5G = 1, /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */ - ODM_BOARD_EXT_LNA_5G = 1, /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */ + ODM_BOARD_EXT_PA_5G = BIT(6), /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */ + ODM_BOARD_EXT_LNA_5G = BIT(7), /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */ }; enum odm_package_type_e { From c3e5cceed811a353cf4399f3a8cec8b5e36daebe Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:18:47 +0200 Subject: [PATCH 03/14] patch 6.8 support --- os_dep/linux/usb_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 95dc47fb..92289012 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -329,7 +329,7 @@ struct rtw_usb_drv usb_drv = { .usbdrv.supports_autosuspend = 1, #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)) .usbdrv.drvwrap.driver.shutdown = rtw_dev_shutdown, #else .usbdrv.driver.shutdown = rtw_dev_shutdown, From c78b863ffeeb9bc83d6635ef14e5b94a905560c1 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:21:12 +0200 Subject: [PATCH 04/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index dc70f446..b702c893 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -408,8 +408,7 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, u8 if (ret != _SUCCESS) goto exit; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) - cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 9, 0)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0); #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0); #else From d0ee7b3e4520b18acc21a64aff58a1ed49b2efbe Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:30:01 +0200 Subject: [PATCH 05/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index b702c893..950274ce 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -4606,7 +4606,16 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, return ret; } -static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_beacon_data *info) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 7, 0)) +static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, + struct cfg80211_ap_update *params) +{ + struct cfg80211_beacon_data *info = ¶ms->beacon; +#else +static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, + struct cfg80211_beacon_data *info) +{ +#endif { int ret = 0; _adapter *adapter = (_adapter *)rtw_netdev_priv(ndev); From 5bd84d5dddeca08dd9cbbab8179fd2b4a9deb7aa Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:33:23 +0200 Subject: [PATCH 06/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 950274ce..9c1a4ff6 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -4640,9 +4640,10 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd } -static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) - , unsigned int link_id +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2)) +static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) +#else +static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id) #endif ) { From d78101c772e214cf978109fae7c65bb4781fe77d Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:35:25 +0200 Subject: [PATCH 07/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 136 +++++++++++----------------------- 1 file changed, 44 insertions(+), 92 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 9c1a4ff6..62997ff7 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -408,7 +408,8 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, u8 if (ret != _SUCCESS) goto exit; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 9, 0)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) + cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0); #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0); #else @@ -1002,7 +1003,7 @@ void rtw_cfg80211_indicate_connect(_adapter *padapter) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)) roam_info.links[0].bssid = cur_network->network.MacAddress; #else - roam_info.bssid = cur_network->network.MacAddress; + roam_info.bssid = cur_network->network.MacAddress; #endif roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2; roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2; @@ -1644,14 +1645,14 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param return ret; } -static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev +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 + int link_id, #endif #if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) - , u8 key_index, bool pairwise, const u8 *mac_addr, + u8 key_index, bool pairwise, const u8 *mac_addr, #else /* (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) */ - , u8 key_index, const u8 *mac_addr, + u8 key_index, const u8 *mac_addr, #endif /* (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) */ struct key_params *params) { @@ -1784,16 +1785,17 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev } -static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev +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 + int link_id, #endif - , u8 keyid -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) - , bool pairwise -#endif - , const u8 *mac_addr, void *cookie - , void (*callback)(void *cookie, struct key_params *)) +#if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr, +#else /* (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) */ + u8 key_index, const u8 *mac_addr, +#endif /* (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) */ + void *cookie, + void (*callback)(void *cookie, struct key_params *)) { #if 0 struct iwm_priv *iwm = ndev_to_iwm(ndev); @@ -1820,7 +1822,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev 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, + int link_id, #endif #if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr) @@ -1842,11 +1844,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, + struct net_device *ndev, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) - int link_id, + int link_id, #endif - u8 key_index + u8 key_index #if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 38)) || defined(COMPAT_KERNEL_RELEASE) , bool unicast, bool multicast #endif @@ -3674,35 +3676,12 @@ int value; value = dbm; #endif - RTW_INFO("OpenHD:cfg80211_rtw_set_txpower with %d mBm %d (?dBm?)",(int)mbm,(int)value); if(value < 0) value = 0; if(value > 40) value = 40; if(type == NL80211_TX_POWER_FIXED) { - RTW_INFO("OpenHD:cfg80211_rtw_set_txpower NL80211_TX_POWER_FIXED"); - // OpenHD dynamic tx power: We hack the driver here by repurposing really small dBm values - // as power index. This is a bit dangerous - since 63mBm now suddenly becomes max power. - // But since 25mW is already ~14dBm (and therefore 140 mBm if you go with the 100 factor) - // i think it is safe to assume that only OpenHD (which knows about the driver) ever calls - // the "set tx power fixed" with those ultra low values. The nice thing then is that we don't even - // need any kernel patches to set the card to an arbitratry high power value, since they are well below the legal limit of - // every country. Note, however, that the card is now not doing what linux tells it - but honestly, someone decided - // to just map dBm values to some power index at some point anyways. - // 22.April: Simplify -> use tpi override value (and dummy tx power commits) - /*int openhd_override_tx_power_index=get_openhd_override_tx_power_index(); - if(openhd_override_tx_power_index>=0 && openhd_override_tx_power_index<=63){ - padapter->registrypriv.RegTxPowerIndexOverride = openhd_override_tx_power_index; - }else{ - padapter->registrypriv.RegTxPowerIndexOverride = 0; - }*/ - if(mbm>=0 && mbm<=63){ - padapter->registrypriv.RegTxPowerIndexOverride = mbm; - RTW_WARN("OpenHD:interpreting %d mBm as tx power index override",(int)mbm); - } - RTW_INFO("OpenHD:Tx power index override is %d",padapter->registrypriv.RegTxPowerIndexOverride); - pHalData->CurrentTxPwrIdx = value; rtw_hal_set_tx_power_level(padapter, pHalData->current_channel); } else @@ -3748,12 +3727,10 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy, HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); RTW_INFO("%s\n", __func__); - if(padapter->registrypriv.RegTxPowerIndexOverride){ - *dbm = padapter->registrypriv.RegTxPowerIndexOverride; - }else{ - // *dbm = (12); - *dbm = pHalData->CurrentTxPwrIdx; - } + + // *dbm = (12); + *dbm = pHalData->CurrentTxPwrIdx; + return 0; } @@ -4616,7 +4593,6 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd struct cfg80211_beacon_data *info) { #endif -{ int ret = 0; _adapter *adapter = (_adapter *)rtw_netdev_priv(ndev); @@ -4639,13 +4615,11 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd return ret; } - #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2)) static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) #else static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id) #endif -) { RTW_INFO(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); return 0; @@ -4908,11 +4882,11 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, } -static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) - unsigned int link_id, +static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, unsigned int link_id, struct cfg80211_chan_def *chandef){ +#else +static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, struct cfg80211_chan_def *chandef){ #endif -struct cfg80211_chan_def *chandef){ _adapter *padapter= wiphy_to_adapter(wiphy); int channel; int control_freq; @@ -5025,17 +4999,13 @@ struct cfg80211_chan_def *chandef){ chandef->center_freq1 = center_freq; chandef->center_freq2 = center_freq2; //RTW_INFO("%s : channel %d width %d freq1 %d freq2 %d center_freq %d offset %d\n", __func__, channel, width, chandef->center_freq1, chandef->center_freq2, chandef->chan->center_freq,rtw_get_oper_choffset(padapter)); - // Consti10: this method seems to be used - if(true){ - RTW_WARN("OpenHD channel debug: %s : channel %d width %d freq1 %d freq2 %d center_freq %d offset %d\n", __func__, channel, width, chandef->center_freq1, chandef->center_freq2, chandef->chan->center_freq,rtw_get_oper_choffset(padapter)); - } } else { return -EINVAL; } return 0; + } -// Consti10: In monitor mode, this method seems to be not used (set_monitor_channel is used instead) static int cfg80211_rtw_set_channel(struct wiphy *wiphy #if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 35)) , struct net_device *ndev @@ -5077,17 +5047,12 @@ static int cfg80211_rtw_set_channel(struct wiphy *wiphy RTW_INFO(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d\n" , FUNC_ADPT_ARG(padapter), chan_target, chan_width, chan_offset); - if(true){ - RTW_WARN(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d OpenHD channel debug\n" - , FUNC_ADPT_ARG(padapter), chan_target, chan_width, chan_offset); - } rtw_set_chbw_cmd(padapter, chan_target, chan_width, chan_offset, RTW_CMDF_WAIT_ACK); return 0; } -// Consti10: In monitor mode, this method is used the set the channel freq, at least on ubuntu 5.19.X static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy #if (CFG80211_API_LEVEL >= KERNEL_VERSION(3, 8, 0)) , struct cfg80211_chan_def *chandef @@ -5182,27 +5147,6 @@ static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy RTW_INFO(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d\n" , FUNC_ADPT_ARG(padapter), target_channal, target_width, target_offset); - // OpenHD channel via module param - // update if module param has been updated - padapter->registrypriv.openhd_override_channel=get_openhd_override_channel(); - padapter->registrypriv.openhd_override_channel_width=get_openhd_override_channel_width(); - - RTW_WARN("OpenHD: override %d %d",padapter->registrypriv.openhd_override_channel,padapter->registrypriv.openhd_override_channel_width); - { - if(padapter->registrypriv.openhd_override_channel){ - target_channal=padapter->registrypriv.openhd_override_channel; - RTW_WARN("OpenHD: using openhd_override_channel"); - } - if(padapter->registrypriv.openhd_override_channel_width){ - target_width=padapter->registrypriv.openhd_override_channel_width; - RTW_WARN("OpenHD: using openhd_override_channel_width"); - } - } - - if(true){ - RTW_WARN(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d OpenHD channel debug\n" - , FUNC_ADPT_ARG(padapter), target_channal, target_width, target_offset); - } rtw_set_chbw_cmd(padapter, target_channal, target_width, target_offset, RTW_CMDF_WAIT_ACK); return 0; @@ -6502,6 +6446,9 @@ static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy, const u8 *peer, #else u8 *peer, +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)) + int link_id, #endif u8 action_code, u8 dialog_token, @@ -7863,12 +7810,13 @@ static struct cfg80211_ops rtw_cfg80211_ops = { .del_pmksa = cfg80211_rtw_del_pmksa, .flush_pmksa = cfg80211_rtw_flush_pmksa, -#ifdef CONFIG_AP_MODE - +#ifdef RTW_VIRTUAL_INT .add_virtual_intf = cfg80211_rtw_add_virtual_intf, .del_virtual_intf = cfg80211_rtw_del_virtual_intf, +#endif -#if (CFG80211_API_LEVEL < KERNEL_VERSION(3, 4, 0)) && !defined(COMPAT_KERNEL_RELEASE) +#ifdef CONFIG_AP_MODE +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) && !defined(COMPAT_KERNEL_RELEASE) .add_beacon = cfg80211_rtw_add_beacon, .set_beacon = cfg80211_rtw_set_beacon, .del_beacon = cfg80211_rtw_del_beacon, @@ -8120,12 +8068,14 @@ void rtw_wdev_unregister(struct wireless_dev *wdev) rtw_cfg80211_indicate_scan_done(adapter, _TRUE); - #if (CFG80211_API_LEVEL >= KERNEL_VERSION(3, 11, 0)) || defined(COMPAT_KERNEL_RELEASE) - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) || defined(COMPAT_KERNEL_RELEASE) + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) if (wdev->links[0].client.current_bss) { + #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2)) + if (wdev->connected) { #else if (wdev->current_bss) { - #endif + #endif RTW_INFO(FUNC_ADPT_FMT" clear current_bss by cfg80211_disconnected\n", FUNC_ADPT_ARG(adapter)); rtw_cfg80211_indicate_disconnect(adapter, 0, 1); } @@ -8160,9 +8110,10 @@ int rtw_cfg80211_ndev_res_alloc(_adapter *adapter) rtw_wiphy_free(wiphy); adapter->wiphy = NULL; } -#endif exit: +#endif + return ret; } @@ -8176,6 +8127,7 @@ void rtw_cfg80211_ndev_res_free(_adapter *adapter) #endif } + int rtw_cfg80211_ndev_res_register(_adapter *adapter) { int ret = _FAIL; @@ -8260,4 +8212,4 @@ void rtw_cfg80211_dev_res_unregister(struct dvobj_priv *dvobj) #endif } -#endif /* CONFIG_IOCTL_CFG80211 */ +#endif /* CONFIG_IOCTL_CFG80211 */ \ No newline at end of file From 7817fcad010f5aa83b312977b0d1d7c55c31b87f Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:46:11 +0200 Subject: [PATCH 08/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 58 ++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 62997ff7..1bd1e3aa 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -3675,13 +3675,35 @@ int value; #else value = dbm; #endif - + RTW_INFO("OpenHD:cfg80211_rtw_set_txpower with %d mBm %d (?dBm?)",(int)mbm,(int)value); if(value < 0) value = 0; if(value > 40) value = 40; if(type == NL80211_TX_POWER_FIXED) { + RTW_INFO("OpenHD:cfg80211_rtw_set_txpower NL80211_TX_POWER_FIXED"); + // OpenHD dynamic tx power: We hack the driver here by repurposing really small dBm values + // as power index. This is a bit dangerous - since 63mBm now suddenly becomes max power. + // But since 25mW is already ~14dBm (and therefore 140 mBm if you go with the 100 factor) + // i think it is safe to assume that only OpenHD (which knows about the driver) ever calls + // the "set tx power fixed" with those ultra low values. The nice thing then is that we don't even + // need any kernel patches to set the card to an arbitratry high power value, since they are well below the legal limit of + // every country. Note, however, that the card is now not doing what linux tells it - but honestly, someone decided + // to just map dBm values to some power index at some point anyways. + // 22.April: Simplify -> use tpi override value (and dummy tx power commits) + /*int openhd_override_tx_power_index=get_openhd_override_tx_power_index(); + if(openhd_override_tx_power_index>=0 && openhd_override_tx_power_index<=63){ + padapter->registrypriv.RegTxPowerIndexOverride = openhd_override_tx_power_index; + }else{ + padapter->registrypriv.RegTxPowerIndexOverride = 0; + }*/ + if(mbm>=0 && mbm<=63){ + padapter->registrypriv.RegTxPowerIndexOverride = mbm; + RTW_WARN("OpenHD:interpreting %d mBm as tx power index override",(int)mbm); + } + RTW_INFO("OpenHD:Tx power index override is %d",padapter->registrypriv.RegTxPowerIndexOverride); + pHalData->CurrentTxPwrIdx = value; rtw_hal_set_tx_power_level(padapter, pHalData->current_channel); } else @@ -3713,7 +3735,12 @@ if(type == NL80211_TX_POWER_FIXED) { return -EOPNOTSUPP; } #endif - RTW_INFO("%s\n", __func__); + if(padapter->registrypriv.RegTxPowerIndexOverride){ + *dbm = padapter->registrypriv.RegTxPowerIndexOverride; + }else{ + // *dbm = (12); + *dbm = pHalData->CurrentTxPwrIdx; + } return 0; } @@ -5047,12 +5074,15 @@ static int cfg80211_rtw_set_channel(struct wiphy *wiphy RTW_INFO(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d\n" , FUNC_ADPT_ARG(padapter), chan_target, chan_width, chan_offset); - + if(true){ + RTW_WARN(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d OpenHD channel debug\n" + , FUNC_ADPT_ARG(padapter), chan_target, chan_width, chan_offset); + } rtw_set_chbw_cmd(padapter, chan_target, chan_width, chan_offset, RTW_CMDF_WAIT_ACK); return 0; } - +// Consti10: In monitor mode, this method is used the set the channel freq, at least on ubuntu 5.19.X static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy #if (CFG80211_API_LEVEL >= KERNEL_VERSION(3, 8, 0)) , struct cfg80211_chan_def *chandef @@ -5146,7 +5176,27 @@ static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy #endif RTW_INFO(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d\n" , FUNC_ADPT_ARG(padapter), target_channal, target_width, target_offset); + // OpenHD channel via module param + // update if module param has been updated + padapter->registrypriv.openhd_override_channel=get_openhd_override_channel(); + padapter->registrypriv.openhd_override_channel_width=get_openhd_override_channel_width(); + + RTW_WARN("OpenHD: override %d %d",padapter->registrypriv.openhd_override_channel,padapter->registrypriv.openhd_override_channel_width); + { + if(padapter->registrypriv.openhd_override_channel){ + target_channal=padapter->registrypriv.openhd_override_channel; + RTW_WARN("OpenHD: using openhd_override_channel"); + } + if(padapter->registrypriv.openhd_override_channel_width){ + target_width=padapter->registrypriv.openhd_override_channel_width; + RTW_WARN("OpenHD: using openhd_override_channel_width"); + } + } + if(true){ + RTW_WARN(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d OpenHD channel debug\n" + , FUNC_ADPT_ARG(padapter), target_channal, target_width, target_offset); + } rtw_set_chbw_cmd(padapter, target_channal, target_width, target_offset, RTW_CMDF_WAIT_ACK); return 0; From 1773a2c381007873f8f7904ec1478298b2eeb76a Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 01:50:52 +0200 Subject: [PATCH 09/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 1bd1e3aa..bf5ebf02 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -3754,10 +3754,12 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy, HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); RTW_INFO("%s\n", __func__); - - // *dbm = (12); - *dbm = pHalData->CurrentTxPwrIdx; - +if(padapter->registrypriv.RegTxPowerIndexOverride){ + *dbm = padapter->registrypriv.RegTxPowerIndexOverride; + }else{ + // *dbm = (12); + *dbm = pHalData->CurrentTxPwrIdx; + } return 0; } From b0f7ad29ac388f6adb307f4d0bb12828151abbc7 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 02:00:34 +0200 Subject: [PATCH 10/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index bf5ebf02..87751a71 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -1787,7 +1787,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, 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, + int link_id,u8 keyid #endif #if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr, @@ -3754,7 +3754,7 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy, HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); RTW_INFO("%s\n", __func__); -if(padapter->registrypriv.RegTxPowerIndexOverride){ + if(padapter->registrypriv.RegTxPowerIndexOverride){ *dbm = padapter->registrypriv.RegTxPowerIndexOverride; }else{ // *dbm = (12); From 6f8ea76e7ed7805ae16196036e1b749618c98a5e Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 02:03:10 +0200 Subject: [PATCH 11/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 87751a71..c48715b2 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -1785,17 +1785,16 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, } -static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, +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,u8 keyid + , int link_id #endif -#if (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) - u8 key_index, bool pairwise, const u8 *mac_addr, -#else /* (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) */ - u8 key_index, const u8 *mac_addr, -#endif /* (CFG80211_API_LEVEL >= KERNEL_VERSION(2, 6, 37)) */ - void *cookie, - void (*callback)(void *cookie, struct key_params *)) + , u8 keyid +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) + , bool pairwise +#endif + , const u8 *mac_addr, void *cookie + , void (*callback)(void *cookie, struct key_params *)) { #if 0 struct iwm_priv *iwm = ndev_to_iwm(ndev); From a96ff765f4c99ccd7328c3560c4ad1b75d2cad00 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 02:08:10 +0200 Subject: [PATCH 12/14] debug --- os_dep/linux/ioctl_cfg80211.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index c48715b2..ac9f6f4e 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -3697,11 +3697,11 @@ if(type == NL80211_TX_POWER_FIXED) { }else{ padapter->registrypriv.RegTxPowerIndexOverride = 0; }*/ - if(mbm>=0 && mbm<=63){ - padapter->registrypriv.RegTxPowerIndexOverride = mbm; - RTW_WARN("OpenHD:interpreting %d mBm as tx power index override",(int)mbm); - } - RTW_INFO("OpenHD:Tx power index override is %d",padapter->registrypriv.RegTxPowerIndexOverride); + // if(mbm>=0 && mbm<=63){ + // padapter->registrypriv.RegTxPowerIndexOverride = mbm; + // RTW_WARN("OpenHD:interpreting %d mBm as tx power index override",(int)mbm); + // } + // RTW_INFO("OpenHD:Tx power index override is %d",padapter->registrypriv.RegTxPowerIndexOverride); pHalData->CurrentTxPwrIdx = value; rtw_hal_set_tx_power_level(padapter, pHalData->current_channel); From 0033867a83629a6e64f149f9af68459dfb50a7bf Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 6 May 2024 02:11:36 +0200 Subject: [PATCH 13/14] Update ioctl_cfg80211.c --- os_dep/linux/ioctl_cfg80211.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index ac9f6f4e..e26dbdad 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -3697,11 +3697,11 @@ if(type == NL80211_TX_POWER_FIXED) { }else{ padapter->registrypriv.RegTxPowerIndexOverride = 0; }*/ - // if(mbm>=0 && mbm<=63){ - // padapter->registrypriv.RegTxPowerIndexOverride = mbm; - // RTW_WARN("OpenHD:interpreting %d mBm as tx power index override",(int)mbm); - // } - // RTW_INFO("OpenHD:Tx power index override is %d",padapter->registrypriv.RegTxPowerIndexOverride); + if(mbm>=0 && mbm<=63){ + padapter->registrypriv.RegTxPowerIndexOverride = mbm; + RTW_WARN("OpenHD:interpreting %d mBm as tx power index override",(int)mbm); + } + RTW_INFO("OpenHD:Tx power index override is %d",padapter->registrypriv.RegTxPowerIndexOverride); pHalData->CurrentTxPwrIdx = value; rtw_hal_set_tx_power_level(padapter, pHalData->current_channel); @@ -3734,12 +3734,7 @@ if(type == NL80211_TX_POWER_FIXED) { return -EOPNOTSUPP; } #endif - if(padapter->registrypriv.RegTxPowerIndexOverride){ - *dbm = padapter->registrypriv.RegTxPowerIndexOverride; - }else{ - // *dbm = (12); - *dbm = pHalData->CurrentTxPwrIdx; - } + RTW_INFO("%s\n", __func__); return 0; } From 5d73ccb4a6ca414d44d32a126d7e9ce47cc36ac3 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Fri, 17 May 2024 22:39:22 +0200 Subject: [PATCH 14/14] update to 6.9 --- .github/workflows/build_test.yml | 2 +- os_dep/linux/usb_intf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 4937fb40..1cf1df2c 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -8,7 +8,7 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 env: CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} steps: diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 92289012..5a12ae63 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -329,7 +329,7 @@ struct rtw_usb_drv usb_drv = { .usbdrv.supports_autosuspend = 1, #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) && (LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)) .usbdrv.drvwrap.driver.shutdown = rtw_dev_shutdown, #else .usbdrv.driver.shutdown = rtw_dev_shutdown,