wifi: rtlwifi: rtl_usb: Store the endpoint addresses
PATCH 1/1 wifi: rtlwifi: rtl_usb: Store the endpoint addresses
And use the stored addresses in rtl8192cu instead of hardcoding them.
This is what the vendor drivers do.
Perhaps this is not strictly necessary for RTL8192CU devices. However, the dual mac version of RTL8192DU has two USB interfaces, each with its own set of endpoints. Hardcoding their addresses in the upcoming rtl8192du driver would require making some assumptions which I'm not qualified to make.
--- .../wireless/realtek/rtlwifi/rtl8192cu/sw.c | 1 - .../wireless/realtek/rtlwifi/rtl8192cu/trx.c | 77 ++++++++++--------- .../wireless/realtek/rtlwifi/rtl8192cu/trx.h | 1 - drivers/net/wireless/realtek/rtlwifi/usb.c | 31 ++++++-- drivers/net/wireless/realtek/rtlwifi/usb.h | 2 + drivers/net/wireless/realtek/rtlwifi/wifi.h | 1 - 6 files changed, 68 insertions(+), 45 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c +0 -1
@@ -145,7 +145,6 @@ MODULE_PARM_DESC(debug_mask, "Set debug mask (default 0)");static struct rtl_hal_usbint_cfg rtl92cu_interface_cfg = {/* rx */ - .in_ep_num =RTL92C_USB_BULK_IN_NUM , .rx_urb_num =RTL92C_NUM_RX_URBS , .rx_max_size =RTL92C_SIZE_MAX_RX_BUFFER , .usb_rx_hdl = rtl8192cu_rx_hdl,
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +42 -35
110 lines not on this page · raw message
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h +0 -1
@@ -4,7 +4,6 @@#ifndef __RTL92CU_TRX_H__#define __RTL92CU_TRX_H__ -#define RTL92C_USB_BULK_IN_NUM 1#define RTL92C_NUM_RX_URBS 8#define RTL92C_NUM_TX_URBS 32
drivers/net/wireless/realtek/rtlwifi/usb.c +24 -7
@@ -216,7 +216,6 @@ static int _rtl_usb_init_rx(struct ieee80211_hw *hw) rtlusb->rx_max_size = rtlpriv->cfg->usb_interface_cfg->rx_max_size; rtlusb->rx_urb_num = rtlpriv->cfg->usb_interface_cfg->rx_urb_num; - rtlusb->in_ep = rtlpriv->cfg->usb_interface_cfg->in_ep_num; rtlusb->usb_rx_hdl = rtlpriv->cfg->usb_interface_cfg->usb_rx_hdl; rtlusb->usb_rx_segregate_hdl = rtlpriv->cfg->usb_interface_cfg->usb_rx_segregate_hdl;
@@ -248,20 +247,38 @@ static int _rtl_usb_init(struct ieee80211_hw *hw) pep_desc = &usb_intf->cur_altsetting->endpoint[epidx].desc; -if (usb_endpoint_dir_in (pep_desc)) +if (usb_endpoint_dir_in (pep_desc)) { +if (usb_endpoint_xfer_bulk (pep_desc)) { +/* The vendor drivers assume there is only one +* bulk in ep and that it's the first in ep. +*/ +if (rtlusb->in_ep_nums ==0 ) + rtlusb->in_ep =usb_endpoint_num (pep_desc); +else +pr_warn ("%s: bulk in endpoint is not the first in endpoint\n" , + __func__); + } + rtlusb->in_ep_nums++; -else if (usb_endpoint_dir_out (pep_desc)) + }else if (usb_endpoint_dir_out (pep_desc)) { +if (rtlusb->out_ep_nums <RTL_USB_MAX_BULKOUT_NUM ) { +if (usb_endpoint_xfer_bulk (pep_desc)) + rtlusb->out_eps[rtlusb->out_ep_nums] = +usb_endpoint_num (pep_desc); + }else { +pr_warn ("%s: found more bulk out endpoints than the expected %d\n" , + __func__,RTL_USB_MAX_BULKOUT_NUM ); + } + rtlusb->out_ep_nums++; + }rtl_dbg (rtlpriv,COMP_INIT ,DBG_DMESG ,"USB EP(0x%02x), MaxPacketSize=%d, Interval=%d\n" , pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize, pep_desc->bInterval); } -if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num) { -pr_err ("Too few input end points found\n" ); -return -EINVAL ; - } +if (rtlusb->out_ep_nums ==0 ) {pr_err ("No output end points found\n" );return -EINVAL ;
drivers/net/wireless/realtek/rtlwifi/usb.h +2 -0
@@ -19,6 +19,7 @@#define RTL_USB_MAX_TXQ_NUM 4/* max tx queue */ #define RTL_USB_MAX_EP_NUM 6/* max ep number */ +#define RTL_USB_MAX_BULKOUT_NUM 4#define RTL_USB_MAX_TX_URBS_NUM 8enum rtl_txq {
@@ -94,6 +95,7 @@ struct rtl_usb {/* Tx */ u8 out_ep_nums ; +u8 out_eps[RTL_USB_MAX_BULKOUT_NUM ];u8 out_queue_sel;struct rtl_ep_map ep_map;
drivers/net/wireless/realtek/rtlwifi/wifi.h +0 -1
@@ -2353,7 +2353,6 @@ struct rtl_mod_params {struct rtl_hal_usbint_cfg {/* data - rx */ -u32 in_ep_num;u32 rx_urb_num;u32 rx_max_size;
Signature · 1 line
2.43.0
Quoted 13 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, February 13, 2024 10:33 PM
To: [email protected]
Cc: Ping-Ke Shih <[email protected]>; Larry Finger <[email protected]>
Subject: [PATCH] wifi: rtlwifi:rtl_usb: Store the endpoint addressesAnd use the stored addresses in rtl8192cu instead of hardcoding them.
This is what the vendor drivers do.
Quoted 7 lines
Perhaps this is not strictly necessary for RTL8192CU devices. However, the dual mac version of RTL8192DU has two USB interfaces, each with its own set of endpoints. Hardcoding their addresses in the upcoming rtl8192du driver would require making some assumptions which I'm not qualified to make.
Signed-off-by Bitterblue Smith <[email protected]>
Though I'm not familiar with endpoints of USB, patch makes sense to me
Quoted 4 lines · Bitterblue Smith
And use the stored addresses in rtl8192cu instead of hardcoding them.
This is what the vendor drivers do.
Quoted 8 lines
Perhaps this is not strictly necessary for RTL8192CU devices. However, the dual mac version of RTL8192DU has two USB interfaces, each with its own set of endpoints. Hardcoding their addresses in the upcoming rtl8192du driver would require making some assumptions which I'm not qualified to make.
Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>
Patch applied to wireless-next.git, thanks.
42ffccd0a36e wifi: rtlwifi: rtl_usb: Store the endpoint addresses
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches