From 7e100d67173c7c3ee96e912b4cd903b13055b1d6 Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 16 Aug 2023 14:54:48 +0200 Subject: [PATCH 1/8] document and analyze the tx error behaviour(s) --- core/rtw_mlme_ext.c | 2 ++ core/rtw_xmit.c | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 4fd8df1c..1b9acc8f 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -7170,12 +7170,14 @@ struct xmit_frame *_alloc_mgtxmitframe(struct xmit_priv *pxmitpriv, bool once) if (pmgntframe == NULL) { RTW_INFO(FUNC_ADPT_FMT" alloc xmitframe fail, once:%d\n", FUNC_ADPT_ARG(pxmitpriv->adapter), once); + //RTW_WARN("OpenHD rtw_alloc_xmitframe fail, once:%d\n", once); goto exit; } pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv); if (pxmitbuf == NULL) { RTW_INFO(FUNC_ADPT_FMT" alloc xmitbuf fail\n", FUNC_ADPT_ARG(pxmitpriv->adapter)); + //RTW_WARN("OpenHD rtw_alloc_xmitbuf_ext fail\n"); rtw_free_xmitframe(pxmitpriv, pmgntframe); pmgntframe = NULL; goto exit; diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 29dad43f..14ed353c 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -26,7 +26,8 @@ static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static int openhd_tx_error_count=0; +static int openhd_alloc_mgtxmitframe_error_count=0; +static int openhd_monitor_alloc_mgtxmitframe_error_count=0; static void _init_txservq(struct tx_servq *ptxservq) { @@ -3105,9 +3106,10 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) _enter_critical(&pfree_queue->lock, &irqL); - if (_rtw_queue_empty(pfree_queue) == _TRUE) - pxmitbuf = NULL; - else { + if (_rtw_queue_empty(pfree_queue) == _TRUE) { + pxmitbuf = NULL; + RTW_WARN("OpenHD alloc rtw_alloc_xmitbuf_ext fail NR_XMIT_EXTBUFF:%d MAX_XMIT_EXTBUF_SZ:%d\n",NR_XMIT_EXTBUFF,MAX_XMIT_EXTBUF_SZ); + }else { phead = get_list_head(pfree_queue); @@ -3124,7 +3126,6 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) RTW_INFO("DBG_XMIT_BUF_EXT ALLOC no=%d, free_xmit_extbuf_cnt=%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt); #endif - pxmitbuf->priv_data = NULL; #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) @@ -3374,13 +3375,11 @@ struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv) _list *plist, *phead; _queue *queue = &pxmitpriv->free_xframe_ext_queue; - // OpenHD: From rtw_mlme_ext.c we go via function calls back to here - //RTW_WARN("OpenHD: calling rtw_alloc_xmitframe_ext"); - _enter_critical_bh(&queue->lock, &irqL); if (_rtw_queue_empty(queue) == _TRUE) { pxframe = NULL; + RTW_WARN("OpenHD alloc rtw_alloc_xmitframe_ext failed "); } else { phead = get_list_head(queue); plist = get_next(phead); @@ -4235,10 +4234,22 @@ static struct xmit_frame* monitor_alloc_mgtxmitframe(struct xmit_priv *pxmitpriv // OpenHD: Here a method that returns a frame if place is in the queue // Is called 4 times with a (increasing) sleep until there is space in the queue // If no space is in the queue after 4 calls, NULL is returned + // The method alloc_mgtxmitframe just calls + // _alloc_mgtxmitframe(pxmitpriv, _FALSE); (once=false) + // wich then calls rtw_alloc_xmitframe_ext + // and rtw_alloc_xmitbuf_ext (Frame and buffer) + // If one of these 2 fails, it returns NULL + // rtw_alloc_xmitframe_ext uses the free_xframe_ext_queue + // rtw_alloc_xmitbuf_ext uses the free_xmit_extbuf_queue + // On tx errors, rtw_alloc_xmitbuf_ext seems to be the one that fails all the time + // with size(s) NR_XMIT_EXTBUFF:64 MAX_XMIT_EXTBUF_SZ:1536 (default in driver as original) for(tries = 3; tries >= 0; tries--) { pmgntframe = alloc_mgtxmitframe(pxmitpriv); if(pmgntframe != NULL) return pmgntframe; + openhd_alloc_mgtxmitframe_error_count++; + RTW_WARN("OpenHD: alloc_mgtxmitframe failed, retries:%d, total error count %d:%d", + tries,openhd_alloc_mgtxmitframe_error_count,openhd_monitor_alloc_mgtxmitframe_error_count); rtw_udelay_os(delay); delay += delay/2; } @@ -4291,8 +4302,8 @@ s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev) //RTW_WARN("OpenHD: calling monitor_alloc_mgtxmitframe X"); if ((pmgntframe = monitor_alloc_mgtxmitframe(pxmitpriv)) == NULL) { DBG_COUNTER(padapter->tx_logs.core_tx_err_pxmitframe); - openhd_tx_error_count++; - RTW_WARN("OpenHD: monitor_alloc_mgtxmitframe - tx busy %d",openhd_tx_error_count); + openhd_monitor_alloc_mgtxmitframe_error_count++; + RTW_WARN("OpenHD: monitor_alloc_mgtxmitframe - tx busy %d",openhd_monitor_alloc_mgtxmitframe_error_count); return NETDEV_TX_BUSY; } From 2bb86028709a2ae4b7d7c2b05f3406a708f0710c Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 16 Aug 2023 20:16:10 +0200 Subject: [PATCH 2/8] use higher retry limit when retry is enabled --- hal/rtl8812a/usb/rtl8812au_xmit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hal/rtl8812a/usb/rtl8812au_xmit.c b/hal/rtl8812a/usb/rtl8812au_xmit.c index b368128d..a3c0d008 100644 --- a/hal/rtl8812a/usb/rtl8812au_xmit.c +++ b/hal/rtl8812a/usb/rtl8812au_xmit.c @@ -121,8 +121,11 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz , u8 ba /* injected frame */ if(pattrib->inject == 0xa5) { SET_TX_DESC_RETRY_LIMIT_ENABLE_8812(ptxdesc, 1); + //RTW_WARN("pattrib->retry_ctrl %d\n",(int)pattrib->retry_ctrl); if (pattrib->retry_ctrl == _TRUE) { - SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 6); + // OpenHD: See https://patchwork.kernel.org/project/linux-wireless/patch/477d745b-6bac-111d-403c-487fc19aa30d@gmail.com/ + //SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 6); + SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 12); } else { SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 0); } From e44e6bebccf63bd6844c4a7fa5991ec74f533336 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 17 Aug 2023 02:49:32 +0200 Subject: [PATCH 3/8] add script --- build_install_no_kms.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 build_install_no_kms.sh diff --git a/build_install_no_kms.sh b/build_install_no_kms.sh new file mode 100755 index 00000000..ced116df --- /dev/null +++ b/build_install_no_kms.sh @@ -0,0 +1,9 @@ +#bin/bash + +# need to run make 2 times for whatever reason to get the .ko +make +make + +sudo rmmod 88XXau_wfb + +sudo insmod 88XXau_wfb.ko From c2580b63f949b9f5e23746df814e563d9f45140f Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 17 Aug 2023 12:58:45 +0200 Subject: [PATCH 4/8] fix channels --- core/rtw_rf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/rtw_rf.c b/core/rtw_rf.c index 6bcf812f..59d95d4d 100644 --- a/core/rtw_rf.c +++ b/core/rtw_rf.c @@ -218,7 +218,8 @@ u8 rtw_get_scch_by_cch_offset(u8 cch, u8 bw, u8 offset) } /* 2.4G, 40MHz */ - if (cch >= 3 && cch <= 11 && bw == CHANNEL_WIDTH_40) { + //if (cch >= 3 && cch <= 11 && bw == CHANNEL_WIDTH_40) { + if (cch >= 3 && cch <= 14 && bw == CHANNEL_WIDTH_40) { // OpenHD fix: t_cch = (offset == HAL_PRIME_CHNL_OFFSET_UPPER) ? cch + 2 : cch - 2; goto exit; } @@ -234,7 +235,8 @@ u8 rtw_get_scch_by_cch_offset(u8 cch, u8 bw, u8 offset) goto exit; /* 5G, 40MHz */ - } else if (cch >= 38 && cch <= 175 && bw == CHANNEL_WIDTH_40) { + //} else if (cch >= 38 && cch <= 175 && bw == CHANNEL_WIDTH_40) { + } else if (cch >= 32 && cch <= 177 && bw == CHANNEL_WIDTH_40) { //OpenHD fix: t_cch = (offset == HAL_PRIME_CHNL_OFFSET_UPPER) ? cch + 2 : cch - 2; goto exit; From c56d9432762ed7bee6dd091b9004519a14fc1bfe Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 18 Aug 2023 03:43:50 +0200 Subject: [PATCH 5/8] use 32 for testing --- hal/rtl8812a/usb/rtl8812au_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/rtl8812a/usb/rtl8812au_xmit.c b/hal/rtl8812a/usb/rtl8812au_xmit.c index a3c0d008..2434fd46 100644 --- a/hal/rtl8812a/usb/rtl8812au_xmit.c +++ b/hal/rtl8812a/usb/rtl8812au_xmit.c @@ -125,7 +125,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz , u8 ba if (pattrib->retry_ctrl == _TRUE) { // OpenHD: See https://patchwork.kernel.org/project/linux-wireless/patch/477d745b-6bac-111d-403c-487fc19aa30d@gmail.com/ //SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 6); - SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 12); + SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 32); } else { SET_TX_DESC_DATA_RETRY_LIMIT_8812(ptxdesc, 0); } From 9a9ad5846b8aa5ecb18b5238e7b0e324eafb4534 Mon Sep 17 00:00:00 2001 From: consti10 Date: Sat, 19 Aug 2023 13:51:29 +0200 Subject: [PATCH 6/8] rssi debug --- core/rtw_recv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 3999948f..d69f4607 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -3800,6 +3800,9 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe) rt_len++; // alignment } + //RTW_WARN("OpenHD rx_pwdb_all:%d rx_power:%d recv_signal_power:%d bt_rx_rssi_percentage:%d signal_strength:%d SNR:[%d:%d:%d:%d]\n",pattrib->phy_info.rx_pwdb_all,pattrib->phy_info.rx_power, + // pattrib->phy_info.recv_signal_power,pattrib->phy_info.bt_rx_rssi_percentage,pattrib->phy_info.signal_strength, + // pattrib->phy_info.rx_snr[0],pattrib->phy_info.rx_snr[1],pattrib->phy_info.rx_snr[2],pattrib->phy_info.rx_snr[3]); /* Signal Quality */ rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_LOCK_QUALITY); From 07f4cd8c8f0e35098c2927ad867cc02e4a589d5c Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 21 Aug 2023 23:41:59 +0200 Subject: [PATCH 7/8] debug time to allocate mgtxmitframe --- core/rtw_xmit.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 14ed353c..bffc5361 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -4284,6 +4284,9 @@ s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev) u32 len = skb->len; u8 category, action; int type = -1; + // OpenHD debug + u64 before_allocate; + u64 delta_allocate; if (skb) rtw_mstat_update(MSTAT_TYPE_SKB, MSTAT_ALLOC_SUCCESS, skb->truesize); @@ -4300,10 +4303,14 @@ s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev) goto fail; //RTW_WARN("OpenHD: calling monitor_alloc_mgtxmitframe X"); + before_allocate=ktime_get_ns(); if ((pmgntframe = monitor_alloc_mgtxmitframe(pxmitpriv)) == NULL) { DBG_COUNTER(padapter->tx_logs.core_tx_err_pxmitframe); openhd_monitor_alloc_mgtxmitframe_error_count++; - RTW_WARN("OpenHD: monitor_alloc_mgtxmitframe - tx busy %d",openhd_monitor_alloc_mgtxmitframe_error_count); + delta_allocate=ktime_get_ns()-before_allocate; + RTW_WARN("OpenHD: monitor_alloc_mgtxmitframe - (%dus) tx busy %d", + (int)(delta_allocate/1000), + openhd_monitor_alloc_mgtxmitframe_error_count); return NETDEV_TX_BUSY; } From 78d0c9e2cb096ba8630705170d1bd13f0b7b3b51 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 21 Aug 2023 23:48:49 +0200 Subject: [PATCH 8/8] do not spam log --- core/rtw_xmit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index bffc5361..745875d7 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -3108,7 +3108,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) if (_rtw_queue_empty(pfree_queue) == _TRUE) { pxmitbuf = NULL; - RTW_WARN("OpenHD alloc rtw_alloc_xmitbuf_ext fail NR_XMIT_EXTBUFF:%d MAX_XMIT_EXTBUF_SZ:%d\n",NR_XMIT_EXTBUFF,MAX_XMIT_EXTBUF_SZ); + //RTW_WARN("OpenHD alloc rtw_alloc_xmitbuf_ext fail NR_XMIT_EXTBUFF:%d MAX_XMIT_EXTBUF_SZ:%d\n",NR_XMIT_EXTBUFF,MAX_XMIT_EXTBUF_SZ); }else { phead = get_list_head(pfree_queue); @@ -3379,7 +3379,7 @@ struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv) if (_rtw_queue_empty(queue) == _TRUE) { pxframe = NULL; - RTW_WARN("OpenHD alloc rtw_alloc_xmitframe_ext failed "); + //RTW_WARN("OpenHD alloc rtw_alloc_xmitframe_ext failed "); } else { phead = get_list_head(queue); plist = get_next(phead); @@ -4248,8 +4248,8 @@ static struct xmit_frame* monitor_alloc_mgtxmitframe(struct xmit_priv *pxmitpriv if(pmgntframe != NULL) return pmgntframe; openhd_alloc_mgtxmitframe_error_count++; - RTW_WARN("OpenHD: alloc_mgtxmitframe failed, retries:%d, total error count %d:%d", - tries,openhd_alloc_mgtxmitframe_error_count,openhd_monitor_alloc_mgtxmitframe_error_count); + //RTW_WARN("OpenHD: alloc_mgtxmitframe failed, retries:%d, total error count %d:%d", + // tries,openhd_alloc_mgtxmitframe_error_count,openhd_monitor_alloc_mgtxmitframe_error_count); rtw_udelay_os(delay); delay += delay/2; }