diff mbox series

[8/8] rsi: miscallaneous changes for 9116 and common

Message ID 20190403041309.12829-9-siva8118@gmail.com (mailing list archive)
State Accepted
Commit 0a60014b76f512f18e48cfb4efc71e07c6791996
Delegated to: Kalle Valo
Headers show
Series rsi: driver changes for new 9116 chipset. | expand

Commit Message

Siva Rebbagondla April 3, 2019, 4:13 a.m. UTC
Below changes are done:
* Device 80MHz clock should be disabled for 9116 in 20MHz band.
* Default edca parameters should be used initially before
  connection.
* Default TA aggregation is 3 for 9116.
* Bootup parameters should be loaded first when channel is
  changed.
* 4 byte register writes are possible for 9116.

Signed-off-by: Siva Rebbagondla <siva8118@gmail.com>
---
 drivers/net/wireless/rsi/rsi_91x_mgmt.c | 27 +++++++++++++++++--------
 drivers/net/wireless/rsi/rsi_91x_usb.c  | 20 +++++++++---------
 2 files changed, 30 insertions(+), 17 deletions(-)

Comments

Johannes Berg Feb. 23, 2024, 10:24 a.m. UTC | #1
On Wed, 2019-04-03 at 09:43 +0530, Siva Rebbagondla wrote:
> 
>  static int rsi_usb_reg_write(struct usb_device *usbdev,
>  			     u32 reg,
> -			     u16 value,
> +			     u32 value,
>  			     u16 len)
>  {
>  	u8 *usb_reg_buf;
> @@ -226,17 +226,17 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
>  	if (!usb_reg_buf)
>  		return status;
>  
> -	usb_reg_buf[0] = (value & 0x00ff);
> -	usb_reg_buf[1] = (value & 0xff00) >> 8;
> -	usb_reg_buf[2] = 0x0;
> -	usb_reg_buf[3] = 0x0;
> +	usb_reg_buf[0] = (cpu_to_le32(value) & 0x00ff);
> +	usb_reg_buf[1] = (cpu_to_le32(value) & 0xff00) >> 8;
> +	usb_reg_buf[2] = (cpu_to_le32(value) & 0x00ff0000) >> 16;
> +	usb_reg_buf[3] = (cpu_to_le32(value) & 0xff000000) >> 24;


The cpu_to_le32() was wrong here, it's already contained in the shifting
that happened here ...


Easier to just write that as

 __le32 *usb_reg_buf;

 ...

 usb_reg_buf[0] = cpu_to_le32(value);

however.

 
>  	status = usb_control_msg(usbdev,
>  				 usb_sndctrlpipe(usbdev, 0),
>  				 USB_VENDOR_REGISTER_WRITE,
>  				 RSI_USB_REQ_OUT,
> -				 ((reg & 0xffff0000) >> 16),
> -				 (reg & 0xffff),
> +				 ((cpu_to_le32(reg) & 0xffff0000) >> 16),
> +				 (cpu_to_le32(reg) & 0xffff),

This change also seems completely wrong, and we should probably revert
it?

johannes
diff mbox series

Patch

diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index f328532fef88..6c7f26ef6476 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -424,6 +424,10 @@  static int rsi_load_radio_caps(struct rsi_common *common)
 	}
 	radio_caps->radio_info |= radio_id;
 
+	if (adapter->device_model == RSI_DEV_9116 &&
+	    common->channel_width == BW_20MHZ)
+		radio_caps->radio_cfg_info &= ~0x3;
+
 	radio_caps->sifs_tx_11n = cpu_to_le16(SIFS_TX_11N_VALUE);
 	radio_caps->sifs_tx_11b = cpu_to_le16(SIFS_TX_11B_VALUE);
 	radio_caps->slot_rx_11n = cpu_to_le16(SHORT_SLOT_VALUE);
@@ -439,14 +443,16 @@  static int rsi_load_radio_caps(struct rsi_common *common)
 	}
 
 	for (ii = 0; ii < NUM_EDCA_QUEUES; ii++) {
-		radio_caps->qos_params[ii].cont_win_min_q =
-			cpu_to_le16(common->edca_params[ii].cw_min);
-		radio_caps->qos_params[ii].cont_win_max_q =
-			cpu_to_le16(common->edca_params[ii].cw_max);
-		radio_caps->qos_params[ii].aifsn_val_q =
-			cpu_to_le16((common->edca_params[ii].aifs) << 8);
-		radio_caps->qos_params[ii].txop_q =
-			cpu_to_le16(common->edca_params[ii].txop);
+		if (common->edca_params[ii].cw_max > 0) {
+			radio_caps->qos_params[ii].cont_win_min_q =
+				cpu_to_le16(common->edca_params[ii].cw_min);
+			radio_caps->qos_params[ii].cont_win_max_q =
+				cpu_to_le16(common->edca_params[ii].cw_max);
+			radio_caps->qos_params[ii].aifsn_val_q =
+				cpu_to_le16(common->edca_params[ii].aifs << 8);
+			radio_caps->qos_params[ii].txop_q =
+				cpu_to_le16(common->edca_params[ii].txop);
+		}
 	}
 
 	radio_caps->qos_params[BROADCAST_HW_Q].txop_q = cpu_to_le16(0xffff);
@@ -1026,6 +1032,11 @@  static int rsi_send_reset_mac(struct rsi_common *common)
 	mgmt_frame->desc_word[1] = cpu_to_le16(RESET_MAC_REQ);
 	mgmt_frame->desc_word[4] = cpu_to_le16(RETRY_COUNT << 8);
 
+#define RSI_9116_DEF_TA_AGGR	3
+	if (common->priv->device_model == RSI_DEV_9116)
+		mgmt_frame->desc_word[3] |=
+			cpu_to_le16(RSI_9116_DEF_TA_AGGR << 8);
+
 	skb_put(skb, FRAME_DESC_SZ);
 
 	return rsi_send_internal_mgmt_frame(common, skb);
diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index f0475b20f153..f5048d4b8cb6 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -213,7 +213,7 @@  static int rsi_usb_reg_read(struct usb_device *usbdev,
  */
 static int rsi_usb_reg_write(struct usb_device *usbdev,
 			     u32 reg,
-			     u16 value,
+			     u32 value,
 			     u16 len)
 {
 	u8 *usb_reg_buf;
@@ -226,17 +226,17 @@  static int rsi_usb_reg_write(struct usb_device *usbdev,
 	if (!usb_reg_buf)
 		return status;
 
-	usb_reg_buf[0] = (value & 0x00ff);
-	usb_reg_buf[1] = (value & 0xff00) >> 8;
-	usb_reg_buf[2] = 0x0;
-	usb_reg_buf[3] = 0x0;
+	usb_reg_buf[0] = (cpu_to_le32(value) & 0x00ff);
+	usb_reg_buf[1] = (cpu_to_le32(value) & 0xff00) >> 8;
+	usb_reg_buf[2] = (cpu_to_le32(value) & 0x00ff0000) >> 16;
+	usb_reg_buf[3] = (cpu_to_le32(value) & 0xff000000) >> 24;
 
 	status = usb_control_msg(usbdev,
 				 usb_sndctrlpipe(usbdev, 0),
 				 USB_VENDOR_REGISTER_WRITE,
 				 RSI_USB_REQ_OUT,
-				 ((reg & 0xffff0000) >> 16),
-				 (reg & 0xffff),
+				 ((cpu_to_le32(reg) & 0xffff0000) >> 16),
+				 (cpu_to_le32(reg) & 0xffff),
 				 (void *)usb_reg_buf,
 				 len,
 				 USB_CTRL_SET_TIMEOUT);
@@ -263,8 +263,10 @@  static void rsi_rx_done_handler(struct urb *urb)
 	struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)rx_cb->data;
 	int status = -EINVAL;
 
-	if (urb->status)
-		goto out;
+	if (urb->status) {
+		dev_kfree_skb(rx_cb->rx_skb);
+		return;
+	}
 
 	if (urb->actual_length <= 0 ||
 	    urb->actual_length > rx_cb->rx_skb->len) {