pacth: txpower/rate/sens/retry restored after card reset

Jirka Bohac jbohac
Sun Mar 2 17:46:26 PST 2003


oops, this time the patch IS attached :-)
-------------- next part --------------
diff -Naur hostap/driver/modules/hostap.c hostap-jb/driver/modules/hostap.c
--- hostap/driver/modules/hostap.c	2003-01-11 07:04:58.000000000 +0100
+++ hostap-jb/driver/modules/hostap.c	2003-03-03 02:26:41.000000000 +0100
@@ -862,6 +862,84 @@
 	netif_stop_queue(dev);
 }
 
+// PATCH: Global set rate function
+
+int prism2_set_rate_from_local(struct net_device *dev)
+{
+	int ret;
+	local_info_t *local = (local_info_t *) dev->priv;
+	ret = (hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
+			       local->tx_rate_control) ||
+	       local->func->reset_port(dev));
+		
+	if (ret) {
+		printk(KERN_DEBUG "%s: TXRateControl setting to 0x%x failed\n",
+		       dev->name, local->tx_rate_control);
+	} else {
+		printk(KERN_DEBUG "%s: TX Rate set to 0x%x\n",
+		       dev->name, local->tx_rate_control);
+	}
+	return ret;
+}
+
+// PATCH: Global set txpower function
+
+int prism2_set_power_from_local(struct net_device *dev)
+{
+	int alc;
+	u16 val;
+	local_info_t *local = (local_info_t *) dev->priv;
+
+	/* set the ALC */
+	alc = local->txpower_type != PRISM2_TXPOWER_FIXED;
+	printk(KERN_DEBUG "%s, Setting ALC to %d\n", dev->name, alc);
+
+	val = HFA384X_TEST_CFG_BIT_ALC;
+	local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+			 (HFA384X_TEST_CFG_BITS << 8), alc, &val, NULL);
+
+	/* if ALC is on, don't set the power */
+	if (alc) return 0;
+	
+	/* set the txpower */
+	val = local->txpower;
+	printk(KERN_DEBUG "%s: Setting TX power to %d \n", dev->name, val);
+	if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
+			     HFA386X_CR_MANUAL_TX_POWER, &val, NULL))
+		return  -EOPNOTSUPP;
+	else return 0;
+}
+
+// PATCH: Global set sensitivity function
+
+int prism2_set_sens_from_local(struct net_device *dev)
+{
+	local_info_t *local = (local_info_t *) dev->priv;
+
+	if (hostap_set_word(dev, HFA384X_RID_CNFSYSTEMSCALE, local->sensitivity)
+			|| local->func->reset_port(dev))
+		return -EINVAL;
+	
+	printk(KERN_DEBUG "%s: sensitivity set to %d\n", dev->name, local->sensitivity);
+
+	return 0;
+}
+					
+
+// PATCH: Global set retry function
+int prism2_set_retry_from_local(struct net_device *dev)
+{
+	int ret=0;
+	local_info_t *local = (local_info_t *) dev->priv;
+	ret = hostap_set_word(dev, HFA384X_RID_CNFALTRETRYCOUNT,
+			local->manual_retry_count) 
+	if (ret) 
+		printk(KERN_DEBUG "%s: Alternate retry count "
+		"setting to %d failed\n", dev->name, local->manual_retry_count);
+	else 
+		printk(KERN_DEBUG "%s: Alternate retry count "
+			"set to %d\n", dev->name, local->manual_retry_count);
+}
 
 struct proc_dir_entry *hostap_proc;
 
@@ -904,6 +982,10 @@
 EXPORT_SYMBOL(hostap_setup_dev);
 EXPORT_SYMBOL(hostap_proc);
 EXPORT_SYMBOL(hostap_set_multicast_list_queue);
+EXPORT_SYMBOL(prism2_set_power_from_local);
+EXPORT_SYMBOL(prism2_set_rate_from_local);
+EXPORT_SYMBOL(prism2_set_sens_from_local);
+EXPORT_SYMBOL(prism2_set_retry_from_local);
 
 module_init(hostap_init);
 module_exit(hostap_exit);
diff -Naur hostap/driver/modules/hostap.h hostap-jb/driver/modules/hostap.h
--- hostap/driver/modules/hostap.h	2002-11-24 05:58:37.000000000 +0100
+++ hostap-jb/driver/modules/hostap.h	2003-03-03 01:14:35.000000000 +0100
@@ -27,6 +27,8 @@
 void hostap_setup_dev(struct net_device *dev, local_info_t *local,
 		      int main_dev);
 void hostap_set_multicast_list_queue(void *data);
+int prism2_set_rate_from_local(struct net_device *dev);
+int prism2_set_power_from_local(struct net_device *dev);
 
 
 /* hostap_proc.c */
diff -Naur hostap/driver/modules/hostap_hw.c hostap-jb/driver/modules/hostap_hw.c
--- hostap/driver/modules/hostap_hw.c	2003-03-01 23:02:01.000000000 +0100
+++ hostap-jb/driver/modules/hostap_hw.c	2003-03-03 02:33:38.000000000 +0100
@@ -1182,6 +1182,16 @@
 	if (!initial || !delayed_enable) {
 		if (!local->dev_enabled)
 			prism2_callback(local, PRISM2_CALLBACK_ENABLE);
+	 }
+	
+// PATCH: Set saved txpower, rate, sens & retry values after HW reset
+
+	prism2_set_power_from_local(dev);
+	prism2_set_rate_from_local(dev);
+	prism2_set_sens_from_local(dev);
+	prism2_set_retry_from_local(dev);
+	
+	if (!initial || !delayed_enable) {
 		local->dev_enabled = 1;
 		return prism2_hw_enable(dev, initial);
 	}
@@ -1975,10 +1985,13 @@
 	if (!res)
 		res = prism2_transmit(dev, idx);
 	if (res) {
-		printk(KERN_DEBUG "%s: prism2_tx - to BAP0 failed\n",
+		printk(KERN_INFO "%s: prism2_tx - to BAP0 failed - skipping card reset\n",
 		       dev->name);
 		local->intransmitfid[idx] = PRISM2_TXFID_EMPTY;
-		PRISM2_SCHEDULE_TASK(&local->reset_queue);
+
+// PATCH: We usually don't need reset in client mode (caused by BAP0)
+		
+		/* PRISM2_SCHEDULE_TASK(&local->reset_queue); */
 		ret = 0; /* do not retry failed frames to avoid problems */
 		goto fail;
 	}
@@ -4031,6 +4044,17 @@
 
 	local->saved_eth_header_parse = local->dev->hard_header_parse;
 
+// PATCH: set default txpower, rate, sens and retry
+
+	local->txpower_type = PRISM2_TXPOWER_FIXED;
+	local->txpower = 127;	/* minimal */
+	local->tx_rate_control = HFA384X_RATES_1MBPS |
+		HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
+		HFA384X_RATES_11MBPS; /* auto */
+	local->sensitivity = 1;
+	local->manual_retry_count = 8;
+	
+
 	return local;
 
  fail:
diff -Naur hostap/driver/modules/hostap_ioctl.c hostap-jb/driver/modules/hostap_ioctl.c
--- hostap/driver/modules/hostap_ioctl.c	2003-02-14 05:56:42.000000000 +0100
+++ hostap-jb/driver/modules/hostap_ioctl.c	2003-03-03 02:22:48.000000000 +0100
@@ -340,7 +340,6 @@
 				struct iw_param *rrq, char *extra)
 {
 	local_info_t *local = (local_info_t *) dev->priv;
-	int ret = 0;
 
 	if (rrq->fixed) {
 		switch (rrq->value) {
@@ -388,15 +387,8 @@
 		}
 	}
 
-	ret = (hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
-			       local->tx_rate_control) ||
-	       local->func->reset_port(dev));
-		
-	if (ret) {
-		printk("%s: TXRateControl setting to 0x%x failed\n",
-		       dev->name, local->tx_rate_control);
-	}
-	return ret;
+// PATCH: Use global function instead of setting locally
+	return prism2_set_rate_from_local(dev);
 }
 
 static int prism2_ioctl_giwrate(struct net_device *dev,
@@ -464,11 +456,11 @@
 	if (sens->value < 1 || sens->value > 3)
 		return -EINVAL;
 
-	if (hostap_set_word(dev, HFA384X_RID_CNFSYSTEMSCALE, sens->value) ||
-	    local->func->reset_port(dev))
-		return -EINVAL;
+	local->sensitivity = sens->value;
+
+	return prism2_set_sens_from_local(dev);
+	
 
-	return 0;
 }
 
 static int prism2_ioctl_giwsens(struct net_device *dev,
@@ -1169,16 +1161,14 @@
 			local->manual_retry_count = -1;
 			local->tx_control &= ~HFA384X_TX_CTRL_ALT_RTRY;
 		} else {
-			if (hostap_set_word(dev, HFA384X_RID_CNFALTRETRYCOUNT,
-					    rrq->value)) {
-				printk(KERN_DEBUG "%s: Alternate retry count "
-				       "setting to %d failed\n",
-				       dev->name, rrq->value);
+			local->manual_retry_count = rrq->value;
+			local->tx_control |= HFA384X_TX_CTRL_ALT_RTRY;
+
+			if (prism2_set_retry_from_local(dev)) {
+				local->manual_retry_count = -1;
 				return -EOPNOTSUPP;
 			}
 
-			local->manual_retry_count = rrq->value;
-			local->tx_control |= HFA384X_TX_CTRL_ALT_RTRY;
 		}
 		return 0;
 	}
@@ -1260,6 +1250,9 @@
  * increasing dBm value should correspond to increasing TX power.
  */
 
+// PATCH: We don't use HFA386 <-> dBm values conversion
+
+/*
 static int prism2_txpower_hfa386x_to_dBm(u16 val)
 {
 	signed char tmp;
@@ -1288,7 +1281,7 @@
 
 	return (unsigned char) tmp;
 }
-
+*/
 
 static int prism2_ioctl_siwtxpow(struct net_device *dev,
 				 struct iw_request_info *info,
@@ -1321,22 +1314,10 @@
 		local->txpower_type = PRISM2_TXPOWER_UNKNOWN;
 	}
 
-	if (!rrq->fixed && local->txpower_type != PRISM2_TXPOWER_AUTO) {
-		printk(KERN_DEBUG "Setting ALC on\n");
-		val = HFA384X_TEST_CFG_BIT_ALC;
-		local->func->cmd(dev, HFA384X_CMDCODE_TEST |
-				 (HFA384X_TEST_CFG_BITS << 8), 1, &val, NULL);
-		local->txpower_type = PRISM2_TXPOWER_AUTO;
-		return 0;
-	}
-
-	if (local->txpower_type != PRISM2_TXPOWER_FIXED) {
-		printk(KERN_DEBUG "Setting ALC off\n");
-		val = HFA384X_TEST_CFG_BIT_ALC;
-		local->func->cmd(dev, HFA384X_CMDCODE_TEST |
-				 (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
-			local->txpower_type = PRISM2_TXPOWER_FIXED;
-	}
+// PATCH: Removed buggy/overengineered functions for setting txpower
+ 
+	local->txpower_type = rrq->fixed?
+		PRISM2_TXPOWER_FIXED:PRISM2_TXPOWER_AUTO;
 
 	if (rrq->flags == IW_TXPOW_DBM)
 		tmp = "dBm";
@@ -1344,7 +1325,6 @@
 		tmp = "mW";
 	else
 		tmp = "UNKNOWN";
-	printk(KERN_DEBUG "Setting TX power to %d %s\n", rrq->value, tmp);
 
 	if (rrq->flags != IW_TXPOW_DBM) {
 		printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
@@ -1352,11 +1332,10 @@
 	}
 
 	local->txpower = rrq->value;
-	val = prism2_txpower_dBm_to_hfa386x(local->txpower);
-	if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
-			     HFA386X_CR_MANUAL_TX_POWER, &val, NULL))
-		ret = -EOPNOTSUPP;
+	
+// PATCH: Use global function instead of setting locally
 
+	ret = prism2_set_power_from_local(dev);
 	return ret;
 }
 
@@ -1375,7 +1354,8 @@
 		if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF,
 				     HFA386X_CR_MANUAL_TX_POWER,
 				     NULL, &resp0) == 0) {
-			rrq->value = prism2_txpower_hfa386x_to_dBm(resp0);
+// PATCH: removed crappy dBm conversion
+			rrq->value = resp0;
 		} else {
 			/* Could not get real txpower; guess 15 dBm */
 			rrq->value = 15;
diff -Naur hostap/driver/modules/hostap_wlan.h hostap-jb/driver/modules/hostap_wlan.h
--- hostap/driver/modules/hostap_wlan.h	2003-02-15 06:39:13.000000000 +0100
+++ hostap-jb/driver/modules/hostap_wlan.h	2003-03-03 01:41:58.000000000 +0100
@@ -1133,6 +1133,8 @@
 		PRISM2_TXPOWER_FIXED, PRISM2_TXPOWER_UNKNOWN
 	} txpower_type;
 	int txpower; /* if txpower_type == PRISM2_TXPOWER_FIXED */
+	int sensitivity;
+
 
 	/* command queue for hfa384x_cmd(); protected with cmdlock */
 	struct list_head cmd_queue;



More information about the Hostap mailing list